Skip to content

Terms

The core separates values from computations (Moggi, 1991). A value can be passed as it is, while a computation may request effects and must be sequenced to give its result. The term classes make these distinctions explicit, including the continuation that receives the answer to an operation.

LogMass(sampleable, origin, batch=()) is the structural total-mass query, with scalar LogWeight result by default. A nonempty batch retains the construction's declared batch axes and returns one log weight per batch entry. LogDensity evaluates the same raw sampleable value at an outcome. Both terms preserve their source origins through substitution and serialization; neither introduces a scoring effect.

terms

Stable value and computation terms for QIEC.

Terms contain no Python callables. Runtime values and handler bodies cross the boundary only through stable attachment and handler identifiers.

SCALE_FLOOR module-attribute

SCALE_FLOOR = 1e-07

The floor an exponentiated scale head of an :class:AffineMap or :class:TableMap is clamped at, which every backend applies alike.

LiteralData

LiteralData = None | bool | int | float | str | bytes | tuple[LiteralData, ...]

The host data a literal carries: a scalar, bytes, or a tuple of literal data.

ReductionOperator

ReductionOperator = Literal['sum', 'mean', 'max', 'min', 'logsumexp', 'prod', 'projective_tree_partition']

The reductions of a whole tensor to one number.

RowwiseOperator

RowwiseOperator = Literal['softmax', 'log_softmax', 'cumsum', 'sort', 'normalize']

The operations along a tensor's last axis that keep its shape.

Computation

A computation term: every term that may perform effects or control flow.

Local didactic-model

Local(*, name: str, type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

A typed binder for a runtime value.

Locals are compared by identity of name and type together, so two binders of the same name at different types are distinct.

PARAMETER DESCRIPTION
name

The binder's display name.

TYPE: str

type

The type of every value bound to it.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

Var didactic-model

Var(*, local: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['var'] = 'var')

Bases: QiecModel

Reference to a bound local.

PARAMETER DESCRIPTION
local

The binder being referenced.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "var".

TYPE: Literal['var'] DEFAULT: 'var'

LiteralValue didactic-model

LiteralValue(*, value: LiteralData = field(opaque=True, extras=OPAQUE_BY_VALUE), type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['literal'] = 'literal')

Bases: QiecModel

A literal host value at a primitive or tuple type.

PARAMETER DESCRIPTION
value

The literal's data: None, a bool, int, float, str, bytes, or a tuple of literal data.

TYPE: LiteralData DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

type

The literal's type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "literal".

TYPE: Literal['literal'] DEFAULT: 'literal'

ConstructorValue didactic-model

ConstructorValue(*, constructor: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), static_arguments: tuple[StaticArgument, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), fields: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['constructor'] = 'constructor')

Bases: QiecModel

Application of a declared constructor to static and value arguments.

PARAMETER DESCRIPTION
constructor

The stable identity of the constructor applied.

TYPE: ConstructorId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

static_arguments

The constructor's telescope instantiation, in binder order.

TYPE: tuple[StaticArgument, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

fields

The field values, in declaration order.

TYPE: tuple[Value, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The indexed family type the application inhabits.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "constructor".

TYPE: Literal['constructor'] DEFAULT: 'constructor'

EvidenceValue didactic-model

EvidenceValue(*, evidence: EqualityEvidence = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['evidence'] = 'evidence')

Bases: QiecModel

Kernel-checked equality evidence used as a value.

PARAMETER DESCRIPTION
evidence

The evidence term.

TYPE: EqualityEvidence DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "evidence".

TYPE: Literal['evidence'] DEFAULT: 'evidence'

AttachmentRef didactic-model

AttachmentRef(*, attachment: AttachmentId = field(opaque=True, extras=OPAQUE_BY_VALUE), type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['attachment'] = 'attachment')

Bases: QiecModel

A stable reference to a runtime-owned host value.

PARAMETER DESCRIPTION
attachment

The identity under which a runtime provider binds the host value.

TYPE: AttachmentId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

type

The type the bound value must inhabit.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "attachment".

TYPE: Literal['attachment'] DEFAULT: 'attachment'

TransportValue didactic-model

TransportValue(*, evidence: EqualityEvidence = field(opaque=True, extras=OPAQUE_BY_VALUE), value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), target_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['transport'] = 'transport')

Bases: QiecModel

Transport a value along kernel-checked equality evidence.

PARAMETER DESCRIPTION
evidence

The equality the value is carried across.

TYPE: EqualityEvidence DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

value

The value at the equality's left type.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

target_type

The type the transported value inhabits, which the equality's right side determines.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "transport".

TYPE: Literal['transport'] DEFAULT: 'transport'

PrimitiveApplication didactic-model

PrimitiveApplication(*, primitive: PrimitiveId = field(opaque=True, extras=OPAQUE_BY_VALUE), name: str, arguments: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['primitive'] = 'primitive')

Bases: QiecModel

Application of a pure primitive from the closed registry.

The primitive is named nominally and its signature is fixed, so the checker validates the arguments against the registry and a backend renders the name it knows or refuses the capability; nothing is resolved by inspecting a runtime value.

PARAMETER DESCRIPTION
primitive

The stable identity of the primitive applied.

TYPE: PrimitiveId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

name

The primitive's nominal name, as the registry spells it.

TYPE: str

arguments

The value arguments, one per parameter.

TYPE: tuple[Value, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The primitive's result type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The application's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "primitive".

TYPE: Literal['primitive'] DEFAULT: 'primitive'

TupleValue didactic-model

TupleValue(*, items: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['tuple'] = 'tuple')

Bases: QiecModel

Construction of a finite product from its components.

PARAMETER DESCRIPTION
items

The component values, in order.

TYPE: tuple[Value, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The product type of the components.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "tuple".

TYPE: Literal['tuple'] DEFAULT: 'tuple'

TensorValue didactic-model

TensorValue(*, items: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['tensor'] = 'tensor')

Bases: QiecModel

Construction of a tensor from its entries along the outermost axis.

A rank-one tensor lists its elements; a tensor of higher rank lists the tensors one rank lower that are its slices, all of one shape, so a matrix literal is a tensor of row tensors.

PARAMETER DESCRIPTION
items

The entries along the outermost axis, in order.

TYPE: tuple[Value, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The Tensor type constructed, whose leading dimension is the number of entries.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "tensor".

TYPE: Literal['tensor'] DEFAULT: 'tensor'

Projection didactic-model

Projection(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), position: int, result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['projection'] = 'projection')

Bases: QiecModel

Select a component of a product or an admitted nominal record local.

The latter is a direct variable of an exact, closed, unindexed singleton layout over ordinary scalars and products. Its index is a declared field ordinal and is checked against the actual nominal constructor.

PARAMETER DESCRIPTION
value

The product value projected from.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

position

The zero-based component selected.

TYPE: int

result_type

The selected component's type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "projection".

TYPE: Literal['projection'] DEFAULT: 'projection'

PlateAxis didactic-model

PlateAxis(*, name: str, size: IndexTerm = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['plate_axis'] = 'plate_axis')

Bases: QiecModel

One axis of a plated distribution.

PARAMETER DESCRIPTION
name

The axis's source name, the object it ranges over.

TYPE: str

size

The axis's extent, an index term of the nat sort.

TYPE: IndexTerm DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "plate_axis".

TYPE: Literal['plate_axis'] DEFAULT: 'plate_axis'

PlateShape didactic-model

PlateShape(*, batch: tuple[PlateAxis, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), event: tuple[PlateAxis, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['plate_shape'] = 'plate_shape')

Bases: QiecModel

The plate a distribution is constructed over.

Batch axes replicate the distribution independently, one draw per position, each scored on its own; event axes join the draws along them into one event, scored together. The trailing event axes are the family's own event dimensions when it has any; any leading ones extend a scalar family's event.

PARAMETER DESCRIPTION
batch

The independent replication axes, outermost first.

TYPE: tuple[PlateAxis, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

event

The joint axes, outermost first.

TYPE: tuple[PlateAxis, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "plate_shape".

TYPE: Literal['plate_shape'] DEFAULT: 'plate_shape'

empty property

empty: bool

Whether the plate has no axes at all.

RETURNS DESCRIPTION
bool

True when neither batch nor event axes are declared.

DistributionValue didactic-model

DistributionValue(*, family: DistributionId = field(opaque=True, extras=OPAQUE_BY_VALUE), name: str, arguments: tuple[tuple[str, Value], ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), plate: PlateShape = field(default=PlateShape(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['distribution'] = 'distribution')

Bases: QiecModel

Construction of a distribution from a family of the semantic registry.

The family is named nominally and its parameters are supplied by name, so the term records which parameterization the source used and a backend renders the spelling it knows without inspecting values. A plate replicates the family over batch axes and joins draws along event axes; a parameter may then be a tensor whose leading dimensions follow a suffix of the plate's axes and broadcast over the rest.

PARAMETER DESCRIPTION
family

The stable identity of the family applied.

TYPE: DistributionId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

name

The family's source name, as the registry spells it.

TYPE: str

arguments

The parameters supplied, each named, in source order.

TYPE: tuple[tuple[str, Value], ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The Sampleable type of the constructed distribution.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The construction's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

plate

The plate the distribution is constructed over; empty for one draw of the family.

TYPE: PlateShape DEFAULT: field(default=PlateShape(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "distribution".

TYPE: Literal['distribution'] DEFAULT: 'distribution'

Gather didactic-model

Gather(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), index: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['gather'] = 'gather')

Bases: QiecModel

Selection along the outermost axis of a tensor.

PARAMETER DESCRIPTION
value

The tensor selected from.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

index

An Int selecting one slice, or an Int tensor selecting a slice per entry.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The selection's type: the slice type for an integer index, or a tensor of slices shaped like the index tensor.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "gather".

TYPE: Literal['gather'] DEFAULT: 'gather'

WeightSum didactic-model

WeightSum(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['weight_sum'] = 'weight_sum')

Bases: QiecModel

The total of a tensor of log weights.

PARAMETER DESCRIPTION
value

A LogWeight tensor of any shape, or a LogWeight.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "weight_sum".

TYPE: Literal['weight_sum'] DEFAULT: 'weight_sum'

SegmentSum didactic-model

SegmentSum(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), index: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), groups: IndexTerm = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['segment_sum'] = 'segment_sum')

Bases: QiecModel

Per-group totals of a vector of log weights.

PARAMETER DESCRIPTION
value

A LogWeight[Fin n].

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

index

A Int[Fin n] naming each entry's group.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

groups

The number of groups, an index term of the nat sort.

TYPE: IndexTerm DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

LogWeight[Fin groups].

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "segment_sum".

TYPE: Literal['segment_sum'] DEFAULT: 'segment_sum'

KernelMatrix didactic-model

KernelMatrix(*, inputs: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), kernel: str, length_scale: float, jitter: float, result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['kernel_matrix'] = 'kernel_matrix')

Bases: QiecModel

A positive-definite covariance over input locations.

PARAMETER DESCRIPTION
inputs

A Real[Fin n] of locations.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

kernel

The kernel's name; "rbf" is the squared-exponential kernel.

TYPE: str

length_scale

The kernel's length scale.

TYPE: float

jitter

The diagonal added for numerical positive definiteness.

TYPE: float

result_type

Real[Fin n, Fin n].

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "kernel_matrix".

TYPE: Literal['kernel_matrix'] DEFAULT: 'kernel_matrix'

Reduction didactic-model

Reduction(*, operator: ReductionOperator = field(opaque=True, extras=OPAQUE_BY_VALUE), value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['reduction'] = 'reduction')

Bases: QiecModel

A number summarizing every entry of a tensor.

PARAMETER DESCRIPTION
operator

The reduction.

TYPE: ReductionOperator DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

value

A tensor of reals, or of integers for sum, max, min, and prod. projective_tree_partition takes a nonempty square score matrix in head-by-dependent order with a final artificial root.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The element type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "reduction".

TYPE: Literal['reduction'] DEFAULT: 'reduction'

DppLogProb didactic-model

DppLogProb(*, features: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), membership: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['dpp_log_prob'] = 'dpp_log_prob')

Bases: QiecModel

A finite Gram determinantal point process's subset log probability.

PARAMETER DESCRIPTION
features

A rank-two real tensor with one row per ground item.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

membership

A rank-one Boolean tensor with the same ground-item extent.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The application's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "dpp_log_prob".

TYPE: Literal['dpp_log_prob'] DEFAULT: 'dpp_log_prob'

DirectedTreeLogPartition didactic-model

DirectedTreeLogPartition(*, scores: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), root: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), mask: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['directed_tree_log_partition'] = 'directed_tree_log_partition')

Bases: QiecModel

The log total mass of directed spanning trees rooted at one node.

PARAMETER DESCRIPTION
scores

The square real edge-score tensor in parent-by-child order.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

root

The integer node index.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

mask

The equally shaped Boolean tensor of permitted edges.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The application's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator.

TYPE: Literal['directed_tree_log_partition'] DEFAULT: 'directed_tree_log_partition'

Rowwise didactic-model

Rowwise(*, operator: RowwiseOperator = field(opaque=True, extras=OPAQUE_BY_VALUE), value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['rowwise'] = 'rowwise')

Bases: QiecModel

An operation along a tensor's last axis keeping its shape.

PARAMETER DESCRIPTION
operator

The operation.

TYPE: RowwiseOperator DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

value

A tensor of reals.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The tensor's own type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "rowwise".

TYPE: Literal['rowwise'] DEFAULT: 'rowwise'

CholeskyFactor didactic-model

CholeskyFactor(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['cholesky_factor'] = 'cholesky_factor')

Bases: QiecModel

The lower Cholesky factor of a symmetric positive-definite matrix.

The factor L of A is the lower-triangular matrix with a positive diagonal and L L^T = A. Leading axes, if any, index independent matrices.

PARAMETER DESCRIPTION
value

A tensor of reals whose last two axes have one extent.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The tensor's own type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "cholesky_factor".

TYPE: Literal['cholesky_factor'] DEFAULT: 'cholesky_factor'

Comprehension didactic-model

Comprehension(*, binder: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), extent: IndexTerm = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['comprehension'] = 'comprehension')

Bases: QiecModel

A tensor built by evaluating a body at every index of an axis.

PARAMETER DESCRIPTION
binder

The Int local the body reads the index through.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

extent

The axis's extent, an index term of the nat sort.

TYPE: IndexTerm DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The entry at each index.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

T[Fin extent] for the body's type T, or, when the body is itself a tensor, the tensor with extent prepended.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "comprehension".

TYPE: Literal['comprehension'] DEFAULT: 'comprehension'

ConditionalValue didactic-model

ConditionalValue(*, condition: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), then: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), otherwise: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['conditional_value'] = 'conditional_value')

Bases: QiecModel

Evaluate exactly one pure branch selected by a scalar Boolean.

PARAMETER DESCRIPTION
condition

Scalar Boolean deciding which branch is evaluated.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

then

Equally typed branches; the inactive branch is not evaluated.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

otherwise

Equally typed branches; the inactive branch is not evaluated.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The common branch type, including its tensor or sampleable indices.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

Serialization discriminator, always conditional_value.

TYPE: Literal['conditional_value'] DEFAULT: 'conditional_value'

LetBinding didactic-model

LetBinding(*, binder: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One binding of a :class:LetValue.

PARAMETER DESCRIPTION
binder

The local the bound value is read through.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

value

The value bound, evaluated once.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

LetValue didactic-model

LetValue(*, bindings: tuple[LetBinding, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['let'] = 'let')

Bases: QiecModel

A pure value shared by name through sequential bindings.

Each binding's value is evaluated once, in order, and is in scope in every later binding and in the body, so a term that reads one intermediate value several times holds it once. The bindings bind sequentially, as let* does: binding k may read binders 0 through k - 1.

PARAMETER DESCRIPTION
bindings

The bindings, in evaluation order; at least one.

TYPE: tuple[LetBinding, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The value the term denotes, read with every binder in scope.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The body's type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "let".

TYPE: Literal['let'] DEFAULT: 'let'

AffineMap didactic-model

AffineMap(*, weight: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), bias: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), sources: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), row_offset: int, rows: int, transform: Literal['identity', 'exp', 'exp_floor'], result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['affine_map'] = 'affine_map')

Bases: QiecModel

One head of an affine parameter map, W x + b on a row block.

For i below rows the head's coordinate i is the sum over j of weight[row_offset + i, j] * x[j] plus bias[row_offset + i], where x concatenates the sources in order; exp exponentiates every coordinate afterwards, and exp_floor exponentiates and clamps each at the scale floor.

PARAMETER DESCRIPTION
weight

A Real[Fin total_rows, Fin columns].

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

bias

A Real[Fin total_rows].

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

sources

The conditioning row's factors in order, each a Real or a Real[Fin width].

TYPE: tuple[Value, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

row_offset

The first row of the head's block.

TYPE: int

rows

The block's height.

TYPE: int

transform

"identity", "exp", or "exp_floor".

TYPE: Literal['identity', 'exp', 'exp_floor']

result_type

Real[Fin rows], or Real for a one-row head.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "affine_map".

TYPE: Literal['affine_map'] DEFAULT: 'affine_map'

TableMap didactic-model

TableMap(*, table: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), index: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), row_offset: int, rows: int, transform: Literal['identity', 'exp', 'exp_floor'], result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['table_map'] = 'table_map')

Bases: QiecModel

One head of a table-indexed parameter map, a row block of T[i].

A kernel over a finite domain reads its parameters from a table with one row per element of the domain: for i below rows the head's coordinate i is table[index, row_offset + i], with exp exponentiating every coordinate afterwards and exp_floor exponentiating and clamping each at the scale floor.

PARAMETER DESCRIPTION
table

A Real[Fin entries, Fin total_rows].

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

index

An Int naming the row, the element of the domain.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

row_offset

The first column of the head's block.

TYPE: int

rows

The block's width.

TYPE: int

transform

"identity", "exp", or "exp_floor".

TYPE: Literal['identity', 'exp', 'exp_floor']

result_type

Real[Fin rows], or Real for a one-column head.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "table_map".

TYPE: Literal['table_map'] DEFAULT: 'table_map'

SiteValue didactic-model

SiteValue(*, label: str, result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['site'] = 'site')

Bases: QiecModel

A named sample site.

A site is the address a probabilistic step is observed and traced under. Its label is the source name of the step, which is stable data; the dynamic address a run adds comes from the request that carries it.

PARAMETER DESCRIPTION
label

The site's source name.

TYPE: str

result_type

The Site type of the value the site produces.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "site".

TYPE: Literal['site'] DEFAULT: 'site'

ParameterName didactic-model

ParameterName(*, owner: str, member: str, tag: Literal['parameter_name'] = 'parameter_name')

Bases: QiecModel

The name of a learned parameter that a declaration owns.

A declaration with learned parameters (a deduction's weighted lexicon and rules) reads each one through Param.get by a String name. The name is the owner's name followed by the parameter's member path below it. Both are names the core resolves by spelling, so content identity treats them as names, not as data: renaming the owner or the production a member path names leaves every declaration that reads the parameter with the same hash, while a run reads the spelled name.

PARAMETER DESCRIPTION
owner

The owning declaration's name.

TYPE: str

member

The parameter's path below the owner, such as lex.0.

TYPE: str

tag

The serialization discriminator; always "parameter_name".

TYPE: Literal['parameter_name'] DEFAULT: 'parameter_name'

spelled

spelled() -> str

The name a run reads the parameter under.

RETURNS DESCRIPTION
str

owner.member.

Source code in src/quivers/qiec/terms.py
def spelled(self) -> str:
    """The name a run reads the parameter under.

    Returns
    -------
    str
        ``owner.member``.
    """
    return f"{self.owner}.{self.member}"

LogMass didactic-model

LogMass(*, sampleable: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), batch: tuple[PlateAxis, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['log_mass'] = 'log_mass')

Bases: QiecModel

Total mass of a sampleable, preserving declared batch axes.

PARAMETER DESCRIPTION
sampleable

The measure, of type Sampleable[A].

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

Source location of the query.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

batch

Independent batch axes retained in the result; empty for one total LogWeight. Event axes are always reduced.

TYPE: tuple[PlateAxis, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

Serialization discriminator, always "log_mass".

TYPE: Literal['log_mass'] DEFAULT: 'log_mass'

LogDensity didactic-model

LogDensity(*, sampleable: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), batch: tuple[PlateAxis, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['log_density'] = 'log_density')

Bases: QiecModel

Evaluation of a distribution's log density at a value.

PARAMETER DESCRIPTION
sampleable

The distribution, of type Sampleable[A].

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

value

The point evaluated, of type A.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The evaluation's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

batch

The batch axes the density is kept apart over: empty for one LogWeight totalling every draw, else the batch axes of the plated construction sampleable must be, for one weight per position.

TYPE: tuple[PlateAxis, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "log_density".

TYPE: Literal['log_density'] DEFAULT: 'log_density'

RecordFieldValue didactic-model

RecordFieldValue(*, label: str, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One labelled field of a record value.

PARAMETER DESCRIPTION
label

The field's label.

TYPE: str

value

The field's value.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

RecordValue didactic-model

RecordValue(*, fields: tuple[RecordFieldValue, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['record_value'] = 'record_value')

Bases: QiecModel

A record built from one value per label.

PARAMETER DESCRIPTION
fields

The fields, in any order; normalized to canonical label order, which is also their evaluation order.

TYPE: tuple[RecordFieldValue, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The closed record type of the fields.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "record_value".

TYPE: Literal['record_value'] DEFAULT: 'record_value'

FieldProjection didactic-model

FieldProjection(*, record: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), label: str, result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['field_projection'] = 'field_projection')

Bases: QiecModel

The value of one field of a record.

PARAMETER DESCRIPTION
record

The record.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

label

The field read.

TYPE: str

result_type

The field's type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "field_projection".

TYPE: Literal['field_projection'] DEFAULT: 'field_projection'

RecordRestriction didactic-model

RecordRestriction(*, record: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['record_restriction'] = 'record_restriction')

Bases: QiecModel

A record cut down to the fields of a contained row.

PARAMETER DESCRIPTION
record

The record.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The record type of the fields kept; its row must be contained in the record's row.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "record_restriction".

TYPE: Literal['record_restriction'] DEFAULT: 'record_restriction'

RecordConcat didactic-model

RecordConcat(*, left: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), right: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['record_concat'] = 'record_concat')

Bases: QiecModel

The record of all fields of two records with disjoint rows.

PARAMETER DESCRIPTION
left

The two records; their rows must combine into the result's row.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

right

The two records; their rows must combine into the result's row.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The record type of the combined row.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "record_concat".

TYPE: Literal['record_concat'] DEFAULT: 'record_concat'

VariantInjection didactic-model

VariantInjection(*, label: str, payload: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['variant_injection'] = 'variant_injection')

Bases: QiecModel

A variant value: one label with its payload.

PARAMETER DESCRIPTION
label

The alternative chosen.

TYPE: str

payload

The value the alternative carries; unit for an alternative without one.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The variant type, whose row must contain the label at the payload's type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "variant_injection".

TYPE: Literal['variant_injection'] DEFAULT: 'variant_injection'

VariantEmbed didactic-model

VariantEmbed(*, variant: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['variant_embed'] = 'variant_embed')

Bases: QiecModel

A variant seen at a variant type of a containing row.

PARAMETER DESCRIPTION
variant

The variant.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The wider variant type; the variant's row must be contained in its row.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "variant_embed".

TYPE: Literal['variant_embed'] DEFAULT: 'variant_embed'

Lambda didactic-model

Lambda(*, code: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), name: str, parameter: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['lambda'] = 'lambda')

Bases: QiecModel

A function value: a closure over the locals in scope.

Building a closure performs nothing. Applying it runs body with the captured locals and the argument bound, as a call of the closure's code: the application has a call address under name, like a call of a named computation, so specialization and defunctionalization can replace it by a call of a generated computation with the same address.

PARAMETER DESCRIPTION
code

The stable identity of the closure's code, from its source site.

TYPE: ComputationId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

name

The code's display name: a local definition's name, or a name derived from the source position of an anonymous function.

TYPE: str

parameter

The local the argument is bound to.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation an application runs.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The function type: the parameter's type, the body's result type, and the row the body may perform.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

Where the function was written.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "lambda".

TYPE: Literal['lambda'] DEFAULT: 'lambda'

HoleValue didactic-model

HoleValue(*, name: str, type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['hole'] = 'hole')

Bases: QiecModel

A typed hole: a value the author has not written yet.

A hole is well typed at its type and at no other, so a body that mentions it checks exactly as it would with any value of that type in its place. Nothing reduces it: the reference machine holds it as a hole closure, the hole paired with the values of the locals in scope, and a step that must inspect the value stops there with an indeterminate result. No compiled or exported form exists, so every export path refuses a module that contains one.

PARAMETER DESCRIPTION
name

The hole's name as written, without the ?. Holes are filled by name; two occurrences of one name are two holes filled together.

TYPE: str

type

The hole's goal: the type every filling must have.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

Where the hole was written.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "hole".

TYPE: Literal['hole'] DEFAULT: 'hole'

Return didactic-model

Return(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['return'] = 'return')

Bases: QiecModel

Return a value with no effects.

PARAMETER DESCRIPTION
value

The value produced.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "return".

TYPE: Literal['return'] DEFAULT: 'return'

Bind didactic-model

Bind(*, binder: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), first: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), then: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['bind'] = 'bind')

Bases: QiecModel

Sequence two computations, binding the first's result in the second.

PARAMETER DESCRIPTION
binder

The local the first computation's result is bound to.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

first

The computation run first.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

then

The computation run second, with binder in scope.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "bind".

TYPE: Literal['bind'] DEFAULT: 'bind'

Perform didactic-model

Perform(*, request: EffectRequest = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['perform'] = 'perform')

Bases: QiecModel

Perform one effect operation.

PARAMETER DESCRIPTION
request

The operation, its instance, static arguments, value arguments, and result type.

TYPE: EffectRequest DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "perform".

TYPE: Literal['perform'] DEFAULT: 'perform'

Handle didactic-model

Handle(*, instance: EffectInstanceId = field(opaque=True, extras=OPAQUE_BY_VALUE), handler: HandlerId = field(opaque=True, extras=OPAQUE_BY_VALUE), computation: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), static_arguments: tuple[StaticArgument, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), arguments: tuple[Value, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['handle'] = 'handle')

Bases: QiecModel

Run a computation under a handler installed for one effect instance.

PARAMETER DESCRIPTION
instance

The effect instance whose operations the handler intercepts.

TYPE: EffectInstanceId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

handler

The stable identity of the handler installed.

TYPE: HandlerId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

computation

The handled computation.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

static_arguments

The handler's telescope instantiation, in binder order.

TYPE: tuple[StaticArgument, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

arguments

The initial values of the handler's parameters, one per parameter, in declaration order; empty for a handler without parameters.

TYPE: tuple[Value, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "handle".

TYPE: Literal['handle'] DEFAULT: 'handle'

CaseMotive didactic-model

CaseMotive(*, indices: Telescope = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

The result family of an indexed case expression.

PARAMETER DESCRIPTION
indices

The binders abstracting the scrutinee's indices in result_type.

TYPE: Telescope DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The type every branch must produce, over indices.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

CaseBranch didactic-model

CaseBranch(*, constructor: ConstructorId = field(opaque=True, extras=OPAQUE_BY_VALUE), static_arguments: tuple[StaticArgument, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), fields: tuple[Local, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), scope: StaticScopeId = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One stable GADT branch with no host-language closure.

PARAMETER DESCRIPTION
constructor

The constructor this branch matches.

TYPE: ConstructorId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

static_arguments

The constructor's static arguments as bound by the pattern, in binder order.

TYPE: tuple[StaticArgument, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

fields

The locals binding the constructor's fields, in declaration order.

TYPE: tuple[Local, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation run when the branch is selected.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

scope

The static scope identity under which the branch's skolems and equality evidence are minted.

TYPE: StaticScopeId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

Case didactic-model

Case(*, scrutinee: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), motive: CaseMotive = field(opaque=True, extras=OPAQUE_BY_VALUE), branches: tuple[CaseBranch, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['case'] = 'case')

Bases: QiecModel

Case analysis over an indexed family value.

PARAMETER DESCRIPTION
scrutinee

The value analyzed.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

motive

The result family, over the scrutinee's indices.

TYPE: CaseMotive DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

branches

One branch per constructor considered; coverage is checked against the exact applied family.

TYPE: tuple[CaseBranch, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "case".

TYPE: Literal['case'] DEFAULT: 'case'

Call didactic-model

Call(*, callee: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), name: str, static_arguments: tuple[StaticArgument, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), arguments: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), effects: EffectRow = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['call'] = 'call')

Bases: QiecModel

Application of a named computation.

The callee is a stable identifier rather than an inlined body, which is what lets a recursive or mutually recursive call graph serialize as a finite tree.

PARAMETER DESCRIPTION
callee

The stable identity of the computation called.

TYPE: ComputationId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

name

The callee's display name, for diagnostics and traces.

TYPE: str

static_arguments

The callee's telescope instantiation, in binder order.

TYPE: tuple[StaticArgument, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

arguments

The value arguments, one per callee parameter.

TYPE: tuple[Value, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The callee's result type under the instantiation.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

effects

The callee's effect row under the instantiation.

TYPE: EffectRow DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The call site's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "call".

TYPE: Literal['call'] DEFAULT: 'call'

ApplyPure didactic-model

ApplyPure(*, callee: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), arguments: tuple[Value, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['apply_pure'] = 'apply_pure')

Bases: QiecModel

Apply a closed address-inert definition to explicit strict operands.

The kernel checks the actual callee body. Application introduces only a lexical scope and does not allocate a call address.

PARAMETER DESCRIPTION
callee

The nominal monomorphic definition.

TYPE: ComputationId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

arguments

The operands, in declaration and evaluation order.

TYPE: tuple of Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The exact declared result.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The original application site for diagnostics.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator, always apply_pure.

TYPE: str DEFAULT: 'apply_pure'

Resume didactic-model

Resume(*, value: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), arguments: tuple[Value, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['resume'] = 'resume')

Bases: QiecModel

Invocation of the enclosing handler clause's continuation.

The resumption is not a value and cannot be stored, so it is a term of its own rather than a call to a bound name. That is what makes a clause's grade checkable by counting invocations along the paths through its body.

PARAMETER DESCRIPTION
value

The value returned to the suspended computation as the operation's result.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The resumption's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

arguments

The values the handler's parameters have while the resumed computation runs, one per parameter, in declaration order. A source resume that names none carries the clause's own parameters.

TYPE: tuple[Value, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "resume".

TYPE: Literal['resume'] DEFAULT: 'resume'

CallAddress didactic-model

CallAddress(*, callee: ComputationId = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), previous: Var | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['call_address'] = 'call_address')

Bases: QiecModel

Allocate the address of a call that discharge has inlined.

Allocation takes place at the original call entry. The address can be restored around several parts of the rewritten continuation.

PARAMETER DESCRIPTION
callee

The called computation's identity.

TYPE: ComputationId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The original call site.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

previous

The replaced call's allocation when this was a tail call.

TYPE: Var | None DEFAULT: field(default=None, opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator.

TYPE: Literal['call_address'] DEFAULT: 'call_address'

InstanceAddress didactic-model

InstanceAddress(*, origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['instance_address'] = 'instance_address')

Bases: QiecModel

Allocate the address of a local instance removed during discharge.

PARAMETER DESCRIPTION
origin

The site of the original allocation.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator.

TYPE: Literal['instance_address'] DEFAULT: 'instance_address'

HandlerReturnAddress didactic-model

HandlerReturnAddress(*, handler: HandlerId = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['handler_return_address'] = 'handler_return_address')

Bases: QiecModel

Allocate the return address of a discharged handler installation.

PARAMETER DESCRIPTION
handler

The installed declaration whose return clause can make requests.

TYPE: HandlerId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator.

TYPE: Literal['handler_return_address'] DEFAULT: 'handler_return_address'

HandlerClauseAddress didactic-model

HandlerClauseAddress(*, site: SiteId = field(opaque=True, extras=OPAQUE_BY_VALUE), captured: tuple[SiteId | Var, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

A relative operation-clause address that reads captured scopes.

PARAMETER DESCRIPTION
site

The static site of the request that entered the clause.

TYPE: SiteId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

captured

The ordered call sites and bindings for captured instance or return addresses.

TYPE: tuple[SiteId | Var, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

WithTraceAddresses didactic-model

WithTraceAddresses(*, addresses: tuple[Var, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), previous: Var | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), resumptions: tuple[int, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), clauses: tuple[DynamicAddressFrame | HandlerClauseAddress, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['with_trace_addresses'] = 'with_trace_addresses')

Bases: QiecModel

Run a residual computation under previously allocated trace addresses.

PARAMETER DESCRIPTION
addresses

The live calls, local instances and handler returns, in outer-to-inner order.

TYPE: tuple[Var, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation that observes the restored addresses.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

previous

A replaced inlined caller whose lexical path a residual tail call inherits.

TYPE: Var | None DEFAULT: field(default=None, opaque=True, extras=OPAQUE_BY_VALUE)

resumptions

The discharged shots enclosing a residual call, in order.

TYPE: tuple[int, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

clauses

The discharged clause activations enclosing a residual call.

TYPE: tuple[DynamicAddressFrame | HandlerClauseAddress, ...] DEFAULT: field(default=(), opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator.

TYPE: Literal['with_trace_addresses'] DEFAULT: 'with_trace_addresses'

NewInstance didactic-model

NewInstance(*, instance: EffectInstanceId = field(opaque=True, extras=OPAQUE_BY_VALUE), effect: EffectRef = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['new_instance'] = 'new_instance')

Bases: QiecModel

Lexically scoped allocation of an effect instance.

The identity is derived from the module, the enclosing computation, the lexical path, and the applied interface, so the same allocation site yields the same instance on every run while two sites of the same interface stay distinct.

PARAMETER DESCRIPTION
instance

The scope-derived stable identity of the allocated instance.

TYPE: EffectInstanceId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

effect

The applied interface the instance provides.

TYPE: EffectRef DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation within which the instance is in scope.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The allocation's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "new_instance".

TYPE: Literal['new_instance'] DEFAULT: 'new_instance'

If didactic-model

If(*, condition: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), then: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), otherwise: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['if'] = 'if')

Bases: QiecModel

Branch on a Boolean value.

Both branches must produce the same type; the row of the whole is the union of the branches' rows. This is what lets a recursive computation stop, since a value-level select would evaluate both branches and never terminate.

PARAMETER DESCRIPTION
condition

The Boolean value branched on.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

then

The computation run when the condition holds.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

otherwise

The computation run when it does not.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "if".

TYPE: Literal['if'] DEFAULT: 'if'

Apply didactic-model

Apply(*, function: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), argument: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), effects: EffectRow = field(opaque=True, extras=OPAQUE_BY_VALUE), origin: SourceOrigin = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['apply'] = 'apply')

Bases: QiecModel

Application of a function value.

PARAMETER DESCRIPTION
function

The function value.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

argument

The argument, at the function's parameter type.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The function's result type.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

effects

The function's effect row, which the application performs.

TYPE: EffectRow DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

origin

The application's source location.

TYPE: SourceOrigin DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "apply".

TYPE: Literal['apply'] DEFAULT: 'apply'

VariantBranch didactic-model

VariantBranch(*, label: str, binder: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One alternative of a variant case.

PARAMETER DESCRIPTION
label

The alternative matched.

TYPE: str

binder

The local its payload is bound to.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation run when the alternative is selected.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

VariantRest didactic-model

VariantRest(*, binder: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

A branch of a variant split, which receives the variant at a part's type.

PARAMETER DESCRIPTION
binder

The local the variant is bound to, at the variant type of the part.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation run when the alternative is in the part.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

VariantCase didactic-model

VariantCase(*, scrutinee: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), branches: tuple[VariantBranch, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['variant_case'] = 'variant_case')

Bases: QiecModel

Case analysis on the alternative of a variant.

PARAMETER DESCRIPTION
scrutinee

The variant analyzed, whose row is closed.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

branches

One branch per alternative of its row.

TYPE: tuple[VariantBranch, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The type every branch returns.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "variant_case".

TYPE: Literal['variant_case'] DEFAULT: 'variant_case'

VariantSplit didactic-model

VariantSplit(*, scrutinee: Value = field(opaque=True, extras=OPAQUE_BY_VALUE), left: VariantRest = field(opaque=True, extras=OPAQUE_BY_VALUE), right: VariantRest = field(opaque=True, extras=OPAQUE_BY_VALUE), result_type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['variant_split'] = 'variant_split')

Bases: QiecModel

Branching on which of two disjoint parts a variant's alternative is in.

PARAMETER DESCRIPTION
scrutinee

The variant, whose row is the combination of the two parts.

TYPE: Value DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

left

The branch for an alternative of the left part, which receives the variant at the left part's variant type.

TYPE: VariantRest DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

right

The same for the right part.

TYPE: VariantRest DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

result_type

The type both branches return.

TYPE: TypeExpr DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "variant_split".

TYPE: Literal['variant_split'] DEFAULT: 'variant_split'

RecursiveBinding didactic-model

RecursiveBinding(*, binder: Local = field(opaque=True, extras=OPAQUE_BY_VALUE), function: Lambda = field(opaque=True, extras=OPAQUE_BY_VALUE))

Bases: QiecModel

One function of a group of local, mutually recursive definitions.

PARAMETER DESCRIPTION
binder

The local the function is bound to, at its function type.

TYPE: Local DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

function

The function, which may refer to every binder of its group.

TYPE: Lambda DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

LetRec didactic-model

LetRec(*, bindings: tuple[RecursiveBinding, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['let_rec'] = 'let_rec')

Bases: QiecModel

Local, mutually recursive function definitions scoped to a body.

PARAMETER DESCRIPTION
bindings

The definitions; each function's body has every binder in scope.

TYPE: tuple[RecursiveBinding, ...] DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation the definitions are visible in.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "let_rec".

TYPE: Literal['let_rec'] DEFAULT: 'let_rec'

Mask didactic-model

Mask(*, instance: EffectInstanceId = field(opaque=True, extras=OPAQUE_BY_VALUE), body: Computation = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['mask'] = 'mask')

Bases: QiecModel

Route one instance's requests past the innermost handler of it.

A request to instance made while body runs skips the innermost handler of that instance installed outside the mask, and is answered by the next one out. This is how a request that reaches generic code through an abstract effect row tunnels past a handler the generic code installed for its own requests: the generic code was never given the instance, so its handler does not see the request. Masks of one instance nest, each skipping one more handler.

PARAMETER DESCRIPTION
instance

The instance whose requests tunnel.

TYPE: EffectInstanceId DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

body

The computation whose requests to instance tunnel. Its row names instance only through an open tail, never explicitly: an explicit entry is a request the enclosing code was given.

TYPE: Computation DEFAULT: field(opaque=True, extras=OPAQUE_BY_VALUE)

tag

The serialization discriminator; always "mask".

TYPE: Literal['mask'] DEFAULT: 'mask'

Cited sources

Eugenio Moggi. Notions of Computation and Monads. Information and Computation, 93(1):55–92, 1991. URL: https://www.sciencedirect.com/science/article/pii/0890540191900524, doi:10.1016/0890-5401(91)90052-4.