Skip to content

AST Nodes

The AST node classes of QVR, each a didactic Model, record the structure of a parsed module: a declaration holds its name, arguments, and expressions, so tools can read and transform these parts. Elaboration, the compiler step that rewrites declarations into explicit core terms, then resolves names and makes implicit operations explicit (correspondences).

ast_nodes

AST node definitions for the quivers DSL ().

The AST is a direct representation of the parsed .qvr source. Each node carries source-location info for error reporting. Recursive sums use dx.TaggedUnion with a kind discriminator: variants subclass their sum's root and pin kind to a Literal[...] value.

This package's submodules group the node families:

  • ._shared for shared helpers (AxisSpec, CompositionLevel, the option-value tagged union)
  • .types for type expressions
  • .let_expressions for let-arith expressions
  • .expressions for value (morphism) expressions
  • .program_steps for monadic program steps
  • .structural for structural-compression helpers
  • .declarations for top-level statements (sixteen variants)
  • .module for the file-level Module container

Every public class is re-exported here so from quivers.dsl.ast_nodes import X keeps working.

MODULE_STATEMENT_TYPES module-attribute

MODULE_STATEMENT_TYPES: tuple[type[Statement], ...] = (ImportDecl, OpenDecl, HoleDecl, LinkDecl)

The statements that belong to the module system rather than the program.

A share stays in the program: elaboration reads it to tie sites and parameters.

MODULE_LANGUAGE_STATEMENT_TYPES module-attribute

MODULE_LANGUAGE_STATEMENT_TYPES: tuple[type[Statement], ...] = (SignatureDecl, ModuleDecl, ImplicitDecl, QiecComputationSpec, DeductionSpec)

Module-language statements, which static interpretation consumes.

LINKING_STATEMENT_TYPES module-attribute

LINKING_STATEMENT_TYPES: tuple[type[Statement], ...] = (HoleDecl, LinkDecl, ShareDecl)

The linking statements, which the module system consumes.

META_STATEMENT_TYPES module-attribute

META_STATEMENT_TYPES = (MetaDecl, StaticAssertDecl, SpliceDecl, DerivingDecl)

The statement classes that belong to the meta phase.

NOTATION_STATEMENT_TYPES module-attribute

NOTATION_STATEMENT_TYPES: tuple[type[Statement], ...] = (NotationDecl, OpenNotationDecl, NameSpellingsDecl)

The statement classes of the notation surface.

QiecValue module-attribute

QiecValue = LetExprNode

A QIEC value, which is the shared pure-expression tree.

Variables, literals, operators, tuples, and builtin applications are the same nodes a program let step uses; constructor application joins that tree, so there is one value language rather than two isomorphic ones.

THEORY_STATEMENT_TYPES module-attribute

THEORY_STATEMENT_TYPES = (TheoryDecl, ViewDecl, ModelDecl)

The declarations of the theory layer, which elaborate at check time.

SEMIRING_STATEMENT_TYPES module-attribute

SEMIRING_STATEMENT_TYPES = (SemiringDecl,)

The semiring declarations, which elaborate at check time.

CompositionLevel

CompositionLevel = Literal['algebra', 'semigroupoid', 'magmoid', 'rule']

Algebraic level the file declares for its composition rule.

The four levels correspond to the quivers.core.algebras.CompositionRule-hierarchy:

  • "algebra" requires a full Algebra (unit, zero, meet, negate, identity, dagger, cup/cap).
  • "semigroupoid" requires a Semigroupoid (associative composition, no identity required); every Semiring algebra qualifies.
  • "magmoid" requires a Magmoid, a rule declared to satisfy no composition law.
  • "composition_rule" is permissive: any CompositionRule is accepted.

MorphismRole

MorphismRole = Literal['parameter', 'observed', 'kernel', 'embed', 'discretize', 'let', 'function']

Role attribute on a morphism declaration.

parameter (learnable point estimate), observed (fixed structural input), kernel (parametric Markov kernel with a family prior), embed (FinSet -> ContinuousSpace boundary), discretize (ContinuousSpace -> FinSet boundary), let (deterministic let-bound morphism), function (learned deterministic map between continuous spaces). Optional; when the option block carries no role, the morphism is a kernel. Every other role is explicit.

LetBinaryOperator

LetBinaryOperator = Literal['+', '-', '*', '/', '%', '==', '!=', '<', '<=', '>', '>=', '&&', '||', '++', '\\']

The operator of a binary let expression: arithmetic, comparison, boolean, concatenation of records or of case functions, or restriction of a record.

QiecHandlerImplementation

QiecHandlerImplementation = Literal['authored', 'foreign']

Whether a handler's clause bodies are written in source.

An "authored" handler carries a body for every clause; a "foreign" handler may give clause signatures without bodies, which the target runtime supplies.

QiecResumptionGrade

QiecResumptionGrade = Literal['0', 'aff', '1', 'omega', 'interval']

How many times an operation clause may resume its continuation.

"0" never resumes, "aff" resumes at most once, "1" resumes exactly once, and "omega" resumes any number of times. The "interval" form uses the clause's inclusive integer bounds.

QiecStaticArgument

QiecStaticArgument = QiecTypeExpr | QiecIndexLiteral

A static argument: a type or effect written as type syntax, or an index literal.

TestKind

TestKind = Literal['test', 'property', 'example']

What declared a test body.

AxisSpec didactic-model

AxisSpec(*, over: tuple[str, ...], iid_over: tuple[str, ...] = (), line: int = 0, col: int = 0)

Bases: Model

Axis-role specification on a distribution clause.

Surface form: over <axes> [iid over <axes>].

over names the event axes, the axes on which the family's joint structure (an MVN covariance, a MatrixNormal Kronecker pair, a GP kernel) lives. The axis count must match the family's declared event rank; the positional ordering corresponds positionally to the family's event-axis ordering.

iid_over is an optional readability assertion naming the batch axes (the complement of over in the surrounding morphism's type signature). Inconsistency with the type signature or with over is a compile-time error.

Axis names resolve against the named factors of the surrounding morphism's dom/cod. The reserved tokens dom and cod are legal shortcuts only when the corresponding side is a single unfactored object.

BundleDecl didactic-model

BundleDecl(*, name: str, rules: tuple[str, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['bundle_decl'] = 'bundle_decl')

Bases: Statement

bundle NAME : [rule1, rule2, ...] first-class schema bundle.

Binds NAME to a tuple of schema references; parser(rules=NAME) and chart_fold(binary=NAME, ...) resolve the bundle by name and splice its members into the rule list.

CategoryDecl didactic-model

CategoryDecl(*, names: tuple[str, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['category_decl'] = 'category_decl')

Bases: Statement

category NAME, NAME, ... declaration.

CompositionDecl didactic-model

CompositionDecl(*, name: str, level: CompositionLevel | None = None, body: tuple[CompositionRuleEntry, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['composition_decl'] = 'composition_decl')

Bases: Statement

composition NAME [level=LEVEL] [: body] declaration.

level records which algebraic level the option block advertises; the optional body defines the rule's operations inline.

CompositionRuleEntry didactic-model

CompositionRuleEntry(*, key: str, params: tuple[str, ...] = (), body: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

One entry of a composition body block.

Function-valued entries (tensor_op, join, negation, meet) declare a lambda over named parameters; value-valued entries (unit, zero) declare a numeric literal. The params tuple is empty for value-valued entries.

ContractionDecl didactic-model

ContractionDecl(*, name: str, inputs: tuple[ContractionInput, ...], domain: ObjectExpr, codomain: ObjectExpr, options: tuple[OptionEntry, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['contraction_decl'] = 'contraction_decl')

Bases: Statement

contraction NAME(inputs) : DOM -> COD [options].

The option block carries:

  • rule=<NAME> (required): names the composition rule whose join is the fold operation for contracted axes.
  • share=[ax1, ax2, ...]: keep listed axes element-wise even when they appear in multiple inputs.
  • wiring="<einsum>": explicit escape hatch; verbatim einsum string.

ContractionInput didactic-model

ContractionInput(*, name: str, input_domain: ObjectExpr, input_codomain: ObjectExpr, line: int = 0, col: int = 0)

Bases: Model

One input wire of a ContractionDecl declaration.

DecoderDecl didactic-model

DecoderDecl(*, name: str, signature: str, sig_args: tuple[str, ...] = (), options: tuple[OptionEntry, ...] = (), dims: tuple[SortDim, ...] = (), structure: LetExprNode | None = None, structure_arg: str | None = None, primitive: LetExprNode | None = None, primitive_arg: str | None = None, factor: LetExprNode | None = None, factor_arg: str | None = None, binder_select: LetExprNode | None = None, binder_select_arg: str | None = None, recursive_default: bool = True, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['decoder_decl'] = 'decoder_decl')

Bases: Statement

decoder NAME : SIG[(sig_args)] [options] : body.

DeductionDecl didactic-model

DeductionDecl(*, name: str, domain: ObjectExpr, codomain: ObjectExpr, options: tuple[OptionEntry, ...] = (), atoms: tuple[str, ...] = (), binders: tuple[str, ...] = (), rules: tuple[SequentRule, ...] = (), lexicon: tuple[LexiconEntry, ...] = (), lexicon_from_file: str | None = None, lexicon_from_file_options: tuple[OptionEntry, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, deriving: tuple[DerivingClass, ...] = (), extends: tuple[DeductionExtension, ...] = (), lexicons: tuple[LexiconReference, ...] = (), instantiations: tuple[RuleInstantiation, ...] = (), origins: tuple[SymbolOrigin, ...] = (), rule_origins: tuple[SymbolOrigin, ...] = (), cores: tuple[DeductionCore, ...] = (), semiring: DeductionSemiring | None = None, category_sets: tuple[CategorySetDecl, ...] = (), semantics: SemanticsDecl | None = None, templates: tuple[LexicalTemplate, ...] = (), lexical_rules: tuple[LexicalRuleDecl, ...] = (), features: tuple[AtomFeatures, ...] = (), refines: str = '', kind: Literal['deduction_decl'] = 'deduction_decl')

Bases: Statement

deduction NAME : DOM -> COD [options] : body.

Body is an indented block of atoms, rule, lexicon entries. semiring is the header's semiring parameter ([S = I] or [S : T]), None for the log semiring. The option block carries start=..., depth=..., axioms=..., signature=..., encoder=.... deriving holds the classes of the header's deriving (...) clause, derived for the deduction's generated item family.

extends, lexicons, and instantiations are the signatures, lexicon modules, and schema instantiations the body names; composition (quivers.dsl.deduction_composition) replaces them by the rules, atoms, and entries they stand for and records each atom's declaration in origins, each rule's in rule_origins, and the signatures extended in cores.

category_sets, semantics, templates, lexical_rules, features, and refines are the body's categories, semantics, template, lexical rule, featured atoms, and refines lines; lexicon expansion (quivers.dsl.lexical) turns a deduction that uses them into one that does not.

EncoderDecl didactic-model

EncoderDecl(*, name: str, signature: str, sig_args: tuple[str, ...] = (), options: tuple[OptionEntry, ...] = (), dims: tuple[SortDim, ...] = (), iterations: int | None = None, readout: LetExprNode | None = None, op_rules: tuple[EncoderRule, ...] = (), init_rules: tuple[EncoderInitRule, ...] = (), message_rules: tuple[EncoderMessageRule, ...] = (), update_rules: tuple[EncoderUpdateRule, ...] = (), var_inits: tuple[EncoderVarInit, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['encoder_decl'] = 'encoder_decl')

Bases: Statement

encoder NAME : SIG[(sig_args)] [options] [: body].

The option block carries factory=... (factory-backed form) plus any factory keyword arguments. Body entries are dim, iterations, readout, per-op rules, init/message/update rules, var_init rules.

ExportDecl didactic-model

ExportDecl(*, expr: Expr, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['export_decl'] = 'export_decl')

Bases: Statement

export EXPR module-level export.

DefineDecl didactic-model

DefineDecl(*, name: str, expr: Expr, where: tuple[Statement, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['define_decl'] = 'define_decl')

Bases: Statement

define NAME = EXPR [where: nested-defines] value binding.

Unlike a MorphismDecl with role=let, this is a value-level binding: its RHS is an arbitrary morphism Expr, not a morphism signature with an init. The program-step let binds tensor arithmetic instead; the two forms never share a keyword.

The where field is typed as tuple[Statement, ...] (the union root) because didactic does not yet accept self-referential forward refs in field annotations. The parser only ever writes DefineDecl instances into the tuple.

LexiconCategory didactic-model

LexiconCategory()

Bases: TaggedUnion

Category position in a lexicon entry. Three shapes:

  • LexiconCategoryFixed -- a known category, e.g. Det.
  • LexiconCategoryWildcard -- the * wildcard. The compiler treats the entry's category as a latent random variable and learns a Categorical distribution over the deduction's full atom set; one learnable weight is allocated per atom.
  • LexiconCategoryRestricted -- a candidate set {A, B}. Same as wildcard but the Categorical is restricted to the listed atoms; one learnable weight per listed atom.

LexiconCategoryFixed didactic-model

LexiconCategoryFixed(*, category: ObjectExpr, kind: Literal['fixed'] = 'fixed')

Bases: LexiconCategory

"the" : Det = the.

LexiconCategoryPolymorphic didactic-model

LexiconCategoryPolymorphic(*, binders: tuple[CategoryBinder, ...], category: ObjectExpr, kind: Literal['polymorphic'] = 'polymorphic')

Bases: LexiconCategory

"and" : ∀ X in Conj. Fwd(Bwd(X, X), X) = coord[X].

A category schema: one entry per assignment of members of the named category sets to the variables (quivers.dsl.lexical).

LexiconCategoryRestricted didactic-model

LexiconCategoryRestricted(*, atoms: tuple[str, ...], kind: Literal['restricted'] = 'restricted')

Bases: LexiconCategory

"saw" : {V, N} = saw. Latent over the listed atoms only.

LexiconCategoryWildcard didactic-model

LexiconCategoryWildcard(*, kind: Literal['wildcard'] = 'wildcard')

Bases: LexiconCategory

"bank" : * = bank. Latent over the deduction's atom set.

LexiconEntry didactic-model

LexiconEntry(*, words: tuple[str, ...], category: LexiconCategory, lf: LetExprNode | None = None, options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0, weights: tuple[str, ...] = (), stands_for: str = '', derived_by: str = '')

Bases: Model

One lexicon-block entry: "word", ... : CAT = LF.

Each word maps to the same category and logical form. A typed entry with an entry name may omit the logical form. weights names the learned weight families the entry's weight multiplies: a written entry names them with #[shared = F], and lexicon expansion gives every instance of a polymorphic entry its entry's family and an entry a lexical rule derives the rule's family.

stands_for names, for an instance of a lazily instantiated entry in the deduction the agenda engine runs (an agenda plan), the placeholder atom whose item stands for it in the chart: such an entry is no axiom, and under normalize=lhs it is a production of its category, read by the rules specialized to the placeholder, while the placeholder's own entry is an axiom and no production.

derived_by names, for an entry a lexical rule in chart mode derives from a lexical item, that rule: the agenda engine derives the entry's item from the lexical item by the rule, and reads the rule's conclusion back as an axiom occurrence of the entry.

LossDecl didactic-model

LossDecl(*, name: str, options: tuple[OptionEntry, ...] = (), body: LetExprNode, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['loss_decl'] = 'loss_decl')

Bases: Statement

loss NAME [options] : body.

Option keys: weight=<expr>, on=<attachment>. The on value is an OptionCall of one of program(NAME), deduction(NAME), encoder(NAME), decoder(NAME), rule(RULE, DEDUCTION), chart(DEDUCTION), or an OptionFlag global.

MorphismDecl didactic-model

MorphismDecl(*, names: tuple[str, ...], domain: ObjectExpr, codomain: ObjectExpr, options: tuple[OptionEntry, ...] = (), init_family: MorphismInitFamily | None = None, init_expr: Expr | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['morphism_decl'] = 'morphism_decl')

Bases: Statement

morphism NAME, ... : DOM -> COD [options] [~ init].

Each name declares an independent morphism (fresh parameters) with the same signature, options, and initializer. The morphism's role travels in the option block; the compiler reads options["role"] (kernel when absent) to pick the runtime construction.

Initializer (~ clause, optional):

  • init_family: ~ Family(args) family call (used for kernel priors, latent priors, distribution-driven init).
  • init_expr: ~ <expression> arbitrary morphism-expression (used for explicit values, composition pipelines, ~ auto named recipes).

The two init slots are mutually exclusive; exactly zero or one is populated.

MorphismInitFamily didactic-model

MorphismInitFamily(*, family: str, args: tuple[DrawArg, ...] = (), line: int = 0, col: int = 0)

Bases: Model

~ Family(args) distribution-family initializer.

MorphismParam didactic-model

MorphismParam(*, name: str, domain: ObjectExpr, codomain: ObjectExpr, line: int = 0, col: int = 0, kind: Literal['morphism_param'] = 'morphism_param')

Bases: ProgramParam

Static morphism parameter: f : Mor[A, B].

ObjectParam didactic-model

ObjectParam(*, name: str, universe: Literal['FinSet', 'Space', 'Object'], line: int = 0, col: int = 0, kind: Literal['object_param'] = 'object_param')

Bases: ProgramParam

Static object parameter: G : FinSet / Space / Object.

OptionCall didactic-model

OptionCall(*, func: str, args: tuple[OptionValue, ...] = (), kind: Literal['option_call'] = 'option_call')

Bases: OptionValue

A key bound to a function-call value (e.g. via=product(a, b)).

OptionEntry didactic-model

OptionEntry(*, key: str, value: OptionValue = field(default_factory=OptionFlag), line: int = 0, col: int = 0)

Bases: Model

One key=value (or bare key) entry in an option block.

The list-of-entries layout (rather than a dict) preserves source order; downstream code typically realises a dict on first use.

OptionFlag didactic-model

OptionFlag(*, kind: Literal['option_flag'] = 'option_flag')

Bases: OptionValue

A bare key with no value (e.g. [learnable]).

OptionList didactic-model

OptionList(*, items: tuple[OptionValue, ...] = (), kind: Literal['option_list'] = 'option_list')

Bases: OptionValue

A key bound to a list of identifiers / numbers / strings.

OptionName didactic-model

OptionName(*, value: str, kind: Literal['option_name'] = 'option_name')

Bases: OptionValue

A key bound to a bare identifier (e.g. role=parameter).

OptionNumber didactic-model

OptionNumber(*, value: float, kind: Literal['option_number'] = 'option_number')

Bases: OptionValue

A key bound to a numeric literal (e.g. depth=8, scale=0.1).

OptionString didactic-model

OptionString(*, value: str, kind: Literal['option_string'] = 'option_string')

Bases: OptionValue

A key bound to a string literal (e.g. path="lex.tsv").

OptionValue didactic-model

OptionValue()

Bases: TaggedUnion

Value inhabiting one entry of an option block.

Surface shapes:

  • Bare flag [role] -> OptionFlag (no value)
  • role=parameter -> OptionName (identifier)
  • depth=8 / scale=0.1 -> OptionNumber
  • path="lex.tsv" -> OptionString
  • over=[a, b] -> OptionList
  • via=product(a, b) -> OptionCall

ProgramDecl didactic-model

ProgramDecl(*, name: str, params: tuple[str, ...] | None = None, type_params: tuple[ProgramParam, ...] | None = None, binders: tuple[QiecBinder, ...] = (), value_parameters: tuple[QiecValueParameter, ...] = (), domain: ObjectExpr, codomain: ObjectExpr, options: tuple[OptionEntry, ...] = (), draws: tuple[ProgramStep, ...] = (), return_vars: tuple[str, ...] = (), return_labels: tuple[str, ...] | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['program_decl'] = 'program_decl')

Bases: Statement

A program's static binders, runtime interface, and effectful body.

binders holds the shared QIEC static telescope. type_params records object/morphism specialization and scalar partial application. value_parameters declares checked runtime values; params names domain factors when their types are inferred from the domain instead. The body contains executable steps and a terminal return.

ProgramParam didactic-model

ProgramParam()

Bases: TaggedUnion

Program-specific specialization and scalar-application metadata.

RuleDecl didactic-model

RuleDecl(*, name: str, variables: tuple[str, ...], premises: tuple[ObjectExpr, ...], conclusion: ObjectExpr, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['rule_decl'] = 'rule_decl')

Bases: Statement

rule NAME[variables] : premises |- conclusion declaration.

Premises and conclusion are ObjectExpr patterns drawn from the unified type-expression family.

ScalarParam didactic-model

ScalarParam(*, name: str, scalar_kind: Literal['Real', 'Nat'], line: int = 0, col: int = 0, kind: Literal['scalar_param'] = 'scalar_param')

Bases: ProgramParam

Runtime scalar metadata for s : Real or s : Nat.

The checked runtime declaration is recorded in value_parameters; this metadata also supports named scalar partial application.

SchemaDecl didactic-model

SchemaDecl(*, name: str, parameters: tuple[SchemaParameter, ...], domain: ObjectExpr, codomain: ObjectExpr, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['schema_decl'] = 'schema_decl')

Bases: Statement

schema NAME[parameters] : DOM -> COD declaration.

SchemaParameter didactic-model

SchemaParameter(*, names: tuple[str, ...], type_expr: ObjectExpr, line: int = 0, col: int = 0)

Bases: Model

One names : type group inside a schema's parameter list.

SequentRule didactic-model

SequentRule(*, name: str, premises: tuple[ObjectExpr, ...], conclusion: ObjectExpr, options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0, parameters: tuple[QiecBinder, ...] = (), weight_source: SpecializedWeight | None = None)

Bases: Model

A named sequent inside a deduction block.

rule NAME : premises |- conclusion [pragma]. Premise and conclusion type-expressions may contain single-uppercase wildcards (X, Y) that bind to actual category subexpressions when the rule fires.

The trailing pragma carries optional rule-level options:

  • #[learnable] -- allocate one learnable log-weight per distinct binding tuple observed at run time. The bindings tuple is (rule_name, *sorted_binding_values). The conclusion weight becomes semiring_product(premise_weights, param[bindings]).
  • #[weight = expr] -- the conclusion weight is semiring_product(premise_weights, expr) where expr is a let-expression evaluated in the rule's binding scope (wildcards bound by the match are in scope). Most general form; subsumes learnable.
  • #[parent = rule_name] -- compose this rule's weight additively with the named parent rule's weight on the same bindings. Specialisation as a correction term.
  • #[shared = F(p, q)] -- the rule's weight is the learnable weight family F at the index (p, q): one log-weight per index, read by every rule that names the same family and index.

parameters is the static telescope of a rule schema (rule r[n : Nat, e : Dir] : ...); a rule with parameters is a family of rules that a rules line instantiates.

weight_source is set only on the rules lexicon expansion (quivers.dsl.lexical) specializes to a lazily instantiated entry: such a rule reads its source rule's learned weight on the source's own bindings.

SyntaxDecl didactic-model

SyntaxDecl(*, name: str, params: tuple[str, ...] = (), sorts: tuple[SortDecl, ...] = (), constructors: tuple[ConstructorDecl, ...] = (), vertex_kinds: tuple[VertexKindDecl, ...] = (), edge_kinds: tuple[EdgeKindDecl, ...] = (), equations: tuple[EquationDecl, ...] = (), equation_options: tuple[OptionEntry, ...] = (), assume_terminating: bool = False, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['syntax_decl'] = 'syntax_decl')

Bases: Statement

syntax NAME[(params)]: a second-order binding signature.

Its body declares sorts, constructors with per-argument binding arities, equations, and vertex and edge kinds.

Statement didactic-model

Statement()

Bases: TaggedUnion

Sum of top-level statement kinds.

ObjectDecl didactic-model

ObjectDecl(*, names: tuple[str, ...], init: TypeInitializer, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['object_decl'] = 'object_decl')

Bases: Statement

object NAME, ... : VALUE declaration.

Each name registers an independent object with the same VALUE. The VALUE's shape picks the discrete-vs-continuous and reference-vs-initializer distinction; the compiler reads init to decide what kind of object (FinSet, EnumSet, FreeResiduated, FreeMonoid, ContinuousSpace) to register in the env.

TypeEnumSet didactic-model

TypeEnumSet(*, elements: tuple[str, ...], line: int = 0, col: int = 0, kind: Literal['type_enum_set'] = 'type_enum_set')

Bases: TypeInitializer

type Atoms : {NP, S, VP} enum-set initializer.

TypeFreeMonoid didactic-model

TypeFreeMonoid(*, generators: str, max_length: int, line: int = 0, col: int = 0, kind: Literal['type_free_monoid'] = 'type_free_monoid')

Bases: TypeInitializer

type Words : FreeMonoid(Atoms, max_length=N) initializer.

TypeFreeResiduated didactic-model

TypeFreeResiduated(*, generators: str, depth: int = 1, ops: tuple[str, ...] = ('slash',), line: int = 0, col: int = 0, kind: Literal['type_free_residuated'] = 'type_free_residuated')

Bases: TypeInitializer

type Cat : FreeResiduated(Atoms, depth=4, ops=[/, \]) initializer.

TypeFromExpr didactic-model

TypeFromExpr(*, expr: ObjectExpr, kind: Literal['type_from_expr'] = 'type_from_expr')

Bases: TypeInitializer

type X : <type-expression> for every non-special-form value.

Covers integer cardinalities, identifiers, products, coproducts, slashes, effect-applies, and constructor calls (FinSet, Real, Simplex, ...).

TypeInitializer didactic-model

TypeInitializer()

Bases: TaggedUnion

Sum of type NAME : VALUE value shapes.

The grammar's _object_value choice corresponds 1:1 to this union.

Expr didactic-model

Expr()

Bases: TaggedUnion

Sum of value-expression node kinds (morphism computations).

ExprCap didactic-model

ExprCap(*, object_name: str, line: int = 0, col: int = 0, kind: Literal['expr_cap'] = 'expr_cap')

Bases: Expr

Compact-closed counit ε_A : A ⊗ A → I for a named object.

ExprChangeBase didactic-model

ExprChangeBase(*, inner: Expr, phi: Expr, line: int = 0, col: int = 0, kind: Literal['expr_change_base'] = 'expr_change_base')

Bases: Expr

Change-of-base: apply a transformation (a carrier map, such as an algebra homomorphism, or a MorphismTransformation) to a morphism.

The transformation is a first-class value: phi is any expression whose compile-time value is a MorphismTransformation or CarrierMap. Concretely:

  • A bare identifier resolving a registered singleton (f.change_base(expectation)) or a let-bound trans value (f.change_base(t)).
  • A constructor call (f.change_base(softmax(B))).
  • A composition (f.change_base(t1 >>> t2)).

ExprChartFold didactic-model

ExprChartFold(*, lex: Expr, binary: Expr | None = None, unary: Expr | None = None, start: str | int = 'S', depth: int = 1, effect_depth: int = 0, line: int = 0, col: int = 0, kind: Literal['expr_chart_fold'] = 'expr_chart_fold')

Bases: Expr

Desugared parser-construction primitive.

Surface form: chart_fold(lex=, binary=, unary=, start=, depth=, effect_depth=).

Constructs a chart parser from morphism-valued arguments rather than from a list of named rule schemas. lex is a morphism Token -> Cat; binary is a Cat * Cat -> Cat morphism (the union of all binary rule schemas); unary is an optional Cat -> Cat morphism (the union of all unary rule schemas); start is the goal category name (or integer index); depth is the maximum category nesting depth; effect_depth bounds effect-stack nesting (defaults to 0).

ExprCompose didactic-model

ExprCompose(*, left: Expr, right: Expr, op: str = '>>', line: int = 0, col: int = 0, kind: Literal['expr_compose'] = 'expr_compose')

Bases: Expr

Algebra-typed sequential composition.

The op field selects which enrichment algebra's monoidal structure to use for the V-Cat composition:

  • ">>" for ProductFuzzyAlgebra noisy-OR (the default).
  • "<<" for reverse ProductFuzzyAlgebra.
  • ">=>" for Kleisli composition (operands' shared algebra).
  • "*>" for Markov sum-product.
  • "~>" for LogProb (log-space sum-product).
  • "||>" for Gödel (lattice min/max with Heyting implication).
  • "?>" for Viterbi (max-plus tropical, best path).
  • "&&>" for Boolean (∧/∨).
  • "+>" for Łukasiewicz (probabilistic sum bounded by 1).

Each operator carries its own algebra; cross-operator composition in one chain requires explicit .change_base(φ) between segments.

ExprCup didactic-model

ExprCup(*, object_name: str, line: int = 0, col: int = 0, kind: Literal['expr_cup'] = 'expr_cup')

Bases: Expr

Compact-closed unit η_A : I → A ⊗ A for a named object.

ExprCurry didactic-model

ExprCurry(*, inner: Expr, direction: Literal['right', 'left'], line: int = 0, col: int = 0, kind: Literal['expr_curry'] = 'expr_curry')

Bases: Expr

The curry combinator.

For f : X * Y -> Z, f.curry_right denotes the curried morphism X -> Y * Z and f.curry_left denotes Y -> X * Z: in the compact closed category of V-matrices the internal hom [Y, Z] is the product set Y * Z, and currying is the bijection Hom(X * Y, Z) ≅ Hom(X, [Y, Z]) (see quivers.core.morphisms.CurriedMorphism). The domain must factor as a product.

ExprDagger didactic-model

ExprDagger(*, inner: Expr, line: int = 0, col: int = 0, kind: Literal['expr_dagger'] = 'expr_dagger')

Bases: Expr

Compact-closed dagger / transpose of an expression.

ExprFan didactic-model

ExprFan(*, exprs: tuple[Expr, ...], line: int = 0, col: int = 0, kind: Literal['expr_fan'] = 'expr_fan')

Bases: Expr

Fan-out (diagonal) composition: fan(f, g, ...).

ExprFreeze didactic-model

ExprFreeze(*, inner: Expr, line: int = 0, col: int = 0, kind: Literal['expr_freeze'] = 'expr_freeze')

Bases: Expr

Detach gradients: inner.freeze materialises inner's tensor with detach() and wraps the result as a frozen ObservedMorphism. Used to pin a learned composition as a structural input that the downstream model treats as constant.

ExprFromData didactic-model

ExprFromData(*, key: str, line: int = 0, col: int = 0, kind: Literal['expr_from_data'] = 'expr_from_data')

Bases: Expr

Data-derived initializer from_data("KEY").

The string key is resolved against the runtime data dictionary at fit time; the morphism's tensor is the looked-up value. The resulting morphism is ObservedMorphism: its entries are frozen / structural inputs, not learnable parameters.

ExprIdent didactic-model

ExprIdent(*, name: str, line: int = 0, col: int = 0, kind: Literal['expr_ident'] = 'expr_ident')

Bases: Expr

Reference to a named morphism or binding.

ExprIdentity didactic-model

ExprIdentity(*, object_name: str, line: int = 0, col: int = 0, kind: Literal['expr_identity'] = 'expr_identity')

Bases: Expr

Identity morphism: identity(A).

ExprMarginalize didactic-model

ExprMarginalize(*, inner: Expr, names: tuple[str, ...], line: int = 0, col: int = 0, kind: Literal['expr_marginalize'] = 'expr_marginalize')

Bases: Expr

Marginalization: expr.marginalize(A, B, ...).

ExprMorphismCall didactic-model

ExprMorphismCall(*, callee: str, args: tuple[str, ...], static_args: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['expr_morphism_call'] = 'expr_morphism_call')

Bases: Expr

Call expression callee(arg1, arg2, ...) resolving to a morphism-level operation.

Used by ContractionDecl declarations: when the user writes let out = op_apply(arg1, arg2, kernel), the op_apply identifier resolves to a registered contraction and the arguments are looked up in the morphism scope.

ExprParser didactic-model

ExprParser(*, rules: tuple[str, ...] = (), categories: tuple[str, ...] = (), terminal: str | None = None, start: str | int = 'S', depth: int = 1, constructors: tuple[str, ...] | None = None, line: int = 0, col: int = 0, kind: Literal['expr_parser'] = 'expr_parser')

Bases: Expr

Deductive parser assembled from rules.

ExprRepeat didactic-model

ExprRepeat(*, expr: Expr, count: int | None, line: int = 0, col: int = 0, kind: Literal['expr_repeat'] = 'expr_repeat')

Bases: Expr

Iterated composition: repeat(f, n) or repeat(f).

ExprScan didactic-model

ExprScan(*, expr: Expr, init: str = 'zeros', outputs: Literal['last', 'all'] = 'last', reverse: bool = False, line: int = 0, col: int = 0, kind: Literal['expr_scan'] = 'expr_scan')

Bases: Expr

Temporal scan: scan(cell) with its options.

The options are init (zeros, learned, or a binding of the scanning program), outputs (last for the final state, all for the state after every position, in input order), and reverse (visit the positions from the last to the first).

ExprStack didactic-model

ExprStack(*, expr: Expr, count: int, line: int = 0, col: int = 0, kind: Literal['expr_stack'] = 'expr_stack')

Bases: Expr

Independent multi-layer composition: stack(f, n).

ExprTensorProduct didactic-model

ExprTensorProduct(*, left: Expr, right: Expr, line: int = 0, col: int = 0, kind: Literal['expr_tensor_product'] = 'expr_tensor_product')

Bases: Expr

Parallel product: left @ right.

ExprTrace didactic-model

ExprTrace(*, inner: Expr, object_name: str, line: int = 0, col: int = 0, kind: Literal['expr_trace'] = 'expr_trace')

Bases: Expr

Compact-closed trace of an expression along a named object.

ExprTransCompose didactic-model

ExprTransCompose(*, left: Expr, right: Expr, line: int = 0, col: int = 0, kind: Literal['expr_trans_compose'] = 'expr_trans_compose')

Bases: Expr

Composition of two transformations: t1 >>> t2 denotes sequential application, first apply t1, then t2.

Required: t1.target == t2.source (typed at compile time; a mismatch raises CompileError). The result behaves as a transformation with source = t1.source and target = t2.target.

LetExprBinOp didactic-model

LetExprBinOp(*, op: LetBinaryOperator, left: LetExprNode, right: LetExprNode, line: int = 0, col: int = 0, kind: Literal['let_expr_binop'] = 'let_expr_binop')

Bases: LetExprNode

Binary operation in an expression.

PARAMETER DESCRIPTION
op

The operator: arithmetic, comparison, or boolean.

TYPE: LetBinaryOperator

left

The left operand.

TYPE: LetExprNode

right

The right operand.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_binop".

TYPE: Literal['let_expr_binop'] DEFAULT: 'let_expr_binop'

LetExprCall didactic-model

LetExprCall(*, func: str, args: tuple[LetExprNode, ...], arg_names: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['let_expr_call'] = 'let_expr_call')

Bases: LetExprNode

Function application in an expression.

PARAMETER DESCRIPTION
func

The callee's authored name.

TYPE: str

args

The arguments, in order.

TYPE: tuple[LetExprNode, ...]

arg_names

The parallel authored names, or empty for a positional application. An empty name marks a positional argument in a mixed application.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_call".

TYPE: Literal['let_expr_call'] DEFAULT: 'let_expr_call'

LetExprFactor didactic-model

LetExprFactor(*, binders: tuple[LetFactorBinder, ...], body: LetExprNode | None = None, cases: tuple[LetFactorCase, ...] = (), line: int = 0, col: int = 0, kind: Literal['let_expr_factor'] = 'let_expr_factor')

Bases: LetExprNode

Multi-axis factor expression: assemble an indexed tensor.

Surface forms:

factor v1 : I1, v2 : I2, ..., vn : In in <body> denotes the tensor of shape (|I1|, ..., |In|, *body_shape) whose value at position (i1, ..., in) is body[v_k := i_k].

factor v : I in { 0 -> e0, 1 -> e1, ... } denotes the single-axis case-structured form: the body at index k is the expression labelled k, and the labels must cover {0, ..., |I|-1} exactly. Multi-axis case form is not accepted; the uniform body form (which can itself contain conditionals on the binders) is the general construction.

Categorically the left adjoint of indexing. Single-axis is a section of the trivial bundle I -> body_type; multi-axis is a section over the product I1 x ... x In. The dual operation is the index pullback arr[i1, ..., in] (LetExprIndex); together they realize the indexed-family colim / lim pair in the slice category over FinSet.

LetExprIndex didactic-model

LetExprIndex(*, array: LetExprNode, indices: tuple[LetExprNode, ...], line: int = 0, col: int = 0, kind: Literal['let_expr_index'] = 'let_expr_index')

Bases: LetExprNode

Indexed access into a finite-domain-indexed family a[i].

Categorically the pullback morphism: given a finite-index-map index : N → A and a per-A morphism arr : A → B, the indexed expression arr[index[n]] denotes arr ∘ index : N → B, the natural Kleisli pullback of arr along index.

ATTRIBUTE DESCRIPTION
array

The indexed-family expression (typically a LetExprVar naming a previously-drawn plate variable).

TYPE: LetExprNode

indices

The index expressions; supports multi-dim indexing for nested plates (coefs[subj[n], k]).

TYPE: tuple of LetExprNode

LetExprLambda didactic-model

LetExprLambda(*, param: str, body: LetExprNode, line: int = 0, col: int = 0, kind: Literal['let_expr_lambda'] = 'let_expr_lambda')

Bases: LetExprNode

Lambda expression param -> body in a let expression.

Closes over the surrounding let-environment at instantiation time. Categorically a curried function in the Kleisli setting; used as the argument to fold / map / filter / reduce combinators.

LetExprList didactic-model

LetExprList(*, items: tuple[LetExprNode, ...], line: int = 0, col: int = 0, kind: Literal['let_expr_list'] = 'let_expr_list')

Bases: LetExprNode

List literal in a let expression: [a, b, c].

Categorically a free-monoid element over the value sublanguage; the runtime represents it as a Python list (with autograd flowing through tensor-valued items).

LetExprLiteral didactic-model

LetExprLiteral(*, value: int | float, integral: bool = False, line: int = 0, col: int = 0, kind: Literal['let_expr_literal'] = 'let_expr_literal')

Bases: LetExprNode

Numeric literal in an expression.

PARAMETER DESCRIPTION
value

The literal's value.

TYPE: int | float

integral

Whether the source spelled an integer, with no fraction or exponent. Integer lexemes retain an exact integer carrier. The QIEC lowerer types them as Int unless the expected context requires Real.

TYPE: bool DEFAULT: False

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_literal".

TYPE: Literal['let_expr_literal'] DEFAULT: 'let_expr_literal'

LetExprMethodCall didactic-model

LetExprMethodCall(*, receiver: LetExprNode, method: str, args: tuple[LetExprNode, ...], line: int = 0, col: int = 0, kind: Literal['let_expr_method_call'] = 'let_expr_method_call')

Bases: LetExprNode

Method call receiver.method(args) in a let expression.

The receiver is itself a let-expression (typically a variable reference to a let-bound chart-valued, list-valued, or other object-valued value); the method is dispatched at runtime against the receiver's type. Used primarily for chart-view queries (chart.weight(item), chart.enumerate(pattern), chart.goal_weight()).

LetExprNode didactic-model

LetExprNode()

Bases: TaggedUnion

Sum of pure expression nodes.

One expression tree serves both surfaces: a program let step and a QIEC value position parse to the same nodes. Every node carries the 1-based source line and column of its first token, which the QIEC lowerer needs for diagnostics and stable provenance; a program step ignores them.

LetExprString didactic-model

LetExprString(*, value: str, line: int = 0, col: int = 0, kind: Literal['let_expr_string'] = 'let_expr_string')

Bases: LetExprNode

String literal in a let expression.

Used for tokenisation, lexicon keys, and as ground-atom names in LF constructors like pred("dog") and forall("x", body). The runtime represents these as plain Python strings.

LetExprUnaryOp didactic-model

LetExprUnaryOp(*, operand: LetExprNode, op: Literal['-', 'not'] = '-', line: int = 0, col: int = 0, kind: Literal['let_expr_unary'] = 'let_expr_unary')

Bases: LetExprNode

Unary negation or boolean negation in an expression.

PARAMETER DESCRIPTION
operand

The operand.

TYPE: LetExprNode

op

"-" for arithmetic negation or "not" for boolean negation.

TYPE: Literal['-', 'not'] DEFAULT: '-'

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_unary".

TYPE: Literal['let_expr_unary'] DEFAULT: 'let_expr_unary'

LetExprVar didactic-model

LetExprVar(*, name: str, line: int = 0, col: int = 0, kind: Literal['let_expr_var'] = 'let_expr_var')

Bases: LetExprNode

Variable reference in an expression.

PARAMETER DESCRIPTION
name

The variable's name.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_var".

TYPE: Literal['let_expr_var'] DEFAULT: 'let_expr_var'

LetExprBool didactic-model

LetExprBool(*, value: bool, line: int = 0, col: int = 0, kind: Literal['let_expr_bool'] = 'let_expr_bool')

Bases: LetExprNode

Boolean literal true or false.

PARAMETER DESCRIPTION
value

The literal's value.

TYPE: bool

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_bool".

TYPE: Literal['let_expr_bool'] DEFAULT: 'let_expr_bool'

LetExprUnit didactic-model

LetExprUnit(*, line: int = 0, col: int = 0, kind: Literal['let_expr_unit'] = 'let_expr_unit')

Bases: LetExprNode

The unit literal unit.

PARAMETER DESCRIPTION
line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_unit".

TYPE: Literal['let_expr_unit'] DEFAULT: 'let_expr_unit'

LetExprTuple didactic-model

LetExprTuple(*, items: tuple[LetExprNode, ...], line: int = 0, col: int = 0, kind: Literal['let_expr_tuple'] = 'let_expr_tuple')

Bases: LetExprNode

Tuple construction (a, b, ...) with at least two components.

PARAMETER DESCRIPTION
items

The components, in order.

TYPE: tuple[LetExprNode, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_tuple".

TYPE: Literal['let_expr_tuple'] DEFAULT: 'let_expr_tuple'

LetFactorBinder didactic-model

LetFactorBinder(*, var: str, index: ObjectExpr, line: int = 0, col: int = 0)

Bases: Model

One <var> : <Index> binder in a multi-axis factor expression.

The variable name binds to integer index values 0, 1, ..., |Index|-1 in the surrounding factor body. The index type expression resolves to a finite-set object whose cardinality is the corresponding axis size of the constructed tensor.

LetFactorCase didactic-model

LetFactorCase(*, label: int, value: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

One <integer> -> <body> case in a factor pattern-match.

The label is the integer index this case populates; the body is the value at that index. The compiler verifies that the union of labels across all cases covers {0, ..., |Index|-1} exactly.

Module didactic-model

Module(*, statements: tuple[Statement, ...] = field(default_factory=tuple), tests: tuple[TestDecl, ...] = field(default_factory=tuple), experiments: tuple[ExperimentDecl, ...] = field(default_factory=tuple))

Bases: Model

A complete .qvr program (sequence of statements).

PARAMETER DESCRIPTION
statements

The module's code, in source order.

TYPE: tuple[Statement, ...] DEFAULT: field(default_factory=tuple)

tests

Its test, property and example declarations, and the examples written in its doc comments, in source order. They check the code and are not part of it: the compiler and the content of the code never include them.

TYPE: tuple[TestDecl, ...] DEFAULT: field(default_factory=tuple)

experiments

Its experiment declarations, in source order. An experiment runs the code and is not part of it, so, like a test, it is kept out of the statements the compiler and the content hashes read.

TYPE: tuple[ExperimentDecl, ...] DEFAULT: field(default_factory=tuple)

ImportDecl didactic-model

ImportDecl(*, path: str, alias: str | None = None, items: tuple[str, ...] | None = None, hidden: tuple[str, ...] = (), reexport: bool = False, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['import_decl'] = 'import_decl')

Bases: Statement

import a.b [as L] [(x, y) | hiding (z)].

ATTRIBUTE DESCRIPTION
path

The dotted module path.

TYPE: str

alias

The name the module is reachable under, when as gives one.

TYPE: str | None

items

The selected names, or None when every public name is imported.

TYPE: tuple[str, ...] | None

hidden

The names hiding excludes.

TYPE: tuple[str, ...]

reexport

Whether export import re-exports what the import brings in.

TYPE: bool

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the import statement.

TYPE: int

OpenDecl didactic-model

OpenDecl(*, module: str, items: tuple[str, ...] | None = None, hidden: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['open_decl'] = 'open_decl')

Bases: Statement

open L [(x, y) | hiding (z)].

ATTRIBUTE DESCRIPTION
module

The opened module's alias or path.

TYPE: str

items

The selected names, or None when every imported name opens.

TYPE: tuple[str, ...] | None

hidden

The names hiding excludes.

TYPE: tuple[str, ...]

line, col

The location of the open statement.

TYPE: int

DeductionSpec didactic-model

DeductionSpec(*, name: str, domain: ObjectExpr, codomain: ObjectExpr, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['deduction_spec'] = 'deduction_spec')

Bases: Statement

deduction G : A -> B without a body.

ATTRIBUTE DESCRIPTION
name

The deduction's name.

TYPE: str

domain, codomain

Its header objects.

TYPE: ObjectExpr

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the declaration.

TYPE: int

ImplicitDecl didactic-model

ImplicitDecl(*, declaration: ModuleDecl, line: int = 0, col: int = 0, kind: Literal['implicit_decl'] = 'implicit_decl')

Bases: Statement

implicit module ...: a module offered to implicit parameters.

ATTRIBUTE DESCRIPTION
declaration

The module.

TYPE: ModuleDecl

line, col

The location of implicit.

TYPE: int

ModuleApplication didactic-model

ModuleApplication(*, functor: str, arguments: tuple[ModuleExpr, ...] = (), line: int = 0, col: int = 0, kind: Literal['module_application'] = 'module_application')

Bases: ModuleExpr

A functor applied to module arguments.

ATTRIBUTE DESCRIPTION
functor

The functor's path as written.

TYPE: str

arguments

The arguments, in parameter order.

TYPE: tuple[ModuleExpr, ...]

line, col

Its location.

TYPE: int

ModuleDecl didactic-model

ModuleDecl(*, name: str, parameters: tuple[ModuleParameter, ...] = (), signature: SignatureExpr | None = None, sealed: bool = False, definition: ModuleExpr | None = None, body: tuple[Statement, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['module_decl'] = 'module_decl')

Bases: Statement

module M[(params)] [: S | :> S] with a body or = E.

ATTRIBUTE DESCRIPTION
name

The module's name.

TYPE: str

parameters

The functor parameters (empty for a structure or a binding).

TYPE: tuple[ModuleParameter, ...]

signature

The ascribed signature, if any.

TYPE: SignatureExpr | None

sealed

Whether the ascription seals (:>) rather than being transparent (:).

TYPE: bool

definition

The bound module expression, for the = form.

TYPE: ModuleExpr | None

body

The body's statements, for a structure or a functor.

TYPE: tuple[Statement, ...]

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the declaration.

TYPE: int

ModuleExpr didactic-model

ModuleExpr()

Bases: TaggedUnion

A module expression: a path, an application, or a sealing.

ModuleParameter didactic-model

ModuleParameter(*, name: str, signature: SignatureExpr, implicit: bool = False, line: int = 0, col: int = 0)

Bases: Model

One parameter of a functor or of a computation.

ATTRIBUTE DESCRIPTION
name

The parameter's name.

TYPE: str

signature

The signature its arguments must match.

TYPE: SignatureExpr

implicit

Whether calls leave the argument to instance resolution ({module S : Sig}).

TYPE: bool

line, col

Its location.

TYPE: int

ModulePath didactic-model

ModulePath(*, name: str, line: int = 0, col: int = 0, kind: Literal['module_path'] = 'module_path')

Bases: ModuleExpr

A module named by a path (an import, a declared module, a parameter).

ATTRIBUTE DESCRIPTION
name

The path as written.

TYPE: str

line, col

Its location.

TYPE: int

ModuleSeal didactic-model

ModuleSeal(*, module: ModuleExpr, signature: SignatureExpr, line: int = 0, col: int = 0, kind: Literal['module_seal'] = 'module_seal')

Bases: ModuleExpr

M :> S: a module sealed by a signature.

ATTRIBUTE DESCRIPTION
module

The sealed module.

TYPE: ModuleExpr

signature

The signature it is sealed by.

TYPE: SignatureExpr

line, col

Its location.

TYPE: int

QiecComputationSpec didactic-model

QiecComputationSpec(*, name: str, binders: tuple[QiecBinder, ...] = (), parameters: tuple[QiecValueParameter, ...] = (), result_type: QiecTypeExpr, effects: QiecEffectRow, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['computation_spec'] = 'computation_spec')

Bases: Statement

define f[binders](params) : T !{row} without a body.

ATTRIBUTE DESCRIPTION
name

The computation's name.

TYPE: str

binders

The static telescope.

TYPE: tuple[QiecBinder, ...]

parameters

The value parameters.

TYPE: tuple[QiecValueParameter, ...]

result_type

The result type.

TYPE: QiecTypeExpr

effects

The effect row.

TYPE: QiecEffectRow

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the declaration.

TYPE: int

QiecFamilySpec didactic-model

QiecFamilySpec(*, name: str, parameters: tuple[QiecBinder, ...] = (), indices: tuple[QiecIndexBinder, ...] = (), result_kind: QiecKindExpr, definition: QiecTypeExpr | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['family_spec'] = 'family_spec')

Bases: Statement

family T[params](indices) : Type [= U], a family without constructors.

Inside a signature it specifies an abstract family, or, with = U, a manifest one. In a module, the = U form declares T a name for the type U.

ATTRIBUTE DESCRIPTION
name

The family's name.

TYPE: str

parameters

Its static parameters.

TYPE: tuple[QiecBinder, ...]

indices

Its refinable indices.

TYPE: tuple[QiecIndexBinder, ...]

result_kind

Its kind.

TYPE: QiecKindExpr

definition

The type it equals, when manifest.

TYPE: QiecTypeExpr | None

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the declaration.

TYPE: int

SharingConstraint didactic-model

SharingConstraint(*, name: str, type_expr: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

with family T = U: an abstract family of a signature made manifest.

ATTRIBUTE DESCRIPTION
name

The family item of the refined signature.

TYPE: str

type_expr

The type it equals.

TYPE: QiecTypeExpr

line, col

The location of the constraint.

TYPE: int

SignatureDecl didactic-model

SignatureDecl(*, name: str, items: tuple[Statement, ...] = (), definition: SignatureExpr | None = None, equations: tuple[EquationDecl, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['signature_decl'] = 'signature_decl')

Bases: Statement

signature S with items, or signature S = T with ....

ATTRIBUTE DESCRIPTION
name

The signature's name.

TYPE: str

items

Its items, in order.

TYPE: tuple[Statement, ...]

definition

The refined signature it abbreviates, for the = form.

TYPE: SignatureExpr | None

equations

The laws of its equations blocks.

TYPE: tuple[EquationDecl, ...]

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the declaration.

TYPE: int

SignatureExpr didactic-model

SignatureExpr(*, base: str, constraints: tuple[SharingConstraint, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A signature reference refined by sharing constraints.

ATTRIBUTE DESCRIPTION
base

The signature's name, as name resolution reads it.

TYPE: str

constraints

The with family constraints, in order.

TYPE: tuple[SharingConstraint, ...]

line, col

The location of the reference.

TYPE: int

HoleDecl didactic-model

HoleDecl(*, path: str, signature: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['hole_decl'] = 'hole_decl')

Bases: Statement

hole P : S.

ATTRIBUTE DESCRIPTION
path

The dotted module path the hole occupies.

TYPE: str

signature

The signature the hole is checked against, as written.

TYPE: str

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the statement.

TYPE: int

LinkDecl didactic-model

LinkDecl(*, hole: str, module: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['link_decl'] = 'link_decl')

Bases: Statement

link P = M.

ATTRIBUTE DESCRIPTION
hole

The dotted path of the hole filled.

TYPE: str

module

The dotted path of the module that fills it.

TYPE: str

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the statement.

TYPE: int

ShareDecl didactic-model

ShareDecl(*, site: str, target: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['share_decl'] = 'share_decl')

Bases: Statement

share x with y.

ATTRIBUTE DESCRIPTION
site

The path whose sites and parameters are tied, as resolved.

TYPE: str

target

The path they are tied to, as resolved.

TYPE: str

docs

Doc-comment lines.

TYPE: tuple[str, ...]

line, col

The location of the statement.

TYPE: int

BindStep didactic-model

BindStep(*, vars: tuple[str, ...], morphism: str, args: tuple[DrawArg, ...] | None = None, index: ObjectExpr | None = None, mode: Literal['sample', 'score', 'marginal'] = 'sample', scope: tuple[ProgramStep, ...] | None = None, axes: AxisSpec | None = None, over: str | None = None, over_objs: tuple[str, ...] | None = None, via: str | None = None, via_axes: tuple[str, ...] | None = None, reduction: str | None = None, weights: str | float | None = None, event: ObservationEvent | None = None, bindings: tuple[ApplyBinding, ...] = (), line: int = 0, col: int = 0, kind: Literal['bind_step'] = 'bind_step')

Bases: ProgramStep

Internal compiler IR: a unified Kleisli bind.

Synthesized from surface SampleStep / ObserveStep / MarginalizeStep during template instantiation. The surface AST never carries this shape directly.

CallStep didactic-model

CallStep(*, name: str, call: QiecCallComputation, bindings: tuple[ApplyBinding, ...] = (), forwards_inputs: bool = False, line: int = 0, col: int = 0, kind: Literal['call_step'] = 'call_step')

Bases: ProgramStep

let name <- computation(args) [bindings] binding step.

The bound name takes the result of a named computation declared in the module; the computation's effects join the program's row. A call of a program supplies its leading parameters as arguments and binds the program's remaining data inputs, its input labels, in the bracket block; the program's observations and the parameters of the morphisms it draws from, which the module names, are this program's under the same names.

ATTRIBUTE DESCRIPTION
name

The name bound to the result.

TYPE: str

call

The call.

TYPE: QiecCallComputation

bindings

The bindings of the called program's input labels.

TYPE: tuple[ApplyBinding, ...]

forwards_inputs

Whether every input of the called program the arguments leave unsupplied is an input of this program under its own label. Only the step program a scan generates around its cell forwards its inputs, its own input labels being the cell's; no source spelling sets it.

TYPE: bool

line

The 1-based source line, or 0 when unknown.

TYPE: int

col

The 0-based source column, or 0 when unknown.

TYPE: int

kind

The variant tag.

TYPE: Literal['call_step']

DrawArg didactic-model

DrawArg()

Bases: TaggedUnion

A single argument in a draw step. Variants cover all four surface shapes the parser can produce: bare identifier (variable reference), numeric literal, distribution-call expression (compositional measure algebra), and list of args.

Sum-type representation rather than a Python union so the panproto translation can carry the AST through the grammar walker, the migration lens, and the pretty-printer uniformly.

DrawArgDist didactic-model

DrawArgDist(*, family: str, args: tuple[DrawArg, ...], line: int = 0, col: int = 0, kind: Literal['dist'] = 'dist')

Bases: DrawArg

Nested Family(...) call inside the args of a draw step.

Surfaces the compositional measure algebra (Mixture, Restrict, Pushforward, PointMass, ...) so distributions can be expressed as ordinary draw-arg expressions:

observe y <- Mixture([0.3, 0.7], [PointMass(0), Poisson(rate)])

The compiler recurses into args to build the inner measure before passing it to the outer family's builder.

DrawArgIndex didactic-model

DrawArgIndex(*, name: str, indices: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['index'] = 'index')

Bases: DrawArg

Bracket-indexed reference in a draw step. name is the base tensor identifier; indices is the tuple of index-tensor identifiers referenced inside the brackets (typically length one, e.g. theta[N]). Both the base name and every index identifier count as dependencies for plate-graph edge emission.

DrawArgList didactic-model

DrawArgList(*, items: tuple[DrawArg, ...], line: int = 0, col: int = 0, kind: Literal['list'] = 'list')

Bases: DrawArg

List-of-draw-args, e.g. [0.3, 0.7] for mixture weights or [PointMass(0), Poisson(rate)] for mixture components. The compiler unpacks the list into a vector or list of inner distributions depending on the consuming family's argument schema.

DrawArgName didactic-model

DrawArgName(*, text: str, line: int = 0, col: int = 0, kind: Literal['name'] = 'name')

Bases: DrawArg

Bare identifier reference in a draw step. Carries only the identifier text; bracket-indexed forms (theta[N]) parse to the dedicated DrawArgIndex variant.

DrawArgNamed didactic-model

DrawArgNamed(*, parameter: str, value: DrawArg, line: int = 0, col: int = 0, kind: Literal['named'] = 'named')

Bases: DrawArg

One keyword argument in a distribution-family construction.

The parameter name is structural: it wraps the argument value instead of being optional metadata on that value. Rewriters must therefore preserve or deliberately transform the complete named entry, and cannot accidentally erase a parameterization while rebuilding its value.

DrawArgScalar didactic-model

DrawArgScalar(*, value: int | float, line: int = 0, col: int = 0, kind: Literal['scalar'] = 'scalar')

Bases: DrawArg

Numeric literal, preserving integer lexemes before numerical execution.

DrawStep didactic-model

DrawStep(*, vars: tuple[str, ...], morphism: str, args: tuple[DrawArg, ...] | None = None, is_observed: bool = False, axes: AxisSpec | None = None, weights: str | float | None = None, event: ObservationEvent | None = None, bindings: tuple[ApplyBinding, ...] = (), line: int = 0, col: int = 0, kind: Literal['draw_step'] = 'draw_step')

Bases: ProgramStep

Internal compiler IR: a scalar sample or score step.

Synthesised from a SampleStep/ObserveStep with no index annotation; is_observed distinguishes sample (False) from score (True). A draw from a program keeps its bindings of the program's input labels.

GroupedBodyObserveStep didactic-model

GroupedBodyObserveStep(*, response_var: str, morphism: str, args: tuple[DrawArg, ...] | None = None, index_set: ObjectExpr | None = None, index_var: str = '', latent_name: str = '', class_size: int = 0, index_map_var: str | None = None, index_map_axes: tuple[str, ...] | None = None, ll_slot: str = '', weights: str | float | None = None, event: ObservationEvent | None = None, line: int = 0, col: int = 0, kind: Literal['grouped_body_observe_step'] = 'grouped_body_observe_step')

Bases: ProgramStep

Internal compiler IR: a captured observe inside a grouped marginalize block.

GroupedLatentInitStep didactic-model

GroupedLatentInitStep(*, latent_name: str, class_size: int, line: int = 0, col: int = 0, kind: Literal['grouped_latent_init_step'] = 'grouped_latent_init_step')

Bases: ProgramStep

Internal compiler IR: initialise the latent's env slot to torch.arange(class_size) at the start of a grouped marginalize block's body.

GroupedMarginalizeStep didactic-model

GroupedMarginalizeStep(*, var_name: str, class_size: int, probs_var: str | None = None, probs_indices: tuple[str, ...] = (), parameterization: Literal['probs', 'logits'] = 'probs', over_obj: str | None = None, over_objs: tuple[str, ...] | None = None, body_ll_var: str = '', body_observes: tuple[GroupedObserveEntry, ...] | None = None, reduction: str | None = None, line: int = 0, col: int = 0, kind: Literal['grouped_marginalize_step'] = 'grouped_marginalize_step')

Bases: ProgramStep

Internal compiler IR: a marginalisation pushforward.

The compiler lowers a surface MarginalizeStep into this shape after expanding the scope. class_size is the resolved cardinality of the latent index; probs_var names the env slot holding the family's probability or logits tensor, which probs_indices gather rows of, left to right, when the prior is written probs[latent] against an enclosing latent; parameterization records whether that tensor is probabilities or logits; over_obj / over_objs carry the grouping object (single or product); body_ll_var names the env slot that the grouped observe pushed its (N_m, K) log-likelihood into; body_observes lists the (ll_slot, index map) entries that the runtime callable consumes for grouped pushforward.

GroupedObserveEntry didactic-model

GroupedObserveEntry(*, ll_slot: str, index_map_var: str | None = None, index_map_axes: tuple[str, ...] | None = None, inner_groups: tuple[str, ...] | None = None, line: int = 0, col: int = 0)

Bases: Model

One entry in a GroupedMarginalizeStep's body_observes list.

Pairs an env slot (where the captured observe writes its (N_m, K) log-likelihood) with the index map that carries those rows into the shared grouping plate. An entry with no index map is a nested grouped block: the slot holds the inner block's per-position aggregates over inner_groups, which the enclosing block projects onto its own grouping plate.

LetStep didactic-model

LetStep(*, name: str, value: LetExprNode, line: int = 0, col: int = 0, kind: Literal['let_step'] = 'let_step')

Bases: ProgramStep

let name = value deterministic step.

The value is a let-arithmetic expression evaluated against the surrounding program env.

MarginalizeStep didactic-model

MarginalizeStep(*, var: str, morphism: str, args: tuple[DrawArg, ...] | None = None, static_args: tuple[DrawArg, ...] = (), index: ObjectExpr | None = None, over: str | None = None, over_objs: tuple[str, ...] | None = None, reduction: str | None = None, options: tuple[OptionEntry, ...] = (), scope: tuple[ProgramStep, ...] = (), line: int = 0, col: int = 0, kind: Literal['marginalize_step'] = 'marginalize_step')

Bases: ProgramStep

marginalize var[: index] <- morphism(args) [options] : scope.

Introduces a coordinate, executes the scope's steps with that coordinate in trace context, and at the end of the scope pushes forward through the projection (logsumexp for discrete, fibrewise integration for continuous). When the option block carries over=..., the reduction is grouped (grouped marginalize); the via clause on each inner observe names the per-observe index map.

ObserveStep didactic-model

ObserveStep(*, vars: tuple[str, ...], morphism: str, args: tuple[DrawArg, ...] | None = None, static_args: tuple[DrawArg, ...] = (), index: ObjectExpr | None = None, axes: AxisSpec | None = None, via: str | None = None, via_axes: tuple[str, ...] | None = None, options: tuple[OptionEntry, ...] = (), morphism_is_module_bound: bool = False, line: int = 0, col: int = 0, kind: Literal['observe_step'] = 'observe_step')

Bases: ProgramStep

observe vars[: index] <- morphism(args) [options].

Scored Kleisli bind; the bound coordinate is clamped at runtime by the observations dict, making the resulting kernel sub-probabilistic. vars shares the pattern shape with SampleStep (a bare name or a parenthesized tuple); the compiler validates arity against the morphism's codomain. A leaf resolved by the recipe expander names a module binding and is independent of the enclosing program's morphism formals.

PlateDrawStep didactic-model

PlateDrawStep(*, name: str, index: ObjectExpr, codomain: ObjectExpr, morphism: str, args: tuple[DrawArg, ...] | None = None, axes: AxisSpec | None = None, line: int = 0, col: int = 0, kind: Literal['plate_draw_step'] = 'plate_draw_step')

Bases: ProgramStep

Internal compiler IR: an A-indexed sample step.

Synthesised from a SampleStep with an index annotation; realises a Kern-morphism A -> Kern(K) as a tensor of shape (|A|, *K.shape).

ProgramStep didactic-model

ProgramStep()

Bases: TaggedUnion

Sum of program-block step node kinds.

ReturnStep didactic-model

ReturnStep(*, vars: tuple[str, ...], labels: tuple[str, ...] | None = None, line: int = 0, col: int = 0, kind: Literal['return_step'] = 'return_step')

Bases: ProgramStep

return v or return (a, b) or return (a: x, b: y) step.

Always the terminal step of a program body. labels is non-None for the labelled-tuple form return (a: x, b: y).

SampleStep didactic-model

SampleStep(*, vars: tuple[str, ...], morphism: str, operation: Literal['sample', 'program', 'apply'] = 'sample', args: tuple[DrawArg, ...] | None = None, static_args: tuple[DrawArg, ...] = (), index: ObjectExpr | None = None, axes: AxisSpec | None = None, options: tuple[OptionEntry, ...] = (), bindings: tuple[ApplyBinding, ...] = (), morphism_is_module_bound: bool = False, line: int = 0, col: int = 0, kind: Literal['sample_step'] = 'sample_step')

Bases: ProgramStep

A model bind with an explicit draw, template, or recipe operation.

The optional index and axis options constrain the model's plate. A template may destructure its return and may take static arguments. A leaf resolved by the recipe expander names a module binding and is independent of the enclosing program's morphism formals. The bracket block of an apply step and of a draw from a program holds ApplyBinding entries, which supply the input labels of the applied definition or of the program, in place of options.

ScoreStep didactic-model

ScoreStep(*, name: str, value: LetExprNode, line: int = 0, col: int = 0, kind: Literal['score_step'] = 'score_step')

Bases: ProgramStep

score name = value log-density factor step.

Like LetStep in that name is bound to the evaluated expression's value for downstream reference, but distinct in that the value is additionally added to the program's log_joint. This is the deduction-style analog of ObserveStep: the chart's goal_weight is a log-density factor on the corpus, and score log_Z = chart.goal_weight() expresses that contribution as a first-class step.

VectorisedObserveStep didactic-model

VectorisedObserveStep(*, index_var: str, index_set: ObjectExpr, morphism: str, args: tuple[DrawArg, ...] | None = None, response_var: str = '', index_map_var: str | None = None, index_map_axes: tuple[str, ...] | None = None, axes: AxisSpec | None = None, weights: str | float | None = None, event: ObservationEvent | None = None, line: int = 0, col: int = 0, kind: Literal['vectorized_observe_step'] = 'vectorized_observe_step')

Bases: ProgramStep

Internal compiler IR: an A-indexed score step.

Synthesised from an ObserveStep with an index annotation; denotes the sub-probabilistic kernel Phi -> Kern_{<=1}(Phi) with score prod_n p_F(r_obs(n); theta(n, phi)).

ApplyBinding didactic-model

ApplyBinding(*, label: str, value: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

One binding label = value of a step's bracket block.

The label is an input label of what the step runs. For an apply step it is a free data name that one of the applied definition's scan cells reads, or the name a scan's init= gives its initial state; for a draw from a program (let x <- program p(a) [...]) or a call of one (let y <- p(a) [...]) it is a data input of the program: a free name its steps read, an index map it reads, or a declared value parameter the arguments leave unsupplied. The value is resolved in the calling program's scope where the step is written: a name bound by an earlier step, else a data input of the calling program, or a numeric literal. The pun [label] binds the label to the name spelled like it.

PARAMETER DESCRIPTION
label

The input label of the applied definition or the program.

TYPE: str

value

The bound value: a LetExprVar or a LetExprLiteral.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

DerivingDecl didactic-model

DerivingDecl(*, classes: tuple[DerivingClass, ...], family: str, shown: str = '', docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['deriving_decl'] = 'deriving_decl')

Bases: Statement

deriving (CLASSES) for FAMILY: derive classes for a named family.

The family may be one a declaration generates, such as a deduction's item family.

PARAMETER DESCRIPTION
classes

The classes, in order.

TYPE: tuple[DerivingClass, ...]

family

The family's name.

TYPE: str

shown

How diagnostics name the family when it is generated under a name people do not write, such as a deduction signature's item family at one sort instantiation (std.grammar.ccg.Categorial.Item); empty to name it by family.

TYPE: str DEFAULT: ''

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "deriving_decl".

TYPE: Literal['deriving_decl'] DEFAULT: 'deriving_decl'

MetaDecl didactic-model

MetaDecl(*, declaration: QiecComputationDecl | QiecFamilyDecl | QiecIndexDecl | ImportDecl, line: int = 0, col: int = 0, kind: Literal['meta_decl'] = 'meta_decl')

Bases: Statement

meta DECLARATION: a declaration that exists in the meta phase only.

PARAMETER DESCRIPTION
declaration

The computation, family, or index sort declared for the meta phase, or the import (meta import M) whose module is available to the meta phase only.

TYPE: QiecComputationDecl | QiecFamilyDecl | QiecIndexDecl | ImportDecl

line

The 1-based source line of meta, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column of meta, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "meta_decl".

TYPE: Literal['meta_decl'] DEFAULT: 'meta_decl'

SpliceDecl didactic-model

SpliceDecl(*, generator: str, static_arguments: tuple[QiecStaticArgument, ...] = (), arguments: tuple[LetExprNode, ...] = (), line: int = 0, col: int = 0, kind: Literal['splice_decl'] = 'splice_decl')

Bases: Statement

$generator[static](arguments): declarations generated at check time.

PARAMETER DESCRIPTION
generator

The meta computation called. It returns one quoted declaration (SynDecl) or a sequence of them (Seq[SynDecl]).

TYPE: str

static_arguments

Its static arguments, in order.

TYPE: tuple[QiecStaticArgument, ...] DEFAULT: ()

arguments

Its value arguments, in order; calls of meta computations may occur in them.

TYPE: tuple[LetExprNode, ...] DEFAULT: ()

line

The 1-based source line of $, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column of $, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "splice_decl".

TYPE: Literal['splice_decl'] DEFAULT: 'splice_decl'

StaticAssertDecl didactic-model

StaticAssertDecl(*, condition: LetExprNode, source: str = '', docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['static_assert_decl'] = 'static_assert_decl')

Bases: Statement

static assert VALUE: a Boolean evaluated while the module is checked.

PARAMETER DESCRIPTION
condition

The asserted value. Calls of meta computations may occur in it.

TYPE: LetExprNode

source

The condition's source text, quoted by a failure diagnostic.

TYPE: str DEFAULT: ''

docs

The doc comment lines attached to the assertion.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "static_assert_decl".

TYPE: Literal['static_assert_decl'] DEFAULT: 'static_assert_decl'

NameSpelling didactic-model

NameSpelling(*, flat: str, written: str)

Bases: Model

How the root module writes one name another module declares.

PARAMETER DESCRIPTION
flat

The name in the flat program, module:name.

TYPE: str

written

The name as the root module writes it: bare when the root imports or opens it unqualified, qualified by the import's alias or path otherwise.

TYPE: str

NameSpellingsDecl didactic-model

NameSpellingsDecl(*, entries: tuple[NameSpelling, ...] = (), kind: Literal['name_spellings_decl'] = 'name_spellings_decl')

Bases: Statement

The root module's spelling of the imported names a program prints.

Static interpretation adds it to a flat program whose root imports a signature, so the generated show of the signature's sorts writes a constructor as the root module's source writes it.

PARAMETER DESCRIPTION
entries

One spelling per imported constructor.

TYPE: tuple[NameSpelling, ...] DEFAULT: ()

kind

The discriminator; always "name_spellings_decl".

TYPE: Literal['name_spellings_decl'] DEFAULT: 'name_spellings_decl'

NotationAntiquote didactic-model

NotationAntiquote(*, name: str | None = None, value: LetExprNode | None = None, start: int = 0, end: int = 0, line: int = 0, col: int = 0, kind: Literal['notation_antiquote'] = 'notation_antiquote')

Bases: NotationItem

$x or $(e): a value of the host language inside a quotation.

In an expression quotation the antiquoted value is spliced; in a pattern quotation $x binds x to the matched subterm and $_ matches anything.

PARAMETER DESCRIPTION
name

The name of $x, or None for $(e).

TYPE: str | None DEFAULT: None

value

The value of $(e), or None for $x.

TYPE: LetExprNode | None DEFAULT: None

start

The byte offset of $.

TYPE: int DEFAULT: 0

end

The byte offset just past the antiquotation.

TYPE: int DEFAULT: 0

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "notation_antiquote".

TYPE: Literal['notation_antiquote'] DEFAULT: 'notation_antiquote'

NotationAtom didactic-model

NotationAtom(*, category: Literal['identifier', 'integer', 'string', 'symbol'], text: str, start: int = 0, end: int = 0, line: int = 0, col: int = 0, kind: Literal['notation_atom'] = 'notation_atom')

Bases: NotationItem

A token of a quotation: a name, an integer, a string, or a symbol run.

PARAMETER DESCRIPTION
category

"identifier", "integer", "string", or "symbol".

TYPE: Literal['identifier', 'integer', 'string', 'symbol']

text

The token as written (a string keeps its quotes).

TYPE: str

start

The token's byte offset in its file, which tells adjacent tokens apart from tokens separated by space.

TYPE: int DEFAULT: 0

end

The byte offset just past the token.

TYPE: int DEFAULT: 0

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "notation_atom".

TYPE: Literal['notation_atom'] DEFAULT: 'notation_atom'

NotationDecl didactic-model

NotationDecl(*, name: str, syntax: str, productions: tuple[NotationProduction, ...] = (), relations: tuple[NotationRelation, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['notation_decl'] = 'notation_decl')

Bases: Statement

notation NAME for SYNTAX: mixfix productions over a signature.

PARAMETER DESCRIPTION
name

The notation's name.

TYPE: str

syntax

The binding signature its templates are terms of.

TYPE: str

productions

The productions, in declaration order.

TYPE: tuple[NotationProduction, ...] DEFAULT: ()

relations

The precedence relations.

TYPE: tuple[NotationRelation, ...] DEFAULT: ()

docs

The doc comment lines.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "notation_decl".

TYPE: Literal['notation_decl'] DEFAULT: 'notation_decl'

NotationGroup didactic-model

NotationGroup(*, opener: Literal['(', '[', '{'], items: tuple[NotationItem, ...] = (), start: int = 0, end: int = 0, line: int = 0, col: int = 0, kind: Literal['notation_group'] = 'notation_group')

Bases: NotationItem

A bracketed group of a quotation's token tree.

PARAMETER DESCRIPTION
opener

"(", "[", or "{".

TYPE: Literal['(', '[', '{']

items

The items between the brackets.

TYPE: tuple[NotationItem, ...] DEFAULT: ()

start

The byte offset of the opening bracket.

TYPE: int DEFAULT: 0

end

The byte offset just past the closing bracket.

TYPE: int DEFAULT: 0

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "notation_group".

TYPE: Literal['notation_group'] DEFAULT: 'notation_group'

NotationItem didactic-model

NotationItem()

Bases: TaggedUnion

One item of a quotation's token tree.

NotationPatternItem didactic-model

NotationPatternItem(*, token: str | None = None, hole: str | None = None, line: int = 0, col: int = 0)

Bases: Model

One item of a production's shape: a quoted token or a hole.

PARAMETER DESCRIPTION
token

The token's text as written between the quotes (leading and trailing spaces are printing space), or None for a hole.

TYPE: str | None DEFAULT: None

hole

The hole's name, or None for a token.

TYPE: str | None DEFAULT: None

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

NotationProduction didactic-model

NotationProduction(*, name: str, items: tuple[NotationPatternItem, ...], template: PatternSyntax, options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

name : shape [options] => template: one mixfix production.

PARAMETER DESCRIPTION
name

The production's name, unique in its notation.

TYPE: str

items

The shape: quoted tokens and holes, in order.

TYPE: tuple[NotationPatternItem, ...]

template

The term the production stands for, over the holes.

TYPE: PatternSyntax

options

The option block (assoc=left|right|none).

TYPE: tuple[OptionEntry, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

NotationRelation didactic-model

NotationRelation(*, left: str, relation: Literal['>', '='], right: str, line: int = 0, col: int = 0)

Bases: Model

a > b (a binds tighter) or a = b (one precedence level).

PARAMETER DESCRIPTION
left

The left production, possibly qualified by its notation.

TYPE: str

relation

">" or "=".

TYPE: Literal['>', '=']

right

The right production.

TYPE: str

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

OpenNotationDecl didactic-model

OpenNotationDecl(*, target: str, notations: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['open_notation_decl'] = 'open_notation_decl')

Bases: Statement

open notation X: activate notations for the rest of the module.

PARAMETER DESCRIPTION
target

A notation declaration (bare or qualified by an import) or a module whose exported notations all become active, as written.

TYPE: str

notations

The flat names of the notations it activates, filled in when the module is resolved.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "open_notation_decl".

TYPE: Literal['open_notation_decl'] DEFAULT: 'open_notation_decl'

QiecQuotation didactic-model

QiecQuotation(*, items: tuple[NotationItem, ...] = (), notations: tuple[str, ...] = (), scoped: bool = False, source: str = '', start: int = 0, line: int = 0, col: int = 0, kind: Literal['qiec_quotation'] = 'qiec_quotation')

Bases: LetExprNode

[| ... |] in a value position: a term written in active notation.

PARAMETER DESCRIPTION
items

The token tree.

TYPE: tuple[NotationItem, ...] DEFAULT: ()

notations

The flat names of the notations active where the quotation stands, in activation order; filled in when the module's open notation statements are read.

TYPE: tuple[str, ...] DEFAULT: ()

scoped

Whether notations has been filled in.

TYPE: bool DEFAULT: False

source

The quotation's source text, for diagnostics and hover.

TYPE: str DEFAULT: ''

start

The byte offset of [| in its file; a token's offset less this is its position in source.

TYPE: int DEFAULT: 0

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_quotation".

TYPE: Literal['qiec_quotation'] DEFAULT: 'qiec_quotation'

QiecQuotationPattern didactic-model

QiecQuotationPattern(*, items: tuple[NotationItem, ...] = (), notations: tuple[str, ...] = (), scoped: bool = False, source: str = '', start: int = 0, line: int = 0, col: int = 0, kind: Literal['qiec_quotation_pattern'] = 'qiec_quotation_pattern')

Bases: QiecPattern

[| ... |] in a pattern position.

PARAMETER DESCRIPTION
items

The token tree.

TYPE: tuple[NotationItem, ...] DEFAULT: ()

notations

The flat names of the active notations, as for QiecQuotation.

TYPE: tuple[str, ...] DEFAULT: ()

scoped

Whether notations has been filled in.

TYPE: bool DEFAULT: False

source

The quotation's source text.

TYPE: str DEFAULT: ''

start

The byte offset of [| in its file; a token's offset less this is its position in source.

TYPE: int DEFAULT: 0

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_quotation_pattern".

TYPE: Literal['qiec_quotation_pattern'] DEFAULT: 'qiec_quotation_pattern'

DerivingClass didactic-model

DerivingClass(*, name: str, static_arguments: tuple[QiecStaticArgument, ...] = (), morphisms: tuple[str, ...] = (), line: int = 0, col: int = 0)

Bases: Model

One class of a deriving (...) clause, as in Quote[Term via q].

PARAMETER DESCRIPTION
name

The class, which names the meta computation that handles it.

TYPE: str

static_arguments

The static arguments written in brackets before via, in order.

TYPE: tuple[QiecStaticArgument, ...] DEFAULT: ()

morphisms

The meta computations named after via, in order; each is evaluated at check time and its value passed to the handler.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecBindComputation didactic-model

QiecBindComputation(*, binder: QiecLocalBinding, first: QiecComputation, then: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_bind_computation'] = 'qiec_bind_computation')

Bases: QiecComputation

let x <- FIRST followed by a computation reading x.

PARAMETER DESCRIPTION
binder

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

TYPE: QiecLocalBinding

first

The computation run first.

TYPE: QiecComputation

then

The computation the binding scopes over.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_bind_computation".

TYPE: Literal['qiec_bind_computation'] DEFAULT: 'qiec_bind_computation'

QiecBinder didactic-model

QiecBinder()

Bases: TaggedUnion

One entry in a heterogeneous static telescope.

QiecCaseBranch didactic-model

QiecCaseBranch(*, pattern: QiecPattern, guard: QiecValue | None = None, body: QiecComputation, line: int = 0, col: int = 0)

Bases: Model

One branch of a case analysis: a pattern, a guard, and a body.

PARAMETER DESCRIPTION
pattern

The pattern the scrutinee is matched against.

TYPE: QiecPattern

guard

A pure Boolean value the branch also requires, or None.

TYPE: QiecValue | None DEFAULT: None

body

The branch body.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecCaseComputation didactic-model

QiecCaseComputation(*, scrutinee: QiecValue, motive: QiecCaseMotive | None = None, branches: tuple[QiecCaseBranch, ...], line: int = 0, col: int = 0, kind: Literal['qiec_case_computation'] = 'qiec_case_computation')

Bases: QiecComputation

Case analysis over an indexed family value.

PARAMETER DESCRIPTION
scrutinee

The value analysed.

TYPE: QiecValue

motive

The motive the branches are checked against, or None when the case is checked against the type its position expects.

TYPE: QiecCaseMotive | None DEFAULT: None

branches

The branches, in order; the first whose pattern and guard match is taken.

TYPE: tuple[QiecCaseBranch, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_case_computation".

TYPE: Literal['qiec_case_computation'] DEFAULT: 'qiec_case_computation'

QiecIfComputation didactic-model

QiecIfComputation(*, condition: QiecValue, then: QiecComputation, otherwise: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_if_computation'] = 'qiec_if_computation')

Bases: QiecComputation

if COND then ... else ..., branching on a Boolean value.

PARAMETER DESCRIPTION
condition

The Boolean value branched on.

TYPE: QiecValue

then

The computation run when the condition holds.

TYPE: QiecComputation

otherwise

The computation run when it does not.

TYPE: QiecComputation

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_if_computation".

TYPE: Literal['qiec_if_computation'] DEFAULT: 'qiec_if_computation'

QiecCaseMotive didactic-model

QiecCaseMotive(*, indices: tuple[QiecIndexBinder, ...], result_type: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

The motive of a case analysis: the indices it abstracts and the result type they determine.

PARAMETER DESCRIPTION
indices

The index binders the motive abstracts over.

TYPE: tuple[QiecIndexBinder, ...]

result_type

The result type under those binders.

TYPE: QiecTypeExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecComputation didactic-model

QiecComputation()

Bases: TaggedUnion

A computation in the QIEC fine-grain call-by-value surface.

QiecComputationDecl didactic-model

QiecComputationDecl(*, name: str, binders: tuple[QiecBinder, ...] = (), parameters: tuple[QiecValueParameter, ...] = (), result_type: QiecTypeExpr, effects: QiecEffectRow, body: QiecComputation, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['computation_decl'] = 'computation_decl', locals: tuple[QiecComputationDecl, ...] = (), module_parameters: tuple[QiecModuleBinder, ...] = ())

Bases: Statement

define NAME[binders](params) : TYPE !ROW = BODY, a named computation.

PARAMETER DESCRIPTION
name

The computation's name.

TYPE: str

binders

The static telescope.

TYPE: tuple[QiecBinder, ...] DEFAULT: ()

parameters

The value parameters.

TYPE: tuple[QiecValueParameter, ...] DEFAULT: ()

result_type

The declared result type.

TYPE: QiecTypeExpr

effects

The declared effect row.

TYPE: QiecEffectRow

body

The body.

TYPE: QiecComputation

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "computation_decl".

TYPE: Literal['computation_decl'] DEFAULT: 'computation_decl'

locals

The local definitions of its where block, which its body and each other may call and use as function values.

TYPE: tuple[QiecComputationDecl, ...] DEFAULT: ()

module_parameters

Its module parameters (module D : S and {module D : S}), each with its position among all parameters. Static interpretation specializes the computation at every module argument and removes them, so no compiled computation has one.

TYPE: tuple[QiecModuleBinder, ...] DEFAULT: ()

QiecInterpretationClause didactic-model

QiecInterpretationClause(*, constructor_kind: Literal['rule', 'axiom'], constructor: str, operation: str, line: int = 0, col: int = 0)

Bases: Model

A computation assigned to one rule or axiom slot.

PARAMETER DESCRIPTION
constructor_kind

Whether the constructor is a rule or an input axiom slot.

TYPE: Literal['rule', 'axiom']

constructor

The constructor's name in its deduction.

TYPE: str

operation

The name of the checked computation that interprets it.

TYPE: str

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

QiecInterpretationDecl didactic-model

QiecInterpretationDecl(*, name: str, deduction: str, carrier: QiecTypeExpr, clauses: tuple[QiecInterpretationClause, ...], options: tuple[OptionEntry, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['interpretation_decl'] = 'interpretation_decl')

Bases: Statement

A named computation that folds a checked deduction or structural proof.

PARAMETER DESCRIPTION
name

The computation's name.

TYPE: str

deduction

The deduction or structural signature whose proof family it consumes.

TYPE: str

carrier

The closed result type of the fold.

TYPE: QiecTypeExpr

clauses

One computation assignment per rule or axiom slot.

TYPE: tuple[QiecInterpretationClause, ...]

options

Structural permissions or the index map used by the interpretation.

TYPE: tuple[OptionEntry, ...] DEFAULT: ()

docs

The attached doc comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The syntax discriminator.

TYPE: Literal['interpretation_decl'] DEFAULT: 'interpretation_decl'

QiecRelationArc didactic-model

QiecRelationArc(*, source: int, target: int, labels: tuple[int | None, ...], weight: str)

Bases: Model

One primitive authored arc, with None denoting an epsilon label.

QiecRelationComposeDecl didactic-model

QiecRelationComposeDecl(*, name: str, left: str, right: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['relation_compose_decl'] = 'relation_compose_decl')

Bases: Statement

A binary composition of two named authored sparse relations.

PARAMETER DESCRIPTION
name

The resulting relation name.

TYPE: str

left

The ordered primitive relation operands.

TYPE: str

right

The ordered primitive relation operands.

TYPE: str

docs

The attached source doc comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The declaration discriminator.

TYPE: Literal['relation_compose_decl'] DEFAULT: 'relation_compose_decl'

QiecRelationDecl didactic-model

QiecRelationDecl(*, name: str, algebra: Literal['markov', 'logprob'], n_states: int, tapes: tuple[QiecRelationTape, ...], arcs: tuple[QiecRelationArc, ...] = (), initial: tuple[QiecRelationMark, ...] = (), final: tuple[QiecRelationMark, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['relation_decl'] = 'relation_decl')

Bases: Statement

A finite sparse topology over typed string tapes.

Tape order includes the input and output boundary. Each record in the arc tuple is a distinct occurrence. Identical weight names denote one original scalar parameter across the module.

PARAMETER DESCRIPTION
name

The authored relation name.

TYPE: str

algebra

The shipped Markov or LogProb scalar algebra.

TYPE: Literal['markov', 'logprob']

n_states

The number of finite control states.

TYPE: int

tapes

Ordered direction and finite alphabet names.

TYPE: tuple[QiecRelationTape, ...]

arcs

Ordered source, target, label tuple, and weight-name records.

TYPE: tuple[QiecRelationArc, ...] DEFAULT: ()

initial

The state and weight-name boundary records.

TYPE: tuple[QiecRelationMark, ...] DEFAULT: ()

final

The state and weight-name boundary records.

TYPE: tuple[QiecRelationMark, ...] DEFAULT: ()

docs

The attached documentation comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The declaration discriminator.

TYPE: Literal['relation_decl'] DEFAULT: 'relation_decl'

QiecRelationMark didactic-model

QiecRelationMark(*, state: int, weight: str)

Bases: Model

One initial or final occurrence of a named weight at a state.

QiecRelationTape didactic-model

QiecRelationTape(*, direction: Literal['input', 'output'], alphabet: str)

Bases: Model

One typed input or output tape of an authored relation.

QiecRelationTransformDecl didactic-model

QiecRelationTransformDecl(*, name: str, operation: Literal['invert', 'trim', 'closure', 'project', 'condition', 'auto_intersect', 'union', 'concatenate', 'intersect', 'join'], source: str, other: str | None = None, positions: tuple[int, ...] = (), word: tuple[int, ...] | None = None, keep_shared: bool = False, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['relation_transform_decl'] = 'relation_transform_decl')

Bases: Statement

An authored unary or binary sparse relation transformation.

PARAMETER DESCRIPTION
name

The resulting relation's name.

TYPE: str

operation

The sparse transformation applied to the source operands.

TYPE: Literal['invert', 'trim', 'closure', 'project', 'condition', 'auto_intersect', 'union', 'concatenate', 'intersect', 'join']

source

Named primitive operands in operation order.

TYPE: str

other

Named primitive operands in operation order.

TYPE: str

positions

Original tape positions for projection, conditioning, equality, or join.

TYPE: tuple[int, ...] DEFAULT: ()

word

The fixed word of a conditioning operation, including empty.

TYPE: tuple[int, ...] | None DEFAULT: None

keep_shared

Whether a join retains the synchronized tape.

TYPE: bool DEFAULT: False

docs

The attached source documentation comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The declaration discriminator.

TYPE: Literal['relation_transform_decl'] DEFAULT: 'relation_transform_decl'

QiecRelationScoreDecl didactic-model

QiecRelationScoreDecl(*, name: str, result_type: QiecTypeExpr, operation: Literal['pair_weight', 'conditional_log_prob', 'path_entropy', 'expected_path_cost'], relation: str | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['relation_score_decl'] = 'relation_score_decl')

Bases: Statement

A named score whose fixed relation request is supplied at runtime.

PARAMETER DESCRIPTION
name

The generated computation name.

TYPE: str

result_type

The closed scalar type of the score.

TYPE: QiecTypeExpr

operation

The relation objective the runtime attachment must implement.

TYPE: Literal['pair_weight', 'conditional_log_prob', 'path_entropy', 'expected_path_cost']

relation

The optional authored topology required by the score.

TYPE: str | None DEFAULT: None

docs

The attached source doc comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The declaration discriminator.

TYPE: Literal['relation_score_decl'] DEFAULT: 'relation_score_decl'

QiecStringGraphDecl didactic-model

QiecStringGraphDecl(*, name: str, variables: tuple[QiecStringGraphVariable, ...], factors: tuple[QiecStringGraphFactor, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['string_graph_decl'] = 'string_graph_decl')

Bases: Statement

An ordered declaration of variables and sparse factor occurrences.

PARAMETER DESCRIPTION
name

The authored graph name.

TYPE: str

variables

Nominally typed variables and their observed words.

TYPE: tuple[QiecStringGraphVariable, ...]

factors

Ordered relation references and their variable scopes.

TYPE: tuple[QiecStringGraphFactor, ...]

docs

Attached documentation comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The declaration discriminator.

TYPE: Literal['string_graph_decl'] DEFAULT: 'string_graph_decl'

QiecStringGraphFactor didactic-model

QiecStringGraphFactor(*, relation: str, scope: tuple[str, ...])

Bases: Model

One ordered occurrence of an existing authored sparse relation.

QiecStringGraphVariable didactic-model

QiecStringGraphVariable(*, name: str, alphabet: str, observed: tuple[int, ...] | None = None)

Bases: Model

One nominal string variable with an optional observed word.

QiecStringGraphScoreDecl didactic-model

QiecStringGraphScoreDecl(*, name: str, result_type: QiecTypeExpr, operation: Literal['tree_partition', 'tree_log_prob'], graph: str | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['string_graph_score_decl'] = 'string_graph_score_decl')

Bases: Statement

A named partition or normalized word score on a runtime string graph.

QiecConstructorValue didactic-model

QiecConstructorValue(*, constructor: str, static_arguments: tuple[QiecStaticArgument, ...] = (), fields: tuple[QiecValue, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_constructor_value'] = 'qiec_constructor_value')

Bases: LetExprNode

A constructor applied to explicit static arguments, C[..](..).

A constructor applied without static arguments is an ordinary call, LetExprCall, resolved to the constructor during elaboration.

PARAMETER DESCRIPTION
constructor

The constructor's name, qualified by its family as in Vec.Cons when the bare name is ambiguous.

TYPE: str

static_arguments

The family parameters and constructor-local static arguments.

TYPE: tuple[QiecStaticArgument, ...] DEFAULT: ()

fields

The field values, in declaration order.

TYPE: tuple[QiecValue, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_constructor_value".

TYPE: Literal['qiec_constructor_value'] DEFAULT: 'qiec_constructor_value'

QiecAnnotatedValue didactic-model

QiecAnnotatedValue(*, value: QiecValue, type_expr: QiecTypeExpr, line: int = 0, col: int = 0, kind: Literal['qiec_annotated_value'] = 'qiec_annotated_value')

Bases: LetExprNode

A value checked against a stated type, (e : T).

PARAMETER DESCRIPTION
value

The value checked.

TYPE: QiecValue

type_expr

The type it is checked against.

TYPE: QiecTypeExpr

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_annotated_value".

TYPE: Literal['qiec_annotated_value'] DEFAULT: 'qiec_annotated_value'

QiecPattern didactic-model

QiecPattern()

Bases: TaggedUnion

A pattern in a case branch head or a destructuring let.

QiecWildcardPattern didactic-model

QiecWildcardPattern(*, line: int = 0, col: int = 0, kind: Literal['qiec_wildcard_pattern'] = 'qiec_wildcard_pattern')

Bases: QiecPattern

_, matching any value and binding nothing.

PARAMETER DESCRIPTION
line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_wildcard_pattern".

TYPE: Literal['qiec_wildcard_pattern'] DEFAULT: 'qiec_wildcard_pattern'

QiecNamePattern didactic-model

QiecNamePattern(*, name: str, type_expr: QiecTypeExpr | None = None, line: int = 0, col: int = 0, kind: Literal['qiec_name_pattern'] = 'qiec_name_pattern')

Bases: QiecPattern

A bare name, x or x : T.

The name is a nullary constructor when the type the pattern is checked against declares one of that name, and a variable binding the matched value otherwise.

PARAMETER DESCRIPTION
name

The name written.

TYPE: str

type_expr

The annotated type, or None.

TYPE: QiecTypeExpr | None DEFAULT: None

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_name_pattern".

TYPE: Literal['qiec_name_pattern'] DEFAULT: 'qiec_name_pattern'

QiecConstructorPattern didactic-model

QiecConstructorPattern(*, constructor: str, static_binders: tuple[QiecTypeName, ...] = (), arguments: tuple[QiecPattern, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_constructor_pattern'] = 'qiec_constructor_pattern')

Bases: QiecPattern

A constructor applied to sub-patterns, C[k](p, q).

The name also resolves to a pattern synonym when one of that name is declared.

PARAMETER DESCRIPTION
constructor

The constructor or pattern synonym named.

TYPE: str

static_binders

The names the constructor's own static telescope binds.

TYPE: tuple[QiecTypeName, ...] DEFAULT: ()

arguments

The sub-patterns, one per field, in declaration order.

TYPE: tuple[QiecPattern, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_constructor_pattern".

TYPE: Literal['qiec_constructor_pattern'] DEFAULT: 'qiec_constructor_pattern'

QiecBinderPattern didactic-model

QiecBinderPattern(*, binders: tuple[str, ...], body: QiecPattern, line: int = 0, col: int = 0, kind: Literal['qiec_binder_pattern'] = 'qiec_binder_pattern')

Bases: QiecPattern

x y. p, opening a constructor argument that binds variables.

Legal only as a constructor argument whose declaration binds as many variables as there are names.

PARAMETER DESCRIPTION
binders

The names given to the bound variables, in binding order.

TYPE: tuple[str, ...]

body

The pattern the argument's body is matched against.

TYPE: QiecPattern

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_binder_pattern".

TYPE: Literal['qiec_binder_pattern'] DEFAULT: 'qiec_binder_pattern'

QiecLiteralPattern didactic-model

QiecLiteralPattern(*, value: LetExprNode, line: int = 0, col: int = 0, kind: Literal['qiec_literal_pattern'] = 'qiec_literal_pattern')

Bases: QiecPattern

A literal, 3, -1, "name", true, or unit.

PARAMETER DESCRIPTION
value

The literal as an expression node.

TYPE: LetExprNode

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_literal_pattern".

TYPE: Literal['qiec_literal_pattern'] DEFAULT: 'qiec_literal_pattern'

QiecTuplePattern didactic-model

QiecTuplePattern(*, items: tuple[QiecPattern, ...], line: int = 0, col: int = 0, kind: Literal['qiec_tuple_pattern'] = 'qiec_tuple_pattern')

Bases: QiecPattern

(p, q, ...), matching a product component by component.

PARAMETER DESCRIPTION
items

The component patterns, at least two.

TYPE: tuple[QiecPattern, ...]

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_tuple_pattern".

TYPE: Literal['qiec_tuple_pattern'] DEFAULT: 'qiec_tuple_pattern'

QiecRecordFieldPattern didactic-model

QiecRecordFieldPattern(*, label: str, pattern: QiecPattern | None = None, line: int = 0, col: int = 0)

Bases: Model

One labelled component of a record pattern.

PARAMETER DESCRIPTION
label

The component's label.

TYPE: str

pattern

The component's pattern, or None to bind it to its label.

TYPE: QiecPattern | None DEFAULT: None

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

QiecRecordPattern didactic-model

QiecRecordPattern(*, fields: tuple[QiecRecordFieldPattern, ...] = (), open: bool = False, line: int = 0, col: int = 0, kind: Literal['qiec_record_pattern'] = 'qiec_record_pattern')

Bases: QiecPattern

{l = p, m, ..}, matching labelled components.

PARAMETER DESCRIPTION
fields

The labelled component patterns.

TYPE: tuple[QiecRecordFieldPattern, ...] DEFAULT: ()

open

Whether a trailing .. leaves the other labels unmatched.

TYPE: bool DEFAULT: False

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_record_pattern".

TYPE: Literal['qiec_record_pattern'] DEFAULT: 'qiec_record_pattern'

QiecOrPattern didactic-model

QiecOrPattern(*, alternatives: tuple[QiecPattern, ...], line: int = 0, col: int = 0, kind: Literal['qiec_or_pattern'] = 'qiec_or_pattern')

Bases: QiecPattern

p | q, matching when either alternative does.

PARAMETER DESCRIPTION
alternatives

The alternatives, in order, at least two.

TYPE: tuple[QiecPattern, ...]

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_or_pattern".

TYPE: Literal['qiec_or_pattern'] DEFAULT: 'qiec_or_pattern'

QiecAsPattern didactic-model

QiecAsPattern(*, pattern: QiecPattern, name: str, line: int = 0, col: int = 0, kind: Literal['qiec_as_pattern'] = 'qiec_as_pattern')

Bases: QiecPattern

p as x, matching p and binding the whole value to x.

PARAMETER DESCRIPTION
pattern

The pattern matched.

TYPE: QiecPattern

name

The name bound to the whole value.

TYPE: str

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_as_pattern".

TYPE: Literal['qiec_as_pattern'] DEFAULT: 'qiec_as_pattern'

QiecPatternBinding didactic-model

QiecPatternBinding(*, pattern: QiecPattern, value: QiecValue, then: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_pattern_binding'] = 'qiec_pattern_binding')

Bases: QiecComputation

let p = VALUE, destructuring a pure expression with a pattern.

The pattern must match every value of the expression's type.

PARAMETER DESCRIPTION
pattern

The pattern the value is matched against.

TYPE: QiecPattern

value

The pure expression.

TYPE: QiecValue

then

The computation the pattern's names scope over.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_pattern_binding".

TYPE: Literal['qiec_pattern_binding'] DEFAULT: 'qiec_pattern_binding'

QiecPatternBind didactic-model

QiecPatternBind(*, pattern: QiecPattern, first: QiecComputation, then: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_pattern_bind'] = 'qiec_pattern_bind')

Bases: QiecComputation

let p <- FIRST, destructuring a computation's result.

The pattern must match every value of the result type.

PARAMETER DESCRIPTION
pattern

The pattern the result is matched against.

TYPE: QiecPattern

first

The computation run first.

TYPE: QiecComputation

then

The computation the pattern's names scope over.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_pattern_bind".

TYPE: Literal['qiec_pattern_bind'] DEFAULT: 'qiec_pattern_bind'

QiecPatternSynonymDecl didactic-model

QiecPatternSynonymDecl(*, name: str, static_binders: tuple[QiecTypeName, ...] = (), parameters: tuple[str, ...] = (), pattern: QiecPattern, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['pattern_synonym_decl'] = 'pattern_synonym_decl')

Bases: Statement

pattern P[k](x, y) = p, naming a pattern.

PARAMETER DESCRIPTION
name

The synonym's name.

TYPE: str

static_binders

The static names the definition's constructor patterns bind, exposed to a use's static binders.

TYPE: tuple[QiecTypeName, ...] DEFAULT: ()

parameters

The value names the definition binds, exposed to a use's sub-patterns, in order.

TYPE: tuple[str, ...] DEFAULT: ()

pattern

The definition.

TYPE: QiecPattern

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "pattern_synonym_decl".

TYPE: Literal['pattern_synonym_decl'] DEFAULT: 'pattern_synonym_decl'

QiecEffectBinder didactic-model

QiecEffectBinder(*, name: str, line: int = 0, col: int = 0, kind: Literal['qiec_effect_binder'] = 'qiec_effect_binder')

Bases: QiecBinder

A telescope binder over effect interfaces.

PARAMETER DESCRIPTION
name

The binder's name.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_effect_binder".

TYPE: Literal['qiec_effect_binder'] DEFAULT: 'qiec_effect_binder'

QiecEffectDecl didactic-model

QiecEffectDecl(*, name: str, binders: tuple[QiecBinder, ...] = (), operations: tuple[QiecOperationDecl, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['effect_decl'] = 'effect_decl')

Bases: Statement

effect NAME[binders] declaring an operation interface.

PARAMETER DESCRIPTION
name

The interface's name.

TYPE: str

binders

The interface's static telescope.

TYPE: tuple[QiecBinder, ...] DEFAULT: ()

operations

The operations declared.

TYPE: tuple[QiecOperationDecl, ...] DEFAULT: ()

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "effect_decl".

TYPE: Literal['effect_decl'] DEFAULT: 'effect_decl'

QiecEffectInstanceDecl didactic-model

QiecEffectInstanceDecl(*, name: str, effect: QiecEffectRef, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['effect_instance_decl'] = 'effect_instance_decl')

Bases: Statement

instance NAME : EFFECT, a module-level lexical effect instance.

PARAMETER DESCRIPTION
name

The instance's name.

TYPE: str

effect

The applied interface the instance carries.

TYPE: QiecEffectRef

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "effect_instance_decl".

TYPE: Literal['effect_instance_decl'] DEFAULT: 'effect_instance_decl'

QiecBernoulliCompletionDecl didactic-model

QiecBernoulliCompletionDecl(*, name: str, computation: str, sites: tuple[str, ...], probabilities: tuple[float, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['bernoulli_completion_decl'] = 'bernoulli_completion_decl')

Bases: Statement

Declare normalized inactive coordinates of a checked Bernoulli branch.

ATTRIBUTE DESCRIPTION
name

The module-local name of the completion.

TYPE: str

computation

The authored computation that owns the selector and two arms.

TYPE: str

sites

The two original arm site labels.

TYPE: tuple of str

probabilities

The corresponding fixed parsed Real probabilities.

TYPE: tuple of float

docs

The attached doc comments.

TYPE: tuple of str

line, col

The 1-based source line and 0-based column.

TYPE: int

kind

The statement discriminator.

TYPE: str

QiecEffectLawDecl didactic-model

QiecEffectLawDecl(*, name: str, instance: str, operations: tuple[str, ...], left: str, right: str, handlers: tuple[str, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['effect_law_decl'] = 'effect_law_decl', method: Literal['finite', 'polynomial', 'rational'] = 'finite')

Bases: Statement

One authored nominal equation and its exact handler checks.

The equation refers to existing named computations and a concrete effect instance. Each handler listed requests its own exact check.

PARAMETER DESCRIPTION
name

The equation's name within the nominal effect.

TYPE: str

instance

The instance that scopes both equation sides.

TYPE: str

operations

The interface operations named by the equation.

TYPE: tuple[str, ...]

left

The names of the open checked computations on the two sides.

TYPE: str

right

The names of the open checked computations on the two sides.

TYPE: str

handlers

The handlers to check independently against the equation. Empty makes the law a local theory of the instance: every handler installed for the instance is checked against it.

TYPE: tuple[str, ...]

docs

The declaration's doc comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line and 0-based column.

TYPE: int DEFAULT: 0

col

The 1-based source line and 0-based column.

TYPE: int DEFAULT: 0

kind

The discriminator, always "effect_law_decl".

TYPE: Literal['effect_law_decl'] DEFAULT: 'effect_law_decl'

method

The checking method requested for each listed handler.

TYPE: Literal['finite', 'polynomial', 'rational'] DEFAULT: 'finite'

QiecCheckpointDerivativeDecl didactic-model

QiecCheckpointDerivativeDecl(*, name: str, primal: str, transition: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['checkpoint_derivative_decl'] = 'checkpoint_derivative_decl')

Bases: Statement

A checkpoint request for a named finite scalar iteration.

ATTRIBUTE DESCRIPTION
name

The module-local name of the request.

TYPE: str

primal, transition

The iteration and the single computation called at each step.

TYPE: str

docs

The attached doc comments.

TYPE: tuple of str

line, col

The 1-based source line and 0-based column.

TYPE: int

kind

The statement discriminator.

TYPE: str

QiecImplicitDerivativeDecl didactic-model

QiecImplicitDerivativeDecl(*, name: str, primal: str, residual: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['implicit_derivative_decl'] = 'implicit_derivative_decl')

Bases: Statement

A named claim that a computation solves a scalar residual.

ATTRIBUTE DESCRIPTION
name

The module-local name of the claim.

TYPE: str

primal, residual

The computation that returns a root and the residual computation with the root argument in the first position.

TYPE: str

docs

The attached doc comments.

TYPE: tuple of str

line, col

The 1-based source line and 0-based column.

TYPE: int

kind

The statement discriminator.

TYPE: str

QiecRationalDerivativeDecl didactic-model

QiecRationalDerivativeDecl(*, name: str, primal: str, jvp: str | None = None, vjp: tuple[str, ...] | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['rational_derivative_decl'] = 'rational_derivative_decl')

Bases: Statement

A named claim about a closed scalar computation's derivative.

ATTRIBUTE DESCRIPTION
name

The module-local name of the derivative claim.

TYPE: str

primal

The authored scalar computation being differentiated.

TYPE: str

jvp

The optional forward action's computation name.

TYPE: str or None

vjp

Optional reverse action names in primal parameter order.

TYPE: tuple of str or None

docs

The declaration's doc comments.

TYPE: tuple of str

line, col

The 1-based source line and 0-based column.

TYPE: int

kind

The statement discriminator.

TYPE: str

QiecSiteEstimatorDecl didactic-model

QiecSiteEstimatorDecl(*, name: str, site: str, estimator: str, line: int = 0, col: int = 0)

Bases: Model

An estimator choice for one literal sample site in an authored computation.

ATTRIBUTE DESCRIPTION
name

The module-local name of the assignment.

TYPE: str

site

The literal label of the sample request's site value.

TYPE: str

estimator

The named method to check on that request.

TYPE: str

line, col

The 1-based source line and 0-based column.

TYPE: int

QiecSiteEstimatorsDecl didactic-model

QiecSiteEstimatorsDecl(*, computation: str, estimators: tuple[QiecSiteEstimatorDecl, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['site_estimators_decl'] = 'site_estimators_decl')

Bases: Statement

Group site policies under the computation that owns their requests.

QiecScopedOperationDecl didactic-model

QiecScopedOperationDecl(*, name: str, instance: str, elaborator: str, body_effects: tuple[str, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['scoped_operation_decl'] = 'scoped_operation_decl')

Bases: Statement

A named static computation argument and its ordinary elaborator.

With empty body_effects the declaration instead elaborates every request to instance: the instance's operations are higher-order, and each request is replaced by the elaborator's clause for it.

QiecHandlerInterchangeDecl didactic-model

QiecHandlerInterchangeDecl(*, name: str, left: str, right: str, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['handler_interchange_decl'] = 'handler_interchange_decl')

Bases: Statement

One named finite observation of two checked handler installation orders.

The two sides are names of existing QVR computations. The finite interchange checker checks their exact installations and common call.

PARAMETER DESCRIPTION
name

The source name of the claim within this module.

TYPE: str

left

The two checked wrapper computation names.

TYPE: str

right

The two checked wrapper computation names.

TYPE: str

docs

The declaration's doc comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line and 0-based column.

TYPE: int DEFAULT: 0

col

The 1-based source line and 0-based column.

TYPE: int DEFAULT: 0

kind

The discriminator, always "handler_interchange_decl".

TYPE: Literal['handler_interchange_decl'] DEFAULT: 'handler_interchange_decl'

QiecEffectKind didactic-model

QiecEffectKind(*, line: int = 0, col: int = 0, kind: Literal['qiec_effect_kind'] = 'qiec_effect_kind')

Bases: QiecKindExpr

The kind Effect of effect interfaces.

PARAMETER DESCRIPTION
line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_effect_kind".

TYPE: Literal['qiec_effect_kind'] DEFAULT: 'qiec_effect_kind'

QiecEffectRef didactic-model

QiecEffectRef(*, name: str, arguments: tuple[QiecStaticArgument, ...] = (), line: int = 0, col: int = 0)

Bases: Model

An applied effect interface such as State[Int].

QiecEffectRequest didactic-model

QiecEffectRequest(*, instance: str, operation: str, static_arguments: tuple[QiecStaticArgument, ...] = (), arguments: tuple[QiecValue, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A request of one operation on a lexical effect instance.

PARAMETER DESCRIPTION
instance

The instance's name.

TYPE: str

operation

The operation's name.

TYPE: str

static_arguments

The static arguments the operation's telescope takes.

TYPE: tuple[QiecStaticArgument, ...] DEFAULT: ()

arguments

The value arguments, in order.

TYPE: tuple[QiecValue, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecEffectRow didactic-model

QiecEffectRow(*, entries: tuple[QiecRowEntry, ...] = (), tail: str | None = None, lacks: tuple[str, ...] = (), line: int = 0, col: int = 0)

Bases: Model

Explicit row entries plus an optional constrained open tail.

QiecFamilyConstructor didactic-model

QiecFamilyConstructor(*, name: str, binders: tuple[QiecBinder, ...] = (), arguments: tuple[QiecTypeExpr, ...] = (), result: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

A GADT constructor with a local telescope and refined result.

QiecFamilyDecl didactic-model

QiecFamilyDecl(*, name: str, parameters: tuple[QiecBinder, ...] = (), indices: tuple[QiecIndexBinder, ...] = (), result_kind: QiecKindExpr, constructors: tuple[QiecFamilyConstructor, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, deriving: tuple[DerivingClass, ...] = (), kind: Literal['indexed_family_decl'] = 'indexed_family_decl')

Bases: Statement

family NAME[params](indices) : KIND with its GADT constructors.

PARAMETER DESCRIPTION
name

The family's name.

TYPE: str

parameters

The uniform static parameters.

TYPE: tuple[QiecBinder, ...] DEFAULT: ()

indices

The refinable index binders.

TYPE: tuple[QiecIndexBinder, ...] DEFAULT: ()

result_kind

The kind of the family's applications.

TYPE: QiecKindExpr

constructors

The family's constructors.

TYPE: tuple[QiecFamilyConstructor, ...] DEFAULT: ()

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

deriving

The classes of the header's deriving (...) clause, in order.

TYPE: tuple[DerivingClass, ...] DEFAULT: ()

kind

The discriminator; always "indexed_family_decl".

TYPE: Literal['indexed_family_decl'] DEFAULT: 'indexed_family_decl'

QiecFunctionType didactic-model

QiecFunctionType(*, parameter: QiecTypeExpr, result: QiecTypeExpr, row: QiecEffectRow | None = None, line: int = 0, col: int = 0, kind: Literal['qiec_function_type'] = 'qiec_function_type')

Bases: QiecTypeExpr

A function type between value types.

PARAMETER DESCRIPTION
parameter

The parameter type.

TYPE: QiecTypeExpr

result

The result type.

TYPE: QiecTypeExpr

row

The effect row an application performs, or None for a pure function.

TYPE: QiecEffectRow | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_function_type".

TYPE: Literal['qiec_function_type'] DEFAULT: 'qiec_function_type'

QiecHandleComputation didactic-model

QiecHandleComputation(*, instance: str, handler: QiecHandlerApplication, body: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_handle_computation'] = 'qiec_handle_computation')

Bases: QiecComputation

A computation run under a handler installed for one instance.

PARAMETER DESCRIPTION
instance

The instance the handler is installed for.

TYPE: str

handler

The handler applied.

TYPE: QiecHandlerApplication

body

The computation run under it.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_handle_computation".

TYPE: Literal['qiec_handle_computation'] DEFAULT: 'qiec_handle_computation'

QiecHandlerApplication didactic-model

QiecHandlerApplication(*, name: str, static_arguments: tuple[QiecStaticArgument, ...] = (), values: tuple[QiecValue, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A handler at its static arguments and its parameters' first values.

PARAMETER DESCRIPTION
name

The handler's name.

TYPE: str

static_arguments

The static arguments, in order.

TYPE: tuple[QiecStaticArgument, ...] DEFAULT: ()

values

The values the handler's parameters start from, in order.

TYPE: tuple[QiecValue, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecCallComputation didactic-model

QiecCallComputation(*, callee: str, static_arguments: tuple[QiecStaticArgument, ...] = (), arguments: tuple[QiecValue, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_call_computation'] = 'qiec_call_computation')

Bases: QiecComputation

Application of a named computation.

The callee is resolved against the module's signature table rather than against a local binding, so a call may precede the declaration it names and mutual recursion needs no forward declaration.

QiecHandlerClause didactic-model

QiecHandlerClause()

Bases: TaggedUnion

One clause of a handler declaration.

A handler answers a returning computation and each operation it covers, and those are different shapes: the return clause binds a value, an operation clause binds the operation's arguments and may resume.

QiecHandlerReturnClause didactic-model

QiecHandlerReturnClause(*, binder: QiecLocalBinding, body: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_handler_return_clause'] = 'qiec_handler_return_clause')

Bases: QiecHandlerClause

What a handler does with the value its computation returns.

QiecHandlerOperationClause didactic-model

QiecHandlerOperationClause(*, operation: str, grade: QiecResumptionGrade, binders: tuple[QiecBinder, ...] = (), parameters: tuple[QiecLocalBinding, ...] = (), body: QiecComputation | None = None, line: int = 0, col: int = 0, bounds: tuple[int, ...] = (), kind: Literal['qiec_handler_operation_clause'] = 'qiec_handler_operation_clause')

Bases: QiecHandlerClause

One operation a handler covers.

A body of None is a signature rather than an implementation, and is legal only where the declaration says implementation=foreign. The interval grade carries its lower and upper endpoints in bounds.

QiecHandlerDecl didactic-model

QiecHandlerDecl(*, name: str, binders: tuple[QiecBinder, ...] = (), effect: QiecEffectRef, input_type: QiecTypeExpr, output_type: QiecTypeExpr, introduced: QiecEffectRow = QiecEffectRow(), coverage: Literal['total', 'partial'] = 'total', forwards_unknown: bool = False, implementation: QiecHandlerImplementation = 'authored', parameters: tuple[QiecValueParameter, ...] = (), clauses: tuple[QiecHandlerClause, ...] = (), duplicate_options: tuple[str, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['handler_decl'] = 'handler_decl')

Bases: Statement

handler NAME[binders] for EFFECT : IN -> OUT with (params), with its clauses.

PARAMETER DESCRIPTION
name

The handler's name.

TYPE: str

binders

The handler's static telescope.

TYPE: tuple[QiecBinder, ...] DEFAULT: ()

effect

The applied interface the handler handles.

TYPE: QiecEffectRef

input_type

The type of the computation handled.

TYPE: QiecTypeExpr

output_type

The type the handled computation yields.

TYPE: QiecTypeExpr

introduced

The effect row the handler's clauses may perform.

TYPE: QiecEffectRow DEFAULT: QiecEffectRow()

coverage

Whether the clauses cover every operation (total) or forward the rest (partial).

TYPE: Literal['total', 'partial'] DEFAULT: 'total'

forwards_unknown

Whether requests of operations without a clause are forwarded outward.

TYPE: bool DEFAULT: False

implementation

Whether the clause bodies are authored here or supplied by a runtime provider.

TYPE: QiecHandlerImplementation DEFAULT: 'authored'

parameters

The handler's typed parameters, in order.

TYPE: tuple[QiecValueParameter, ...] DEFAULT: ()

clauses

The return and operation clauses.

TYPE: tuple[QiecHandlerClause, ...] DEFAULT: ()

duplicate_options

The option names the source repeated, kept so the checker can report them.

TYPE: tuple[str, ...] DEFAULT: ()

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "handler_decl".

TYPE: Literal['handler_decl'] DEFAULT: 'handler_decl'

QiecContextSort didactic-model

QiecContextSort(*, signature: str, line: int = 0, col: int = 0, kind: Literal['qiec_context_sort'] = 'qiec_context_sort')

Bases: QiecIndexSort

The sort of contexts over a structural signature.

PARAMETER DESCRIPTION
signature

The signature's name.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_context_sort".

TYPE: Literal['qiec_context_sort'] DEFAULT: 'qiec_context_sort'

QiecInstanceComputation didactic-model

QiecInstanceComputation(*, name: str, effect: QiecEffectRef, body: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_instance_computation'] = 'qiec_instance_computation')

Bases: QiecComputation

with instance x : E in, allocating a lexically scoped instance.

The binder is live only in body. Its identity is derived rather than generated, so the same allocation site yields the same instance on every run.

QiecIndexApplication didactic-model

QiecIndexApplication(*, constructor: str, arguments: tuple[QiecIndexExpr, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_index_application'] = 'qiec_index_application')

Bases: QiecIndexExpr

A user index-sort constructor applied to index arguments.

PARAMETER DESCRIPTION
constructor

The constructor's name.

TYPE: str

arguments

The index arguments, in order.

TYPE: tuple[QiecIndexExpr, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_index_application".

TYPE: Literal['qiec_index_application'] DEFAULT: 'qiec_index_application'

QiecIndexBinder didactic-model

QiecIndexBinder(*, name: str, sort: QiecIndexSort, line: int = 0, col: int = 0, kind: Literal['qiec_index_binder'] = 'qiec_index_binder')

Bases: QiecBinder

A telescope binder over a closed index sort.

PARAMETER DESCRIPTION
name

The binder's name.

TYPE: str

sort

The sort the binder ranges over.

TYPE: QiecIndexSort

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_index_binder".

TYPE: Literal['qiec_index_binder'] DEFAULT: 'qiec_index_binder'

QiecModuleBinder didactic-model

QiecModuleBinder(*, name: str, signature: str, constraints: tuple[QiecModuleSharing, ...] = (), implicit: bool = False, position: int = 0, line: int = 0, col: int = 0, core: str = '')

Bases: Model

A module parameter of a computation.

PARAMETER DESCRIPTION
name

The parameter's name.

TYPE: str

signature

The signature's name, as name resolution reads it; empty for a deduction parameter.

TYPE: str

constraints

Its with family constraints.

TYPE: tuple[QiecModuleSharing, ...] DEFAULT: ()

core

For module D : Deduction extends S, the deduction signature S every deduction passed for it extends; empty otherwise.

TYPE: str DEFAULT: ''

implicit

Whether calls leave the argument to instance resolution.

TYPE: bool DEFAULT: False

position

Its index among all the computation's parameters.

TYPE: int DEFAULT: 0

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecModuleSharing didactic-model

QiecModuleSharing(*, name: str, type_expr: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

with family T = U on a module parameter's signature.

PARAMETER DESCRIPTION
name

The family item of the signature.

TYPE: str

type_expr

The type it equals.

TYPE: QiecTypeExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecIndexConstructor didactic-model

QiecIndexConstructor(*, name: str, arguments: tuple[QiecIndexSort, ...] = (), line: int = 0, col: int = 0)

Bases: Model

One constructor of a closed user-defined index sort.

QiecIndexDecl didactic-model

QiecIndexDecl(*, name: str, constructors: tuple[QiecIndexConstructor, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['index_decl'] = 'index_decl')

Bases: Statement

index NAME = C1 | C2(...) | ..., a closed user index sort.

PARAMETER DESCRIPTION
name

The sort's name.

TYPE: str

constructors

The sort's constructors.

TYPE: tuple[QiecIndexConstructor, ...]

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "index_decl".

TYPE: Literal['index_decl'] DEFAULT: 'index_decl'

QiecIndexExpr didactic-model

QiecIndexExpr()

Bases: TaggedUnion

A source-level term in a closed index sort.

QiecIndexLiteral didactic-model

QiecIndexLiteral(*, value: int, line: int = 0, col: int = 0, kind: Literal['qiec_index_literal'] = 'qiec_index_literal')

Bases: QiecIndexExpr

A natural-number index literal.

PARAMETER DESCRIPTION
value

The literal's value.

TYPE: int

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_index_literal".

TYPE: Literal['qiec_index_literal'] DEFAULT: 'qiec_index_literal'

QiecIndexMapClause didactic-model

QiecIndexMapClause(*, constructor: str, parameters: tuple[str, ...], body: QiecIndexExpr, line: int = 0, col: int = 0)

Bases: Model

One constructor clause of an authored index map.

PARAMETER DESCRIPTION
constructor

The constructor of the source sort.

TYPE: str

parameters

Names for the images of the constructor's arguments, in order.

TYPE: tuple[str, ...]

body

The target index term.

TYPE: QiecIndexExpr

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

QiecIndexMapDecl didactic-model

QiecIndexMapDecl(*, name: str, source: QiecUserIndexSort, target: QiecUserIndexSort, clauses: tuple[QiecIndexMapClause, ...], docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['index_map_decl'] = 'index_map_decl')

Bases: Statement

A constructor-by-constructor map between declared index sorts.

PARAMETER DESCRIPTION
name

The map's name.

TYPE: str

source

The source index sort.

TYPE: QiecUserIndexSort

target

The target index sort.

TYPE: QiecUserIndexSort

clauses

The image of each source constructor.

TYPE: tuple[QiecIndexMapClause, ...]

docs

The attached doc comments.

TYPE: tuple[str, ...] DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

kind

The syntax discriminator.

TYPE: Literal['index_map_decl'] DEFAULT: 'index_map_decl'

QiecIndexName didactic-model

QiecIndexName(*, name: str, line: int = 0, col: int = 0, kind: Literal['qiec_index_name'] = 'qiec_index_name')

Bases: QiecIndexExpr

A reference to an index binder in scope.

PARAMETER DESCRIPTION
name

The binder's name.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_index_name".

TYPE: Literal['qiec_index_name'] DEFAULT: 'qiec_index_name'

QiecIndexSort didactic-model

QiecIndexSort()

Bases: TaggedUnion

A closed index sort annotation.

QiecKindExpr didactic-model

QiecKindExpr()

Bases: TaggedUnion

A QIEC kind appearing in source.

QiecLocalBinding didactic-model

QiecLocalBinding(*, name: str, type_expr: QiecTypeExpr | None = None, line: int = 0, col: int = 0)

Bases: Model

A local name bound by a computation, with an optional type annotation.

PARAMETER DESCRIPTION
name

The local's name.

TYPE: str

type_expr

The annotated type, or None when inferred.

TYPE: QiecTypeExpr | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecOperationDecl didactic-model

QiecOperationDecl(*, name: str, binders: tuple[QiecBinder, ...] = (), arguments: tuple[QiecTypeExpr, ...] = (), result: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

One operation of an effect interface declaration.

PARAMETER DESCRIPTION
name

The operation's name.

TYPE: str

binders

The operation's own static telescope.

TYPE: tuple[QiecBinder, ...] DEFAULT: ()

arguments

The argument types, in order.

TYPE: tuple[QiecTypeExpr, ...] DEFAULT: ()

result

The result type.

TYPE: QiecTypeExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecPerformComputation didactic-model

QiecPerformComputation(*, request: QiecEffectRequest, line: int = 0, col: int = 0, kind: Literal['qiec_perform_computation'] = 'qiec_perform_computation')

Bases: QiecComputation

perform of one effect request.

PARAMETER DESCRIPTION
request

The request performed.

TYPE: QiecEffectRequest

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_perform_computation".

TYPE: Literal['qiec_perform_computation'] DEFAULT: 'qiec_perform_computation'

QiecProductType didactic-model

QiecProductType(*, components: tuple[QiecTypeExpr, ...], line: int = 0, col: int = 0, kind: Literal['qiec_product_type'] = 'qiec_product_type')

Bases: QiecTypeExpr

A finite product of value types.

PARAMETER DESCRIPTION
components

The component types, in order.

TYPE: tuple[QiecTypeExpr, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_product_type".

TYPE: Literal['qiec_product_type'] DEFAULT: 'qiec_product_type'

QiecPureBinding didactic-model

QiecPureBinding(*, binder: QiecLocalBinding, value: QiecValue, then: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_pure_binding'] = 'qiec_pure_binding')

Bases: QiecComputation

let x = VALUE, binding a pure expression.

Separate from QiecBindComputation, which binds a computation's result. The two have different typing rules and neither is sugar for the other.

PARAMETER DESCRIPTION
binder

The local the value is bound to.

TYPE: QiecLocalBinding

value

The pure expression.

TYPE: QiecValue

then

The computation the binding scopes over.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_pure_binding".

TYPE: Literal['qiec_pure_binding'] DEFAULT: 'qiec_pure_binding'

QiecResumeComputation didactic-model

QiecResumeComputation(*, value: QiecValue | None = None, parameters: tuple[QiecValue, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_resume_computation'] = 'qiec_resume_computation')

Bases: QiecComputation

Invocation of the enclosing handler clause's continuation.

The resumption is not a named local, so there is exactly one way to invoke it. A value of None resumes with unit. The parameters are the values the handler's parameters have while the continuation runs; an empty tuple keeps the clause's own.

QiecReturnComputation didactic-model

QiecReturnComputation(*, value: QiecValue, line: int = 0, col: int = 0, kind: Literal['qiec_return_computation'] = 'qiec_return_computation')

Bases: QiecComputation

return VALUE, the computation that performs nothing.

PARAMETER DESCRIPTION
value

The value returned.

TYPE: QiecValue

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_return_computation".

TYPE: Literal['qiec_return_computation'] DEFAULT: 'qiec_return_computation'

QiecRowEntry didactic-model

QiecRowEntry(*, instance: str, line: int = 0, col: int = 0)

Bases: Model

A named lexical effect instance in an effect row.

QiecSequenceComputation didactic-model

QiecSequenceComputation(*, first: QiecComputation, then: QiecComputation, line: int = 0, col: int = 0, kind: Literal['qiec_sequence_computation'] = 'qiec_sequence_computation')

Bases: QiecComputation

Two computations run in order, the first result discarded.

PARAMETER DESCRIPTION
first

The computation run first.

TYPE: QiecComputation

then

The computation run after it.

TYPE: QiecComputation

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_sequence_computation".

TYPE: Literal['qiec_sequence_computation'] DEFAULT: 'qiec_sequence_computation'

QiecNatSort didactic-model

QiecNatSort(*, line: int = 0, col: int = 0, kind: Literal['qiec_nat_sort'] = 'qiec_nat_sort')

Bases: QiecIndexSort

The sort Nat of natural-number indices.

PARAMETER DESCRIPTION
line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_nat_sort".

TYPE: Literal['qiec_nat_sort'] DEFAULT: 'qiec_nat_sort'

QiecShapeIndex didactic-model

QiecShapeIndex(*, dimensions: tuple[QiecIndexExpr, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_shape_index'] = 'qiec_shape_index')

Bases: QiecIndexExpr

A shape written as a bracketed list of dimensions.

PARAMETER DESCRIPTION
dimensions

The dimension indices, outermost first.

TYPE: tuple[QiecIndexExpr, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_shape_index".

TYPE: Literal['qiec_shape_index'] DEFAULT: 'qiec_shape_index'

QiecShapeSort didactic-model

QiecShapeSort(*, rank: int | None = None, line: int = 0, col: int = 0, kind: Literal['qiec_shape_sort'] = 'qiec_shape_sort')

Bases: QiecIndexSort

The sort of shapes, of a fixed rank or of any rank.

PARAMETER DESCRIPTION
rank

The rank a shape must have, or None for any rank.

TYPE: int | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_shape_sort".

TYPE: Literal['qiec_shape_sort'] DEFAULT: 'qiec_shape_sort'

QiecTypeApplication didactic-model

QiecTypeApplication(*, constructor: str, static_arguments: tuple[QiecStaticArgument, ...] = (), indices: tuple[QiecIndexExpr, ...] = (), line: int = 0, col: int = 0, kind: Literal['qiec_type_application'] = 'qiec_type_application')

Bases: QiecTypeExpr

A type constructor applied to static arguments and indices.

PARAMETER DESCRIPTION
constructor

The constructor's name.

TYPE: str

static_arguments

The uniform type arguments, in order.

TYPE: tuple[QiecStaticArgument, ...] DEFAULT: ()

indices

The refinable index arguments, in order.

TYPE: tuple[QiecIndexExpr, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_type_application".

TYPE: Literal['qiec_type_application'] DEFAULT: 'qiec_type_application'

QiecTypeBinder didactic-model

QiecTypeBinder(*, name: str, binder_kind: QiecKindExpr, line: int = 0, col: int = 0, kind: Literal['qiec_type_binder'] = 'qiec_type_binder')

Bases: QiecBinder

A telescope binder of kind Type or Effect.

PARAMETER DESCRIPTION
name

The binder's name.

TYPE: str

binder_kind

The kind the binder ranges over.

TYPE: QiecKindExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_type_binder".

TYPE: Literal['qiec_type_binder'] DEFAULT: 'qiec_type_binder'

QiecTypeExpr didactic-model

QiecTypeExpr()

Bases: TaggedUnion

A value type in the QIEC source stratum.

QiecTypeKind didactic-model

QiecTypeKind(*, line: int = 0, col: int = 0, kind: Literal['qiec_type_kind'] = 'qiec_type_kind')

Bases: QiecKindExpr

The kind Type of value types.

PARAMETER DESCRIPTION
line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_type_kind".

TYPE: Literal['qiec_type_kind'] DEFAULT: 'qiec_type_kind'

QiecTypeName didactic-model

QiecTypeName(*, name: str, line: int = 0, col: int = 0, kind: Literal['qiec_type_name'] = 'qiec_type_name')

Bases: QiecTypeExpr

A reference to a type by name: a primitive, a binder, or a declared family without arguments.

PARAMETER DESCRIPTION
name

The type's name.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_type_name".

TYPE: Literal['qiec_type_name'] DEFAULT: 'qiec_type_name'

QiecUserIndexSort didactic-model

QiecUserIndexSort(*, name: str, line: int = 0, col: int = 0, kind: Literal['qiec_user_index_sort'] = 'qiec_user_index_sort')

Bases: QiecIndexSort

A reference to a user-declared closed index sort.

PARAMETER DESCRIPTION
name

The sort's name.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_user_index_sort".

TYPE: Literal['qiec_user_index_sort'] DEFAULT: 'qiec_user_index_sort'

QiecWeightedTotal didactic-model

QiecWeightedTotal(*, index: str, count: int, weights: tuple[str, ...], weight_index: str, responses: tuple[QiecValue, ...], response_index: str, addition: str, action: str, line: int = 0, col: int = 0, addition_col: int = 0, action_col: int = 0, kind: Literal['qiec_weighted_total'] = 'qiec_weighted_total')

Bases: QiecComputation

The bounded source bundles of an authored weighted operation clause.

QiecValueParameter didactic-model

QiecValueParameter(*, name: str, type_expr: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

One typed value parameter of a computation declaration.

PARAMETER DESCRIPTION
name

The parameter's name.

TYPE: str

type_expr

The parameter's type.

TYPE: QiecTypeExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

JudgmentArgumentDecl didactic-model

JudgmentArgumentDecl(*, name: str, sort: str, argument: str | None = None, mode: Literal['in', 'out'])

Bases: Model

One argument of a judgment: ctx : Context[Type] in.

PARAMETER DESCRIPTION
name

The argument's name.

TYPE: str

sort

Its sort, or Context for a context.

TYPE: str

argument

The entry sort of a context, None otherwise.

TYPE: str or None DEFAULT: None

mode

"in" or "out".

TYPE: str

JudgmentDecl didactic-model

JudgmentDecl(*, name: str, arguments: tuple[JudgmentArgumentDecl, ...] = (), rules: tuple[JudgmentRuleDecl, ...] = (), options: tuple[OptionEntry, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['judgment_decl'] = 'judgment_decl')

Bases: Statement

judgment NAME(arguments) [options] with its rules.

PARAMETER DESCRIPTION
name

The judgment's name.

TYPE: str

arguments

Its moded arguments.

TYPE: tuple of JudgmentArgumentDecl DEFAULT: ()

rules

Its rules.

TYPE: tuple of JudgmentRuleDecl DEFAULT: ()

options

Its options.

TYPE: tuple of OptionEntry DEFAULT: ()

docs

Its doc comment lines.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

JudgmentRuleDecl didactic-model

JudgmentRuleDecl(*, name: str, schematic: tuple[str, ...] = (), premises: tuple[PatternSyntax, ...] = (), conclusion: PatternSyntax, options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A rule rule name[a, b] : P_1, ..., P_n |- C #[...].

PARAMETER DESCRIPTION
name

The rule's name.

TYPE: str

schematic

The variables fresh at each use.

TYPE: tuple of str DEFAULT: ()

premises

The premises as written.

TYPE: tuple of PatternSyntax DEFAULT: ()

conclusion

The conclusion as written.

TYPE: PatternSyntax

options

The trailing pragma's entries, such as weight.

TYPE: tuple of OptionEntry DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

ArgumentDecl didactic-model

ArgumentDecl(*, sort: str, binds: tuple[BoundVariableDecl, ...] = (), label: str | None = None)

Bases: Model

One argument of a constructor and its binding arity.

Term is an unbound argument, (ty : Type) an unbound argument labeled ty, and (x : Term).Term an argument of sort Term that binds x.

BoundVariableDecl didactic-model

BoundVariableDecl(*, name: str, sort: str, annotation: str | None = None)

Bases: Model

A variable an argument binds: x : Term or x : Term : ty.

name is a display name; references inside the argument are by de Bruijn index. annotation names an earlier unbound argument by its label; the encoder and decoder initialize the variable from it.

EquationDecl didactic-model

EquationDecl(*, name: str, left: PatternSyntax, right: PatternSyntax, oriented: bool = False, line: int = 0, col: int = 0)

Bases: Model

One equation of a signature: name : lhs = rhs or lhs ~> rhs.

The sides are written second-order terms whose names are resolved against the signature when the theory is checked.

ConstructorDecl didactic-model

ConstructorDecl(*, name: str, arguments: tuple[ArgumentDecl, ...] = (), codomain: str, line: int = 0, col: int = 0)

Bases: Model

A typed operation name : a_1, ..., a_n -> s in a signature.

Each argument a_i carries its sort and the variables it binds.

domain property

domain: tuple[str, ...]

The sort of each argument.

RETURNS DESCRIPTION
tuple of str

The sorts, in order.

EdgeKindDecl didactic-model

EdgeKindDecl(*, name: str, src: str, tgt: str, directed: bool = True, line: int = 0, col: int = 0)

Bases: Model

An edge kind in a graph-shaped signature.

directed is True for src -> tgt, False for src -- tgt.

EncoderInitRule didactic-model

EncoderInitRule(*, kind: str, arg: str, body: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

Graph-signature initializer: maps vertex data payloads to initial vertex embeddings before message passing.

EncoderMessageRule didactic-model

EncoderMessageRule(*, edge_kind: str, src: str, tgt: str, body: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

Graph-signature message: maps a (src, tgt) pair on an edge kind to a message vector.

EncoderRule didactic-model

EncoderRule(*, op: str, args: tuple[str, ...], body: LetExprNode, mode: Literal['plain', 'recurrent', 'attention'] = 'plain', state_var: str | None = None, prefix_var: str | None = None, line: int = 0, col: int = 0)

Bases: Model

A per-operation encoder function.

The body is a let-expression evaluated in an environment where the constructor arguments (as named in args) are bound to child vectors, plus framework-supplied helpers (ctx for binder contexts, state/prefix for recurrent / attention shapes).

mode selects sequence sugar:

  • "plain" for direct algebra-hom rule (default).
  • "recurrent" for left-fold, state carries the accumulator.
  • "attention" for prefix carries the running list of prior compressed children.

EncoderUpdateRule didactic-model

EncoderUpdateRule(*, vertex_kind: str, self_var: str, msgs_var: str, body: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

Graph-signature update: maps (self_embed, aggregated_msgs) to the next vertex embedding, per vertex kind.

EncoderVarInit didactic-model

EncoderVarInit(*, var_sort: str, annot_sort: str | None = None, ty: str | None = None, body: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

One var_init <var_sort> [from <annot_sort> [as <name>]] rule.

annot_sort=None is the unannotated-binder case (no type annotation; the body sees no extra arg). When annot_sort is set, ty is the body's parameter name bound to the annotation embedding.

SortDecl didactic-model

SortDecl(*, name: str, kind: Literal['object', 'index', 'data'], options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

One sort within a signature.

kind is one of "object", "index", "data". The surface form moves dim and vocab into the unified option block: s : data [dim=16, vocab=["a", "b"]]. The compiler reads them back out of options at elaboration time.

SortDim didactic-model

SortDim(*, sort: str, dim: int)

Bases: Model

A (sort, dim) association declared in a encoder/decoder.

SortVocabLiteral didactic-model

SortVocabLiteral(*, kind: Literal['string', 'integer', 'float'], text: str)

Bases: Model

One entry of a data sort's closed vocabulary.

The literal carries its surface text plus a tag so the compiler can decode each entry into the canonical Python value the runtime stores in Sort.vocab (str, int, or float).

VertexKindDecl didactic-model

VertexKindDecl(*, name: str, kind: Literal['object', 'index', 'data'], options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A vertex kind in a graph-shaped signature.

Like SortDecl, the surface threads dim and any other modifier through the unified option block.

ContentPin didactic-model

ContentPin(*, algorithm: str, digest: str)

Bases: Model

A content hash pinned to a file: @blake3:<hex>.

PARAMETER DESCRIPTION
algorithm

The hash algorithm, such as "blake3".

TYPE: str

digest

The hexadecimal digest, lowercase.

TYPE: str

render

render() -> str

The pin as it is written in source.

RETURNS DESCRIPTION
str

@<algorithm>:<digest>.

Source code in src/quivers/dsl/ast_nodes/experiments.py
def render(self) -> str:
    """The pin as it is written in source.

    Returns
    -------
    str
        ``@<algorithm>:<digest>``.
    """
    return f"@{self.algorithm}:{self.digest}"

ExperimentData didactic-model

ExperimentData(*, name: str, path: str, pin: ContentPin | None = None, line: int = 0, col: int = 0)

Bases: Model

data NAME <- "PATH" @blake3:...: a parameter read from a file.

PARAMETER DESCRIPTION
name

The program parameter (or site) the file's value is given to.

TYPE: str

path

The file, relative to the module's directory.

TYPE: str

pin

The pinned content hash, or None when the clause pins none.

TYPE: ContentPin | None DEFAULT: None

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentDecl didactic-model

ExperimentDecl(*, name: str, program: str, program_line: int, infer: ExperimentInfer, seed: int, data: tuple[ExperimentData, ...] = (), fixed: tuple[ExperimentValue, ...] = (), sweeps: tuple[ExperimentSweep, ...] = (), reference: ExperimentReference | None = None, tolerances: tuple[ExperimentValue, ...] = (), links: tuple[ExperimentLink, ...] = (), handlers: tuple[ExperimentHandler, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0)

Bases: Model

An experiment declaration.

PARAMETER DESCRIPTION
name

The experiment's name.

TYPE: str

program

The entry it runs (a program or a define), resolved to its flat-program name.

TYPE: str

program_line

The line of the program clause.

TYPE: int

data

Its data clauses, in source order.

TYPE: tuple[ExperimentData, ...] DEFAULT: ()

fixed

Its fix clauses, in source order.

TYPE: tuple[ExperimentValue, ...] DEFAULT: ()

infer

Its inference configuration.

TYPE: ExperimentInfer

seed

Its seed.

TYPE: int

sweeps

Its sweeps, in source order; the experiment is the family of runs indexed by their product.

TYPE: tuple[ExperimentSweep, ...] DEFAULT: ()

reference

The stored reference results qvr experiment check compares against, or None.

TYPE: ExperimentReference | None DEFAULT: None

tolerances

The pinned tolerances of that comparison.

TYPE: tuple[ExperimentValue, ...] DEFAULT: ()

links

The holes it fills.

TYPE: tuple[ExperimentLink, ...] DEFAULT: ()

handlers

The handlers it installs around the entry, outermost first.

TYPE: tuple[ExperimentHandler, ...] DEFAULT: ()

docs

Its doc comment lines.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentHandler didactic-model

ExperimentHandler(*, instance: str, handler: QiecHandlerApplication, line: int = 0, col: int = 0)

Bases: Model

handle I with H: a handler installed around the entry.

PARAMETER DESCRIPTION
instance

The effect instance, resolved to its flat-program name.

TYPE: str

handler

The handler application, its name resolved.

TYPE: QiecHandlerApplication

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentInfer didactic-model

ExperimentInfer(*, method: str, options: tuple[ExperimentValue, ...] = (), line: int = 0, col: int = 0)

Bases: Model

infer METHOD(k = v, ...): the inference configuration.

PARAMETER DESCRIPTION
method

The inference method's name.

TYPE: str

options

Its options, in source order.

TYPE: tuple[ExperimentValue, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentLink(*, hole: str, module: str, line: int = 0, col: int = 0)

Bases: Model

link P = M: a hole of the program's package filled for this experiment.

PARAMETER DESCRIPTION
hole

The hole's module path.

TYPE: str

module

The filling module's path.

TYPE: str

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentReference didactic-model

ExperimentReference(*, path: str, pin: ContentPin | None = None, line: int = 0, col: int = 0)

Bases: Model

reference "PATH" @blake3:...: the stored reference results.

PARAMETER DESCRIPTION
path

The reference file, relative to the module's directory.

TYPE: str

pin

Its pinned content hash, or None when the clause pins none.

TYPE: ContentPin | None DEFAULT: None

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentSweep didactic-model

ExperimentSweep(*, name: str, values: tuple[str, ...], line: int = 0, col: int = 0)

Bases: Model

sweep NAME in [v1, ..., vn]: a finite index type of values.

PARAMETER DESCRIPTION
name

The name each point gives its value to.

TYPE: str

values

The points, each as canonical JSON text, in source order.

TYPE: tuple[str, ...]

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

ExperimentValue didactic-model

ExperimentValue(*, name: str, value: str, line: int = 0, col: int = 0)

Bases: Model

fix NAME = VALUE or NAME = VALUE in an option list.

PARAMETER DESCRIPTION
name

The name the value is given to.

TYPE: str

value

The literal value as canonical JSON text.

TYPE: str

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

TestBinder didactic-model

TestBinder(*, name: str, type: QiecTypeExpr, domain: tuple[LetExprNode, ...] = (), line: int = 0, col: int = 0)

Bases: Model

One quantified variable of a property.

PARAMETER DESCRIPTION
name

The variable.

TYPE: str

type

Its type.

TYPE: QiecTypeExpr

domain

The values it ranges over when listed with in [...]; empty when it ranges over its whole type.

TYPE: tuple[LetExprNode, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

TestDecl didactic-model

TestDecl(*, kind: TestKind, name: str, steps: tuple[TestStep, ...], binders: tuple[TestBinder, ...] = (), options: tuple[OptionEntry, ...] = (), subject: str = '', docs: tuple[str, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A test, property, or example declaration.

PARAMETER DESCRIPTION
kind

Which keyword declared it.

TYPE: TestKind

name

Its title.

TYPE: str

steps

The body.

TYPE: tuple[TestStep, ...]

binders

A property's quantified variables; empty otherwise.

TYPE: tuple[TestBinder, ...] DEFAULT: ()

options

The declaration's pinned options (numbers, cases, seed, size, limit).

TYPE: tuple[OptionEntry, ...] DEFAULT: ()

subject

For an example written in a declaration's doc comment, the name of that declaration; "" otherwise.

TYPE: str DEFAULT: ''

docs

The declaration's own doc comment lines.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

TestExpect didactic-model

TestExpect(*, subject: LetExprNode, exact: bool = False, tolerance: LetExprNode | None = None, line: int = 0, col: int = 0, kind: Literal['test_expect'] = 'test_expect')

Bases: TestStep

Assert that a term is true.

A term that is a comparison is checked as a relation between its two sides, which the report states when it fails.

PARAMETER DESCRIPTION
subject

The asserted term.

TYPE: LetExprNode

exact

Whether it was written exactly: an equality of reals that must hold with no rounding.

TYPE: bool DEFAULT: False

tolerance

For within, the largest absolute difference an equality of reals admits, pinned here in the source; None otherwise.

TYPE: LetExprNode | None DEFAULT: None

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "test_expect".

TYPE: Literal['test_expect'] DEFAULT: 'test_expect'

TestLet didactic-model

TestLet(*, name: str, value: LetExprNode, line: int = 0, col: int = 0, kind: Literal['test_let'] = 'test_let')

Bases: TestStep

Bind a name to a term's value for the rest of the body.

PARAMETER DESCRIPTION
name

The bound name.

TYPE: str

value

The term.

TYPE: LetExprNode

line

The 1-based source line.

TYPE: int DEFAULT: 0

col

The 0-based source column.

TYPE: int DEFAULT: 0

kind

The discriminator; always "test_let".

TYPE: Literal['test_let'] DEFAULT: 'test_let'

TestStep didactic-model

TestStep()

Bases: TaggedUnion

Sum of the steps of a test body.

ContinuousConstructor didactic-model

ContinuousConstructor(*, constructor: Literal['Real', 'Simplex', 'Sphere', 'Ball', 'CholeskyFactor', 'Covariance', 'Correlation', 'Orthogonal', 'Stiefel', 'LowerTriangular', 'Diagonal'], args: tuple[str, ...] = (), kwargs: dict[str, float | int | str] = field(default_factory=dict), line: int = 0, col: int = 0, kind: Literal['continuous_constructor'] = 'continuous_constructor')

Bases: ObjectExpr

A continuous-space constructor call.

The eleven continuous constructors are: Real, Simplex, Sphere, Ball, CholeskyFactor, Covariance, Correlation, Orthogonal, Stiefel, LowerTriangular, Diagonal. The compiler dispatches on the constructor field to pick the appropriate quivers.continuous.spaces.ContinuousSpace subclass.

DiscreteConstructor didactic-model

DiscreteConstructor(*, constructor: Literal['FinSet'], args: tuple[str, ...] = (), kwargs: dict[str, float | int | str] = field(default_factory=dict), line: int = 0, col: int = 0, kind: Literal['discrete_constructor'] = 'discrete_constructor')

Bases: ObjectExpr

A discrete-type constructor call: currently FinSet(N).

ObjectCoproduct didactic-model

ObjectCoproduct(*, components: tuple[ObjectExpr, ...], line: int = 0, col: int = 0, kind: Literal['object_coproduct'] = 'object_coproduct')

Bases: ObjectExpr

Coproduct type: A + B.

ObjectEffectApply didactic-model

ObjectEffectApply(*, effect: str, args: tuple[ObjectExpr, ...], line: int = 0, col: int = 0, kind: Literal['object_effect_apply'] = 'object_effect_apply')

Bases: ObjectExpr

Effect-typed type-application: T(X).

The effect field names the effect (a previously-declared effect or stdlib effect); args are its applied arguments. Legal only inside a FreeResiduated whose effects list mentions the named effect.

ObjectExpr didactic-model

ObjectExpr()

Bases: TaggedUnion

Sum of type-expression node kinds.

TypeName didactic-model

TypeName(*, name: str, line: int = 0, col: int = 0, kind: Literal['type_name'] = 'type_name')

Bases: ObjectExpr

A named type reference (identifier or integer literal).

ObjectProduct didactic-model

ObjectProduct(*, components: tuple[ObjectExpr, ...], line: int = 0, col: int = 0, kind: Literal['object_product'] = 'object_product')

Bases: ObjectExpr

Product type: A * B.

ObjectSequence didactic-model

ObjectSequence(*, argument: str, length: str, line: int = 0, col: int = 0, kind: Literal['object_sequence'] = 'object_sequence')

Bases: ObjectExpr

A name sequence argument ... length, an argument of an application in a rule schema.

The names argument_1 through argument_length, the sequence variable's names as in a slash spine (ObjectSpine): an application whose argument it is stands for one application per name, nested to the right, e(z ... n, B) being B at n = 0 and e(z_1, e(z_2, ... e(z_n, B))) otherwise. Instantiating the schema replaces the application by the nested applications it stands for, so Lam(z ... n, B) binds n names, which a spine G |App z ... n over the same name applies G to in order.

ObjectSlash didactic-model

ObjectSlash(*, result: ObjectExpr, argument: ObjectExpr, direction: Literal['/', '\\'], line: int = 0, col: int = 0, kind: Literal['object_slash'] = 'object_slash')

Bases: ObjectExpr

Residuated slash type: result / argument or result \ argument.

Legal only when both operands inhabit a residuated universe (typically a FreeResiduated object). The compiler enforces this at use-site; the grammar accepts the slash on any pair of type expressions.

ObjectSpine didactic-model

ObjectSpine(*, head: ObjectExpr, slash: str, argument: str, length: str, line: int = 0, col: int = 0, kind: Literal['object_spine'] = 'object_spine')

Bases: ObjectExpr

A slash spine head |slash argument ... length of a rule schema.

The category head taking length arguments argument_1 through argument_length, each through the slash slash: a sequence pattern whose length is a schema parameter or a numeral. Instantiating the schema replaces it by the nested applications it stands for.

ObjectFeatures didactic-model

ObjectFeatures(*, atom: str, features: tuple[ObjectExpr, ...], line: int = 0, col: int = 0, kind: Literal['object_features'] = 'object_features')

Bases: ObjectExpr

An atom at feature values, NP[sg] or NP[n], in a refined deduction.

The atom is declared with features (atoms NP[num : Num]); each feature is a member of the feature's category set or a variable over it. Expanding the deduction (quivers.dsl.lexical) replaces it by the atom the refinement declares for those values.

AtomFeature didactic-model

AtomFeature(*, set_name: str, name: str = '', line: int = 0, col: int = 0)

Bases: Model

num : Num: one feature of an atom and the set its values range over.

PARAMETER DESCRIPTION
name

The feature's name, or empty when unnamed.

TYPE: str DEFAULT: ''

set_name

The category set of its values.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

AtomImage didactic-model

AtomImage(*, atom: str, image: str)

Bases: Model

An atom of a refinement and the base atom it forgets to.

PARAMETER DESCRIPTION
atom

The refinement's atom, such as NP__sg.

TYPE: str

image

The base atom, such as NP.

TYPE: str

AtomFeatures didactic-model

AtomFeatures(*, atom: str, features: tuple[AtomFeature, ...], line: int = 0, col: int = 0)

Bases: Model

NP[num : Num]: an atom declared with features.

PARAMETER DESCRIPTION
atom

The atom.

TYPE: str

features

Its features, in order.

TYPE: tuple[AtomFeature, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

CategoryBinder didactic-model

CategoryBinder(*, name: str, set_name: str, line: int = 0, col: int = 0)

Bases: Model

X in Conj: a category variable and the set it ranges over.

PARAMETER DESCRIPTION
name

The variable.

TYPE: str

set_name

The declared category set.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

CategorySetDecl didactic-model

CategorySetDecl(*, name: str, members: tuple[ObjectExpr, ...], line: int = 0, col: int = 0)

Bases: Model

categories Conj = S, N, Bwd(Conj, Arg): a regular set of categories.

The set is the least one holding every member, where a member names the set itself or another declared set at the positions it may take any of that set's elements.

PARAMETER DESCRIPTION
name

The set.

TYPE: str

members

The members, each a category whose atoms may name declared sets.

TYPE: tuple[ObjectExpr, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

FixedBinding didactic-model

FixedBinding(*, name: str, value: ObjectExpr)

Bases: Model

A variable of a rule bound once, when the rule is written.

PARAMETER DESCRIPTION
name

The variable of the source rule.

TYPE: str

value

The category or meaning it is bound to.

TYPE: ObjectExpr

LexicalRuleDecl didactic-model

LexicalRuleDecl(*, name: str, premise: ObjectExpr, conclusion: ObjectExpr, options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

lexical rule r : premise |- conclusion: a rule over lexical items.

PARAMETER DESCRIPTION
name

The rule.

TYPE: str

premise

The lexical item it applies to.

TYPE: ObjectExpr

conclusion

The lexical item it derives, over the same span.

TYPE: ObjectExpr

options

Its pragma: learnable, mode (compile or chart), and bound (how many lexical rules a compiled entry may chain).

TYPE: tuple[OptionEntry, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

LexicalTemplate didactic-model

LexicalTemplate(*, name: str, parameter: str, category: ObjectExpr, lf: LetExprNode, binders: tuple[CategoryBinder, ...] = (), options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

template noun(p) : N = Lam(x, App(p, x)): a family of entries.

An entry whose category names the template takes the template's category and its meaning at the entry's own meaning.

PARAMETER DESCRIPTION
name

The template.

TYPE: str

parameter

The name the template's meaning abstracts over.

TYPE: str

binders

The category variables of a polymorphic template.

TYPE: tuple[CategoryBinder, ...] DEFAULT: ()

category

The category.

TYPE: ObjectExpr

lf

The meaning, over parameter.

TYPE: LetExprNode

options

The template's pragma, shared by every entry it makes.

TYPE: tuple[OptionEntry, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

SemanticClause didactic-model

SemanticClause(*, category: ObjectExpr, type_expr: ObjectExpr, line: int = 0, col: int = 0)

Bases: Model

Fwd(A, B) => Arr(B, A): the semantic type of a category shape.

PARAMETER DESCRIPTION
category

The category pattern; names that are not atoms are variables.

TYPE: ObjectExpr

type_expr

The semantic type, a term of the typing judgment's syntax over the pattern's variables, each standing for its category's type.

TYPE: ObjectExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

SemanticsDecl didactic-model

SemanticsDecl(*, judgment: str, clauses: tuple[SemanticClause, ...], line: int = 0, col: int = 0)

Bases: Model

semantics Ty: the semantic types of the deduction's categories.

PARAMETER DESCRIPTION
judgment

The typing judgment every lexical meaning is checked against, Ty(ctx, term, type).

TYPE: str

clauses

One clause per category shape, tried in order.

TYPE: tuple[SemanticClause, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

SpecializedWeight didactic-model

SpecializedWeight(*, rule: str, bindings: tuple[FixedBinding, ...] = (), deduction: str = '', images: tuple[AtomImage, ...] = (), entries: tuple[int, ...] = ())

Bases: Model

The learned weight of another rule a rule reads.

A rule specialized to a lazily instantiated entry reads its source rule's learned weight on the source's own bindings: those the specialized rule matches, and those the specialization fixed. A rule a refinement inherits from its base reads the base rule's learned weight on the forgetful images of its bindings, so the two deductions share the rule's parameters.

PARAMETER DESCRIPTION
rule

The source rule.

TYPE: str

bindings

The source rule's variables the specialization fixed.

TYPE: tuple[FixedBinding, ...] DEFAULT: ()

deduction

The deduction the source rule belongs to, when it is the base of a refinement; empty for the rule's own deduction.

TYPE: str DEFAULT: ''

images

The forgetful map on atoms, for a base rule: every binding is read through it.

TYPE: tuple[AtomImage, ...] DEFAULT: ()

entries

For a rule specialized to a lazily instantiated entry, the positions in the lexicon of the consumed instances whose weights the rule also reads: every one in a grammar normalized per left-hand side, whose production weights it reads, and otherwise those of an entry that weighs each instance apart, whose weight families it reads; empty otherwise.

TYPE: tuple[int, ...] DEFAULT: ()

AgendaPlan didactic-model

AgendaPlan(*, deduction: DeductionDecl = field(opaque=True, extras=OPAQUE_BY_VALUE), sources: Mapping[str, str] = field(opaque=True, default_factory=dict, extras=OPAQUE_BY_VALUE), instances: Mapping[str, Mapping[int, ObjectExpr]] = field(opaque=True, default_factory=dict, extras=OPAQUE_BY_VALUE), placeholders: Mapping[str, tuple[tuple[ObjectExpr, int], ...]] = field(opaque=True, default_factory=dict, extras=OPAQUE_BY_VALUE), apart: tuple[str, ...] = (), wrapper: str = '', lift: str = '', lexical: tuple[str, ...] = ())

Bases: ValueModel

The deduction the agenda engine runs in place of one, and what it stands for.

PARAMETER DESCRIPTION
deduction

The deduction the agenda runs: the written deduction's rules and entries, with the placeholder entries, the specialized rules, the wrapped lexical items, and the lift added.

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

sources

Each rule the plan adds, mapped to the written rule it stands for: a specialized rule to its source, a chart lexical rule specialized to a placeholder to the lexical rule. The lift is no entry.

TYPE: Mapping[str, str] DEFAULT: field(opaque=True, default_factory=dict, extras=OPAQUE_BY_VALUE)

instances

Each specialized rule's instance category at each premise position that takes a placeholder.

TYPE: Mapping[str, Mapping[int, ObjectExpr]] DEFAULT: field(opaque=True, default_factory=dict, extras=OPAQUE_BY_VALUE)

placeholders

Each placeholder atom, the instance categories it stands for, and the plan's lexicon position of each instance's entry (an entry that is no axiom, read under normalize=lhs as the instance's production), whose weights the instance also reads where its placeholder is in apart.

TYPE: Mapping[str, tuple[tuple[ObjectExpr, int], ...]] DEFAULT: field(opaque=True, default_factory=dict, extras=OPAQUE_BY_VALUE)

apart

The placeholders of entries that weigh each instance apart (per_instance), which weigh nothing themselves.

TYPE: tuple[str, ...] DEFAULT: ()

wrapper

The atom wrapping lexical items for chart lexical rules, or empty.

TYPE: str DEFAULT: ''

lift

The rule unwrapping a lexical item, or empty.

TYPE: str DEFAULT: ''

lexical

The plan's copies of the chart lexical rules, one per lexical rule and level, each concluding a wrapped item the lift reads as an entry of the deduction.

TYPE: tuple[str, ...] DEFAULT: ()

DeductionCore didactic-model

DeductionCore(*, name: str, symbols: tuple[str, ...] = (), deriving: tuple[DerivingClass, ...] = (), includes: tuple[str, ...] = ())

Bases: Model

A deduction signature a composed deduction extends.

PARAMETER DESCRIPTION
name

The signature.

TYPE: str

symbols

Every symbol the signature declares or includes, in declaration order: the constructors of its item family.

TYPE: tuple[str, ...] DEFAULT: ()

deriving

The classes the signature derives for its item family; an extension deriving a class into the same target copairs the signature's algebra with its own.

TYPE: tuple[DerivingClass, ...] DEFAULT: ()

includes

The signatures it includes, itself among them: the declarations whose atoms and rules are its language.

TYPE: tuple[str, ...] DEFAULT: ()

DeductionExtension didactic-model

DeductionExtension(*, name: str, constraints: tuple[SchemaConstraint, ...] = (), weights: WeightMode = 'unweighted', line: int = 0, col: int = 0)

Bases: Model

One entry of an extends line: a signature and its restriction.

PARAMETER DESCRIPTION
name

The deduction signature extended.

TYPE: str

constraints

Constraints that keep only the instances of the signature's schemata whose parameters satisfy them.

TYPE: tuple[SchemaConstraint, ...] DEFAULT: ()

weights

How the deduction weighs the rules and schemata it takes from the signature: shared gives each rule one learned weight, read by every instance of a schema; per instance gives each instance its own; unweighted (the default) learns none.

TYPE: WeightMode DEFAULT: 'unweighted'

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

LexiconReference didactic-model

LexiconReference(*, name: str, weights: WeightMode = 'unweighted', line: int = 0, col: int = 0)

Bases: Model

One lexicon module a deduction takes its entries from.

PARAMETER DESCRIPTION
name

The lexicon module.

TYPE: str

weights

How the deduction weighs the module's entries: shared gives a polymorphic entry one learned weight across its instances, per instance one per instance, and unweighted (the default) learns none.

TYPE: WeightMode DEFAULT: 'unweighted'

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

RuleInstantiation didactic-model

RuleInstantiation(*, schema: str, constraints: tuple[SchemaConstraint, ...] = (), condition: LetExprNode | None = None, line: int = 0, col: int = 0)

Bases: Model

rules r[n <= 2, e in Dir] where c: instances of one schema.

PARAMETER DESCRIPTION
schema

The rule schema instantiated.

TYPE: str

constraints

The bracketed constraints on its parameters.

TYPE: tuple[SchemaConstraint, ...] DEFAULT: ()

condition

The where condition, if any.

TYPE: LetExprNode | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

SchemaCondition didactic-model

SchemaCondition(*, condition: LetExprNode, line: int = 0, col: int = 0, kind: Literal['schema_condition'] = 'schema_condition')

Bases: SchemaConstraint

A condition on the parameters, such as n <= 2.

PARAMETER DESCRIPTION
condition

A Boolean expression over the schema's parameters.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "schema_condition".

TYPE: Literal['schema_condition'] DEFAULT: 'schema_condition'

SchemaConstraint didactic-model

SchemaConstraint()

Bases: TaggedUnion

A constraint on the parameters of a rule schema.

SchemaMembership didactic-model

SchemaMembership(*, parameter: str, domain: str = '', elements: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['schema_membership'] = 'schema_membership')

Bases: SchemaConstraint

p in Dir or p in {Fwd, Bwd}: the values a parameter takes.

PARAMETER DESCRIPTION
parameter

The schema parameter.

TYPE: str

domain

The index sort named after in, or empty for an element set.

TYPE: str DEFAULT: ''

elements

The listed elements, for in {...}.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "schema_membership".

TYPE: Literal['schema_membership'] DEFAULT: 'schema_membership'

SymbolOrigin didactic-model

SymbolOrigin(*, symbol: str, origin: str)

Bases: Model

Where a symbol or a rule of a composed deduction was declared.

PARAMETER DESCRIPTION
symbol

An atom of the deduction, or the name of one of its rules.

TYPE: str

origin

The deduction signature, lexicon module, or deduction declaring it.

TYPE: str

DeductionSignatureDecl didactic-model

DeductionSignatureDecl(*, name: str, extends: tuple[DeductionExtension, ...] = (), atoms: tuple[str, ...] = (), binders: tuple[str, ...] = (), rules: tuple[SequentRule, ...] = (), instantiations: tuple[RuleInstantiation, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, deriving: tuple[DerivingClass, ...] = (), kind: Literal['deduction_signature_decl'] = 'deduction_signature_decl')

Bases: Statement

deduction signature NAME: atoms and rules with no lexicon.

PARAMETER DESCRIPTION
name

The signature's name.

TYPE: str

extends

The signatures it includes.

TYPE: tuple[DeductionExtension, ...] DEFAULT: ()

atoms

The atoms it declares.

TYPE: tuple[str, ...] DEFAULT: ()

binders

The binder constructors it declares.

TYPE: tuple[str, ...] DEFAULT: ()

rules

Its rules and rule schemata.

TYPE: tuple[SequentRule, ...] DEFAULT: ()

instantiations

Its rules lines.

TYPE: tuple[RuleInstantiation, ...] DEFAULT: ()

docs

The doc comment.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

deriving

The classes derived for its item family.

TYPE: tuple[DerivingClass, ...] DEFAULT: ()

kind

The discriminator; always "deduction_signature_decl".

TYPE: Literal['deduction_signature_decl'] DEFAULT: 'deduction_signature_decl'

LexiconDecl didactic-model

LexiconDecl(*, name: str, signature: str, atoms: tuple[str, ...] = (), entries: tuple[LexiconEntry, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['lexicon_decl'] = 'lexicon_decl')

Bases: Statement

lexicon NAME for S: lexical entries typed against a signature.

PARAMETER DESCRIPTION
name

The lexicon module's name.

TYPE: str

signature

The deduction signature its categories are drawn from.

TYPE: str

atoms

The logical-form constants it declares.

TYPE: tuple[str, ...] DEFAULT: ()

entries

Its entries.

TYPE: tuple[LexiconEntry, ...] DEFAULT: ()

docs

The doc comment.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "lexicon_decl".

TYPE: Literal['lexicon_decl'] DEFAULT: 'lexicon_decl'

ModelDecl didactic-model

ModelDecl(*, name: str, theory: str | None = None, interpretations: tuple[ModelInterpretationDecl, ...] = (), construction: Literal['reduct', 'free'] | None = None, source: str | None = None, view: str | None = None, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['model_decl'] = 'model_decl')

Bases: Statement

model NAME of T with its interpretations, or a constructed model.

Exactly one form is written: theory with interpretations, or construction with source and view.

PARAMETER DESCRIPTION
name

The model's name.

TYPE: str

theory

The theory it interprets, for the interpreted form.

TYPE: str or None DEFAULT: None

interpretations

The interpretation of each sort and operation.

TYPE: tuple of ModelInterpretationDecl DEFAULT: ()

construction

"reduct" or "free", for a constructed model.

TYPE: str or None DEFAULT: None

source

The model the construction starts from.

TYPE: str or None DEFAULT: None

view

The view it is taken along.

TYPE: str or None DEFAULT: None

docs

Its doc comment lines.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

ModelInterpretationDecl didactic-model

ModelInterpretationDecl(*, symbol: str, value: str, line: int = 0, col: int = 0)

Bases: Model

S = Bool or plus = bool_or in a model.

PARAMETER DESCRIPTION
symbol

A sort or operation of the model's theory.

TYPE: str

value

The QIEC type interpreting a sort, or the computation interpreting an operation.

TYPE: str

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryArgument didactic-model

TheoryArgument(*, parameter: str, theory: str, view: str | None = None, line: int = 0, col: int = 0)

Bases: Model

One argument P := X via v of a generic theory's instantiation.

PARAMETER DESCRIPTION
parameter

The parameter of the generic theory.

TYPE: str

theory

The actual theory.

TYPE: str

view

The fitting view from the parameter's theory to theory, or None when theory includes the parameter's theory.

TYPE: str or None DEFAULT: None

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryBinderDecl didactic-model

TheoryBinderDecl(*, names: tuple[str, ...], sort: PatternSyntax, line: int = 0, col: int = 0)

Bases: Model

a b : Ob: names that range over one sort.

PARAMETER DESCRIPTION
names

The names bound.

TYPE: tuple of str

sort

Their sort: a sort's name, or a dependent sort applied to earlier names, Hom(a, b).

TYPE: PatternSyntax

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryDecl didactic-model

TheoryDecl(*, name: str, parameters: tuple[TheoryParameterDecl, ...] = (), value: TheoryExpr | None = None, includes: tuple[TheoryIncludeDecl, ...] = (), sorts: tuple[TheorySortDecl, ...] = (), operations: tuple[TheoryOperationDecl, ...] = (), equations: tuple[EquationDecl, ...] = (), equation_options: tuple[OptionEntry, ...] = (), assume_terminating: bool = False, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['theory_decl'] = 'theory_decl')

Bases: Statement

theory NAME[params] = e with its body.

PARAMETER DESCRIPTION
name

The theory's name.

TYPE: str

parameters

Its parameters, for a generic theory.

TYPE: tuple of TheoryParameterDecl DEFAULT: ()

value

The theory expression it extends, if written.

TYPE: TheoryExpr or None DEFAULT: None

includes

The theories it includes.

TYPE: tuple of TheoryIncludeDecl DEFAULT: ()

sorts

Its own sorts.

TYPE: tuple of TheorySortDecl DEFAULT: ()

operations

Its own operations.

TYPE: tuple of TheoryOperationDecl DEFAULT: ()

equations

Its own equations (=) and rules (~>).

TYPE: tuple of EquationDecl DEFAULT: ()

equation_options

The options of its equations block.

TYPE: tuple of OptionEntry DEFAULT: ()

assume_terminating

Whether termination of its rules is a recorded assumption.

TYPE: bool DEFAULT: False

docs

Its doc comment lines.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryExpr didactic-model

TheoryExpr()

Bases: TaggedUnion

Sum of the theory expressions of the module algebra.

TheoryHiding didactic-model

TheoryHiding(*, theory: TheoryExpr, names: tuple[str, ...] = (), line: int = 0, col: int = 0, form: Literal['theory_hiding'] = 'theory_hiding')

Bases: TheoryExpr

e hiding (a, ...): a theory with symbols removed from its exports.

PARAMETER DESCRIPTION
theory

The theory.

TYPE: TheoryExpr

names

The hidden sorts and operations.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryIncludeDecl didactic-model

TheoryIncludeDecl(*, theory: TheoryExpr, options: tuple[OptionEntry, ...] = (), line: int = 0, col: int = 0)

Bases: Model

include e [conservative] in a theory body.

PARAMETER DESCRIPTION
theory

The included theory.

TYPE: TheoryExpr

options

The declared classification of the extension.

TYPE: tuple of OptionEntry DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryInputDecl didactic-model

TheoryInputDecl(*, names: tuple[str, ...] = (), sort: PatternSyntax, implicit: bool = False, line: int = 0, col: int = 0)

Bases: Model

An input of an operation: a sort, (f : Hom(a, b)), or {a b : Ob}.

PARAMETER DESCRIPTION
names

The names of the inputs it declares, empty for one unnamed input.

TYPE: tuple of str DEFAULT: ()

sort

Their sort.

TYPE: PatternSyntax

implicit

Whether the inputs are implicit, inferred where the operation is applied rather than written as arguments.

TYPE: bool DEFAULT: False

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryInstantiation didactic-model

TheoryInstantiation(*, theory: str, arguments: tuple[TheoryArgument, ...] = (), line: int = 0, col: int = 0, form: Literal['theory_instantiation'] = 'theory_instantiation')

Bases: TheoryExpr

G[P := X via v, ...]: a generic theory instantiated by pushout.

PARAMETER DESCRIPTION
theory

The generic theory.

TYPE: str

arguments

One argument per parameter.

TYPE: tuple of TheoryArgument DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryOperationDecl didactic-model

TheoryOperationDecl(*, name: str, inputs: tuple[TheoryInputDecl, ...] = (), output: PatternSyntax, line: int = 0, col: int = 0)

Bases: Model

An operation name : A, B -> C a theory declares.

PARAMETER DESCRIPTION
name

The operation's name.

TYPE: str

inputs

Its inputs, in order.

TYPE: tuple of TheoryInputDecl DEFAULT: ()

output

The sort of its result.

TYPE: PatternSyntax

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryParameterDecl didactic-model

TheoryParameterDecl(*, name: str, theory: str, line: int = 0, col: int = 0)

Bases: Model

A parameter P : S of a generic theory.

PARAMETER DESCRIPTION
name

The parameter's name.

TYPE: str

theory

The theory the parameter ranges over.

TYPE: str

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryRef didactic-model

TheoryRef(*, name: str, line: int = 0, col: int = 0, form: Literal['theory_ref'] = 'theory_ref')

Bases: TheoryExpr

A theory named by its declaration.

PARAMETER DESCRIPTION
name

The theory's name.

TYPE: str

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryRename didactic-model

TheoryRename(*, source: str, target: str, line: int = 0, col: int = 0)

Bases: Model

One source => target pair of a renaming.

PARAMETER DESCRIPTION
source

The sort or operation renamed.

TYPE: str

target

Its new name.

TYPE: str

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheoryRenaming didactic-model

TheoryRenaming(*, theory: TheoryExpr, renames: tuple[TheoryRename, ...] = (), line: int = 0, col: int = 0, form: Literal['theory_renaming'] = 'theory_renaming')

Bases: TheoryExpr

e renaming (a => b, ...): a copy of a theory with new names.

PARAMETER DESCRIPTION
theory

The renamed theory.

TYPE: TheoryExpr

renames

The renamed symbols.

TYPE: tuple of TheoryRename DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheorySortDecl didactic-model

TheorySortDecl(*, name: str, parameters: tuple[TheoryBinderDecl, ...] = (), line: int = 0, col: int = 0)

Bases: Model

A sort a theory declares, Ob or Hom(a b : Ob).

PARAMETER DESCRIPTION
name

The sort's name.

TYPE: str

parameters

Its parameters, for a dependent sort.

TYPE: tuple of TheoryBinderDecl DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

TheorySum didactic-model

TheorySum(*, summands: tuple[TheoryExpr, ...] = (), shared: tuple[str, ...] = (), line: int = 0, col: int = 0, form: Literal['theory_sum'] = 'theory_sum')

Bases: TheoryExpr

A + B over C: the colimit of theories over declared shared theories.

PARAMETER DESCRIPTION
summands

The theories composed.

TYPE: tuple of TheoryExpr DEFAULT: ()

shared

The theories they are declared to share.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

ViewAssumptionDecl didactic-model

ViewAssumptionDecl(*, equation: str, line: int = 0, col: int = 0)

Bases: Model

An equation whose obligation a view records as assumed.

PARAMETER DESCRIPTION
equation

The equation's name in the view's domain.

TYPE: str

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

ViewDecl didactic-model

ViewDecl(*, name: str, domain: str, codomain: str, mappings: tuple[ViewMappingDecl, ...] = (), assumptions: tuple[ViewAssumptionDecl, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['view_decl'] = 'view_decl')

Bases: Statement

view NAME : S -> T with its mappings.

PARAMETER DESCRIPTION
name

The view's name.

TYPE: str

domain

The theory mapped.

TYPE: str

codomain

The theory mapped into.

TYPE: str

mappings

The image of each sort and operation.

TYPE: tuple of ViewMappingDecl DEFAULT: ()

assumptions

The obligations recorded as assumed.

TYPE: tuple of ViewAssumptionDecl DEFAULT: ()

docs

Its doc comment lines.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

ViewMappingDecl didactic-model

ViewMappingDecl(*, source: PatternSyntax, target: PatternSyntax, line: int = 0, col: int = 0)

Bases: Model

M => S or mul(x, y) => plus(x, y) in a view.

PARAMETER DESCRIPTION
source

A sort or operation name, or an operation applied to distinct variables naming its arguments.

TYPE: PatternSyntax

target

The image: a name, or a term over the source's variables.

TYPE: PatternSyntax

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

DeductionSemiring didactic-model

DeductionSemiring(*, name: str, instance: str | None = None, theory: str | None = None, line: int = 0, col: int = 0)

Bases: Model

The semiring parameter of a deduction header.

Exactly one of instance and theory is given.

PARAMETER DESCRIPTION
name

The parameter's name, a label of the deduction.

TYPE: str

instance

The instance the deduction runs in, for [S = I].

TYPE: str or None DEFAULT: None

theory

The theory whose instances the deduction ranges over, for [S : T].

TYPE: str or None DEFAULT: None

line

The source position of the bracket.

TYPE: int DEFAULT: 0

col

The source position of the bracket.

TYPE: int DEFAULT: 0

SemiringDecl didactic-model

SemiringDecl(*, name: str, theory: str, algebra: str, carrier: str, assumptions: tuple[ViewAssumptionDecl, ...] = (), docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['semiring_decl'] = 'semiring_decl')

Bases: Statement

semiring I : T = algebra A on C with its assumed laws.

PARAMETER DESCRIPTION
name

The instance's name.

TYPE: str

theory

The semiring theory it is an instance of.

TYPE: str

algebra

The shipped algebra realizing it, by the name of its law claims (LogProb, MaxPlus, Boolean, Counting, ...).

TYPE: str

carrier

The kernel type holding its elements (LogWeight, Real, Bool, Int).

TYPE: str

assumptions

The laws of T recorded as assumed.

TYPE: tuple of ViewAssumptionDecl DEFAULT: ()

docs

Its doc comment lines.

TYPE: tuple of str DEFAULT: ()

line

The source position.

TYPE: int DEFAULT: 0

col

The source position.

TYPE: int DEFAULT: 0

LetExprHole didactic-model

LetExprHole(*, name: str, type_expr: QiecTypeExpr | None = None, line: int = 0, col: int = 0, kind: Literal['let_hole'] = 'let_hole')

Bases: LetExprNode

A value hole ?name or ?name : T.

PARAMETER DESCRIPTION
name

The hole's name, without the ?.

TYPE: str

type_expr

The goal type written after the hole, or None when the position the hole stands in supplies it.

TYPE: QiecTypeExpr | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_hole".

TYPE: Literal['let_hole'] DEFAULT: 'let_hole'

QiecTypeHole didactic-model

QiecTypeHole(*, name: str, line: int = 0, col: int = 0, kind: Literal['qiec_type_hole'] = 'qiec_type_hole')

Bases: QiecTypeExpr

A type hole ?A: an unknown type, distinct from every other type.

PARAMETER DESCRIPTION
name

The hole's name, without the ?.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_type_hole".

TYPE: Literal['qiec_type_hole'] DEFAULT: 'qiec_type_hole'

LetAxisBinder didactic-model

LetAxisBinder(*, name: str, axis: QiecTypeExpr, line: int = 0, col: int = 0)

Bases: Model

One name : T binder of a tabulation or a reduction.

PARAMETER DESCRIPTION
name

The name the body reads an element through.

TYPE: str

axis

The finite type it ranges over.

TYPE: QiecTypeExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

LetExprReduction didactic-model

LetExprReduction(*, operator: str, binders: tuple[LetAxisBinder, ...], body: LetExprNode, line: int = 0, col: int = 0, kind: Literal['let_expr_reduction'] = 'let_expr_reduction')

Bases: LetExprNode

The reduction logsumexp over w : World. e.

PARAMETER DESCRIPTION
operator

The reduction: sum, mean, max, min, prod, or logsumexp.

TYPE: str

binders

The binders it reduces over, at least one.

TYPE: tuple[LetAxisBinder, ...]

body

The term reduced.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_reduction".

TYPE: Literal['let_expr_reduction'] DEFAULT: 'let_expr_reduction'

LetExprTabulation didactic-model

LetExprTabulation(*, binders: tuple[LetAxisBinder, ...], body: LetExprNode, line: int = 0, col: int = 0, kind: Literal['let_expr_tabulation'] = 'let_expr_tabulation')

Bases: LetExprNode

The tensor for w : World, s : Subject. e.

Its entry at each element of the binders' types is the body there, so its type is the body's indexed by those types, in canonical axis order.

PARAMETER DESCRIPTION
binders

The binders, at least one.

TYPE: tuple[LetAxisBinder, ...]

body

The entry.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_tabulation".

TYPE: Literal['let_expr_tabulation'] DEFAULT: 'let_expr_tabulation'

QiecFinType didactic-model

QiecFinType(*, extent: QiecIndexExpr, line: int = 0, col: int = 0, kind: Literal['qiec_fin_type'] = 'qiec_fin_type')

Bases: QiecTypeExpr

The positional index set Fin n.

PARAMETER DESCRIPTION
extent

The number of positions, a natural-number index.

TYPE: QiecIndexExpr

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_fin_type".

TYPE: Literal['qiec_fin_type'] DEFAULT: 'qiec_fin_type'

QiecTensorType didactic-model

QiecTensorType(*, element: QiecTypeExpr, axes: tuple[QiecTypeExpr, ...], line: int = 0, col: int = 0, kind: Literal['qiec_tensor_type'] = 'qiec_tensor_type')

Bases: QiecTypeExpr

A tensor of a parenthesized element type, (E)[T1, ..., Tk].

A tensor of a named element type is the application Real[World]; this node is the same type when the element is compound.

PARAMETER DESCRIPTION
element

The element type.

TYPE: QiecTypeExpr

axes

The finite types indexing its axes, as written.

TYPE: tuple[QiecTypeExpr, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_tensor_type".

TYPE: Literal['qiec_tensor_type'] DEFAULT: 'qiec_tensor_type'

LetExprCaseBranch didactic-model

LetExprCaseBranch(*, label: str, binder: str | None = None, body: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

One branch l(x) => body of a case function.

PARAMETER DESCRIPTION
label

The alternative the branch handles.

TYPE: str

binder

The name its payload is bound to, or None when the branch ignores it.

TYPE: str | None DEFAULT: None

body

The branch's result.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

LetExprCaseValue didactic-model

LetExprCaseValue(*, branches: tuple[LetExprCaseBranch, ...], line: int = 0, col: int = 0, kind: Literal['let_expr_case_value'] = 'let_expr_case_value')

Bases: LetExprNode

A first-class case case { l(x) => e, ... }: a function on a variant.

PARAMETER DESCRIPTION
branches

One branch per alternative, in source order.

TYPE: tuple[LetExprCaseBranch, ...]

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_case_value".

TYPE: Literal['let_expr_case_value'] DEFAULT: 'let_expr_case_value'

LetExprInjection didactic-model

LetExprInjection(*, label: str, payload: LetExprNode | None = None, line: int = 0, col: int = 0, kind: Literal['let_expr_injection'] = 'let_expr_injection')

Bases: LetExprNode

An injection <l = v> into one alternative of a variant.

PARAMETER DESCRIPTION
label

The alternative.

TYPE: str

payload

The value it carries, or None for <l>, which carries unit.

TYPE: LetExprNode | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_injection".

TYPE: Literal['let_expr_injection'] DEFAULT: 'let_expr_injection'

LetExprProjection didactic-model

LetExprProjection(*, record: LetExprNode, label: str, line: int = 0, col: int = 0, kind: Literal['let_expr_projection'] = 'let_expr_projection')

Bases: LetExprNode

The field label of a record expression.

A field of a local is written x.label and parses as one dotted name; this node is the same projection on an arbitrary expression, which substituting an expression for x produces.

PARAMETER DESCRIPTION
record

The record expression.

TYPE: LetExprNode

label

The field read.

TYPE: str

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_projection".

TYPE: Literal['let_expr_projection'] DEFAULT: 'let_expr_projection'

LetExprRecord didactic-model

LetExprRecord(*, fields: tuple[LetExprRecordField, ...] = (), base: LetExprNode | None = None, line: int = 0, col: int = 0, kind: Literal['let_expr_record'] = 'let_expr_record')

Bases: LetExprNode

A record {l = v, ...}, or an extension {x with l = v, ...}.

PARAMETER DESCRIPTION
fields

The fields written, in source order.

TYPE: tuple[LetExprRecordField, ...] DEFAULT: ()

base

The extended record, or None for a record built from its fields alone.

TYPE: LetExprNode | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "let_expr_record".

TYPE: Literal['let_expr_record'] DEFAULT: 'let_expr_record'

LetExprRecordField didactic-model

LetExprRecordField(*, label: str, value: LetExprNode, line: int = 0, col: int = 0)

Bases: Model

One field label = value of a record expression.

PARAMETER DESCRIPTION
label

The field's label.

TYPE: str

value

Its value.

TYPE: LetExprNode

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecRecordDecl didactic-model

QiecRecordDecl(*, name: str, binders: tuple[QiecBinder, ...] = (), type: QiecRecordType, docs: tuple[str, ...] = (), line: int = 0, col: int = 0, kind: Literal['record_decl'] = 'record_decl')

Bases: Statement

record NAME[binders] {row}, a name for a record type.

PARAMETER DESCRIPTION
name

The record type's name.

TYPE: str

binders

The static telescope the type is over.

TYPE: tuple[QiecBinder, ...] DEFAULT: ()

type

The record type it names.

TYPE: QiecRecordType

docs

The doc comment lines attached to the declaration.

TYPE: tuple[str, ...] DEFAULT: ()

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "record_decl".

TYPE: Literal['record_decl'] DEFAULT: 'record_decl'

QiecRecordType didactic-model

QiecRecordType(*, fields: tuple[QiecRowField, ...] = (), tail: str | None = None, line: int = 0, col: int = 0, kind: Literal['qiec_record_type'] = 'qiec_record_type')

Bases: QiecTypeExpr

A record type {l : T, ... | r}.

PARAMETER DESCRIPTION
fields

The explicit entries, in source order.

TYPE: tuple[QiecRowField, ...] DEFAULT: ()

tail

The row variable standing for further entries, or None.

TYPE: str | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_record_type".

TYPE: Literal['qiec_record_type'] DEFAULT: 'qiec_record_type'

QiecRowField didactic-model

QiecRowField(*, label: str, type: QiecTypeExpr | None = None, line: int = 0, col: int = 0)

Bases: Model

One entry label : T of a row; a bare label carries Unit.

PARAMETER DESCRIPTION
label

The entry's label.

TYPE: str

type

Its type, or None for a bare label.

TYPE: QiecTypeExpr | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

QiecRowKind didactic-model

QiecRowKind(*, kind: Literal['qiec_row_kind'] = 'qiec_row_kind')

Bases: QiecKindExpr

The kind Row of a row binder.

PARAMETER DESCRIPTION
kind

The discriminator; always "qiec_row_kind".

TYPE: Literal['qiec_row_kind'] DEFAULT: 'qiec_row_kind'

QiecRowPredicate didactic-model

QiecRowPredicate(*, left: QiecRecordType, right: QiecRecordType | None = None, result: QiecRecordType | None = None, larger: QiecRecordType | None = None, line: int = 0, col: int = 0, kind: Literal['qiec_row_predicate'] = 'qiec_row_predicate')

Bases: QiecBinder

A row predicate in a static telescope.

PARAMETER DESCRIPTION
left

The first operand; a bare row variable r is the row {| r}.

TYPE: QiecRecordType

right

The second part of a combination left ++ right ~ result, or None for a containment.

TYPE: QiecRecordType | None DEFAULT: None

result

The combined row of a combination, or None for a containment.

TYPE: QiecRecordType | None DEFAULT: None

larger

The containing row of a containment left <= larger, or None for a combination.

TYPE: QiecRecordType | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_row_predicate".

TYPE: Literal['qiec_row_predicate'] DEFAULT: 'qiec_row_predicate'

QiecVariantType didactic-model

QiecVariantType(*, fields: tuple[QiecRowField, ...] = (), tail: str | None = None, line: int = 0, col: int = 0, kind: Literal['qiec_variant_type'] = 'qiec_variant_type')

Bases: QiecTypeExpr

A variant type <l : T, m, ... | r>.

PARAMETER DESCRIPTION
fields

The explicit alternatives, in source order.

TYPE: tuple[QiecRowField, ...] DEFAULT: ()

tail

The row variable standing for further alternatives, or None.

TYPE: str | None DEFAULT: None

line

The 1-based source line, or 0 when unknown.

TYPE: int DEFAULT: 0

col

The 0-based source column, or 0 when unknown.

TYPE: int DEFAULT: 0

kind

The discriminator; always "qiec_variant_type".

TYPE: Literal['qiec_variant_type'] DEFAULT: 'qiec_variant_type'

atom_to_draw_arg

atom_to_draw_arg(value: str | float | int | DrawArg) -> DrawArg

Lift a plain Python value into the DrawArg it denotes.

PARAMETER DESCRIPTION
value

A name, a number, or an argument that is already a DrawArg.

TYPE: str | float | int | DrawArg

RETURNS DESCRIPTION
DrawArg

A DrawArgName for a string, a DrawArgScalar for a number, and value itself for a DrawArg.

RAISES DESCRIPTION
TypeError

If value is none of the accepted kinds.

Source code in src/quivers/dsl/ast_nodes/program_steps.py
def atom_to_draw_arg(value: str | float | int | DrawArg) -> DrawArg:
    """Lift a plain Python value into the `DrawArg` it denotes.

    Parameters
    ----------
    value : str | float | int | DrawArg
        A name, a number, or an argument that is already a `DrawArg`.

    Returns
    -------
    DrawArg
        A `DrawArgName` for a string, a `DrawArgScalar` for a number,
        and ``value`` itself for a `DrawArg`.

    Raises
    ------
    TypeError
        If ``value`` is none of the accepted kinds.
    """
    if isinstance(value, DrawArg):
        return value
    if isinstance(value, str):
        return DrawArgName(text=value)
    if isinstance(value, (int, float)):
        return DrawArgScalar(value=value)
    raise TypeError(
        f"atom_to_draw_arg: expected str | float | DrawArg, got {type(value).__name__}"
    )

fin_tensor

fin_tensor(element: QiecTypeExpr, extents: tuple[QiecIndexExpr, ...]) -> QiecTypeExpr

The positional tensor type element[Fin e1, ..., Fin ek].

PARAMETER DESCRIPTION
element

The element type.

TYPE: QiecTypeExpr

extents

One extent per axis, outermost first.

TYPE: tuple[QiecIndexExpr, ...]

RETURNS DESCRIPTION
QiecTypeExpr

The application E[Fin e1, ...] for a named element type, the tensor type (E)[Fin e1, ...] for any other.

Source code in src/quivers/dsl/ast_nodes/axes.py
def fin_tensor(
    element: QiecTypeExpr, extents: tuple[QiecIndexExpr, ...]
) -> QiecTypeExpr:
    """The positional tensor type ``element[Fin e1, ..., Fin ek]``.

    Parameters
    ----------
    element : QiecTypeExpr
        The element type.
    extents : tuple[QiecIndexExpr, ...]
        One extent per axis, outermost first.

    Returns
    -------
    QiecTypeExpr
        The application ``E[Fin e1, ...]`` for a named element type, the
        tensor type ``(E)[Fin e1, ...]`` for any other.
    """
    axes = tuple(QiecFinType(extent=extent) for extent in extents)
    if isinstance(element, QiecTypeName):
        return QiecTypeApplication(
            constructor=element.name,
            static_arguments=axes,
            line=element.line,
            col=element.col,
        )
    return QiecTensorType(element=element, axes=axes)