Low-level kernel & storage

judgment_core reference

The public API of the judgment_core stateless checking kernel: every name src/judgment_core/__init__.mojo exports, rendered from the sources' docstrings. The design is on the stateless checker page, the kernel page, and the conversion page. Names that begin with _ are not part of the public API (see the trusted base).

Application and proof-authoring code works through Session (proof-authoring guide) and the API guide.

The stateless checker

Pure local checks of termbank.dag rows against their children's verified facts, chunk checking (check_chunk, check_dag_chunk), declaration and theory verification (check_declaration, check_theory), the construction engine (Constructor) and its derived rules (Derivations), statement keys, and the logic core prefix (KC1, K1.12).

Answer

@fieldwise_init
struct Answer(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
kind UInt8 The answer kind.
a UInt32 The key's first part.
b UInt32 The key's second part, or NONE.
c UInt32 The key's third part, or NONE.
value UInt32 The answer: a DSET for MEMBER and WITNESS, or NONE.
flags UInt8 Bit 0: the answer of a yes/no question.
weight UInt64 Its weight (Definition LC-18).

A per-type snapshot answer a proof check established: membership or witnessing (Definition LC-13; TD1.6).

Defined in src/judgment_core/checker_base.mojo.

Chunk

@fieldwise_init
struct Chunk(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
start UInt64 The first row.
end UInt64 The row after the last.

A half-open range of rows that one call of check_chunk checks.

Defined in src/judgment_core/checker_base.mojo.

CheckFail

@fieldwise_init
struct CheckFail(ImplicitlyCopyable, TrivialRegisterPassable, Writable)
Field Type Description
kind RefusalKind The refusal's kind.
detail UInt16 The refusal's detail code.
operand UInt32 The operand position concerned, or NO_OPERAND.

The error raised inside a check; the row boundary turns it into a Refusal.

Defined in src/judgment_core/checker_base.mojo.

CheckFail.write_to

def write_to(self, mut writer: Some[Writer])

Write the failure.

Arguments.

  • writer: The writer.

Fact

@fieldwise_init
struct Fact(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
key FactKey The node and signature.
origin UInt64 The row whose check established it.
type UInt32 The node's type; NONE for a type node.
home UInt32 Its home theory for the signature.
scope UInt32 The innermost frame that fixes one of its locals, or NONE.
sorts UInt32 A DSET of its sorted type variables (tag DEP_TVAR).
locals UInt32 A DSET of its locals (tag DEP_LOCAL).
flags UInt8 FACT_CANONICAL, FACT_TYPE and FACT_PROP.
weight UInt64 Its weight: the recursive tree weight every read of it charges (Definition LC-18).

A verified fact about a bound-closed node for a signature (KC1.4, Requirement Q-R1).

Every id is a row of the view below origin. weight is what establishing the fact charges when no fact is cached, so a check that reads the fact charges the same (KC1.10).

Defined in src/judgment_core/checker_base.mojo.

Facts

@fieldwise_init
struct Facts(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
fact_start UInt32 The fact run's first entry.
fact_count UInt32 Its length.
answer_start UInt32 The answer run's first entry.
answer_count UInt32 Its length.

The runs of the scratch's fact and answer logs that one check established (KC1.4, item 4).

Defined in src/judgment_core/checker_base.mojo.

FACT_CANONICAL

comptime FACT_CANONICAL: UInt8 = 1

A fact's flag: the node is canonical for the signature.

Defined in src/judgment_core/checker_base.mojo.

Info

@fieldwise_init
struct Info(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
type Ref The node's type; NO_REF for a type node.
home UInt64 Its home theory for the signature.
scope UInt32 The innermost frame that fixes one of its locals, or NONE.
sorts UInt64 Its sorted type variables.
locals UInt64 Its locals.
flags UInt8 FACT_CANONICAL, FACT_TYPE and FACT_PROP.
weight UInt64 Its weight (Definition LC-18).

What the checker knows of a node for a signature, in scratch: a fact whose parts may be scratch rows (KC1.4, item 3).

type is a reference; home is a theory reference (THEORY row, or a scratch vector tagged with SCRATCH_BIT); sorts and locals are set references (DSET row, or a scratch set). Only an Info whose parts are all rows of the view becomes a published Fact.

Defined in src/judgment_core/checker_base.mojo.

Refusal

@fieldwise_init
struct Refusal(ImplicitlyCopyable, TrivialRegisterPassable, Writable)
Field Type Description
kind RefusalKind What went wrong.
row UInt64 The row refused.
tag UInt16 Its rule or declaration tag.
detail UInt16 A detail code (DETAIL_*).
operand UInt32 The operand position concerned, or NO_OPERAND.

A refused row: owns no heap memory.

Defined in src/judgment_core/checker_base.mojo.

Refusal.write_to

def write_to(self, mut writer: Some[Writer])

Write the refusal.

Arguments.

  • writer: The writer.

RefusalKind

@fieldwise_init
struct RefusalKind(Equatable, ImplicitlyCopyable, TrivialRegisterPassable, Writable)
Field Type Description
code UInt8 The kind's number; compare kinds with ==.

The kind of a refusal: a closed set.

Defined in src/judgment_core/checker_base.mojo.

RefusalKind.MISMATCH

comptime MISMATCH = RefusalKind(1)

A stored field differs from what the rule computes.

RefusalKind.ILL_TYPED

comptime ILL_TYPED = RefusalKind(2)

A term the row introduces has the wrong type.

RefusalKind.SIDE_CONDITION

comptime SIDE_CONDITION = RefusalKind(3)

A side condition of the rule fails.

RefusalKind.SCOPE

comptime SCOPE = RefusalKind(4)

A cited theory, declaration, local or hypothesis is not visible or usable.

RefusalKind.DECLARATION

comptime DECLARATION = RefusalKind(5)

A condition of a declaration form fails.

RefusalKind.NAME_CLASH

comptime NAME_CLASH = RefusalKind(6)

A name is declared twice in one theory.

RefusalKind.LIMIT

comptime LIMIT = RefusalKind(7)

The budget ran out; undecided; stops the chunk.

RefusalKind.CAPACITY

comptime CAPACITY = RefusalKind(8)

A scratch area or a width limit would be exceeded; undecided; stops the chunk.

RefusalKind.STORAGE

comptime STORAGE = RefusalKind(9)

A spilled block could not be read; undecided; stops the chunk.

RefusalKind.UNSUPPORTED

comptime UNSUPPORTED = RefusalKind(10)

A row no admitted checker checks; undecided.

RefusalKind.UNREADY

comptime UNREADY = RefusalKind(11)

The view does not yet hold what the row needs; undecided.

RefusalKind.INTERNAL

comptime INTERNAL = RefusalKind(12)

A broken invariant: a bug, never a property of the input; stops the chunk.

RefusalKind.decided

def decided(self) -> Bool

Decide whether the kind rejects the row (G16).

Returns. True for the decided kinds, MISMATCH to NAME_CLASH.

RefusalKind.stops

def stops(self) -> Bool

Decide whether the kind stops a chunk (KC1.9, item 4).

Returns. True for LIMIT, CAPACITY, STORAGE and INTERNAL.

RefusalKind.write_to

def write_to(self, mut writer: Some[Writer])

Write the kind's name.

Arguments.

  • writer: The writer.

DETAIL_CONTEXT

comptime DETAIL_CONTEXT: UInt16 = 9

The context does not extend a premise's, or does not fix a local of V (R1).

Defined in src/judgment_core/checker_base.mojo.

term_info

def term_info[V: CheckView](v: V, mut s: Scratch, sig: UInt32, t: Ref) raises CheckFail -> Info

Read or establish what a bound-closed node is for a signature (KC1.7, item 6).

The fact is read from the row memo, the chunk memo or the view, or derived from its children's facts, deriving theirs first. Whichever route gives it, the check is charged the fact's weight: a function of the term and the signature only (Definition LC-18), so a cached fact only makes the work faster. Derivation itself is not charged.

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • s: The scratch.
  • sig: The signature theory.
  • t: A node.

Returns. Its info.

Raises.

  • CheckFail: ILL_TYPED for a term that is open or ill typed; SCOPE; LIMIT; CAPACITY; STORAGE; UNREADY.

Defined in src/judgment_core/checker_facts.mojo.

th_includes

def th_includes[V: CheckView](v: V, mut s: Scratch, a: UInt64, b: UInt64) raises CheckFail -> Bool

Decide whether theory a includes theory b.

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • s: The scratch.
  • a: A theory reference.
  • b: Another.

Returns. True when every entry of b is at most a's for its segment.

Raises.

  • CheckFail: LIMIT; STORAGE.

Defined in src/judgment_core/checker_facts.mojo.

member_answer

def member_answer[V: CheckView](v: V, mut s: Scratch, theory: UInt32, type: Ref, tvar: Ref) raises CheckFail -> UInt64

Decide whether a type has a type variable's sort in a theory (Definition Y-11).

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • s: The scratch.
  • theory: The theory.
  • type: A type.
  • tvar: A type variable.

Returns. The snapshot's member answer: bit 32 when the type has the sort, the low 32 bits a DSET of the declarations used; UInt32.MAX as the set for the empty sort.

Raises.

  • CheckFail: What computing the answer raises.

Defined in src/judgment_core/checker_engine.mojo.

CheckView

trait CheckView(Copyable)

An immutable snapshot of termbank.dag as the checker reads it.

Defined in src/judgment_core/checker_view.mojo.

CheckView.top

def top(self) -> UInt64

Give the sequence number below which rows are readable.

Returns. top() of KC1.2.

CheckView.theory_mark

def theory_mark(self) -> UInt64

Give the sequence number below which the theory pass has accepted every declaration and theory row.

Returns. The theory mark.

CheckView.locate

def locate(self, seq: UInt64) raises CheckFail -> UInt64

Find the table and id of a sequence number (TD1.1, item 4).

Arguments.

  • seq: A sequence number below top().

Returns. table << 32 | id.

Raises.

  • CheckFail: STORAGE; INTERNAL.

CheckView.count

def count(self, table: Int, seq: UInt64) raises CheckFail -> UInt32

Count the rows of a table below a sequence number (TD1.1, item 4).

Arguments.

  • table: The table (T_*).
  • seq: A sequence number at most top().

Returns. The count; every id below it is a row before seq.

Raises.

  • CheckFail: STORAGE; INTERNAL.

CheckView.core

def core(self) -> CoreIds

Give the core prefix's rows.

Returns. The core ids.

CheckView.head_key

def head_key(self, h: UInt32) raises CheckFail -> UInt64

Read a head's key: fnv1a64 of its name.

Arguments.

  • h: A head.

Returns. The key.

Raises.

  • CheckFail: STORAGE.

CheckView.head_name

def head_name(self, h: UInt32) raises CheckFail -> UInt32

Read a head's name.

Arguments.

  • h: A head.

Returns. The name's POOL row.

Raises.

  • CheckFail: STORAGE.

CheckView.head_payload

def head_payload(self, h: UInt32) raises CheckFail -> UInt8

Read a head's payload kind.

Arguments.

  • h: A head.

Returns. PAYLOAD_NONE, PAYLOAD_IMMEDIATE or PAYLOAD_POOLED.

Raises.

  • CheckFail: STORAGE.

CheckView.head_binder

def head_binder(self, h: UInt32) raises CheckFail -> UInt8

Read how many variables a head binds over its last argument.

Arguments.

  • h: A head.

Returns. 0 or 1.

Raises.

  • CheckFail: STORAGE.

CheckView.head_flags

def head_flags(self, h: UInt32) raises CheckFail -> UInt8

Read a head's flags.

Arguments.

  • h: A head.

Returns. Its flags.

Raises.

  • CheckFail: STORAGE.

CheckView.head_class

def head_class(self, h: UInt32) raises CheckFail -> UInt8

Classify a head: the kind of every node it heads (K_*).

Arguments.

  • h: A head.

Returns. The kind.

Raises.

  • CheckFail: STORAGE.

CheckView.head_decl

def head_decl(self, h: UInt32) raises CheckFail -> UInt32

Read the declaration a head belongs to.

Arguments.

  • h: A head.

Returns. The declaration, or NONE for a structural head.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_head

def decl_head(self, d: UInt32) raises CheckFail -> UInt32

Find the head of a declaration (TD1.10, head by declaration).

Arguments.

  • d: A declaration.

Returns. Its head, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.pool_length

def pool_length(self, p: UInt32) raises CheckFail -> UInt32

Read a pooled string's length.

Arguments.

  • p: A POOL row.

Returns. Its byte count.

Raises.

  • CheckFail: STORAGE.

CheckView.pool_fnv

def pool_fnv(self, p: UInt32) raises CheckFail -> UInt64

Read a pooled string's fnv1a64.

Arguments.

  • p: A POOL row.

Returns. The hash.

Raises.

  • CheckFail: STORAGE.

CheckView.pool_read

def pool_read(self, p: UInt32, mut out: List[UInt8]) raises CheckFail

Append a pooled string's bytes to a caller's buffer.

Arguments.

  • p: A POOL row.
  • out: The buffer.

Raises.

  • CheckFail: STORAGE.

CheckView.lookup_bytes

def lookup_bytes(self, bytes: List[UInt8], below: UInt32) raises CheckFail -> UInt32

Find the pooled string with these bytes.

Arguments.

  • bytes: The bytes.
  • below: Only rows below this id count.

Returns. The row, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.node_head

def node_head(self, n: UInt32) raises CheckFail -> UInt32

Read a node's head.

Arguments.

  • n: A node.

Returns. Its head.

Raises.

  • CheckFail: STORAGE.

CheckView.node_payload

def node_payload(self, n: UInt32) raises CheckFail -> UInt64

Read a node's payload; a POOL row under a pooled head.

Arguments.

  • n: A node.

Returns. Its payload.

Raises.

  • CheckFail: STORAGE.

CheckView.node_arity

def node_arity(self, n: UInt32) raises CheckFail -> UInt32

Read a node's child count.

Arguments.

  • n: A node.

Returns. The count.

Raises.

  • CheckFail: STORAGE.

CheckView.node_child

def node_child(self, n: UInt32, i: UInt32) raises CheckFail -> UInt32

Read one child of a node.

Arguments.

  • n: A node.
  • i: A position below its arity.

Returns. The child.

Raises.

  • CheckFail: STORAGE.

CheckView.node_shash

def node_shash(self, n: UInt32) raises CheckFail -> UInt64

Read a node's structural hash.

Arguments.

  • n: A node.

Returns. The hash.

Raises.

  • CheckFail: STORAGE.

CheckView.node_loose

def node_loose(self, n: UInt32) raises CheckFail -> UInt32

Read a node's loose bound.

Arguments.

  • n: A node.

Returns. One more than its greatest loose index, or 0.

Raises.

  • CheckFail: STORAGE.

CheckView.node_flags

def node_flags(self, n: UInt32) raises CheckFail -> UInt8

Read a node's flags.

Arguments.

  • n: A node.

Returns. Its flags.

Raises.

  • CheckFail: STORAGE.

CheckView.lookup_node

def lookup_node(self, head: UInt32, payload: UInt64, children: List[UInt32], below: UInt32) raises CheckFail -> UInt32

Find the node with this content, by an exact comparison.

Arguments.

  • head: Its head.
  • payload: Its payload.
  • children: Its children.
  • below: Only nodes below this id count (KC1.2, item 6).

Returns. The node, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.local_depth

def local_depth(self, l: UInt32) raises CheckFail -> UInt32

Read a local's binding depth: the depth of the frame that fixes it.

Arguments.

  • l: A LOCAL row.

Returns. Its binding depth.

Raises.

  • CheckFail: STORAGE.

CheckView.local_name

def local_name(self, l: UInt32) raises CheckFail -> UInt32

Read a local's name.

Arguments.

  • l: A LOCAL row.

Returns. Its name, a POOL row.

Raises.

  • CheckFail: STORAGE.

CheckView.local_type

def local_type(self, l: UInt32) raises CheckFail -> UInt32

Read a local's type.

Arguments.

  • l: A LOCAL row.

Returns. Its type node.

Raises.

  • CheckFail: STORAGE.

CheckView.local_frame

def local_frame(self, l: UInt32) raises CheckFail -> UInt32

Find the frame that fixes a local (K1.5; TD1.7).

Arguments.

  • l: A LOCAL row.

Returns. The CONTEXT row whose entry fixes it, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_parent

def ctx_parent(self, c: UInt32) raises CheckFail -> UInt32

Read a frame's parent.

Arguments.

  • c: A frame.

Returns. Its parent, NONE for the empty frame.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_theory

def ctx_theory(self, c: UInt32) raises CheckFail -> UInt32

Read a frame's theory.

Arguments.

  • c: A frame.

Returns. Its theory.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_entry_kind

def ctx_entry_kind(self, c: UInt32) raises CheckFail -> UInt8

Read a frame's entry kind.

Arguments.

  • c: A frame.

Returns. ENTRY_NONE, ENTRY_FIX or ENTRY_ASSUME.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_entry

def ctx_entry(self, c: UInt32) raises CheckFail -> UInt32

Read a frame's entry.

Arguments.

  • c: A frame.

Returns. A LOCAL for a fix, a NODE for an assume, NONE for a rebase.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_depth

def ctx_depth(self, c: UInt32) raises CheckFail -> UInt32

Read a frame's depth.

Arguments.

  • c: A frame.

Returns. The frames on the chain below it.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_jump

def ctx_jump(self, c: UInt32) raises CheckFail -> UInt32

Read a frame's jump pointer.

Arguments.

  • c: A frame.

Returns. Its jump frame.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_sorts

def ctx_sorts(self, c: UInt32) raises CheckFail -> UInt32

Read a frame's sorted type variables, a DSET of tag-6 items (TD1.7, Definition LC-7(5)).

Arguments.

  • c: A frame.

Returns. The set.

Raises.

  • CheckFail: STORAGE.

CheckView.ctx_ancestor

def ctx_ancestor(self, c: UInt32, depth: UInt32, mut steps: UInt64) raises CheckFail -> UInt32

Find the frame at a depth on a frame's chain, by its jump pointers.

Arguments.

  • c: A frame.
  • depth: A depth at most ctx_depth(c).
  • steps: Increased by the links followed: from a frame deeper than depth, its jump when that is not shallower than depth, else its parent.

Returns. The ancestor of c (or c) at that depth.

Raises.

  • CheckFail: STORAGE.

CheckView.hset_count

def hset_count(self, h: UInt32) raises CheckFail -> UInt32

Read a hypothesis set's size.

Arguments.

  • h: An HSET row.

Returns. Its item count.

Raises.

  • CheckFail: STORAGE.

CheckView.hset_item

def hset_item(self, h: UInt32, i: UInt32) raises CheckFail -> UInt32

Read an item of a hypothesis set; items strictly increase.

Arguments.

  • h: An HSET row.
  • i: A position.

Returns. The proposition's node.

Raises.

  • CheckFail: STORAGE.

CheckView.lookup_hset

def lookup_hset(self, items: List[UInt32], below: UInt32) raises CheckFail -> UInt32

Find the hypothesis set with these items.

Arguments.

  • items: Strictly increasing node ids.
  • below: Only rows below this id count.

Returns. The row, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.dset_count

def dset_count(self, d: UInt32) raises CheckFail -> UInt32

Read a dependency set's size.

Arguments.

  • d: A DSET row.

Returns. Its item count.

Raises.

  • CheckFail: STORAGE.

CheckView.dset_item

def dset_item(self, d: UInt32, i: UInt32) raises CheckFail -> UInt64

Read an item of a dependency set; items strictly increase.

Arguments.

  • d: A DSET row.
  • i: A position.

Returns. The item, tag << 32 | id.

Raises.

  • CheckFail: STORAGE.

CheckView.lookup_dset

def lookup_dset(self, items: List[UInt64], below: UInt32) raises CheckFail -> UInt32

Find the dependency set with these items.

Arguments.

  • items: Strictly increasing items.
  • below: Only rows below this id count.

Returns. The row, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.theory_count

def theory_count(self, t: UInt32) raises CheckFail -> UInt32

Read a theory's version-vector length.

Arguments.

  • t: A THEORY row.

Returns. Its entry count.

Raises.

  • CheckFail: STORAGE.

CheckView.theory_entry

def theory_entry(self, t: UInt32, i: UInt32) raises CheckFail -> UInt64

Read an entry of a theory's version vector; segments strictly increase.

Arguments.

  • t: A THEORY row.
  • i: A position.

Returns. segment << 32 | count.

Raises.

  • CheckFail: STORAGE.

CheckView.lookup_theory

def lookup_theory(self, entries: List[UInt32], below: UInt32) raises CheckFail -> UInt32

Find the theory with this version vector.

Arguments.

  • entries: Entries as (segment, count) pairs, segments strictly increasing.
  • below: Only rows below this id count.

Returns. The row, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.theory_published

def theory_published(self, t: UInt32) -> Bool

Decide whether the theory pass has published its decision on a theory, so its snapshot entries may be read.

Arguments.

  • t: A theory.

Returns. True when the theory row is below the theory mark.

CheckView.signature_of

def signature_of(self, t: UInt32) raises CheckFail -> UInt32

Give a theory's signature theory (snapshot, SIGNATURE).

Arguments.

  • t: A theory.

Returns. Its signature theory, or NONE when the snapshot has no answer.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_kind

def decl_kind(self, d: UInt32) raises CheckFail -> UInt8

Read a declaration's kind (DECL_*).

Arguments.

  • d: A declaration.

Returns. Its kind.

Raises.

  • CheckFail: STORAGE.

CheckView.head_part

def head_part(self, h: UInt32) raises CheckFail -> UInt32

Read which part of its declaration a head names: 0 for a declaration's own head.

Arguments.

  • h: A head.

Returns. The part.

Raises.

  • CheckFail: STORAGE.

CheckView.part_head

def part_head(self, d: UInt32, part: UInt32) raises CheckFail -> UInt32

Find the head of a part of a declaration: a type definition's abs (1) and rep (2), a specification's constants (1 to k), a class's predicate (1); part 0 is decl_head (TD1.10, head by declaration).

Arguments.

  • d: A declaration.
  • part: The part.

Returns. Its head, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_operand_count

def decl_operand_count(self, d: UInt32) raises CheckFail -> UInt32

Read how many operands a declaration has, in its form's grammar (TD1.7, decl_layout).

Arguments.

  • d: A declaration.

Returns. The operand count.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_operand

def decl_operand(self, d: UInt32, i: UInt32) raises CheckFail -> UInt32

Read one operand of a declaration, in its form's grammar (TD1.7, decl_layout).

Arguments.

  • d: A declaration.
  • i: A position below decl_operand_count.

Returns. The operand.

Raises.

  • CheckFail: STORAGE; MISMATCH for a position out of range.

CheckView.decl_segment

def decl_segment(self, d: UInt32) raises CheckFail -> UInt32

Read a declaration's segment.

Arguments.

  • d: A declaration.

Returns. Its segment.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_position

def decl_position(self, d: UInt32) raises CheckFail -> UInt32

Read a declaration's position in its segment, from 1.

Arguments.

  • d: A declaration.

Returns. Its position.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_parent

def decl_parent(self, d: UInt32) raises CheckFail -> UInt32

Read the theory a declaration is declared in.

Arguments.

  • d: A declaration.

Returns. The theory.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_type

def decl_type(self, d: UInt32) raises CheckFail -> UInt32

Read a declaration's type: a constant's or definition's type, a literal kind's carrier.

Arguments.

  • d: A declaration.

Returns. The type node, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_params

def decl_params(self, d: UInt32) raises CheckFail -> UInt32

Read a declaration's type-parameter count (s_params): a constant's type arguments.

Arguments.

  • d: A declaration.

Returns. The count.

Raises.

  • CheckFail: STORAGE.

CheckView.decl_param

def decl_param(self, d: UInt32, i: UInt32) raises CheckFail -> UInt32

Read a declaration's type parameter.

Arguments.

  • d: A declaration.
  • i: A position below decl_params.

Returns. The type variable's node.

Raises.

  • CheckFail: STORAGE.

CheckView.acu_targs

def acu_targs(self, d: UInt32) raises CheckFail -> UInt32

Read an ACU operator's type-argument count (s_ntargs).

Arguments.

  • d: An ACU operator declaration.

Returns. The count.

Raises.

  • CheckFail: STORAGE.

CheckView.acu_targ

def acu_targ(self, d: UInt32, i: UInt32) raises CheckFail -> UInt32

Read an ACU operator's type-argument pattern.

Arguments.

  • d: An ACU operator declaration.
  • i: A position.

Returns. The type node.

Raises.

  • CheckFail: STORAGE.

CheckView.acu_unit

def acu_unit(self, d: UInt32) raises CheckFail -> UInt32

Read an ACU operator's unit pattern.

Arguments.

  • d: An ACU operator declaration.

Returns. The unit's node, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.lit_impl

def lit_impl(self, kind: UInt32) raises CheckFail -> UInt8

Read a literal kind's implementation code (LITBIND.implementation).

Arguments.

  • kind: A literal-kind declaration.

Returns. The LiteralImpl code.

Raises.

  • CheckFail: STORAGE.

CheckView.lit_base

def lit_base(self, kind: UInt32) raises CheckFail -> UInt32

Read a literal kind's base kind (LITBIND.base).

Arguments.

  • kind: A literal-kind declaration.

Returns. The base kind, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.lit_bind

def lit_bind(self, kind: UInt32, op: Int) raises CheckFail -> UInt32

Read the instance a literal kind binds to an operation (LITBIND.bind).

Arguments.

  • kind: A literal-kind declaration.
  • op: A LiteralOp code.

Returns. The instance's node, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.sig_acu_count

def sig_acu_count(self, sig: UInt32, constant: UInt32) raises CheckFail -> UInt32

Count the ACU operator declarations of a constant in a signature (snapshot; TD1.6 ACU_OPERATORS).

Arguments.

  • sig: A signature theory.
  • constant: A constant's declaration.

Returns. The count.

Raises.

  • CheckFail: STORAGE; UNREADY when the snapshot has no answer.

CheckView.sig_acu

def sig_acu(self, sig: UInt32, constant: UInt32, i: UInt32) raises CheckFail -> UInt32

Read one ACU operator declaration of a constant in a signature, in the snapshot's fixed order (snapshot).

Arguments.

  • sig: A signature theory.
  • constant: A constant's declaration.
  • i: A position.

Returns. The ACU operator's declaration.

Raises.

  • CheckFail: STORAGE.

CheckView.sig_binding

def sig_binding(self, sig: UInt32, instance: UInt32) raises CheckFail -> UInt32

Find the literal operation an instance is bound to in a signature (snapshot; TD1.6 BINDING).

Arguments.

  • sig: A signature theory.
  • instance: A constant instance's node.

Returns. kind << 4 | op, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.sig_carrier

def sig_carrier(self, sig: UInt32, type: UInt32) raises CheckFail -> UInt32

Find the literal kind whose carrier a type is in a signature (snapshot; TD1.6 CARRIER).

Arguments.

  • sig: A signature theory.
  • type: A type node.

Returns. The literal kind, or NONE.

Raises.

  • CheckFail: STORAGE.

CheckView.visible

def visible(self, theory: UInt32, d: UInt32) raises CheckFail -> Bool

Decide whether a declaration is visible in a theory.

Arguments.

  • theory: A theory.
  • d: A declaration.

Returns. True when it is.

Raises.

  • CheckFail: STORAGE.

CheckView.member

def member(self, theory: UInt32, type: UInt32, sort: UInt32) raises CheckFail -> Optional[SortAnswer]

Read whether a type has a sort in a theory, with the declarations used (snapshot, MEMBER; Definition Y-9).

Arguments.

  • theory: A theory.
  • type: A type node.
  • sort: A sort node.

Returns. The published answer, if any: its verdict, its DSET of instance and class-relation declarations, its weight.

Raises.

  • CheckFail: STORAGE.

CheckView.witness

def witness(self, theory: UInt32, sort: UInt32) raises CheckFail -> Optional[SortAnswer]

Read whether a sort is witnessed in a theory, with the witness's declarations (snapshot, WITNESS; Definition Y-12a).

Arguments.

  • theory: A theory.
  • sort: A sort node.

Returns. The published answer, if any.

Raises.

  • CheckFail: STORAGE.

CheckView.entails

def entails(self, theory: UInt32, sort: UInt32, other: UInt32) raises CheckFail -> Optional[SortAnswer]

Read whether a sort entails another in a theory, with the class relations used (snapshot, ENTAILS; Definitions Y-9, Y-10a).

Arguments.

  • theory: A theory.
  • sort: A sort node.
  • other: Another sort node.

Returns. The published answer, if any.

Raises.

  • CheckFail: STORAGE.

CheckView.sort_declarations

def sort_declarations(self, kind: UInt8, key: UInt32, mut out: List[UInt32]) raises CheckFail

Append, in commit order, every instance (kind DECL_INSTANCE) of a type constructor or class relation (DECL_CLASS_RELATION) from a subclass; key NONE for all of the kind.

The list is not filtered to a theory: the caller keeps the ones its theory includes.

Arguments.

  • kind: DECL_INSTANCE or DECL_CLASS_RELATION.
  • key: The type constructor or subclass, or NONE.
  • out: Receives the declarations.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_rule

def proof_rule(self, p: UInt32) raises CheckFail -> UInt8

Read a proof row's kind.

Arguments.

  • p: A PROOF row.

Returns. Its kind (TD1.8).

Raises.

  • CheckFail: STORAGE.

CheckView.proof_ops

def proof_ops(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's operand count.

Arguments.

  • p: A PROOF row.

Returns. The count.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_op

def proof_op(self, p: UInt32, i: UInt32) raises CheckFail -> UInt32

Read a proof row's operand.

Arguments.

  • p: A PROOF row.
  • i: A position.

Returns. The operand.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_conclusion

def proof_conclusion(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's conclusion.

Arguments.

  • p: A PROOF row.

Returns. Its NODE.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_hyps

def proof_hyps(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's hypothesis set.

Arguments.

  • p: A PROOF row.

Returns. Its HSET.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_deps

def proof_deps(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's dependency set.

Arguments.

  • p: A PROOF row.

Returns. Its DSET.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_context

def proof_context(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's context.

Arguments.

  • p: A PROOF row.

Returns. Its CONTEXT.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_signature

def proof_signature(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's signature theory.

Arguments.

  • p: A PROOF row.

Returns. Its THEORY.

Raises.

  • CheckFail: STORAGE.

CheckView.proof_home

def proof_home(self, p: UInt32) raises CheckFail -> UInt32

Read a proof row's home theory.

Arguments.

  • p: A PROOF row.

Returns. Its THEORY.

Raises.

  • CheckFail: STORAGE.

CheckView.fact

def fact(self, node: UInt32, sig: UInt32) raises CheckFail -> Optional[Fact]

Find a published verified fact (KC1.2, item 4).

Arguments.

  • node: A node.
  • sig: A signature theory.

Returns. The fact with the smallest origin, or None.

Raises.

  • CheckFail: STORAGE.

Scratch

struct Scratch(Movable, ThreadTransferable)
Field Type Description
limits ScratchLimits Its limits.
temporary_bytes UInt64 Live workspace reserved by scoped computations outside the pooled areas.
nodes List[SNode] Rebuilt nodes.
ops List[Ref] Their children.
spans List[UInt64] Scratch byte strings: start << 32 | length.
span_fnv List[UInt64] Their fnv1a64.
bytes List[UInt8] Their bytes.
sets List[UInt64] Scratch sets and theory vectors: start << 32 | count into set_words.
set_words List[UInt64] A stack of words for set and vector computations.
sealed List[UInt64] The items of sealed scratch sets and vectors.
infos List[Info] What the checker has established about nodes, in scratch.
memo MemoTable The row memo: engine results and infos, cleared with each truncation.
chunk MemoTable The chunk memo of facts that passing rows established (KC1.3, item 6).
facts List[Fact] The fact log.
indexed_facts Int Leading fact-log entries already indexed by the constructor in this scratch's chunk memo.
answers List[Answer] The answer log: per-type snapshot answers the checks established (Definition LC-13).
answer_sets List[List[UInt64]] The item sets of computed answers that no DSET row holds yet, for a producer to intern (checker_answers).
refusals List[Refusal] The refusal log.
frames List[Frame] The engine's step stack.
values List[Ref] The engine's value stack.
jobs List[Job] The engine's jobs.
map_index MemoTable Exact substitution keys by twice the job id, plus one for locals; rule validation uses the high-bit namespace.
refs List[Ref] A stack of references for callers' temporaries.
sort_buffer List[UInt64] Reusable merge and word-sort storage, empty between sorts.
envs List[UInt64] Binder environments: parent, type, depth and ancestor jump; environment 0 is empty.
comp UInt64 A counter that names each standalone computation, so that its memo entries are its own.
words List[UInt64] A stack of words for callers' temporaries.
ids List[UInt32] A buffer for the children of a lookup.
wbuf List[UInt64] A buffer for the items of a set or theory lookup.
lit List[UInt8] A buffer for literal encodings.
steps UInt64 The units still allowed.
charged UInt64 The units charged since the last reset.
below_node UInt32 Lookups find nodes below this id: the checked row's bound (KC1.2, item 6).
below_pool UInt32 Lookups find pooled strings below this id.
below_hset UInt32 Lookups find hypothesis sets below this id.
below_dset UInt32 Lookups find dependency sets below this id.
below_theory UInt32 Lookups find theories below this id.
below_local UInt32 Lookups find locals below this id.
row UInt64 The row being checked.
produce Bool Produce mode: the rules compute a row's stored fields into the out_* areas instead of comparing them.
out_ops List[UInt32] Produce mode: the row's operands, in its kind's layout.
out_conclusion UInt64 Produce mode: the conclusion, possibly a scratch node.
out_hyps List[UInt64] Produce mode: Γ, sorted and deduplicated node references.
out_locals List[UInt64] Produce mode: V, sorted tagged local items.
out_deps List[UInt64] Produce mode: the dependency set, sorted tagged items.
out_home UInt64 Produce mode: the home, a theory reference.
out_site_entry UInt32 Produce mode, a natural-deduction row: its site's entry frame (Definition LC-9).
out_site_theory UInt64 Produce mode, a natural-deduction row: its site's theory; the site is the entry frame rebased to it.

A pooled arena that holds every temporary of a check (KC1.3); moved, never copied.

Defined in src/judgment_core/checker_scratch.mojo.

Scratch.__init__

def __init__(out self, limits: ScratchLimits)

Make a scratch.

Arguments.

  • limits: Its limits.

Scratch.reset

def reset(mut self)

Empty every area, keeping the capacity (KC1.3, item 2).

Scratch.mark

def mark(self) -> ScratchMark

Record the areas' extents.

Returns. The mark.

Scratch.truncate

def truncate(mut self, m: ScratchMark)

Drop everything allocated after a mark, and clear the row memo and the stacks.

Arguments.

  • m: A mark of this scratch, taken since its last reset.

Scratch.room

def room(self, extra: UInt64 = 0) raises CheckFail

Refuse when the areas in use exceed max_bytes (KC1.3, item 3).

Arguments.

  • extra: Additional temporary storage owned by the current computation.

Raises.

  • CheckFail: CAPACITY.

Scratch.reserve_temporary

def reserve_temporary(mut self, bytes: UInt64) raises CheckFail

Reserve bounded temporary workspace, restored by its computation on every exit.

Arguments.

  • bytes: Additional workspace, including its index and container overhead.

Raises.

  • CheckFail: CAPACITY when the reservation exceeds the scratch limit.

Scratch.charge

@always_inline
def charge(mut self, n: UInt64) raises CheckFail

Charge units of work (G3, KC1.10).

Arguments.

  • n: The units.

Raises.

  • CheckFail: LIMIT when they exceed what remains.

Scratch.find_node

def find_node(self, key: UInt64, head: UInt32, payload: UInt64, spooled: UInt8, start: Int) -> Int

Find the scratch node with this content.

Arguments.

  • key: The content's key (scratch_key).
  • head: Its head.
  • payload: Its payload.
  • spooled: Whether the payload is a scratch byte string.
  • start: Its children are refs[start:].

Returns. The node's index, or -1.

Scratch.add_node

def add_node(mut self, key: UInt64, node: SNode, start: Int) raises CheckFail -> Int

Append a scratch node and index it; the caller has found no equal node.

Arguments.

  • key: The content's key.
  • node: The node; its start and arity are set here.
  • start: Its children are refs[start:].

Returns. Its index.

Raises.

  • CheckFail: CAPACITY.

Scratch.add_span

def add_span(mut self, fnv: UInt64) raises CheckFail -> UInt64

Append the bytes of lit as a scratch byte string, or find an equal one.

Arguments.

  • fnv: Their fnv1a64.

Returns. Its index.

Raises.

  • CheckFail: CAPACITY.

Scratch.add_set

def add_set(mut self, start: Int) raises CheckFail -> UInt64

Seal the words pushed on set_words since start as a scratch set or vector, and pop them.

Arguments.

  • start: Where its items start in set_words.

Returns. Its index.

Raises.

  • CheckFail: CAPACITY.

Scratch.set_start

def set_start(self, i: Int) -> Int

Read where a scratch set's items start.

Arguments.

  • i: The set's index.

Returns. The position in sealed.

Scratch.set_count

def set_count(self, i: Int) -> Int

Read a scratch set's item count.

Arguments.

  • i: The set's index.

Returns. The count.

ScratchLimits

@fieldwise_init
struct ScratchLimits(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
initial_bytes UInt64 The size a new scratch reserves.
max_bytes UInt64 The size no scratch exceeds.

A scratch's first and greatest size.

Defined in src/judgment_core/checker_scratch.mojo.

check_proof

def check_proof[V: CheckView](v: V, seq: UInt64, mut budget: Budget, mut s: Scratch) -> Result[Facts, Refusal]

Check one inference step: one proof row (KC1.7). Never raises.

On refusal the scratch is truncated to the mark taken on entry, so a refused row leaves no facts.

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • seq: The row's sequence number.
  • budget: Charged; termbank's Budget.
  • s: The scratch.

Returns. The facts established, or the row's refusal.

Defined in src/judgment_core/checker_rules.mojo.

ChunkVerdict

struct ChunkVerdict(Movable, ThreadTransferable)
Field Type Description
chunk Chunk The chunk.
passed_end UInt64 Every row of [chunk.start, passed_end) passed.
facts List[Fact] The facts of the passing prefix, in row order, each key once; exactly sized.
answers List[Answer] The per-type answers of the passing prefix, in row order; exactly sized.
refused List[Refusal] Refusals that did not stop the chunk, by row.
stop Optional[Refusal] The refusal that stopped the loop; later rows are unchecked.
steps UInt64 The units charged.

What checking a chunk established.

Defined in src/judgment_core/checker_chunk.mojo.

ChunkVerdict.__init__

def __init__(out self, chunk: Chunk)

Make an empty verdict.

Arguments.

  • chunk: The chunk.

check_chunk

def check_chunk[V: CheckView](v: V, chunk: Chunk, budget: Budget, mut s: Scratch) -> ChunkVerdict

Check the rows of a chunk in sequence order (KC1.9). Never raises.

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • chunk: The rows.
  • budget: The chunk's allowance.
  • s: A scratch; reset first, so what an earlier user left cannot affect the result.

Returns. The chunk's verdict.

Defined in src/judgment_core/checker_chunk.mojo.

chunk_allowance

def chunk_allowance[V: CheckView](v: V, chunk: Chunk) -> Budget

Give a chunk its allowance: the canonical policy, a function of nothing but the policy (KC1.10, item 2).

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • chunk: The chunk.

Returns. UInt64.MAX steps.

Defined in src/judgment_core/checker_chunk.mojo.

PERMUTED

comptime PERMUTED = 6

Type variables up to which every renaming is compared.

Defined in src/judgment_core/checker_keys.mojo.

StatementKey

@fieldwise_init
struct StatementKey(ImplicitlyCopyable, TrivialRegisterPassable)
Field Type Description
node Ref The canonical renamed statement: a view node or a scratch node, equal for statements equal up to renaming.
order_start Int The statement's own type variables, by canonical position, are s.words[order_start:order_start + count].
count Int How many type variables the statement has.

A statement's key (Definition I-5).

Defined in src/judgment_core/checker_keys.mojo.

statement_key

def statement_key[V: CheckView](v: V, mut s: Scratch, sig: UInt32, statement: Ref) raises CheckFail -> StatementKey

Key a closed statement canonical for a signature, up to renaming its type variables (Definition I-5).

The candidates are the renamings order[i] ↦ ?i for every order of the statement's type variables when there are at most PERMUTED, else for the first-occurrence order alone; the key is the least candidate in the structural order, the first in lexicographic order of positions among equals. ?i keeps the sort of order[i].

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • s: The scratch; the key's order is left on s.words.
  • sig: The signature theory.
  • statement: A closed statement, canonical for sig.

Returns. The key: the statement itself, with an empty order, when it has no type variables.

Raises.

  • CheckFail: LIMIT; CAPACITY; STORAGE; what the substitution raises.

Defined in src/judgment_core/checker_keys.mojo.

type_params

def type_params[V: CheckView](v: V, mut s: Scratch, t: Ref) raises CheckFail -> Int

Push a node's type variables on s.words in order of first occurrence (Definition S-3).

The walk is left to right and pre-order over the node's explicit syntax: binder types, the type arguments of constant instances, and every argument. It does not enter a local's type or a type variable's sort atoms. A shared node is entered once: its variables have already occurred. One unit is charged per node entered.

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • s: The scratch.
  • t: A node.

Returns. How many type variables were pushed.

Raises.

  • CheckFail: LIMIT; STORAGE.

Defined in src/judgment_core/checker_terms.mojo.

compare_refs

def compare_refs[V: CheckView](v: V, mut s: Scratch, a: Ref, b: Ref) raises CheckFail -> Int

Compare two nodes by the structural order, iteratively.

Termination (G2): every descent selects an earlier child pair. One unit is charged per pair visited and per equal child skipped, as termbank charges (G3).

Parameters.

  • V: The view's type.

Arguments.

  • v: The view.
  • s: The scratch.
  • a: A reference.
  • b: Another.

Returns. -1, 0 or 1.

Raises.

  • CheckFail: LIMIT; STORAGE; INTERNAL when two distinct references compare equal.

Defined in src/judgment_core/checker_terms.mojo.

DagCheckView

struct DagCheckView(CheckView, Copyable)
Field Type Description
view DagView The snapshot.
ids CoreIds The core prefix's ids, as the bank recorded them.
plain UInt32 For a producer: the signature theory of every theory, one with no ACU declaration and no literal kind; NONE for the checker.
pending ArcPointer[PendingSignatures] The theory pass's decided, unpublished signature answers (empty elsewhere); shared by copies.
strict Bool For the theory pass: signature_of answers NONE for a theory with neither a pending nor a published answer, never plain (fail closed); producers keep the plain fallback.
opened List[UInt32] A producer's opened binders (Rule L1): the types of the locals opened_base + i, which no row holds. They let the construction engine compute K(o) in its scratch without writing a local. Empty for the checker and the theory pass, whose locals are all rows.
opened_depth List[UInt32] Each opened binder's depth, increasing along one opening.
opened_base UInt32 The first opened binder's id: the bank's local count when the view was made.
opened_name UInt32 The name every opened binder carries, a POOL row.
opened_frame UInt32 The frame every opened binder answers as its own: one frame, so they lie on one chain.

A DagView read as a CheckView.

Defined in src/judgment_core/checker/dag_view.mojo.

DagCheckView.__init__

def __init__(out self, view: DagView)

Adapt a view.

Arguments.

  • view: The snapshot.

DagCheckView.producing

@staticmethod
def producing(view: DagView, plain: UInt32) -> Self

Adapt a view for a producer, which runs ahead of the theory pass and so cannot wait for its answers.

Every theory is taken as published, with the signature theory plain, which has no ACU declaration and no literal kind: so no constant has an ACU operator and no instance or type a literal binding. The producer may only use it for theories of which this holds; the checker verifies its rows against the theory pass's answers all the same.

Arguments.

  • view: The snapshot.
  • plain: The signature theory.

Returns. The view.

DagCheckView.open_local

def open_local(mut self, type: UInt32, depth: UInt32, name: UInt32, frame: UInt32) -> UInt32

A producer's opened binder: a local of type that no row holds, answered by this view alone (Rule L1).

Its id lies above every row's, and each call gives a new one, so a scratch atom of it is never a bank node's and never another opened binder's.

Arguments.

  • type: Its type.
  • depth: Its depth.
  • name: Its name, a POOL row.
  • frame: The frame it answers as its own.

Returns. The local's id.

DagCheckView.top

def top(self) -> UInt64

See CheckView.

Returns. The answer.

DagCheckView.theory_mark

def theory_mark(self) -> UInt64

See CheckView.

Returns. The answer.

DagCheckView.locate

def locate(self, seq: UInt64) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • seq: A sequence number.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.count

def count(self, table: Int, seq: UInt64) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • table: A table.
  • seq: A sequence number.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.core

def core(self) -> CoreIds

See CheckView.

Returns. The answer.

DagCheckView.head_key

def head_key(self, h: UInt32) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_name

def head_name(self, h: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_payload

def head_payload(self, h: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_binder

def head_binder(self, h: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_flags

def head_flags(self, h: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_class

def head_class(self, h: UInt32) raises CheckFail -> UInt8

See CheckView: the class registered with the head (register_head's kind).

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_decl

def head_decl(self, h: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_head

def decl_head(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.pool_length

def pool_length(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A pooled string.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.pool_fnv

def pool_fnv(self, p: UInt32) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • p: A pooled string.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.pool_read

def pool_read(self, p: UInt32, mut out: List[UInt8]) raises CheckFail

See CheckView.

Arguments.

  • p: A pooled string.
  • out: The buffer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lookup_bytes

def lookup_bytes(self, bytes: List[UInt8], below: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • bytes: The bytes.
  • below: The bound.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_head

def node_head(self, n: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • n: A node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_payload

def node_payload(self, n: UInt32) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • n: A node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_arity

def node_arity(self, n: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • n: A node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_child

def node_child(self, n: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • n: A node.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_shash

def node_shash(self, n: UInt32) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • n: A node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_loose

def node_loose(self, n: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • n: A node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.node_flags

def node_flags(self, n: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • n: A node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lookup_node

def lookup_node(self, head: UInt32, payload: UInt64, children: List[UInt32], below: UInt32) raises CheckFail -> UInt32

See CheckView; the children are passed in place, as NodeIds of the same layout.

Arguments.

  • head: The head.
  • payload: The payload.
  • children: The children.
  • below: The bound.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.local_depth

def local_depth(self, l: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • l: A local.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.local_name

def local_name(self, l: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • l: A local.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.local_type

def local_type(self, l: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • l: A local.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.local_frame

def local_frame(self, l: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • l: A local.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_parent

def ctx_parent(self, c: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_theory

def ctx_theory(self, c: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_entry_kind

def ctx_entry_kind(self, c: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_entry

def ctx_entry(self, c: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_depth

def ctx_depth(self, c: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_jump

def ctx_jump(self, c: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_sorts

def ctx_sorts(self, c: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • c: A frame.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.ctx_ancestor

def ctx_ancestor(self, c: UInt32, depth: UInt32, mut steps: UInt64) raises CheckFail -> UInt32

See CheckView: termbank's walk, under one reader epoch.

Arguments.

  • c: A frame.
  • depth: A depth at most the frame's.
  • steps: Increased by the links followed.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.hset_count

def hset_count(self, h: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • h: A set.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.hset_item

def hset_item(self, h: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • h: A set.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lookup_hset

def lookup_hset(self, items: List[UInt32], below: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • items: The items.
  • below: The bound.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.dset_count

def dset_count(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A set.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.dset_item

def dset_item(self, d: UInt32, i: UInt32) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • d: A set.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lookup_dset

def lookup_dset(self, items: List[UInt64], below: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • items: The items.
  • below: The bound.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.theory_count

def theory_count(self, t: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • t: A theory.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.theory_entry

def theory_entry(self, t: UInt32, i: UInt32) raises CheckFail -> UInt64

See CheckView.

Arguments.

  • t: A theory.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lookup_theory

def lookup_theory(self, entries: List[UInt32], below: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • entries: The entries.
  • below: The bound.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.theory_published

def theory_published(self, t: UInt32) -> Bool

See CheckView.

Arguments.

  • t: A theory.

Returns. The answer.

DagCheckView.signature_of

def signature_of(self, t: UInt32) raises CheckFail -> UInt32

See CheckView: the SIGNATURE answer.

Arguments.

  • t: A theory.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.head_part

def head_part(self, h: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • h: A head.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.part_head

def part_head(self, d: UInt32, part: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.
  • part: The part.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_at

def decl_at(self, seg: UInt32, pos: UInt32) raises CheckFail -> UInt32

Read the declaration at a position of a segment.

Arguments.

  • seg: The segment.
  • pos: The position in it.

Returns. The declaration.

Raises.

  • CheckFail: MISMATCH (DETAIL_DECL_FORM) when the segment has no declaration there, or a storage refusal.

DagCheckView.decl_operand_count

def decl_operand_count(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_operand

def decl_operand(self, d: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_kind

def decl_kind(self, d: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_segment

def decl_segment(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_position

def decl_position(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_parent

def decl_parent(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_type

def decl_type(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_params

def decl_params(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.decl_param

def decl_param(self, d: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.acu_targs

def acu_targs(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.acu_targ

def acu_targ(self, d: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.acu_unit

def acu_unit(self, d: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lit_impl

def lit_impl(self, kind: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • kind: A literal kind.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lit_base

def lit_base(self, kind: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • kind: A literal kind.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.lit_bind

def lit_bind(self, kind: UInt32, op: Int) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • kind: A literal kind.
  • op: An operation.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.sig_acu_count

def sig_acu_count(self, sig: UInt32, constant: UInt32) raises CheckFail -> UInt32

See CheckView: the ACU_OPERATORS answer's size.

Arguments.

  • sig: A signature theory.
  • constant: A constant.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.sig_acu

def sig_acu(self, sig: UInt32, constant: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView: an item of the ACU_OPERATORS answer.

Arguments.

  • sig: A signature theory.
  • constant: A constant.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.sig_binding

def sig_binding(self, sig: UInt32, instance: UInt32) raises CheckFail -> UInt32

See CheckView: the BINDING answer.

Arguments.

  • sig: A signature theory.
  • instance: An instance node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.sig_carrier

def sig_carrier(self, sig: UInt32, type: UInt32) raises CheckFail -> UInt32

See CheckView: the CARRIER answer.

Arguments.

  • sig: A signature theory.
  • type: A type node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.visible

def visible(self, theory: UInt32, d: UInt32) raises CheckFail -> Bool

See CheckView.

Arguments.

  • theory: A theory.
  • d: A declaration.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.member

def member(self, theory: UInt32, type: UInt32, sort: UInt32) raises CheckFail -> Optional[SortAnswer]

See CheckView: the MEMBER answer.

Arguments.

  • theory: A theory.
  • type: A type.
  • sort: A sort node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.witness

def witness(self, theory: UInt32, sort: UInt32) raises CheckFail -> Optional[SortAnswer]

See CheckView: the WITNESS answer.

Arguments.

  • theory: A theory.
  • sort: A sort node.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.entails

def entails(self, theory: UInt32, sort: UInt32, other: UInt32) raises CheckFail -> Optional[SortAnswer]

See CheckView: the ENTAILS answer.

Arguments.

  • theory: A theory.
  • sort: A sort node.
  • other: Another.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.sort_declarations

def sort_declarations(self, kind: UInt8, key: UInt32, mut out: List[UInt32]) raises CheckFail

See CheckView: one probe of termbank's class summary (instances_of, relations_from, all_*).

Arguments.

  • kind: DECL_INSTANCE or DECL_CLASS_RELATION.
  • key: The type constructor or subclass, or NONE.
  • out: Receives the declarations.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_rule

def proof_rule(self, p: UInt32) raises CheckFail -> UInt8

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_ops

def proof_ops(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_op

def proof_op(self, p: UInt32, i: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.
  • i: A position.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_conclusion

def proof_conclusion(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_hyps

def proof_hyps(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_deps

def proof_deps(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_context

def proof_context(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_signature

def proof_signature(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.proof_home

def proof_home(self, p: UInt32) raises CheckFail -> UInt32

See CheckView.

Arguments.

  • p: A proof row.

Returns. The answer.

Raises.

  • CheckFail: As CheckView.

DagCheckView.fact

def fact(self, node: UInt32, sig: UInt32) raises CheckFail -> Optional[Fact]

See CheckView: a published fact, with its weight.

Arguments.

  • node: A node.
  • sig: A signature theory.

Returns. The fact, or None.

Raises.

  • CheckFail: As CheckView.

check_dag_chunk

def check_dag_chunk(view: DagCheckView, chunk: Chunk, budget: Budget, mut s: Scratch) -> ChunkVerdict

Check a chunk of a termbank.dag bank under one reader guard (KC1.9, TD1.10). Never raises.

The guard is entered once and held until the check returns, so every read of the chunk takes the view's fast path instead of entering an epoch per call.

Arguments.

  • view: The view.
  • chunk: The rows.
  • budget: The chunk's allowance.
  • s: A scratch, as check_chunk takes it.

Returns. check_chunk's verdict.

Defined in src/judgment_core/checker/dag_view.mojo.

Constructor

comptime Constructor = ConstructorWithError[]

Construction with the existing diagnostic-only error boundary.

Defined in src/judgment_core/checker/construct.mojo.

ConstructorWithError and DerivationsWithError accept a ConstructionFailure implementation to select the error type reported to their caller. ConclusionWork owns a prepared inference computation that can run on a worker before its result is integrated in source order.

ConstructorWithError

struct ConstructorWithError[Failure: ConstructionFailure = _ErasedConstructionError](Movable)
Field Type Description
w WriterSource The writer: a bank's, shared with the producer's sink and nothing else, or a workspace's (WriterSource).
s Scratch The scratch, reset for every operation.
view DagCheckView A producer's view of every row committed so far; refreshed by publishing.
core CoreIds The core prefix's ids.
plain UInt32 The root theory: the signature theory of every theory the engine has no canonical declaration for.
sig UInt32 The current theory's signature theory: the root's, or the theory just after the engine's last canonical declaration (_enter_signature).
sigs ArcPointer[PendingSignatures] The engine's own signature answers, read through its producing view: complete for each signature theory it entered, and the signature of each theory it declared in after one.
base List[UInt32] The root theory's version vector, as (segment, count) pairs.
segment UInt32 The article's segment over the root theory, or NONE before its first declaration.
count UInt32 Declarations in the article's segment.
theory UInt32 The current theory: the root theory, or AFTER of the last declaration.
top UInt32 The top of the producer's chain of frames: every row's β.
anchor UInt32 The last frame with an entry on the chain, or the empty frame: a rebase's parent.
no_sorts UInt32 The empty sort set.
open_name UInt32 The name of the binders a Rule L1 index step opens in scratch, interned when the engine is made.
types _Logged[Int, Int, Self.Failure] Type operators by name: their heads.
constants _Logged[Int, Int, Self.Failure] Constants by name: their heads.
locals _Logged[Tuple[UInt64, UInt64], Int, Self.Failure] Locals by (name, type).
sequents _Logged[Int, _Sequent, Self.Failure] Declarations' sequents, for their rows.
axioms _Logged[Int, Int, Self.Failure] Axioms by statement.
stack List[Ref] Interning's work stack.
ids List[NodeId] Interning's child buffer.
hyp_ids List[NodeId] A produced row's hypotheses, interned.
names Int Synthetic names made.
sub_locals List[UInt32] subst_operands' reused buffer: the premise's locals.
sub_images List[UInt32] subst_operands' reused buffer: the locals' type images under θ.
sub_out List[UInt64] subst_operands' reused buffer: the row's operands.
sub_pairs List[UInt64] subst_operands' reused buffer: μ's pairs.
app_fun _Logged[Int, Int, Self.Failure] Applications of a λ the engine built, by result: the function, or -1 when two different ones reach it.
app_arg _Logged[Int, Int, Self.Failure] The same applications' arguments.
exists_head UInt32 The head of core.exists.
unguarded_predicate UInt32 The last define_type_operator's predicate before its erased-parameter guard, when it guarded one; else NONE.
providers _Logged[Int, Int, Self.Failure] The providers in declaration order (Rule L1): rule << 48 | part << 32 | declaration at 0, 1, …; their count at -1.
provider_statements _Logged[Int, Int, Self.Failure] The same providers' statements, by position.
l1_index _Logged[Tuple[UInt64, Int, Int], List[Int], Self.Failure] The Rule L1 index: (h, k, n), for h the structural hash of K(o_{k,n}(t)), to the positions of the providers with that hash, in declaration order (Rule L1, Q-3f). A lookup recomputes each one's K(o) to resolve collisions.
l1_entries _Logged[Tuple[Int, Int, Int], _ProviderEntry, Self.Failure] Each provider's entry at a shape, (i, k, n): λ_o's binder positions, then θ_o's type variables.
l1_shapes _Logged[Tuple[Int, Int], Int, Self.Failure] Each shape (k, n) computed: how many providers it indexes.
narrow List[UInt32] nd_row's reused buffer: the operands at row width.
term_params List[UInt32] constant_term's reused buffer: the declared type's variables.
match_values List[UInt32] _match_term_params' reused buffer: the variables' values.
match_work List[Tuple[Ref, Ref]] _match_term_params' reused work stack.
match_seen Dict[Tuple[Ref, Ref], Bool] _match_term_params' reused pair memo (prevents exponential DAG retraversal).
sorts_seen Dict[Int, Bool] _entry_sorts' reused buffer: the nodes visited.
sorts_work List[UInt32] _entry_sorts' reused work stack.
sorts_found List[UInt64] _entry_sorts' reused buffer: the entry's sorted type variables, then the frame's.

The construction engine over a bank's writer, for one producer on one thread.

Parameters.

  • Failure: The error boundary. KernelError retains typed causes; the default preserves diagnostic-only behavior for clients with mixed error handlers.

Defined in src/judgment_core/checker/construct.mojo.

ConstructorWithError.__init__

def __init__(out self, w: ArcPointer[DagWriter], limits: ScratchLimits, mut budget: Budget) raises Self.Failure

Start over a bank whose core prefix is committed and recorded.

Arguments.

  • w: The writer.
  • limits: The scratch's limits.
  • budget: Charged for interning the empty sort set.

Raises. Self.Failure: When the core is not recorded, or the writer refuses.

ConstructorWithError.__init__

def __init__(out self, var w: WriterSource, limits: ScratchLimits, mut budget: Budget) raises Self.Failure

Start over a bank or a workspace whose core prefix is committed and recorded.

Arguments.

  • w: The writer.
  • limits: The scratch's limits.
  • budget: Charged for interning the empty sort set.

Raises. Self.Failure: When the core is not recorded, or the writer refuses.

ConstructorWithError.producing_view

def producing_view(self) -> DagCheckView

The engine's producing view of its writer's current rows, with its own signature answers: the view its operations read, for a client's read-only structural queries (compare_refs).

Returns. The view.

ConstructorWithError.declare_acu_operator

def declare_acu_operator(mut self, instance: UInt64, unit: UInt64, associativity: UInt32, commutativity: UInt32, unit_law: UInt32, mut budget: Budget) raises Self.Failure -> DeclId

Declare an ACU operator (K1.3, Definition T-6), layout D*T;?R;DD?D;; its theory becomes the current signature theory, so the engine builds what follows canonically for it.

The ACU_OPERATORS set for the constant in the new signature is interned between the declaration and its theory row, where the theory pass reads it (TD1.6, "Signature answers"). The laws must be stated canonically for the current signature, before this declaration.

Arguments.

  • instance: The operator c[ρ̄]: a constant's instance at its type arguments, with no term argument.
  • unit: The unit's node, or UInt64.MAX for none.
  • associativity: The associativity law's declaration.
  • commutativity: The commutativity law's declaration.
  • unit_law: The unit law's declaration, or NONE (with no unit).
  • budget: Charged.

Returns. The declaration.

Raises. Self.Failure: For an instance whose head has no declaration; what the writer raises. The theory pass decides the declaration.

ConstructorWithError.declare_literal_kind

def declare_literal_kind(mut self, name: UInt64, implementation: UInt32, carrier: UInt64, domain: UInt64, bindings: List[Tuple[Int, UInt64]], laws: List[Tuple[Int, UInt32]], base: UInt32, mut budget: Budget) raises Self.Failure -> DeclId

Declare a literal kind (K1.3, Definition T-7; C1.4; K2.2), layout SNT?T;*NR;*ND;?D;, with its head lit:<name>; its theory becomes the current signature theory.

Arguments.

  • name: The name, a POOL row.
  • implementation: EXACT_INTEGER 1, EXACT_RATIONAL 2 or FORMAL_POLYNOMIAL 3.
  • carrier: The carrier type.
  • domain: The domain predicate, or UInt64.MAX for none.
  • bindings: (LiteralOp code, instance) pairs.
  • laws: (LiteralLaw code, declaration) pairs.
  • base: A polynomial kind's base kind, or NONE.
  • budget: Charged.

Returns. The declaration.

Raises. Self.Failure: What the writer raises. The theory pass decides the declaration.

ConstructorWithError.literal

def literal(mut self, kind: UInt32, encoding: List[UInt8], mut budget: Budget) raises Self.Failure -> UInt64

A literal atom of a kind: its head over the pooled canonical encoding.

The encoding is not validated here: the checker refuses a non-canonical one, or one of the values 0 and 1, which are the kind's ZERO and ONE instances.

Arguments.

  • kind: The literal kind's declaration.
  • encoding: The canonical encoding.
  • budget: Charged.

Returns. The atom's node.

Raises. Self.Failure: For a kind without its head; what the writer raises.

ConstructorWithError.log_caches

def log_caches(mut self)

Make the name caches' writes undoable, for an engine over a workspace (mark, truncate; G9).

ConstructorWithError.mark

def mark(self) -> ConstructorMark

The state truncate returns to; take it with the workspace's mark.

Returns. The mark.

ConstructorWithError.truncate

def truncate(mut self, m: ConstructorMark) raises Self.Failure

Return to a mark after the workspace was truncated to its own: the caches forget what came after it.

The fact cache starts afresh: its facts may name dropped rows. That changes the work, never an output.

Arguments.

  • m: A mark of this engine, taken while log_caches was on.

Raises. Self.Failure: For a mark the logs have passed below.

ConstructorWithError.adopt_declaration

def adopt_declaration(mut self, d: UInt32, mut budget: Budget, provider: Bool = True) raises Self.Failure

Adopt a declaration this engine did not make: its names resolve to its heads, it provides what it provides when this engine declares it (adopt_provider), and a canonical one enters its signature theory.

Arguments.

  • d: The declaration.
  • budget: Charged for interning its names and keying its statements.
  • provider: False for a declaration whose statement a later version supersedes (Rule L1, as amended): it is named but provides nothing, so the version's own proof of the statement is declared.

Raises. Self.Failure: What the view or the writer raises.

ConstructorWithError.after_commit

def after_commit(mut self, var source: WriterSource, m: ConstructorMark, translation: Translation, committed: List[UInt32], allowance: UInt64) raises Self.Failure

Continue in the parent after this engine's workspace was committed into it (TD1.12(6)).

The engine appended through a child workspace since m; the child's rows are now the parent's, under translation. In one place: the parent's source replaces the child's, the caches return to m (so a child id never resolves in the parent), the declaration state takes the child's final values translated, and the committed declarations are adopted, as a loaded library's are. Caches the child learned otherwise (locals, applications) are relearned on demand: a change of work, never of an output.

Arguments.

  • source: The parent's writer; the child's slot may be emptied once this returns.
  • m: The mark taken when the child was opened, its caches logged.
  • translation: The commit's translation of the child's ids.
  • committed: The committed declarations, in the parent's ids, in order.
  • allowance: What the caller charged for the adoption before the commit, while a refusal changed nothing: what the child spent, which bounds it, since adoption interns the declarations' names and keys their statements as declaring them did. The commit is irreversible, and an adoption stopped halfway would leave names unresolved, a change of output (G-atomic).

Raises. Self.Failure: For a mark the logs have passed below; what adopting raises, an exhausted allowance included (the bound failed: a defect, not a refusal).

ConstructorWithError.variables

def variables(self) -> Dict[Tuple[UInt64, UInt64], Int]

The variables this engine made or adopted, for a sibling's adopt_branch.

Returns. Each variable's key (its name's POOL row and its type's node, as (name, type)) and its local.

ConstructorWithError.adopt_branch

def adopt_branch(mut self, branch: ConstructorMark, branch_locals: Dict[Tuple[UInt64, UInt64], Int], translation: Translation, committed: List[UInt32], allowance: UInt64) raises Self.Failure

Take a sibling engine's declarations after its workspace, a child of this engine's, was committed into this engine's (a session's fork merged back, TD1.12(6)).

The sibling started from this engine's declarations and this engine declared nothing since, so the sibling's declaration state extends this one's: it becomes this engine's, translated, and the committed declarations are adopted, as a loaded library's are. This engine's caches stay: the commit only appended rows.

Arguments.

  • branch: The sibling's state (mark), taken before its workspace was committed.
  • branch_locals: The sibling's variables (name and type to local), whose ids the translation maps.
  • translation: The commit's translation of the sibling's ids.
  • committed: The sibling's declarations, in this engine's ids, in order.
  • allowance: What the caller charged for the adoption before the commit (as after_commit's).

Raises. Self.Failure: When this engine declared since the sibling started from it (its base is not a prefix of the sibling's), changing nothing; what adopting raises, an exhausted allowance included.

ConstructorWithError.close_segment

def close_segment(mut self)

End the open declaration segment; the next declaration opens a new one over the current theory.

A library profile built through the engine (a foundation) is then one segment, and an article's declarations start a fresh one whose base is the profile's theory. Without an open segment, nothing changes.

ConstructorWithError.resume

def resume(mut self, segment: UInt32, count: UInt32, mut budget: Budget) raises Self.Failure

Continue a segment that already holds count declarations, as a loaded library's (ST7.2's later versions).

The engine's open segment becomes segment, and its current theory the one just after the last of those declarations: the engine's base joined with (segment, count). The next declaration goes at position count + 1, parented on that theory, as if this engine had declared the earlier ones. Their names and providers are adopted separately (adopt_constant, adopt_type_operator, adopt_provider).

Arguments.

  • segment: The segment, over the engine's base theory.
  • count: The declarations it holds.
  • budget: Charged for interning the theory. Synthetic names (judgment.axiom.N, judgment.thm.N) continue past the largest the segment's declarations carry, so a later declaration never repeats one of their names.

Raises. Self.Failure: When the engine has an open segment of its own, when segment does not extend the engine's current theory, or when it does not hold exactly count declarations.

ConstructorWithError.adopt_constant

def adopt_constant(mut self, name: UInt64, head: UInt32)

Resolve the constant name name (a POOL row) to head, a declaration of a loaded library.

Arguments.

  • name: The name.
  • head: The head it resolves to.

ConstructorWithError.adopt_type_operator

def adopt_type_operator(mut self, name: UInt64, head: UInt32)

Resolve the type operator name name (a POOL row) to head, a declaration of a loaded library.

Arguments.

  • name: The name.
  • head: The head it resolves to.

ConstructorWithError.adopt_provider

def adopt_provider(mut self, d: UInt32, mut budget: Budget) raises Self.Failure

Index a loaded declaration as a provider (Rule L1), as if this engine had declared it.

Each provides what it provides when this engine declares it: an Axiom or a Proven its statement (and an axiom is reused by a later article axiom of that statement); a Definition with a head its equation; a type definition its two facts (parts 3 and 4); a specification its fact (part k + 1); an instance definition its equation. A class's predicate is resolved by definitionThm from the declaration itself.

Arguments.

  • d: The declaration.
  • budget: Charged for keying the statement.

Raises. Self.Failure: What the view, the writer or keying raises.

ConstructorWithError.type_operator

def type_operator(mut self, name: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

A type operator by name.

Arguments.

  • name: The name, a POOL row.
  • budget: Charged.

Returns. Its head, or UNKNOWN | name until its first application declares it.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.type_variable

def type_variable(mut self, name: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

A type variable of the empty sort.

Arguments.

  • name: The name, a POOL row.
  • budget: Charged.

Returns. Its node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.sorted_type_variable

def sorted_type_variable(mut self, name: UInt64, classes: Span[UInt64, _], mut budget: Budget) raises Self.Failure -> UInt64

A type variable α^S of the sort of some classes, normalized structurally (Definition Y-9; K2.8).

The sort is the minimal classes under the initial class order (the superclass edges alone, not class relations: the classes page, "Structural and semantic sorts"), as class atoms in the structural order, the form the fact walk requires (check_sort_atoms). No class is a type variable of the empty sort.

Arguments.

  • name: The name, a POOL row.
  • classes: Classes, in any order, possibly repeated.
  • budget: Charged.

Returns. Its node.

Raises. Self.Failure: For a declaration that is not a class; what the engine, the view or the writer raises.

ConstructorWithError.type_application

def type_application(mut self, operator: UInt64, arguments: Span[UInt64, _], mut budget: Budget) raises Self.Failure -> UInt64

A type operator applied to types; an unknown operator is declared at this arity.

Arguments.

  • operator: A type operator handle.
  • arguments: Types.
  • budget: Charged.

Returns. The type's node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.declare_type_operator

def declare_type_operator(mut self, name: UInt64, arity: Int, mut budget: Budget) raises Self.Failure -> UInt64

Declare an opaque type operator of an arity (a TypeConstructor, K1.3), as an unknown one's first application does.

Arguments.

  • name: The name, a POOL row, not yet a type operator's.
  • arity: Its arity, at most 65,535.
  • budget: Charged.

Returns. Its head.

Raises. Self.Failure: For a name already a type operator's or an arity out of range; what the writer raises.

ConstructorWithError.constant

def constant(mut self, name: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

A constant by name.

Arguments.

  • name: The name, a POOL row.
  • budget: Charged.

Returns. Its head, or UNKNOWN | name until its first instance declares it.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.variable

def variable(mut self, name: UInt64, type: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

A variable as a local: the same local for the same name and type, fixed over the top on a miss.

Arguments.

  • name: The name, a POOL row.
  • type: Its type.
  • budget: Charged.

Returns. The local.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.variant_e

def variant_e(mut self, name: UInt64, type: UInt64, mut budget: Budget, prefix: StaticString = "") raises Self.Failure -> UInt64

A name for a new local of a type through the variable cache: variant_e(τ, n) (D10).

It is the first of n, n′, n″, … (n with prefix in front, then i copies of U+2032) that the cache does not hold for τ and that no local over the top of type τ carries, so variable fixes a new local under it. A caller that wants the cache's sharing passes its name to variable unchanged.

Arguments.

  • name: The base name, a POOL row.
  • type: The type.
  • budget: Charged, one unit per name tried.
  • prefix: Bytes put in front of the base name, such as a reserved ·r·.

Returns. The name, a POOL row.

Raises. Self.Failure: What the view or the writer raises.

ConstructorWithError.variant_e

def variant_e(mut self, name: String, type: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

variant_e(τ, n) for a name given as text (D10): the base name is interned first.

Arguments.

  • name: The base name, reserved prefix included.
  • type: The type.
  • budget: Charged, one unit per name tried.

Returns. The name, a POOL row.

Raises. Self.Failure: What the view or the writer raises.

ConstructorWithError.variable_term

def variable_term(mut self, local: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

A local as a term.

Arguments.

  • local: The local.
  • budget: Charged.

Returns. Its node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.declare_constant

def declare_constant(mut self, name: UInt64, type: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

Declare a non-overloaded constant without a definition at a type (a Constant, K1.3), as an unknown one's first instance does; its type parameters are the type's variables in first-occurrence order.

Arguments.

  • name: The name, a POOL row, not yet a constant's.
  • type: Its declared type.
  • budget: Charged.

Returns. Its head.

Raises. Self.Failure: For a name already a constant's; what the view or the writer raises.

ConstructorWithError.constant_term

def constant_term(mut self, constant: UInt64, type: UInt64, mut budget: Budget, signature: UInt32 = NONE) raises Self.Failure -> UInt64

A constant at a type: its canonical instance, the type arguments matched against its declared type.

Arguments.

  • constant: A constant handle; an unknown one is declared at this type.
  • type: The instance's type.
  • budget: Charged.
  • signature: Optional canonical signature for a captured proof. Defaults to the current signature.

Returns. The instance's node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.canonical_node

def canonical_node(mut self, node: UInt32, signature: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

Rebuild a stored term at a checked canonical signature (Corollary C-9a).

Arguments.

  • node: A well-typed stored term.
  • signature: The destination signature, including that of the source term.
  • budget: Pays for normalization and interning.

Returns. The canonical node in this writer.

Raises. Self.Failure: What normalization or the writer raises.

ConstructorWithError.application

def application(mut self, function: UInt64, argument: UInt64, mut budget: Budget, signature: UInt32 = NONE) raises Self.Failure -> UInt64

N(f(x)).

Arguments.

  • function: A term.
  • argument: A term.
  • budget: Charged.
  • signature: Optional canonical signature for a captured proof. Defaults to the current signature.

Returns. The canonical application's node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.abstraction

def abstraction(mut self, local: UInt64, body: UInt64, mut budget: Budget, signature: UInt32 = NONE) raises Self.Failure -> UInt64

λ:τ_v. abs_v(body).

Arguments.

  • local: The bound local.
  • body: A term.
  • budget: Charged.
  • signature: Optional canonical signature for a captured proof. Defaults to the current signature.

Returns. The abstraction's node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.instance

def instance(mut self, head: UInt64, type_args: Span[UInt64, _], mut budget: Budget) raises Self.Failure -> UInt64

c[τ̄]: a constant's head at its type arguments, without term arguments, the function of its spines.

Arguments.

  • head: The constant's head.
  • type_args: Its type arguments, as many as its type parameters (type_arity).
  • budget: Charged.

Returns. The instance's node.

Raises. Self.Failure: For a wrong count of type arguments; what the engine, the view or the writer raises.

ConstructorWithError.literal_read

def literal_read(mut self, node: UInt64, mut budget: Budget) raises Self.Failure -> Optional[LiteralRead]

A node's literal kind and value in the engine's current signature (literal_of, K2.3).

Arguments.

  • node: A term.
  • budget: Charged.

Returns. Its kind and value, or none for a node that is not a literal there.

Raises. Self.Failure: What literal_of refuses (UNREADY, MISMATCH); what the view raises.

ConstructorWithError.convertible

def convertible(mut self, a: UInt64, b: UInt64, mut budget: Budget) raises Self.Failure -> Bool

Whether two terms convert with no definition unfolded: D_∅(a) and D_∅(b) are one node (Corollary C-8a), the test convert makes with an empty unfolding list. It writes no row.

Arguments.

  • a: A term canonical for the engine's current signature.
  • b: Another.
  • budget: Charged, one unit per node unfold visits.

Returns. True when convert with no unfolding would accept the one for the other.

Raises. Self.Failure: What unfold refuses (LIMIT, CAPACITY, STORAGE); what the view raises.

ConstructorWithError.instance_arity

def instance_arity(mut self, head: UInt64, mut budget: Budget) raises Self.Failure -> Int

How many type arguments a constant's head takes: its spines' leading children (type_arity, S-3).

Arguments.

  • head: The constant's head.
  • budget: Charged.

Returns. The count.

Raises. Self.Failure: What the engine or the view raises.

ConstructorWithError.open_body

def open_body(mut self, binder: UInt64, value: UInt64, mut budget: Budget, signature: UInt32 = NONE) raises Self.Failure -> UInt64

A λ's or a let's body with its bound variable replaced: body{0 := value}.

A let's value is not substituted: the body is opened at value, as a λ's is. instantiate re-canonicalizes only the spines over the bound variable, so a binder built in an older signature can open to a body that is not canonical in the engine's current one (an ACU declaration since then); such a body is refused here, never handed out for a rule to refuse.

Arguments.

  • binder: A λ or a let.
  • value: A term of the binder's type, closed under binders (a local, typically).
  • budget: Charged.
  • signature: The checked construction signature; NONE selects the current signature.

Returns. The opened body's node.

Raises. Self.Failure: For another form; for a body not canonical in the current signature; what the engine, the view or the writer raises.

ConstructorWithError.app_argument

def app_argument(mut self, first: UInt64, second: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

appThm's optional term (Definition Q-16): none, unless the second premise concludes True.

Arguments.

  • first: The first premise.
  • second: The second premise.
  • budget: Charged.

Returns. UInt64.MAX for none.

Raises. Self.Failure: For a True premise, whose literal the producer does not choose yet.

ConstructorWithError.subst_operands

def subst_operands(mut self, mut operands: List[UInt64], mut budget: Budget) raises Self.Failure

Compose an article subst's two stages into one inst row's operands (Definition Q-8).

The article gives θ and a term part σ keyed by variables of the type-instantiated theorem. The row's μ is keyed by the premise's own locals: for each local ℓ of the premise's V, ρ(ℓ) is the local of type τ_ℓθ with ℓ's name (ℓ itself when θ does not move its type), and μ(ℓ) = σ(ρ(ℓ)). Exactly the locals with μ(ℓ) ≠ ℓ are listed, in V's order; a pair of σ whose variable is no ρ(ℓ) has no effect and is dropped.

The operands are rewritten in place through reused buffers. Exact lookup indexes replace pairwise searches: expected linear work in the collected type variables, substitution pairs and premise locals, in addition to the existing type walks. Their retained capacity is proportional to the largest substitution, like the operand buffers. Traversals retain their scratch work allowance; index loops are bounded by those collected variables and the finite operand lists.

Arguments.

  • operands: J*TT;*LR; as the article gives them; on return, as the row stores them.
  • budget: Charged.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.conclusion

def conclusion(mut self, rule: UInt8, operands: Span[UInt64, _], mut budget: Budget, at: Optional[UInt32] = None, *, capture_sequent: Bool = False) raises Self.Failure -> Produced

A step's stored fields, computed by its rule in produce mode and interned (the module's choices).

Arguments.

  • rule: The kind (TD1.8).
  • operands: The operands in the kind's layout, every one committed.
  • budget: Charged.
  • at: The construction frame. For a natural-deduction row at an explicit frame, use that frame's checked canonical signature.
  • capture_sequent: Use the explicit frame's signature for a sequent as well.

Returns. The fields.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.prepare_conclusion

@no_inline
def prepare_conclusion(mut self, rule: UInt8, operands: Span[UInt64, _], var scratch: Scratch, mut budget: Budget) raises Self.Failure -> ConclusionWork

Capture an inference over committed operands for a joined worker.

Arguments.

  • rule: Inference kind.
  • operands: Committed operands in the rule's layout.
  • scratch: Private reusable scratch from this constructor's worker pool.
  • budget: The step's work allowance; computation is charged on integration.

Returns. Owned work; no writer or mutable constructor state is transferred.

Raises. Self.Failure: A preparation refusal.

ConstructorWithError.integrate_conclusion

@no_inline
def integrate_conclusion(mut self, mut work: ConclusionWork, mut budget: Budget) raises Self.Failure -> Produced

Intern a completed computation on its originating constructor's thread.

Arguments.

  • work: A successfully computed result, joined before this call.
  • budget: Charged for computation and interning.

Returns. Stored fields; work keeps its scratch for reuse.

Raises. Self.Failure: Work exhaustion or a writer refusal.

ConstructorWithError.nd_fix

def nd_fix(mut self, parent: UInt32, name: UInt64, type: UInt64, mut budget: Budget) raises Self.Failure -> Tuple[UInt32, UInt32]

The local with this binding site and its fix frame over parent, for a natural-deduction derivation; the chain's top stays.

Arguments.

  • parent: The frame to extend.
  • name: The local's name, a POOL row.
  • type: Its type.
  • budget: Charged.

Returns. The local and its frame.

Raises. Self.Failure: What the writer raises.

ConstructorWithError.nd_assume

def nd_assume(mut self, parent: UInt32, proposition: UInt64, mut budget: Budget) raises Self.Failure -> UInt32

An assume frame over parent, for a natural-deduction derivation; the chain's top stays.

Arguments.

  • parent: The frame to extend.
  • proposition: The hypothesis, a canonical proposition.
  • budget: Charged.

Returns. The frame.

Raises. Self.Failure: What the writer raises.

ConstructorWithError.nd_row

def nd_row(mut self, rule: UInt8, operands: List[UInt64], mut budget: Budget, at: Optional[UInt32] = None) raises Self.Failure -> UInt32

Commit a natural-deduction row (or any row) the engine derives itself, at its computed fields.

Arguments.

  • rule: The kind (TD1.8).
  • operands: Its operands in the kind's layout.
  • budget: Charged.
  • at: Explicit construction context. The checker validates the row's scope.

Returns. The proof row.

Raises. Self.Failure: What the rule or the writer raises.

ConstructorWithError.closure_local_order

def closure_local_order(mut self, proof: UInt64, mut budget: Budget) raises Self.Failure -> ClosureLocalOrder

The canonical closure of a committed sequent row's sequent, with the leaf and renaming that give it.

A Proven declared by theorem from this proof states K(s). Its instance from the proof's own sequent takes the quantifiers in the order π and the antecedents in the order σ (Theorem Q-3b), not in binding order and structural order. Charged like the theory pass's check.

Arguments.

  • proof: A committed sequent row.
  • budget: Charged.

Returns. K(s), π, σ and θ*'s order.

Raises. Self.Failure: For locals off one chain or hypotheses with one closed form; what the engine or the view raises.

ConstructorWithError.holds_variable

def holds_variable(self, name: UInt64, type: UInt64) -> Bool

Whether the variable cache holds a local for a name and a type (D10).

Arguments.

  • name: The name, a POOL row.
  • type: The type.

Returns. True when variable(name, type) would return a cached local.

ConstructorWithError.resolve_axiom

def resolve_axiom(mut self, hypotheses: Span[UInt64, _], conclusion: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

Prove an article axiom Γ ⊢ φ from a provider of its canonical closure, declaring nothing (Rule L1).

The provider is the first declaration whose statement t has an index entry (K(o_{k,n}(t)), k, n) equal to (K(q), k, n) for q = Γ ⊢ φ (Definition Q-3d): an axiom or a Proven, cited by an axiom row, or a definition's, type definition's or specification's fact, cited by its definitional row [d, part] (Definition Q-17). When t accepts q (Definition Q-2), that row concludes q. Otherwise the engine fixes u₁, …, u_k over the top under the reserved names ·open·i, the row concludes o_{k,n}(t), and an inst row maps it onto q (Proposition Q-3f). The rows are committed here.

Arguments.

  • hypotheses: Γ.
  • conclusion: φ.
  • budget: Charged.

Returns. The proof row concluding Γ ⊢ φ, or UInt64.MAX when no provider states its canonical closure.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.statement_provided

def statement_provided(mut self, hypotheses: Span[UInt64, _], conclusion: UInt64, mut budget: Budget) raises Self.Failure -> Bool

Whether a provider already states the canonical closure of Γ ⊢ φ (Rule L1).

An article theorem whose statement is provided declares nothing: the producer commits no thm row, and its proof rows stay checked and unreferenced.

Arguments.

  • hypotheses: Γ.
  • conclusion: φ.
  • budget: Charged.

Returns. True when the key (K(q), k, n) has a provider.

Raises. Self.Failure: What the engine or the view raises.

ConstructorWithError.statement_provider

def statement_provider(mut self, hypotheses: Span[UInt64, _], conclusion: UInt64, mut budget: Budget) raises Self.Failure -> Optional[Tuple[UInt32, UInt32]]

The provider of the canonical closure of Γ ⊢ φ (Rule L1): its declaration and part, or None.

As statement_provided, but naming the provider, for a name a source gives the statement (ST6.5 version 6).

Arguments.

  • hypotheses: Γ.
  • conclusion: φ.
  • budget: Charged.

Returns. The declaration and part of the first provider of the key, or None when none provides it.

Raises. Self.Failure: What the engine or the view raises.

ConstructorWithError.axiom

def axiom(mut self, hypotheses: Span[UInt64, _], conclusion: UInt64, mut budget: Budget) raises Self.Failure -> DeclId

An axiom stating the canonical closure K(q) of q = Γ ⊢ φ, or the axiom already stating it.

Axioms are deduplicated by (K(q), k, n) (Rule L1). The statement's parameters are its type variables in first-occurrence order; with 1 to PERMUTED of them it is in key form (Theorem Q-3e(1)). Its axiom row concludes Γ ⊢ φ only when the statement accepts it: resolve_axiom proves Γ ⊢ φ from it in every case.

Arguments.

  • hypotheses: Γ.
  • conclusion: φ.
  • budget: Charged.

Returns. The axiom; the row is part 0 of it.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.term_type

def term_type(mut self, term: UInt64, mut budget: Budget, signature: UInt32 = NONE) raises Self.Failure -> UInt64

The type of a term the engine built, for an authoring session that refuses an ill-typed one when it is built.

Arguments.

  • term: A node of the writer's view.
  • budget: Charged the fact's derivation, as the checker charges it.
  • signature: Optional canonical signature for a captured proof. Defaults to the current signature.

Returns. Its type's node.

Raises. Self.Failure: When the term is ill-typed or not bound-closed; what the view or the writer raises.

ConstructorWithError.axiom_named

def axiom_named(mut self, name: UInt64, statement: UInt64, mut budget: Budget) raises Self.Failure -> DeclId

A named axiom stating a closed proposition, for a foundation whose identities include the name.

Its parameters are the statement's type variables in order of first occurrence (Definition S-3), not key form; its row [d, 0] concludes ∅ ⊢ φ. An article axiom stating the same proposition later reuses it, as it reuses any axiom of the producer's.

Arguments.

  • name: The axiom's name, a POOL row.
  • statement: φ, closed.
  • budget: Charged.

Returns. The axiom.

Raises. Self.Failure: When φ is not a closed proposition; what the engine, the view or the writer raises.

ConstructorWithError.proven

def proven(mut self, name: UInt64, statement: UInt64, proof: UInt64, mut budget: Budget) raises Self.Failure -> Tuple[DeclId, UInt32]

A named Proven declaration of a committed proof of ∅ ⊢ φ, as theorem declares one.

With 1 to PERMUTED type variables it is in key form under the given name (Definition I-5), and an inst row may be its proof. A natural-deduction proof qualifies when it is closed (Definition LC-21(2)).

Arguments.

  • name: The declaration's name, a POOL row.
  • statement: φ: the proof's conclusion.
  • proof: The committed proof row, without hypotheses.
  • budget: Charged.

Returns. The declaration, and the proof row its thm row must cite.

Raises. Self.Failure: When the proof concludes another proposition or has hypotheses; what theorem raises.

ConstructorWithError.theorem

def theorem(mut self, proof: UInt64, hypotheses: Span[UInt64, _], conclusion: UInt64, mut budget: Budget, name: UInt64 = UInt64.MAX) raises Self.Failure -> Tuple[DeclId, UInt32]

A Proven declaration of the canonical closure K(s) of a committed proof's sequent, which must be Γ ⊢ φ.

Its parameters are the statement's type variables in first-occurrence order (Definition S-3). With 1 to PERMUTED of them the statement is in key form (Definition I-5, Theorem Q-3e(1)), as ST1.4 writes a keyed theorem. The declaration cites the proof itself: K does not depend on the names of the sequent's locals or type variables (Theorem Q-3a). A thm row citing it is a use with V = Γ = ∅ (Definition Q-17): it concludes ∅ ⊢ K(s), closed, not the proof's own sequent.

Arguments.

  • proof: The committed proof row.
  • hypotheses: Γ as the article states it.
  • conclusion: φ as the article states it.
  • budget: Charged.
  • name: The declaration's name, a POOL row; by default a synthetic judgment.thm.<n>.

Returns. The declaration, and the proof row its thm row must cite.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.define_constant

def define_constant(mut self, name: UInt64, term: UInt64, mut budget: Budget, transparent: Bool = False) raises Self.Failure -> DeclId

A definition c := t at the type of t, opaque unless asked; its row concludes ∅ ⊢ Eq(c[ᾱ_c], t).

Arguments.

  • name: The name, a POOL row.
  • term: The closed body.
  • budget: Charged.
  • transparent: Whether convert may unfold it (operand 3 is 1, K1.3); an article's definitions are opaque.

Returns. The definition; its row is part 0 of it.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.claim

def claim(mut self, p: UInt32, mut budget: Budget) raises Self.Failure -> NodeId

A proof row's claim, as a natural-deduction row reads it as a premise (Definition LC-21(1)), interned: a natural-deduction row's conclusion, or the closure of a sequent row's stored sequent (Definition Q-3: ⇒ over its hypotheses, ∀ over the locals of its dependency set), built as the checker builds it.

Arguments.

  • p: A proof row.
  • budget: Charged.

Returns. The claim's node.

Raises. Self.Failure: What the engine, the view or the writer raises.

ConstructorWithError.provided_statement

def provided_statement(mut self, d: UInt32, mut budget: Budget, part: UInt32 = 0) raises Self.Failure -> NodeId

The key (Definition I-5) of the statement a declaration's row at a part concludes, closed, as a bank node.

At part 0 a Proven's or an Axiom's statement, a Definition's equation Eq(c[ᾱ_c], t) (Definition L-1), or an instance definition's Eq(c[τ̄], t) (K2.7); a type definition's facts at parts 3 and 4, ∀a. abs(rep a) = a and ∀r. P r = (rep(abs r) = r), the closures of what its rows [d, 3] and [d, 4] conclude (Definition Q-17); a specification's fact φ[c̄/v̄] at part k + 1. Keyed in this engine's signature theory and interned, so that a library writer can serialize it for its statement identity (Definition I-6). Interning is deterministic and adds no row any declaration or proof reaches.

Arguments.

  • d: A visible declaration of one of those kinds.
  • budget: Charged.
  • part: The part.

Returns. The key's node.

Raises. Self.Failure: For another kind of declaration or part; what the engine, the view or the writer raises.

ConstructorWithError.statement_type_variables

def statement_type_variables(mut self, d: UInt32, mut budget: Budget, part: UInt32 = 0) raises Self.Failure -> List[UInt32]

The type variables of the statement a declaration provides at a part, as it states them, by their key positions (Definition I-5): the order an alias names them in (Definition L-3).

A read: the statement is built in scratch and keyed there, so the writer gains no row and no provider is registered (Rule L1).

Arguments.

  • d: A visible declaration of a kind provided_statement keys.
  • budget: Charged.
  • part: The part.

Returns. The statement's type-variable nodes; position i is the one the key renames to ?i.

Raises. Self.Failure: For another kind of declaration or part; what the engine or the view raises.

ConstructorWithError.declare_class

def declare_class(mut self, name: UInt64, superclasses: Span[UInt64, _], parameters: Span[UInt64, _], axiom: UInt64, mut budget: Budget) raises Self.Failure -> DeclId

Declare a class (K2.8, S*D;*D;R) with its sort atom (part 0) and its predicate of_class_c (part 1).

The article name class.<name> resolves to the predicate from then on, for constTerm and definitionThm.

Arguments.

  • name: The name, a POOL row.
  • superclasses: Classes.
  • parameters: Overloaded constants' heads.
  • axiom: The axiom A(α), a closed proposition.
  • budget: Charged.

Returns. The class.

Raises. Self.Failure: What the engine or the writer raises.

ConstructorWithError.sort_node

def sort_node(mut self, classes: Span[UInt64, _], mut budget: Budget) raises Self.Failure -> UInt64

The sort node of some classes: the tvar node with the empty name over their normalized atoms.

Arguments.

  • classes: Classes, in any order, possibly repeated.
  • budget: Charged.

Returns. Its node.

Raises. Self.Failure: As sorted_type_variable.

ConstructorWithError.witness_declaration

def witness_declaration(mut self, proof: UInt64, mut budget: Budget) raises Self.Failure -> DeclId

The declaration that states a closed witness theorem ⊢ φ: its provider, or a new Proven (Rule L1).

An instance or a class relation cites a theorem of its parent by declaration (Definitions Y-10, Y-10a; ST6.5 retains it as an auxiliary Proven). When an axiom or a Proven already states the statement's key, that declaration is the witness.

Arguments.

  • proof: A committed proof row concluding ⊢ φ.
  • budget: Charged.

Returns. The witness.

Raises. Self.Failure: When the key's provider is a definitional part, not an axiom or a Proven; what theorem raises.

ConstructorWithError.named_witness

def named_witness(mut self, proof: UInt64, mut budget: Budget, name: UInt64 = UInt64.MAX) raises Self.Failure -> DeclId

witness_declaration with a name for a new Proven: the provider of ⊢ φ's key, or a new theorem (Rule L1).

Every witness a declaration cites goes through here (a type definition's, a specification's, an instance's or a class relation's), so a witness never restates an earlier provider: a library leaves a restatement out (Rule L1), and a declaration citing it would then cite nothing.

Arguments.

  • proof: A committed proof row concluding ⊢ φ.
  • budget: Charged.
  • name: The new theorem's name, a POOL row; by default a synthetic judgment.thm.<n>.

Returns. The witness.

Raises. Self.Failure: When the key's provider is a definitional part, not an axiom or a Proven; what theorem raises.

ConstructorWithError.declare_instance

def declare_instance(mut self, operator: UInt64, sorts: Span[UInt64, _], class_: UInt64, witness: UInt64, mut budget: Budget) raises Self.Failure -> DeclId

An instance κ :: (S̄) c (K2.8, D*T;DD; Definition Y-10).

The theory pass checks the witness's statement, the arity's freshness and hereditary coregularity (Lemma Y-4c).

Arguments.

  • operator: The type constructor's head.
  • sorts: Its argument sorts, as sort nodes (sort_node).
  • class_: The class.
  • witness: The witness declaration (witness_declaration).
  • budget: Charged.

Returns. The instance.

Raises. Self.Failure: For a head without a type constructor; what the writer raises.

ConstructorWithError.arity_visible

def arity_visible(mut self, operator: UInt64, class_: UInt64, mut budget: Budget) raises Self.Failure -> UInt32

An instance κ :: (S̄) c visible in the current theory, for the producer's derived arities.

Read from the bank (termbank's class summary of κ's instances, and the theory pass's visibility, th_includes of the current theory and the instance's after-theory), never from producer memory.

Arguments.

  • operator: The type constructor's head.
  • class_: The class.
  • budget: Charged.

Returns. The first such instance in commit order, or NONE.

Raises. Self.Failure: For a head without a type constructor; what the view raises.

ConstructorWithError.instance_coregular

def instance_coregular(mut self, operator: UInt64, sorts: Span[UInt64, _], class_: UInt64, weakest: Span[UInt64, _], mut budget: Budget) raises Self.Failure -> Bool

Advisory, for the producer: whether κ :: (S̄) c declared now would pass Lemma Y-4c's items.

Decided as the theory pass decides them (sorts.instance_items_hold), against the instances of κ visible in the current theory, with the candidate's domain given as classes, so nothing is interned. It writes nothing to the bank or the theory. A visible instance in c itself is not an item: the theory pass refuses a second arity of κ at c, so the caller decides that case itself (arity_visible). weakest names classes in which the caller declares κ :: (∅, …, ∅) before the candidate (the producer's derived universal arities); they count as visible instances. The theory pass still decides; this only lets the producer order its declarations.

An advisory query never refuses: the theory pass owns refusals and their kinds. Whatever it cannot evaluate (a head without a type constructor, sorts malformed, not of κ's arity or naming no class, a class operand that is no class, a malformed instance of κ) it answers True, no conflict: the producer declares the instance at once, and the theory pass refuses it with its own kind. Only LIMIT and STORAGE are raised.

Arguments.

  • operator: κ's head.
  • sorts: The domain, each argument sort as its class count followed by its class declarations.
  • class_: The class declaration.
  • weakest: Classes of arities κ :: (∅, …, ∅) declared before the candidate.
  • budget: Charged: the instances of κ and the class walks.

Returns. Whether every item of the candidate's pairs would hold; True for whatever it cannot evaluate.

Raises. Self.Failure: LIMIT; STORAGE.

ConstructorWithError.relation_coregular

def relation_coregular(mut self, sub: UInt64, sup: UInt64, mut budget: Budget) raises Self.Failure -> Bool

Advisory, for the producer: whether a class relation sub ≤ sup declared now would pass (Definition Y-10a).

Decided as the theory pass decides it (sorts.relation_items_hold): acyclic, and every Lemma Y-4c item with the new edge on a path holds, for every pair of visible instances of every κ, in the current theory with the edge. It writes nothing to the bank or the theory. The theory pass still decides.

An advisory query never refuses. Whatever it cannot evaluate (an operand that is no class, a malformed instance) it answers False: the producer then leaves the relation where the article puts it, and the theory pass judges it there. Only LIMIT and STORAGE are raised.

Arguments.

  • sub: The subclass's declaration.
  • sup: The superclass's declaration.
  • budget: Charged: every visible instance and the class walks.

Returns. Whether the relation would be acyclic and coregular; False for whatever it cannot evaluate.

Raises. Self.Failure: LIMIT; STORAGE.

ConstructorWithError.class_relation

def class_relation(mut self, sub: UInt64, sup: UInt64, witness: UInt64, mut budget: Budget) raises Self.Failure -> DeclId

A later class relation c ≤ d (K2.8, DDD; Definition Y-10a).

The theory pass checks the witness's statement, acyclicity and the recheck of coregularity.

Arguments.

  • sub: The subclass c.
  • sup: The superclass d.
  • witness: The witness declaration (witness_declaration).
  • budget: Charged.

Returns. The relation.

Raises. Self.Failure: What the writer raises.

ConstructorWithError.definition_theorem

def definition_theorem(mut self, constant: UInt64, mut budget: Budget) raises Self.Failure -> Tuple[DeclId, UInt32]

The defining theorem of a visible definition, for the article's definitionThm.

The producer commits it as the definition's defineConst row, [d, 0], concluding ∅ ⊢ Eq(c[ᾱ_c], t) (Definition Q-17). Any visible Definition qualifies, not only one this engine declared; a class predicate does not yet, as no class is declared.

Arguments.

  • constant: A constant handle (its head).
  • budget: Charged.

Returns. The Definition and the part its row concludes: 0, or 1 for a class's predicate (Definition Y-8).

Raises. Self.Failure: For an unknown constant or one that is not a Definition's or a class predicate; what the engine raises.

ConstructorWithError.overloaded_constant

def overloaded_constant(mut self, name: UInt64, type: UInt64, mut budget: Budget) raises Self.Failure -> UInt64

Declare an overloaded constant at a type (K2.7), with its type's variables as parameters.

Arguments.

  • name: The name, a POOL row.
  • type: Its type.
  • budget: Charged.

Returns. Its head; the name resolves to it from then on.

Raises. Self.Failure: What the engine or the writer raises.

ConstructorWithError.define_instance

def define_instance(mut self, constant: UInt64, types: Span[UInt64, _], term: UInt64, mut budget: Budget) raises Self.Failure -> Tuple[DeclId, UInt32]

An instance definition c[τ̄] := t of an overloaded constant (K2.7, Definition Y-3); its row concludes ∅ ⊢ Eq(c[τ̄], t).

The engine checks the form: an overloaded constant, τ̄ of its arity, t closed of type σ_c[τ̄] with its type variables in τ̄. Orthogonality against the constant's earlier instance definitions is the theory pass's (K2.7). The defineInstance row [d, 0] concludes the equation (Definition Q-17).

Arguments.

  • constant: The overloaded constant's head.
  • types: τ̄, one type per parameter, in the constant's parameter order.
  • term: The body t, closed.
  • budget: Charged.

Returns. The instance definition, and 0.

Raises. Self.Failure: For a constant that is not overloaded, another number of types, a body that is open, of another type or with a type variable not in τ̄; what the engine, the view or the writer raises.

ConstructorWithError.define_type_operator

def define_type_operator(mut self, name: UInt64, abs: UInt64, rep: UInt64, parameters: Span[UInt64, _], proof: UInt64, mut budget: Budget, witness_name: UInt64 = UInt64.MAX, predicate: UInt64 = UInt64.MAX, argument: UInt64 = UInt64.MAX, sorted: Bool = False) raises Self.Failure -> Tuple[DeclId, UInt32]

A type definition (K2.6, Definition Y-1) from the article's ⊢ P t, with its witness ⊢ ∃x:σ. P x.

The witness is derived off the chain and declared Proven: fix q : Prop, assume ∀x. P x → q, take its instance at t, apply it to the theorem, discharge, generalize q, and convert the result to ∃x:σ. P x by unfolding core.exists. With 1 to PERMUTED type variables the witness is in key form (Definition I-5); the type definition keeps its declared predicate and parameters. Its type constructor, abs and rep are parts 0, 1 and 2, and its two theorems parts 3 and 4, which the producer's rows [d, 3] and [d, 4] conclude.

Arguments.

  • name: The type operator's name, a POOL row.
  • abs: abs's name.
  • rep: rep's name.
  • parameters: The type variables' names, in the type operator's argument order.
  • proof: The committed proof of ⊢ P t, closed.
  • budget: Charged.
  • witness_name: The witness's name, a POOL row; by default a synthetic judgment.thm.<n>.
  • predicate: P, a committed term, with argument; by default P and t are read off the theorem, from the application the engine built when P is a λ.
  • argument: t, a committed term, with predicate.
  • sorted: defineSortedTypeOp: parameters are type variables, each with exactly the sort it has in P.

Returns. The type definition, and 0.

Raises. Self.Failure: When the theorem has hypotheses or free locals, is not an application (or not N(P t) for the given P and t), P is not closed or not a predicate, or a type variable of P is not a parameter or a parameter repeats; what the engine, the view or the writer raises. A parameter that P does not mention (β-conversion erased it from the article's predicate) is kept by guarding P as λc. P c ∧ ∀x:A. True.

ConstructorWithError.define_type_from_witness

def define_type_from_witness(mut self, name: UInt64, abs: UInt64, rep: UInt64, parameters: List[UInt32], predicate: UInt32, witness: UInt32, mut budget: Budget) raises Self.Failure -> Tuple[DeclId, UInt32]

A type definition (K2.6, Definition Y-1) from its witness, a declaration stating ∃x:σ. P x, as a session's subset gives it.

Its type constructor, abs and rep are parts 0, 1 and 2, and its two theorems parts 3 and 4, which the producer's rows [d, 3] and [d, 4] conclude. The theory pass decides the predicate, the parameters and the witness (Definition Y-1).

Arguments.

  • name: The type operator's name, a POOL row.
  • abs: abs's name.
  • rep: rep's name.
  • parameters: The type variables, nodes, in the type operator's argument order.
  • predicate: P, a closed predicate's node.
  • witness: The witness's declaration, visible in the current theory.
  • budget: Charged.

Returns. The type definition, and 0.

Raises. Self.Failure: What the view or the writer raises.

ConstructorWithError.define_constant_list

def define_constant_list(mut self, names: Span[UInt64, _], locals: Span[UInt64, _], proof: UInt64, mut budget: Budget, witness_name: UInt64 = UInt64.MAX) raises Self.Failure -> Tuple[DeclId, UInt32]

A specification (K2.6, Definition Y-2) from the article's {v₁ = t₁, …, v_k = t_k} ⊢ φ, with its witness.

The witness ⊢ ∀v̄. v₁ = t₁ → … → v_k = t_k → φ is derived off the chain and declared Proven: fix fresh ūᵢ in command order, assume uᵢ = tᵢ in order, instantiate the theorem's closure at the ū, discharge its antecedents with the hypotheses, then imp_intro the assumptions and forall_intro the ū, innermost first. Constant cᵢ is part i; the theorem φ[c̄/v̄] is part k + 1, which the producer's row [d, k + 1] concludes.

Arguments.

  • names: The constants' names, POOL rows.
  • locals: The variables v̄, in the same order.
  • proof: The committed proof of the theorem.
  • budget: Charged.
  • witness_name: The witness's name, a POOL row; by default a synthetic judgment.thm.<n>.

Returns. The specification, and k + 1.

Raises. Self.Failure: When the hypotheses are not exactly the vᵢ = tᵢ with each tᵢ closed and its type variables in vᵢ's type, or the theorem's free locals are not exactly v̄; what the engine, the view or the writer raises.

ConstructorWithError.specify

def specify(mut self, names: Span[UInt64, _], witness: UInt32, mut budget: Budget) raises Self.Failure -> Tuple[DeclId, UInt32]

A specification (K2.6, Definition Y-2) from its witness, a declaration stating ∀v₁ … v_k. v₁ = t₁ → … → v_k = t_k → φ, as a session's specification gives it.

Constant cᵢ is part i, its arity the type variables of the witness's i-th quantifier as declared (Definition S-3); the theorem φ[c̄/v̄] is part k + 1, which the producer's row [d, k + 1] concludes. The engine reads only the k leading quantifiers: the theory pass decides the witness's form and kind.

Arguments.

  • names: The constants' names, POOL rows, one per leading universal.
  • witness: The witness's declaration, visible in the current theory.
  • budget: Charged.

Returns. The specification, and k + 1.

Raises. Self.Failure: For no names, or a witness with fewer than k leading universals; what the view or the writer raises.

ConstructorWithError.defined_constant

def defined_constant(mut self, declaration: UInt64, index: Int) raises Self.Failure -> UInt64

A constant a declaration defines.

Arguments.

  • declaration: A definition, a type definition or a specification.
  • index: 0 for a definition; 0 (abs) or 1 (rep) for a type definition; i for a specification's c_{i+1}.

Returns. Its head.

Raises. Self.Failure: For another index; what the view raises.

ConstructorWithError.defined_type_operator

def defined_type_operator(mut self, declaration: UInt64) raises Self.Failure -> UInt64

The type operator a type definition defines.

Arguments.

  • declaration: A type definition.

Returns. Its head.

Raises. Self.Failure: For another declaration; what the view raises.

ConstructorWithError.core_axiom

def core_axiom(mut self, name: StaticString, mut budget: Budget) raises Self.Failure -> DeclId

An axiom of the logic core by its name (core.propext), made citable: its axiom row (part 0) concludes ⊢ its closed statement.

Arguments.

  • name: The core declaration's name.
  • budget: Charged.

Returns. The axiom.

Raises. Self.Failure: When the core declares no axiom of that name; what the writer raises.

ConclusionWork

@fieldwise_init
struct ConclusionWork(Movable, ThreadTransferable)
Field Type Description
view DagCheckView Committed premise rows and immutable signature answers.
scratch Scratch The task's exclusively owned computation and result storage.
rule UInt8 Inference kind.
frame UInt32 Construction frame captured when the operands were prepared.
signature UInt32 Canonical signature for this step.

An owned inference computation with private scratch and a read-only DAG view.

The originating constructor must remain idle while compute runs on a worker. No writer is transferred. Integrate on that constructor after joining, in source order; the result still requires ordinary kernel checking.

Defined in src/judgment_core/checker/construct.mojo.

ConclusionWork.take_scratch

def take_scratch(deinit self) -> Scratch

Return private working storage after integration or a discarded computation.

Returns. Reusable scratch, tied to the originating constructor's DAG.

ConclusionWork.compute

@no_inline
def compute(mut self) raises CheckFail

Compute the rule's conclusion without interning or writing any DAG row.

Raises.

  • CheckFail: The rule's refusal or scratch/work exhaustion.

ConstructorMark

@fieldwise_init
struct ConstructorMark(Copyable)
Field Type Description
logs List[Int] The name caches' log lengths, in Constructor.mark's order.
base List[UInt32] Constructor.base.
segment UInt32 Constructor.segment.
count UInt32 Constructor.count.
theory UInt32 Constructor.theory.
top UInt32 Constructor.top.
anchor UInt32 Constructor.anchor.
names Int Constructor.names.
exists_head UInt32 Constructor.exists_head.
unguarded_predicate UInt32 Constructor.unguarded_predicate.
sig UInt32 Constructor.sig.
sigs PendingSignatures A copy of Constructor.sigs.

The engine state Constructor.truncate returns to: its scalars and its name caches' log lengths.

Defined in src/judgment_core/checker/construct.mojo.

WriterSource

struct WriterSource(Movable)

The writer a Constructor appends through: a bank's, or a workspace's, kept alive with its owner.

Defined in src/judgment_core/checker/construct.mojo.

WriterSource.__init__

def __init__(out self, w: ArcPointer[DagWriter])

A bank's writer.

Arguments.

  • w: The writer.

WriterSource.__init__

def __init__(out self, ws: ArcPointer[Workspace])

A workspace's one writer; the workspace stays alive while this does.

Arguments.

  • ws: The workspace.

WriterSource.__init__

def __init__(out self, slot: ArcPointer[WorkspaceSlot])

The writer of the workspace in a slot; the slot stays alive while this does, and must not be emptied while an engine appends through this source.

Arguments.

  • slot: The slot.

WorkspaceSlot

struct WorkspaceSlot(Movable)
Field Type Description
ws Optional[Workspace] The workspace; empty once taken.

A workspace a session shares with its engine's WriterSource, which a commit or a discard takes out.

Workspace.commit and discard consume the workspace, so that a closed one cannot be written again; the slot lets its owner move it out of a shared ArcPointer. Reading an empty slot aborts: the engine is switched to another source before its slot is emptied.

Defined in src/judgment_core/checker/construct.mojo.

WorkspaceSlot.__init__

def __init__(out self, var ws: Workspace)

A full slot.

Arguments.

  • ws: The workspace.

WorkspaceSlot.take

def take(mut self) raises KernelError -> Workspace

Move the workspace out; the slot is empty after.

Returns. The workspace.

Raises.

  • KernelError: BAD_HANDLE for an empty slot.

Produced

@fieldwise_init
struct Produced(ImplicitlyCopyable, Movable)
Field Type Description
conclusion UInt32 [NODE].
hyps UInt32 [HSET].
deps UInt32 [DSET].
context UInt32 [CONTEXT]: β.
signature UInt32 [THEORY].
home UInt32 [THEORY].

A proof row's stored fields beside its operands (TD1.7), interned.

Defined in src/judgment_core/checker/construct.mojo.

UNKNOWN

comptime UNKNOWN: UInt64 = UInt64(1) << 63

Marks a type operator or constant handle that names an undeclared name: UNKNOWN | name.

Defined in src/judgment_core/checker/construct.mojo.

Derivations

comptime Derivations = DerivationsWithError[]

Derived steps over the default construction boundary.

Defined in src/judgment_core/checker/derived.mojo.

DerivationsWithError

struct DerivationsWithError[Failure: ConstructionFailure = _ErasedConstructionError](Movable)
Field Type Description
lemmas Dict[Tuple[UInt8, UInt64], Int] Lemma rows by rule and type.

Derived equality steps over one constructor, caching lemmas once per type.

Parameters.

  • Failure: The associated constructor's error boundary.

Defined in src/judgment_core/checker/derived.mojo.

DerivationsWithError.__init__

def __init__(out self)

Start with no lemma.

DerivationsWithError.eq_refl

def eq_refl(mut self, mut c: ConstructorWithError[Self.Failure], term: UInt64, type: UInt64, mut budget: Budget) raises Self.Failure -> UInt32

(Refl): ⊢ t = t, a natural-deduction row.

Arguments.

  • c: The engine.
  • term: t, a committed canonical term.
  • type: Its type.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: What the engine raises.

DerivationsWithError.eq_sym

def eq_sym(mut self, mut c: ConstructorWithError[Self.Failure], p: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(Sym): from Γ ⊢ s = t, Γ ⊢ t = s.

Arguments.

  • c: The engine.
  • p: The premise.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: When the premise is not an equation; what the engine raises.

DerivationsWithError.eq_trans

def eq_trans(mut self, mut c: ConstructorWithError[Self.Failure], p: UInt32, q: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(Trans): from Γ ⊢ s = t and Γ ⊢ t = u, Γ ⊢ s = u.

Arguments.

  • c: The engine.
  • p: The first premise.
  • q: The second; its left side is p's right side.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: When a premise is not an equation or the middle terms differ; what the engine raises.

DerivationsWithError.eq_apply

def eq_apply(mut self, mut c: ConstructorWithError[Self.Failure], p: UInt32, arguments: List[UInt32], mut budget: Budget) raises Self.Failure -> UInt32

(Cong): from Γ ⊢ f = g and Γ ⊢ aᵢ = bᵢ, Γ ⊢ f(ā) = g(b̄), one argument at a time, with β.

Arguments.

  • c: The engine.
  • p: The functions' equation.
  • arguments: The arguments' equations, in order.
  • budget: Charged.

Returns. The row; p itself without arguments.

Raises. Self.Failure: When a premise is not an equation or an argument's type is not the function's domain; what the engine raises.

DerivationsWithError.eq_subst

def eq_subst(mut self, mut c: ConstructorWithError[Self.Failure], predicate: UInt64, p: UInt32, q: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(Subst): from P: τ → Prop, Γ ⊢ a = b and Γ ⊢ app(P, a), Γ ⊢ app(P, b), with β.

Arguments.

  • c: The engine.
  • predicate: P, a committed canonical term of type τ → Prop.
  • p: The equation.
  • q: app(P, a)'s row.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: When p is not an equation or q does not conclude app(P, a); what the engine raises.

DerivationsWithError.and_left

@staticmethod
def and_left(mut c: ConstructorWithError[Self.Failure], p: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(∧E₁): from Γ ⊢ A ∧ B, Γ ⊢ A; the checked kind and_left.

Arguments.

  • c: The engine.
  • p: The conjunction.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: What the engine raises.

DerivationsWithError.and_right

@staticmethod
def and_right(mut c: ConstructorWithError[Self.Failure], p: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(∧E₂): from Γ ⊢ A ∧ B, Γ ⊢ B; the checked kind and_right.

Arguments.

  • c: The engine.
  • p: The conjunction.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: What the engine raises.

DerivationsWithError.eq_abstract

@staticmethod
def eq_abstract(mut c: ConstructorWithError[Self.Failure], local: UInt32, p: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(ξ): from Γ, x:τ ⊢ a = b, Γ ⊢ (λ:τ. abs_x a) = (λ:τ. abs_x b); the checked kind eq_abstract.

Arguments.

  • c: The engine.
  • local: x, the innermost entry of p's frame.
  • p: The equation.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: What the engine raises.

DerivationsWithError.exists_intro

@staticmethod
def exists_intro(mut c: ConstructorWithError[Self.Failure], predicate: UInt64, type: UInt64, witness: UInt64, p: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(∃I), derived: from Γ ⊢ P t, Γ ⊢ ∃x:τ. P x.

Off the premise's frame: fix q, assume ∀x. P x → q, ∀E at t, →E with p, →I, ∀I q, then convert to exists[τ](P) by unfolding core.exists.

Arguments.

  • c: The engine.
  • predicate: P, a committed canonical term of type τ → Prop.
  • type: τ.
  • witness: t.
  • p: The proof of app(P, t).
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: What the engine raises; the checker's refusal when p does not conclude app(P, t).

DerivationsWithError.exists_elim

@staticmethod
def exists_elim(mut c: ConstructorWithError[Self.Failure], existence: UInt32, local: UInt32, h: UInt32, branch: UInt32, mut budget: Budget) raises Self.Failure -> UInt32

(∃E), derived: from Γ ⊢ ∃x:τ. P x and Γ, x:τ, h: P x ⊢ C, with x not in C, Γ ⊢ C.

converts the existential to ∀q. (∀x. P x → q) → q, instantiates it at C, and discharges it with ∀x. P x → C, the branch by →I h and ∀I x.

Arguments.

  • c: The engine.
  • existence: The proof of exists[τ](P).
  • local: x, whose fix frame is h's parent.
  • h: The assume frame of app(P, x).
  • branch: The proof of C at h.
  • budget: Charged.

Returns. The row.

Raises. Self.Failure: When existence is not an existential; what the engine raises; the checker's refusal when x occurs in C or h is not P x.

TheoryVerdict

struct TheoryVerdict(Movable)
Field Type Description
verdict Verdict THEORY over the range; passed is the end of the decided rows.
stop Optional[Refusal] The refusal that stopped the pass.
steps UInt64 The units charged.

What a theory pass decided.

Defined in src/judgment_core/checker/theory.mojo.

TheoryVerdict.__init__

def __init__(out self, var verdict: Verdict, stop: Optional[Refusal], steps: UInt64)

Assemble a verdict.

Arguments.

  • verdict: The THEORY verdict.
  • stop: The refusal, if any.
  • steps: The units charged.

TheoryVerdict.take

def take(deinit self) -> Verdict

Give up the verdict, for submit.

Returns. The THEORY verdict.

check_declaration

def check_declaration(v: DagCheckView, mut s: Scratch, plain: UInt32, d: UInt32, mut parts: PartNames, mut classes: ClassCache, mut canon: _Canon, trusted: Bool = False) raises CheckFail

Check one declaration row under the conditions of K1.3 and K2.6 to K2.9 (Definition LC-12).

Arguments.

  • v: A producer's view (DagCheckView.producing) with the root theory as every signature.
  • s: The scratch.
  • plain: The signature theory of the declaration's parent (the root theory when it has no canonical declaration).
  • d: The declaration.
  • parts: The names of the parts declared before d in its segment, scanned as needed.
  • classes: The pass's class-order cache (sorts.ClassCache).
  • canon: The pass's canonical declarations, per segment (_Canon).
  • trusted: d belongs to a library's class layer imported whole (ST9.8): instances and class relations skip the coregularity and acyclicity their library's publication checked (check_instance, check_class_relation); every other condition is checked.

Raises.

  • CheckFail: The declaration's refusal; UNSUPPORTED for a form the pass does not cover.

Defined in src/judgment_core/checker/theory.mojo.

check_theory

def check_theory(view: DagView, start: UInt64, end: UInt64, budget: Budget, mut s: Scratch, trusted: Bool = False) -> TheoryVerdict

Decide the declaration and theory rows of [start, end), from the theory mark, in commit order (KC1.11). Never raises.

Arguments.

  • view: The bank's check view.
  • start: The first row: the view's theory mark.
  • end: The end of the range, at most the view's top.
  • budget: The pass's allowance.
  • s: A scratch; reset first.
  • trusted: The range is a statement-only import of a library, its whole class layer in the library's commit order (ST9.8): instances and class relations are checked as check_declaration does with trusted.

Returns. The THEORY verdict, with a SIGNATURE answer for every theory row it decides.

Defined in src/judgment_core/checker/theory.mojo.

core_prefix

def core_prefix(mut w: DagWriter, mut budget: Budget) raises BankError -> CoreIds

Commit the core prefix to an empty bank and record its ids (TD1.1, item 5; K1.4).

Arguments.

  • w: The bank's writer; nothing may have been committed yet.
  • budget: Charged for every row.

Returns. The core ids, as set_core recorded them.

Raises.

  • BankError: What the writer raises; WORKSPACE when the core is already recorded.

Defined in src/judgment_core/checker/core_prefix.mojo.

refusal_code

def refusal_code(r: Refusal) -> UInt32

Pack a refusal for a verdict.

Arguments.

  • r: The refusal.

Returns. kind << 16 | detail.

Defined in src/judgment_core/checker/verdict.mojo.

rows_verdict

def rows_verdict(view: DagView, result: ChunkVerdict) -> Verdict

Make the ROWS verdict of a checked chunk (KC1.6, item 2).

Arguments.

  • view: A view of the bank the chunk was checked in.
  • result: The chunk's result; its facts are copied into the verdict.

Returns. The verdict, over [chunk.start, chunk.end) with the passing prefix [chunk.start, passed_end).

Defined in src/judgment_core/checker/verdict.mojo.

Declarations

Core names, exact literal values, canonical byte codecs, and law codes used by theory declarations (K1.3, C1.4).

LiteralImpl

Mojo

@fieldwise_init
struct LiteralImpl(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
code UInt8 The implementation's number; compare with ==.

Python

from judgment import LiteralImpl

Python constructor:

def __init__(self, code)
Field Description
code The implementation's number; compare with ==.

A literal implementation of the kernel.

Defined in src/judgment_core/literal_values.mojo.

LiteralImpl.EXACT_INTEGER

Mojo

comptime EXACT_INTEGER = LiteralImpl(1)

Python

LiteralImpl.EXACT_INTEGER

Integers: apn_mojo Integer.

LiteralImpl.EXACT_RATIONAL

Mojo

comptime EXACT_RATIONAL = LiteralImpl(2)

Python

LiteralImpl.EXACT_RATIONAL

Rationals: apn_mojo Rational; adds INV.

LiteralImpl.FORMAL_POLYNOMIAL

Mojo

comptime FORMAL_POLYNOMIAL = LiteralImpl(3)

Python

LiteralImpl.FORMAL_POLYNOMIAL

Polynomials with rational coefficients: PolyValue; adds INDET and COEFF, over a base kind.

LiteralImpl.write_to

Mojo

def write_to(self, mut writer: Some[Writer])

Python

str(value)

Use str(value) or print(value) in Python.

Write the implementation's name.

Arguments.

  • writer: The writer to write to.

LiteralValue

Mojo

struct LiteralValue(Copyable, Writable)

Python

from judgment import LiteralValue

Python constructor:

def __init__(self, value)

A literal's value: an apn_mojo Integer or Rational, or a PolyValue.

Defined in src/judgment_core/literal_values.mojo.

LiteralValue.__init__

Mojo

@implicit
def __init__(out self, value: Integer)

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make an integer value.

Arguments.

  • value: The integer.

LiteralValue.__init__

Mojo

@implicit
def __init__(out self, value: Rational)

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make a rational value.

Arguments.

  • value: The rational.

LiteralValue.__init__

Mojo

@implicit
def __init__(out self, var value: PolyValue)

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make a polynomial value; the kernel accepts it only in canonical form (check_kind).

Arguments.

  • value: The polynomial.

LiteralValue.__init__

Mojo

def __init__(out self, *, var form: Choice[LiteralForm])

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make a value from its stored form, moving the payload in.

Arguments.

  • form: The form and its payload.

LiteralValue.is_integer

Mojo

def is_integer(self) -> Bool

Python

def is_integer(self)

Tell whether the value was given as an Integer.

Returns. True for an Integer.

LiteralValue.is_polynomial

Mojo

def is_polynomial(self) -> Bool

Python

def is_polynomial(self)

Tell whether the value was given as a PolyValue.

Returns. True for a PolyValue.

LiteralValue.integer

Mojo

def integer(self) raises KernelError -> Integer

Python

def integer(self)

Read an Integer value.

Returns. The integer.

Raises.

  • KernelError: ENCODING when the value is a Rational or a PolyValue.

LiteralValue.rational

Mojo

def rational(self) raises KernelError -> Rational

Python

def rational(self)

Read the value as a Rational.

Returns. The rational, or the integer as a rational.

Raises.

  • KernelError: ENCODING when the value is a PolyValue.

LiteralValue.polynomial

Mojo

def polynomial(self) raises KernelError -> PolyValue

Python

def polynomial(self)

Read a PolyValue.

Returns. The polynomial.

Raises.

  • KernelError: ENCODING when the value is an Integer or a Rational.

LiteralValue.write_to

Mojo

def write_to(self, mut writer: Some[Writer])

Python

str(value)

Use str(value) or print(value) in Python.

Write the value: a number in decimal, a polynomial as a sum of terms.

Arguments.

  • writer: The writer to write to.

PolyValue

Mojo

struct PolyValue(Copyable, Equatable, Writable)
Field Type Description
terms List[PolyTerm] The terms, in strictly increasing monomial order, none with a zero coefficient; none for the zero polynomial.

Python

from judgment import PolyValue

Python constructor:

def __init__(self, terms=[])
Field Description
terms The terms, in strictly increasing monomial order, none with a zero coefficient; none for the zero polynomial.

A formal polynomial with rational coefficients: a value of the FORMAL_POLYNOMIAL kind.

The kernel accepts a value only in canonical form (check_poly).

Defined in src/judgment_core/literal_values.mojo.

PolyValue.__init__

Mojo

def __init__(out self)

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make the zero polynomial.

PolyValue.__init__

Mojo

def __init__(out self, var terms: List[PolyTerm])

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make a polynomial from terms already in canonical form.

Arguments.

  • terms: The terms.

PolyValue.constant

Mojo

@staticmethod
def constant(c: Rational) -> PolyValue

Python

This overload is available only in Mojo; it is not exposed by the Python client.

Make a constant polynomial.

Arguments.

  • c: The constant.

Returns. c: no term for 0.

PolyValue.indeterminate

Mojo

@staticmethod
def indeterminate(index: Int64) -> PolyValue

Python

This overload is available only in Mojo; it is not exposed by the Python client.

Make an indeterminate.

Arguments.

  • index: Its index.

Returns. X_index.

PolyValue.write_to

Mojo

def write_to(self, mut writer: Some[Writer])

Python

str(value)

Use str(value) or print(value) in Python.

Write the polynomial as a sum of its terms, or 0.

Arguments.

  • writer: The writer to write to.

PolyTerm

Mojo

struct PolyTerm(Copyable, Equatable, Writable)
Field Type Description
monomial List[Tuple[Int64, UInt32]] The monomial's (index, exponent) pairs: indices strictly increasing, exponents at least 1; none for a constant term.
coefficient Rational The coefficient, nonzero.

Python

from judgment import PolyTerm

Python constructor:

def __init__(self, monomial, coefficient)
Field Description
monomial The monomial's (index, exponent) pairs: indices strictly increasing, exponents at least 1; none for a constant term.
coefficient The coefficient, nonzero.

A term of a formal polynomial: a monomial and its nonzero rational coefficient.

Defined in src/judgment_core/literal_values.mojo.

PolyTerm.__init__

Mojo

def __init__(out self, var monomial: List[Tuple[Int64, UInt32]], var coefficient: Rational)

Python

Use the Python constructor shown above. Python does not mirror Mojo constructor overloads.

Make a term.

Arguments.

  • monomial: The monomial's pairs.
  • coefficient: The coefficient.

PolyTerm.write_to

Mojo

def write_to(self, mut writer: Some[Writer])

Python

str(value)

Use str(value) or print(value) in Python.

Write the term: its coefficient, then *X[i]^e for each pair, the exponent omitted when it is 1.

Arguments.

  • writer: The writer to write to.

decode

def decode(impl: LiteralImpl, data: Span[UInt8, _]) raises KernelError -> LiteralValue

Decode and validate an encoding.

Arguments.

  • impl: The implementation.
  • data: The encoding.

Returns. The value: an Integer for EXACT_INTEGER, a Rational for EXACT_RATIONAL, a PolyValue for FORMAL_POLYNOMIAL.

Raises.

  • KernelError: CAPACITY past the ceiling; ENCODING for an encoding that is not canonical, and for a polynomial encoding of 0 or 1.

Defined in src/judgment_core/literals.mojo.

encode

def encode(impl: LiteralImpl, value: LiteralValue) raises KernelError -> List[UInt8]

Encode a value of an implementation.

Arguments.

  • impl: The implementation.
  • value: The value, of the implementation's form (check_kind).

Returns. The canonical encoding.

Raises.

  • KernelError: ENCODING for a value of another form; INTERNAL when apn_mojo fails.

Defined in src/judgment_core/literals.mojo.

encoded_length

def encoded_length(impl: LiteralImpl, value: LiteralValue) raises KernelError -> Int

Measure a value's encoding; the values 0 and 1, which have no pool entry, count 1.

Arguments.

  • impl: The implementation.
  • value: The value.

Returns. The length in bytes.

Raises.

  • KernelError: As encode.

Defined in src/judgment_core/literals.mojo.

law_code

def law_code(law: LiteralLaw) -> Int

Number a literal law: R1–R7 are 0–6, O1–O7 are 7–13, F1–F2 14–15, E1–E4 16–19, P1–P4 20–23, Q1–Q8 24–31.

Arguments.

  • law: The law.

Returns. Its number, or -1 for a law that does not exist.

Defined in src/judgment_core/law_codes.mojo.

LiteralOp

Mojo

@fieldwise_init
struct LiteralOp(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
code UInt8 The operation's number; compare with ==.

Python

from judgment import LiteralOp

Python constructor:

def __init__(self, code)
Field Description
code The operation's number; compare with ==.

An operation a literal kind binds.

Defined in src/judgment_core/inspect.mojo.

LiteralOp.ZERO

Mojo

comptime ZERO = LiteralOp(0)

Python

LiteralOp.ZERO

The value 0.

LiteralOp.ONE

Mojo

comptime ONE = LiteralOp(1)

Python

LiteralOp.ONE

The value 1.

LiteralOp.ADD

Mojo

comptime ADD = LiteralOp(2)

Python

LiteralOp.ADD

Addition.

LiteralOp.MUL

Mojo

comptime MUL = LiteralOp(3)

Python

LiteralOp.MUL

Multiplication.

LiteralOp.NEG

Mojo

comptime NEG = LiteralOp(4)

Python

LiteralOp.NEG

Negation.

LiteralOp.INV

Mojo

comptime INV = LiteralOp(5)

Python

LiteralOp.INV

Inverse.

LiteralOp.POW

Mojo

comptime POW = LiteralOp(6)

Python

LiteralOp.POW

Power.

LiteralOp.EXPONENT

Mojo

comptime EXPONENT = LiteralOp(7)

Python

LiteralOp.EXPONENT

The predicate of integer exponents.

LiteralOp.LT

Mojo

comptime LT = LiteralOp(8)

Python

LiteralOp.LT

Strict order.

LiteralOp.LE

Mojo

comptime LE = LiteralOp(9)

Python

LiteralOp.LE

Order.

LiteralOp.INDET

Mojo

comptime INDET = LiteralOp(10)

Python

LiteralOp.INDET

The indeterminates of a polynomial kind, from its base kind's integers.

LiteralOp.COEFF

Mojo

comptime COEFF = LiteralOp(11)

Python

LiteralOp.COEFF

The constant polynomials, from its base kind's values.

LiteralOp.write_to

Mojo

def write_to(self, mut writer: Some[Writer])

Python

str(value)

Use str(value) or print(value) in Python.

Write the operation's name.

Arguments.

  • writer: The writer to write to.

LiteralLaw

Mojo

@fieldwise_init
struct LiteralLaw(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
family UInt8 0 for R (ring), 1 for O (order), 2 for F (field), 3 for E (exponent), 4 for P (power), 5 for Q (polynomial).
number UInt8 The law's number within its family, from 1.

Python

from judgment import LiteralLaw

Python constructor:

def __init__(self, family, number)
Field Description
family 0 for R (ring), 1 for O (order), 2 for F (field), 3 for E (exponent), 4 for P (power), 5 for Q (polynomial).
number The law's number within its family, from 1.

A literal law of Definition C-5, or of Definition C-5P for a polynomial kind, that a literal kind cites.

Defined in src/judgment_core/inspect.mojo.

LiteralLaw.write_to

Mojo

def write_to(self, mut writer: Some[Writer])

Python

str(value)

Use str(value) or print(value) in Python.

Write the law's name, such as R3.

Arguments.

  • writer: The writer to write to.

CoreName

@fieldwise_init
struct CoreName(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
code UInt8 The declaration's position in the logic core.

A declaration of the logic core.

Defined in src/judgment_core/inspect.mojo.

CoreName.PROP

comptime PROP = CoreName(0)

core.Prop, the type constructor of propositions.

CoreName.TRUE

comptime TRUE = CoreName(1)

core.True: Prop.

CoreName.FALSE

comptime FALSE = CoreName(2)

core.False: Prop.

CoreName.AND

comptime AND = CoreName(3)

core.and: Prop → Prop → Prop.

CoreName.OR

comptime OR = CoreName(4)

core.or: Prop → Prop → Prop.

CoreName.IMP

comptime IMP = CoreName(5)

core.imp: Prop → Prop → Prop.

CoreName.FORALL

comptime FORALL = CoreName(6)

core.forall[α]: (α → Prop) → Prop.

CoreName.EQ

comptime EQ = CoreName(7)

core.eq[α]: α → α → Prop, the kernel equality.

CoreName.NOT

comptime NOT = CoreName(8)

core.not:= λP. imp(P, False), transparent.

CoreName.IFF

comptime IFF = CoreName(9)

core.iff:= λP Q. and(imp(P, Q), imp(Q, P)), transparent.

CoreName.EXISTS

comptime EXISTS = CoreName(10)

core.exists[α]:= λP. forall[Prop](λQ. imp(forall[α](λx. imp(P(x), Q)), Q)), transparent.

CoreName.PROPEXT

comptime PROPEXT = CoreName(11)

core.propext: ∀P Q:Prop. imp(imp(P, Q), imp(imp(Q, P), eq[Prop](P, Q))), the axiom of propositional extensionality.

CoreName.ITSELF

comptime ITSELF = CoreName(12)

core.itself, the type constructor of arity 1 whose predicates are properties of types (Definition Y-7, K2.8).

CoreName.TYPE

comptime TYPE = CoreName(13)

core.TYPE[α]: itself(α) (Definition Y-7, K2.8).

CoreName.ARROW

comptime ARROW = CoreName(14)

core.arrow, the intrinsic binary function constructor with its existing structural head.

CoreName.COUNT

comptime COUNT = 15

How many declarations the logic core has.

CoreName.write_to

def write_to(self, mut writer: Some[Writer])

Write the declaration's qualified name.

Arguments.

  • writer: The writer to write to.

Limits and proofs

The limits of a literal operation (K1.1), and the rule tags with their operand layouts (K1.10): rule_layout gives a tag's operand grammar.

Limits

@fieldwise_init
struct Limits(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
steps UInt64 Steps a call may take; every input-dependent loop charges them (G3).
nodes UInt64 New nodes a call may add.

The limits of one Call.

Defined in src/judgment_core/limits.mojo.

Limits.__init__

def __init__(out self)

Make the default limits: the largest values the types allow.

Limits.write_to

def write_to(self, mut writer: Some[Writer])

Write the limits.

Arguments.

  • writer: The writer to write to.

RuleTag

@fieldwise_init
struct RuleTag(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
code UInt8 The tag's number; compare with ==.

The rule of a proof node: one per method of K1.8, and EXPORT, LIFT, SEALED.

Defined in src/judgment_core/inspect.mojo.

RuleTag.HYPOTHESIS

comptime HYPOTHESIS = RuleTag(0)

hypothesis(Γ, h): operands Context, Hyp.

RuleTag.USE

comptime USE = RuleTag(1)

use(Γ, d, τ̄, t̄): Context, Decl, Count, Type…, Count, Term….

RuleTag.TRUTH

comptime TRUTH = RuleTag(2)

truth(Γ): Context.

RuleTag.IMP_INTRO

comptime IMP_INTRO = RuleTag(3)

imp_intro(h, p): Hyp, Judgment.

RuleTag.IMP_ELIM

comptime IMP_ELIM = RuleTag(4)

imp_elim(p, q): Judgment, Judgment.

RuleTag.AND_INTRO

comptime AND_INTRO = RuleTag(5)

and_intro(p, q): Judgment, Judgment.

RuleTag.AND_LEFT

comptime AND_LEFT = RuleTag(6)

and_left(p): Judgment.

RuleTag.AND_RIGHT

comptime AND_RIGHT = RuleTag(7)

and_right(p): Judgment.

RuleTag.OR_LEFT

comptime OR_LEFT = RuleTag(8)

or_left(p, B): Judgment, Term.

RuleTag.OR_RIGHT

comptime OR_RIGHT = RuleTag(9)

or_right(A, p): Term, Judgment.

RuleTag.OR_ELIM

comptime OR_ELIM = RuleTag(10)

or_elim(d, l, r): Judgment, Judgment, Judgment.

RuleTag.FALSE_ELIM

comptime FALSE_ELIM = RuleTag(11)

false_elim(p, Q): Judgment, Term.

RuleTag.FORALL_INTRO

comptime FORALL_INTRO = RuleTag(12)

forall_intro(x, p): Local, Judgment.

RuleTag.FORALL_ELIM

comptime FORALL_ELIM = RuleTag(13)

forall_elim(p, t): Judgment, Term.

RuleTag.EQ_REFL

comptime EQ_REFL = RuleTag(14)

eq_refl(Γ, t): Context, Term.

RuleTag.EQ_SYM

comptime EQ_SYM = RuleTag(15)

eq_sym(p): Judgment.

RuleTag.EQ_TRANS

comptime EQ_TRANS = RuleTag(16)

eq_trans(p, q): Judgment, Judgment.

RuleTag.EQ_APPLY

comptime EQ_APPLY = RuleTag(17)

eq_apply(p, q̄): Judgment, Count, Judgment….

RuleTag.EQ_ABSTRACT

comptime EQ_ABSTRACT = RuleTag(18)

eq_abstract(x, p): Local, Judgment.

RuleTag.EQ_SUBST

comptime EQ_SUBST = RuleTag(19)

eq_subst(P, p, q): Term, Judgment, Judgment.

RuleTag.CONVERT

comptime CONVERT = RuleTag(20)

convert(p, Q, U): Judgment, Term, Count, Decl….

RuleTag.TRANSPORT

comptime TRANSPORT = RuleTag(21)

transport(p, m): Judgment, Context, Count, (Local, Term)…, Count, (Hyp, Judgment)….

RuleTag.CERTIFICATE

comptime CERTIFICATE = RuleTag(22)

A certificate step; no checker is implemented.

RuleTag.EXPORT

comptime EXPORT = RuleTag(23)

export(p, outer): Judgment, Context.

RuleTag.LIFT

comptime LIFT = RuleTag(24)

A premise lifted to a larger canonical signature: Judgment.

RuleTag.SEALED

comptime SEALED = RuleTag(25)

The leaf of a judgment whose proof is not kept: no operands.

RuleTag.OF_CLASS

comptime OF_CLASS = RuleTag(26)

of_class(Γ, τ, c): Context, Type, Decl (Definition Y-14, K2.8).

RuleTag.UNCONSTRAIN

comptime UNCONSTRAIN = RuleTag(27)

unconstrain(p, α): Judgment, Type (Definition Y-14, K2.8).

RuleTag.COUNT

comptime COUNT = 28

How many tags there are.

RuleTag.write_to

def write_to(self, mut writer: Some[Writer])

Write the tag's name.

Arguments.

  • writer: The writer to write to.

rule_layout

def rule_layout(tag: RuleTag) -> StaticString

Give the operand layout of a rule's proof node: the grammar its operands follow.

The operands of an authoring PROOF row, of kind 0x40 + the tag's code, follow the layout of its tag exactly (TD1.8). Each letter is one operand: C a context, H a hypothesis, J a judgment (or a reference to an earlier node, PROOF), R a term, T a type, D a declaration, L a local. * is one count operand n, after which the letters up to the next ; occur n times, in order; groups do not nest. CERTIFICATE and SEALED have the empty layout: no checker exists, and a sealed leaf has no operands. An existing tag's layout never changes; a new tag gets a new layout.

Arguments.

  • tag: The rule.

Returns. The layout; empty for CERTIFICATE, SEALED, and a code that is not a tag.

Defined in src/judgment_core/layout.mojo.

Errors

Typed kernel error values and error kinds (K1.1).

ConstructionFailure lets construction clients choose how to report bank, checker, and constructor refusals. KernelError preserves their typed causes for kernel clients; Store uses its own StoreError implementation.

ConstructionFailure

trait ConstructionFailure(Copyable, Writable)

A construction consumer's error boundary, independent of the algorithm.

Defined in src/judgment_core/errors.mojo.

ConstructionFailure.__init__

@implicit
def __init__(out self, error: BankError)

Convert a bank refusal at the construction boundary.

Arguments.

  • error: The bank's typed cause.

ConstructionFailure.__init__

@implicit
def __init__(out self, error: CheckFail)

Convert a checker refusal at the construction boundary.

Arguments.

  • error: The checker's typed cause and coordinates.

ConstructionFailure.from_kind

@staticmethod
def from_kind(kind: ErrorKind, message: String) -> Self

Represent a refusal produced directly by the constructor.

Arguments.

  • kind: The failure category.
  • message: Its diagnostic.

Returns. The consumer's representation of the failure.

KernelError

struct KernelError(ConstructionFailure)
Field Type Description
kind ErrorKind What went wrong.
message String A description for people; callers match on kind.

The error every failing kernel method raises.

Defined in src/judgment_core/errors.mojo.

KernelError.__init__

def __init__(out self, kind: ErrorKind, message: String)

Make an error.

Arguments.

  • kind: What went wrong.
  • message: A description for people.

KernelError.from_kind

@staticmethod
def from_kind(kind: ErrorKind, message: String) -> Self

Construct the typed error selected by a construction consumer.

Arguments.

  • kind: The typed cause.
  • message: Its diagnostic, without classification by text.

Returns. The kernel error.

KernelError.__init__

@implicit
def __init__(out self, error: BankError)

Convert termbank capacity, work and storage errors; invalid syntax is a kernel bug.

Capacity, work and storage refusals retain their kinds. The other errors become INTERNAL because the kernel should never supply invalid syntax to its bank. Those messages retain the original termbank kind.

Arguments.

  • error: The termbank error.

KernelError.__init__

@implicit
def __init__(out self, error: CheckFail)

Preserve a stateless construction failure's kind and checker coordinates.

Arguments.

  • error: The checker's typed failure, before it is formatted as text.

KernelError.write_to

def write_to(self, mut writer: Some[Writer])

Write the kind and the message.

Arguments.

  • writer: The writer to write to.

ErrorKind

Mojo

@fieldwise_init
struct ErrorKind(Equatable, ImplicitlyCopyable, Writable)
Field Type Description
code UInt8 The kind's number; compare kinds with ==, never by this number.

Python

from judgment import ErrorKind

Python constructor:

def __init__(self, code, name)
Field Description
code The kind's number; compare kinds with ==, never by this number.

What went wrong in a kernel call.

Defined in src/judgment_core/errors.mojo.

ErrorKind.ILL_TYPED

Mojo

comptime ILL_TYPED = ErrorKind(1)

Python

ErrorKind.ILL_TYPED

A term or type does not have the type its use requires.

ErrorKind.NOT_A_PROP

Mojo

comptime NOT_A_PROP = ErrorKind(2)

Python

ErrorKind.NOT_A_PROP

A term used as a proposition does not have type Prop.

ErrorKind.BAD_HANDLE

Mojo

comptime BAD_HANDLE = ErrorKind(3)

Python

ErrorKind.BAD_HANDLE

A handle names no live entry of this kernel: out of range, never certified, or stale.

ErrorKind.WRONG_KERNEL

Mojo

comptime WRONG_KERNEL = ErrorKind(4)

Python

ErrorKind.WRONG_KERNEL

A handle was made by another kernel.

ErrorKind.SCOPE

Mojo

comptime SCOPE = ErrorKind(5)

Python

ErrorKind.SCOPE

An operand is not usable where it is used (K1.6), or a declaration is not visible.

ErrorKind.SIDE_CONDITION

Mojo

comptime SIDE_CONDITION = ErrorKind(6)

Python

ErrorKind.SIDE_CONDITION

A rule's side condition fails.

ErrorKind.MISMATCH

Mojo

comptime MISMATCH = ErrorKind(7)

Python

ErrorKind.MISMATCH

Premises or terms that must agree do not.

ErrorKind.DECLARATION

Mojo

comptime DECLARATION = ErrorKind(8)

Python

ErrorKind.DECLARATION

A declaration violates a condition of its form.

ErrorKind.NAME_CLASH

Mojo

comptime NAME_CLASH = ErrorKind(9)

Python

ErrorKind.NAME_CLASH

A name is already declared in the theory.

ErrorKind.ENCODING

Mojo

comptime ENCODING = ErrorKind(10)

Python

ErrorKind.ENCODING

A literal's encoding or value is invalid.

ErrorKind.LIMIT

Mojo

comptime LIMIT = ErrorKind(11)

Python

ErrorKind.LIMIT

A budget ran out (G3).

ErrorKind.CAPACITY

Mojo

comptime CAPACITY = ErrorKind(12)

Python

ErrorKind.CAPACITY

A table, an id, or a literal would exceed its limit (G4).

ErrorKind.UNSUPPORTED

Mojo

comptime UNSUPPORTED = ErrorKind(13)

Python

ErrorKind.UNSUPPORTED

The request is valid but unsupported by the kernel or a dependency.

ErrorKind.INTERNAL

Mojo

comptime INTERNAL = ErrorKind(14)

Python

ErrorKind.INTERNAL

A broken invariant of the kernel: a bug, never a property of the input.

ErrorKind.STORAGE

Mojo

comptime STORAGE = ErrorKind(15)

Python

ErrorKind.STORAGE

Paged storage access, integrity or capacity failed before publication.

ErrorKind.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 to write to.
judgment v1.0.0 for Mojo 1.2 · Apache License 2.0 with LLVM Exceptions · Source on GitHub