quivers.dsl¶
QVR is the modeling language of quivers, written in .qvr files. load and loads parse, check,
and compile source to a Program, parse
produces the AST that Compiler compiles and module_to_source prints, and the QIEC lowering
elaborates a module into the Quivers Indexed Effect Core and checks it.
The package re-exports the public names of its modules, and the AST node classes are documented
in quivers.dsl.ast_nodes.
dsl
¶
quivers DSL: parse .qvr files into trainable PyTorch models.
The DSL provides a declarative syntax for specifying V-enriched
categorical morphism networks that compile to quivers.Program
instances (nn.Module subclasses). Parsing is delegated to panproto
via the qvr tree-sitter grammar; the AST is a tree of
quivers.dsl.ast_nodes didactic Models.
Morphism roles need not be declared: a morphism drawn with sample
compiles as latent, one drawn with observe as observed, and any
other morphism as a kernel. An explicit [role=...] option always
wins over inference.
Quick start
::
from quivers.dsl import load, loads
program = loads('''
object Resp : FinSet 8
morphism bias : Resp -> Real 1 ~ Normal(0.0, 5.0)
program m : Resp -> Resp
let b <- sample bias
observe y : Resp <- Normal(b, 1.0)
return y
export m
''')
program = load("model.qvr")
optimizer = torch.optim.Adam(program.parameters())
DISTRIBUTION_FAMILIES
module-attribute
¶
DISTRIBUTION_FAMILIES: frozenset[str] = frozenset((*_FAMILY_PARAMETERS, *FAMILY_ALIASES))
Every distribution-family name accepted in QVR source.
Highlighters consume this set so their surface vocabulary follows the same schemas used by validation and lowering.
FAMILY_ALIASES
module-attribute
¶
Surface family names that resolve to another family's registry record.
A key is a name a source may write; its value is the family whose specification builds the distribution.
PARAMETER_ALIASES
module-attribute
¶
PARAMETER_ALIASES: dict[str, dict[str, str]] = {'LogitNormal': {'mu': 'loc', 'sigma': 'scale'}, 'TruncatedNormal': {'mu': 'loc', 'sigma': 'scale'}, 'Mixture': {'components': 'component'}, 'OrderedLogistic': {'predictor': 'eta'}, 'Pushforward': {'bijector': 'transforms'}}
Surface keywords that name a registry parameter under another name.
A family's entry maps each keyword a source may write to the registry parameter it fills, which means the same quantity. A keyword absent here and from the registry record names no parameter of the family.
NOMINAL_KINDS
module-attribute
¶
NOMINAL_KINDS: frozenset[StructureKind] = frozenset({'category', 'morphism', 'encoder', 'decoder', 'relation', 'theory'})
Structure kinds whose name is part of their meaning.
A category is an atom of a categorial calculus, distinct from every other
atom by its name alone; a morphism, encoder, decoder, or relation owns
learned parameters that the compiled runtime and its fit state key by the
declaration's name, outside the checked core. Two such declarations with the
same content are still different declarations, so their name is content. A
theory's name is content too: it is the theory's identity of origin, so two
theories with one presentation are different theories, which a colimit
keeps apart. A deduction is not nominal: its learned parameters are read
through quivers.qiec.terms.ParameterName, whose owner the core reads as a
name, so the deduction's name reaches the free names of every entry that
reads them, where fit keys see it, and the deduction itself is identified by
its content. Every other declaration is identified by its content, and its
name is metadata.
STRUCTURE_STATEMENT_TYPES
module-attribute
¶
STRUCTURE_STATEMENT_TYPES: tuple[type[Statement], ...] = tuple(_KINDS)
The statement classes recorded as structure declarations.
SHARED_OPTION
module-attribute
¶
The option key naming a rule's shared weight family.
QVR_DEDUCTION_PROTOCOL
module-attribute
¶
QVR_DEDUCTION_PROTOCOL: Protocol = panproto.define_protocol({'name': 'qvr_deduction', 'schema_theory': 'ThBratSchema', 'instance_theory': 'ThBratInstance', 'edge_rules': _DEDUCTION_EDGE_RULES, 'obj_kinds': _DEDUCTION_OBJECT_KINDS, 'constraint_sorts': _DEDUCTION_CONSTRAINT_SORTS})
Panproto protocol for a weighted deductive system.
Vertex kinds:
* deduction_system: the top-level declaration.
* deduction_atom: an atom of the item algebra.
* deduction_rule: a named sequent-style inference rule.
* deduction_premise: one premise pattern of a rule.
* deduction_conclusion: a rule's conclusion pattern.
Edges:
* decl: system :math:\to rule.
* atom: system :math:\to atom.
* premise: rule :math:\to premise.
* conclusion: rule :math:\to conclusion.
Constraint sorts carry the system's semiring and the status of each
law the semiring claims, its start and depth, each pattern's textual
form, and, from the rule presentation the rules are derived from, each
rule's identity and weight parameter and each pattern's judgment. Schema morphisms over this protocol
correspond to specializations of deduction systems
(e.g., :math:\mathsf{CCG} \subset \mathsf{Lambek} \subset \mathsf{MultimodalLambek}).
QVR_PROGRAM_PROTOCOL
module-attribute
¶
QVR_PROGRAM_PROTOCOL: Protocol = panproto.define_protocol({'name': 'qvr_program', 'schema_theory': 'ThBratSchema', 'instance_theory': 'ThBratInstance', 'edge_rules': _EDGE_RULES, 'obj_kinds': _OBJECT_KINDS, 'constraint_sorts': _CONSTRAINT_SORTS})
Panproto protocol for a compiled QVR program.
extract_program_schema writes schemas in this protocol. The vertex
kinds, edge rules, and constraint sorts are the ones the module
docstring lists.
QIEC_STATEMENT_TYPES
module-attribute
¶
QIEC_STATEMENT_TYPES = (surface.QiecIndexDecl, surface.QiecIndexMapDecl, surface.QiecFamilyDecl, surface.QiecPatternSynonymDecl, surface.QiecEffectDecl, surface.QiecEffectInstanceDecl, surface.QiecEffectLawDecl, surface.QiecBernoulliCompletionDecl, surface.QiecCheckpointDerivativeDecl, surface.QiecImplicitDerivativeDecl, surface.QiecRationalDerivativeDecl, surface.QiecSiteEstimatorsDecl, surface.QiecScopedOperationDecl, surface.QiecHandlerInterchangeDecl, surface.QiecHandlerDecl, surface.QiecComputationDecl, QiecRecordDecl, surface.QiecInterpretationDecl, surface.QiecRelationDecl, surface.QiecRelationComposeDecl, surface.QiecRelationTransformDecl, surface.QiecRelationScoreDecl, surface.QiecStringGraphDecl, surface.QiecStringGraphScoreDecl, *surface.META_STATEMENT_TYPES, *surface.NOTATION_STATEMENT_TYPES)
The declaration classes that make up the QIEC surface of a module.
qiec_projection keeps these statements and non_qiec_projection
drops them, so the tuple fixes where the two routes divide a module.
QVR_SOURCE_VERSION
module-attribute
¶
The source protocol a QvrQiecLowerer route accepts.
lower_qvr_to_qiec checks its source_version argument against this
identifier, which names the QVR surface the elaboration reads.
StructureStatement
¶
StructureStatement = ObjectDecl | MorphismDecl | DefineDecl | ExportDecl | ProgramDecl | DeductionDecl | SyntaxDecl | EncoderDecl | DecoderDecl | LossDecl | CategoryDecl | RuleDecl | SchemaDecl | BundleDecl | ContractionDecl | CompositionDecl | JudgmentDecl | QiecRelationDecl | QiecRelationComposeDecl | QiecRelationTransformDecl | QiecStringGraphDecl | TheoryDecl | ViewDecl | ModelDecl | SemiringDecl
A statement recorded as a structure declaration.
SchemaValue
¶
A value of a schema parameter: a numeral, a Boolean, or an index value.
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:
|
tests
|
Its
TYPE:
|
experiments
|
Its
TYPE:
|
Compiler
¶
Compiler(module: Module, *, module_name: str | None = None, file_path: str = '<source>', lower_qiec: bool = True, families: FamilyCatalog | None = None)
Bases: _DeclarationsMixin, _ProgramsMixin, _StructuralMixin, _DeductionsMixin, _ResolutionMixin, _ExpressionsMixin
Compile a quivers DSL AST into a Program.
The compiler maintains three environments:
- objects: name -> SetObject (discrete finite sets)
- spaces: name -> ContinuousSpace
- morphisms: name -> Morphism or ContinuousMorphism (any morphism-like)
It processes statements in order and compiles the output expression into a Program wrapping the morphism DAG.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed AST.
TYPE:
|
lower_qiec
|
Whether to lower the checked QIEC projection. Tooling sets this to
TYPE:
|
families
|
Immutable custom family contracts and native implementations.
TYPE:
|
Source code in src/quivers/dsl/compiler/core.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
programs
property
¶
programs: dict[str, ProgramDecl]
Every declared program, by name.
A program with typed parameters (a template) and one without
both appear: each is a scope whose parameters and sites are
addressed by program::site paths. A program without typed
parameters also compiles to a morphism, listed in morphisms.
losses
property
¶
Declared loss heads (loss NAME : ... [on=...]).
Keyed by entry name; values are the registered :class:LossEntry
records. Empty when no loss decl appears in the module.
bundles
property
¶
Declared bundle aliases (bundle NAME = R1 | R2 | ...).
contractions
property
¶
Declared tensor-network contractions
(contraction NAME : ... [wiring=...]).
transformations
property
¶
User-declared transformation constructors / singletons.
qiec_module
property
¶
qiec_module: QiecModule | None
The checked QIEC module, or None when the source has no QIEC surface.
| RETURNS | DESCRIPTION |
|---|---|
QiecModule | None
|
The module, lowered on first access. |
| RAISES | DESCRIPTION |
|---|---|
QiecDiagnosticError
|
If the source's QIEC surface fails to lower, other than by a program gap, which the module records instead. |
qiec_generated_declarations
property
¶
qiec_generated_declarations: tuple[GeneratedDeclaration, ...]
Return generated declarations retained by the cached QIEC check.
relation_specs
property
¶
relation_specs: dict[str, RationalRelationSpec]
Return the checked authored relation specifications in this source.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, RationalRelationSpec]
|
Topologies and live weight identities keyed by source name. |
composed_relation_specs
property
¶
composed_relation_specs: dict[str, ComposedRelationSpec]
Return checked binary compositions keyed by their authored names.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, ComposedRelationSpec]
|
Ordered operand specifications and original weight identities. |
transformed_relation_specs
property
¶
transformed_relation_specs: dict[str, UnaryRelationTransformSpec | BinaryRelationTransformSpec | RelationCascadeSpec]
Return checked sparse transformations by their authored names.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, UnaryRelationTransformSpec | BinaryRelationTransformSpec | RelationCascadeSpec]
|
Ordered original operands and selected sparse operations, including cascades. |
string_graph_specs
property
¶
string_graph_specs: dict[str, StringFactorGraphSpec]
Return checked string graphs by their authored names.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, StringFactorGraphSpec]
|
Ordered observations and factor scopes with original relation identities. |
deferred_statements
property
¶
deferred_statements: tuple[Statement, ...]
Authored declarations awaiting finite-object specialization.
| RETURNS | DESCRIPTION |
|---|---|
tuple[Statement, ...]
|
Uncompiled declarations in source order, retaining their authored types. No finite cardinalities are invented for these declarations. |
entry_points
¶
entry_points() -> tuple[EntryPoint, ...]
The executable entry points of the checked module.
| RETURNS | DESCRIPTION |
|---|---|
tuple[EntryPoint, ...]
|
Every |
Source code in src/quivers/dsl/compiler/core.py
entry
¶
entry(name: str) -> EntryPoint
One entry point of the checked module, by name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The entry's source name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EntryPoint
|
The entry. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
With code |
Source code in src/quivers/dsl/compiler/core.py
authored_checkpointed_gradient
¶
authored_checkpointed_gradient(name: str, arguments: tuple[int | Fraction, ...], *, max_work: int = 65536, fuel: int = 65536) -> ExactCheckpointCertificate
Differentiate a named source iteration using checkpoint replay.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The module-local checkpoint derivative declaration.
TYPE:
|
arguments
|
The exact initial state and shared parameters in declared order.
TYPE:
|
max_work
|
The bound on transition evaluations, including replay.
TYPE:
|
fuel
|
The reference step budget per transition evaluation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExactCheckpointCertificate
|
The checked source identities, derived step count and measured result. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the declaration is absent or the request arguments are malformed. |
QiecDiagnosticError
|
If the source fails the checkpoint call-chain check. |
JvpUnsupported
|
If a reached transition fails the regular scalar derivative check. |
JvpLimit
|
If evaluation exhausts a resource limit. |
authored_implicit_gradient
¶
authored_implicit_gradient(name: str, arguments: tuple[int | Fraction, ...], *, max_work: int = 65536, fuel: int = 65536) -> ExactImplicitCertificate
Check a named source computation's implicit derivative.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The module-local implicit derivative claim.
TYPE:
|
arguments
|
The exact point in the primal's parameter order.
TYPE:
|
max_work
|
The arithmetic budget for the rational composition proof.
TYPE:
|
fuel
|
The reference evaluator step budget per run.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExactImplicitCertificate
|
The named definitions, strict domain, and local derivative. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the claim is missing or the request arguments are malformed. |
QiecDiagnosticError
|
If a definition in the declaration fails nominal resolution. |
ImplicitRootError
|
If the identity is false or the reached root is singular. |
JvpUnsupported
|
If an exact rational proof or a regular scalar evaluation is unavailable. |
JvpLimit
|
If the proof or evaluation exhausts a bound. |
authored_derivative_rule
¶
authored_derivative_rule(name: str) -> RationalDerivativeDeclaration
Resolve a source claim's scalar derivative actions by checked identity.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The module-local name in the authored effect law declaration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RationalDerivativeDeclaration
|
The named primal and actions in the checked source. Use the derivative checker or an effect plan request to check the formulas. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the checked source has no derivative declaration of this name. |
QiecDiagnosticError
|
If the source fails to lower or names an unknown computation. |
authored_bernoulli_completion
¶
authored_bernoulli_completion(name: str, arguments: tuple[int | Fraction, ...], direction: tuple[int | Fraction, ...], *, completed_module: QiecModule | None = None, fuel: int = 65536) -> BernoulliCompletion
Check a named source completion at an exact point and direction.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The named completion in the checked source.
TYPE:
|
arguments
|
The original computation's arguments and an exact direction.
TYPE:
|
direction
|
The original computation's arguments and an exact direction.
TYPE:
|
completed_module
|
An optional completed graph to verify against the declaration.
TYPE:
|
fuel
|
The step limit for each ordinary replay.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BernoulliCompletion
|
The completed graph and the exact original, extended and projected addressed histories at the requested point. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the completion does not exist or the arguments are invalid. |
QiecDiagnosticError
|
If the parsed source or completion fails to lower. |
JvpUnsupported
|
If the point or completed graph leaves the checked fragment. |
JvpLimit
|
If the exact replay exhausts its bound. |
authored_site_estimators
¶
authored_site_estimators(computation: str) -> tuple[SiteEstimator, ...]
Return the explicit estimator policies for one lexical computation.
| PARAMETER | DESCRIPTION |
|---|---|
computation
|
The name of the authored computation containing the sample requests.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple of SiteEstimator
|
The policies in source order, bound to the original static sites. A computation with no assignments has an empty tuple. The estimator planner checks which sites execute at its point. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the source has no authored computation of this name. |
QiecDiagnosticError
|
If the checked source or an estimator assignment fails to lower. |
effect_plan
¶
effect_plan(name: str, *, obligations: tuple[EffectLawObligation, ...] = (), interchanges: tuple[FiniteHandlerInterchange, ...] = (), law_evidence: tuple[EffectLawEvidence, ...] = (), max_assignments: int = 65536, max_work: int = 65536, fuel: int = 65536) -> EffectPlan
Report checked effect analysis for one of the source's entry points.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The program or computation entry point's name.
TYPE:
|
obligations
|
The additional nominal equations to check alongside this source's authored finite laws.
TYPE:
|
interchanges
|
The additional finite handler interchanges to check after those declared in the source.
TYPE:
|
law_evidence
|
Claimed tests or assumptions bound to the requested obligations.
TYPE:
|
max_assignments
|
The domain size limit per finite obligation.
TYPE:
|
max_work
|
The work limit per scalar obligation.
TYPE:
|
fuel
|
The step limit per side and assignment in an exact interpreter.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EffectPlan
|
The entry's carrier reports, separately checked obligations, and the stages and obstacles of the ordinary discharge result. For a program, retains the matching parsed source for target reports on the public export. |
| RAISES | DESCRIPTION |
|---|---|
ExecutionFailure
|
If the source does not have the named checked entry point. |
ValueError
|
If a requested resource limit is invalid. |
Source code in src/quivers/dsl/compiler/core.py
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | |
compile
¶
compile() -> Program
Compile the module into a trainable Program.
| RETURNS | DESCRIPTION |
|---|---|
Program
|
The compiled nn.Module wrapping the morphism DAG. |
| RAISES | DESCRIPTION |
|---|---|
CompileError
|
On semantic errors (undefined names, type mismatches, etc.), and for a module with typed holes, which has no compiled form; the message lists every hole. |
Source code in src/quivers/dsl/compiler/core.py
check
¶
Compile the module to check it, without keeping a Program.
Every check compile makes is made, but no compiled program
leaves the call, so a module with typed holes is checked around
them: a hole is well typed at its goal, and only a compiled form
has nowhere to put it.
| RAISES | DESCRIPTION |
|---|---|
CompileError
|
On semantic errors, as |
Source code in src/quivers/dsl/compiler/core.py
compile_env
¶
Compile all statements and return the full environment.
Useful for inspection without requiring an output declaration.
| PARAMETER | DESCRIPTION |
|---|---|
defer_unresolved
|
Retain unresolved finite objects and their dependent declarations symbolically, compiling independent declarations for inspection. False requires data to specialize every inferred object.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
Combined environment of every declared atom: the active algebra, objects, spaces, morphisms, rules, programs (parametric templates), deductions, signatures, encoders, decoders, losses, bundles, contractions, transformations. |
Source code in src/quivers/dsl/compiler/core.py
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | |
CompileError
¶
Bases: Exception
Raised when the compiler encounters a semantic error.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
Error description.
TYPE:
|
line
|
Source line number (0 if unknown).
TYPE:
|
col
|
Source column number (0 if unknown).
TYPE:
|
Source code in src/quivers/dsl/compiler/_prelude.py
Violation
didactic-model
¶
Bases: Model
One constraint-solver finding.
Every finding check_constraints reports is an error. Compiler
diagnostics that should surface in qvr check output without
failing the compile set severity to "warning".
| PARAMETER | DESCRIPTION |
|---|---|
code
|
The stable diagnostic code.
TYPE:
|
message
|
What is wrong.
TYPE:
|
line
|
The one-based source line.
TYPE:
|
col
|
The source column.
TYPE:
|
severity
|
TYPE:
|
EmitError
¶
Bases: Exception
Raised when an AST value has no valid .qvr surface form.
LetExprExtension
¶
Bases: Protocol
Expose binder-free downstream expressions to canonical traversal.
An adapter lists every expression child in a stable order and rebuilds its node over children in that same order. It preserves all other fields. An extension cannot introduce a binder; binder scope and capture avoidance are defined by the shared surface AST, independently of the downstream IR.
children
¶
children(node: LetExprNode) -> tuple[LetExprNode, ...] | None
Read the direct children of a supported extension.
| PARAMETER | DESCRIPTION |
|---|---|
node
|
Expression that is not a canonical surface variant.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[LetExprNode, ...] or None
|
All expression children in source order, or None for an unsupported node. An empty tuple denotes a supported leaf. |
Source code in src/quivers/dsl/let_expr_traversal.py
rebuild
¶
rebuild(node: LetExprNode, children: tuple[LetExprNode, ...]) -> LetExprNode
Rebuild an extension without changing its non-expression metadata.
| PARAMETER | DESCRIPTION |
|---|---|
node
|
Supported extension previously read by children.
TYPE:
|
children
|
Rewritten operands in the same order and arity.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
The reconstructed extension, retaining its other fields. |
Source code in src/quivers/dsl/let_expr_traversal.py
StructureEncodingError
¶
Bases: ValueError
A statement holds a value no structure term represents.
StructureLayer
didactic-model
¶
StructureLayer(*, structures: tuple[StructureDecl, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), names: Mapping[StructureTarget, str] = field(default_factory=dict, opaque=True, extras=OPAQUE_BY_VALUE))
Bases: ValueModel
A module's structure declarations with the names their references use.
| PARAMETER | DESCRIPTION |
|---|---|
structures
|
The declarations, in source order.
TYPE:
|
names
|
The name each referenced declaration has in the module.
TYPE:
|
ModuleError
¶
ModuleError(diagnostic: ModuleDiagnostic)
Bases: Exception
Raised when the module graph does not load or a name does not resolve.
| PARAMETER | DESCRIPTION |
|---|---|
diagnostic
|
The structured diagnostic.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
diagnostic |
The structured diagnostic.
TYPE:
|
Source code in src/quivers/dsl/modules/errors.py
code
property
¶
code: ModuleErrorCode
The diagnostic's code.
| RETURNS | DESCRIPTION |
|---|---|
ModuleErrorCode
|
The stable code. |
ParseError
¶
Bases: Exception
Raised when .qvr source fails to parse or wrap into AST nodes.
parse and parse_file raise it with a message that starts with
the file path and locates the first syntax error.
CompositionError
¶
Bases: ValueError
A deduction whose parts do not compose.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong.
TYPE:
|
line
|
Where.
TYPE:
|
col
|
Where.
TYPE:
|
Source code in src/quivers/dsl/deduction_composition.py
ExtensionVerdict
didactic-model
¶
ExtensionVerdict(*, deduction: str, signature: str, classification: Classification, reason: str, sentence: tuple[str, ...] = (), item: str = '', line: int = 0, col: int = 0)
Bases: Model
The classification of one deduction's extension of one signature.
| PARAMETER | DESCRIPTION |
|---|---|
deduction
|
The extending deduction.
TYPE:
|
signature
|
The extended signature.
TYPE:
|
classification
|
What the checker established.
TYPE:
|
reason
|
Why.
TYPE:
|
sentence
|
For
TYPE:
|
item
|
For
TYPE:
|
line
|
The deduction's location.
TYPE:
|
col
|
The deduction's location.
TYPE:
|
ReificationError
¶
Bases: ValueError
A signature whose item family or folds cannot be generated.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong.
TYPE:
|
line
|
Where.
TYPE:
|
col
|
Where.
TYPE:
|
Source code in src/quivers/dsl/deduction_reification.py
SchemaError
¶
Bases: ValueError
A rule schema or instantiation that does not denote a finite rule set.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What is wrong.
TYPE:
|
line
|
Where.
TYPE:
|
col
|
Where.
TYPE:
|
Source code in src/quivers/dsl/deduction_schemata.py
QvrLexer
¶
Bases: Lexer
Pygments lexer for .qvr (quivers DSL) files.
The lexer is a thin walker over the in-tree tree-sitter parse; the grammar is the single source of truth. There is no regex approximation: when the shared library can't be loaded, the lexer raises a typed exception so the failure is visible at the rendering site rather than silently emitting a degraded highlight.
get_tokens_unprocessed
¶
Yield (index, token_type, text) tuples for text.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
tuple[int, _TokenType, str]
|
The character offset, Pygments token type, and text of each leaf of the parse and of the whitespace between leaves. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the in-tree tree-sitter parser library cannot be loaded. |
Source code in src/quivers/dsl/pygments_lexer.py
QiecDiagnosticError
¶
QiecDiagnosticError(message: str, *, code: str, file: str, line: int = 0, column: int = 0, program: str | None = None)
Bases: ValueError
A source-located, stable-code diagnostic from QIEC elaboration.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What was rejected.
TYPE:
|
code
|
The stable diagnostic code.
TYPE:
|
file
|
The file the source was read from.
TYPE:
|
line
|
The one-based line, or zero when unknown.
TYPE:
|
column
|
The zero-based column.
TYPE:
|
program
|
The program whose elaboration raised the diagnostic, when it was
raised inside a program body;
TYPE:
|
Source code in src/quivers/dsl/qiec_diagnostics.py
InferenceError
¶
Bases: ValueError
An expression has no type, or one inference cannot find.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
What failed.
TYPE:
|
node
|
The source node, read for its line and column.
TYPE:
|
Source code in src/quivers/dsl/row_inference.py
TypeScheme
didactic-model
¶
TypeScheme(*, binders: Telescope = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), predicates: tuple[RowPredicate, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), type: TypeExpr = field(opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
A principal type: a type over variables and the predicates they meet.
| PARAMETER | DESCRIPTION |
|---|---|
binders
|
The type and row variables, in order of first occurrence.
TYPE:
|
predicates
|
The row predicates every instance must meet.
TYPE:
|
type
|
The type.
TYPE:
|
render
¶
Write the scheme in source spelling.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/dsl/row_inference.py
CheckedQvrQiec
didactic-model
¶
CheckedQvrQiec(*, module: QiecModule = field(opaque=True, extras=OPAQUE_BY_VALUE), closed_interpretations: tuple[ClosedInterpretationBinding, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), packed_interpretations: tuple[PackedBooleanInterpretationBinding, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), generated_declarations: tuple[GeneratedDeclaration, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE))
Bases: QiecModel
The checked result passed between Didactic's ordered stages.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The kernel module the stages produced.
TYPE:
|
closed_interpretations
|
Source companions retained through checked model schema extraction.
TYPE:
|
packed_interpretations
|
Each verified invocation of a closed interpretation's packed form.
TYPE:
|
generated_declarations
|
Source declarations and their provenance from the checked meta expansion.
TYPE:
|
QvrQiecLowerer
¶
Quivers-owned implementation of Didactic's extension-lowering protocol.
check
¶
check(source: QvrQiecSource) -> CheckedQvrQiec
Elaborate a source module and recheck the result.
The recheck is deliberate rather than redundant: it rebuilds a registry from the lowered module alone, so a bug in elaboration surfaces here instead of reaching a backend.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The QIEC projection, its module name, and its file path.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CheckedQvrQiec
|
The checked module. |
| RAISES | DESCRIPTION |
|---|---|
QiecDiagnosticError
|
If elaboration rejects the source, carrying a stable code and a source position. |
KernelError
|
If the lowered module fails its independent recheck. |
Source code in src/quivers/dsl/qiec_lowering.py
lower
¶
lower(checked: CheckedQvrQiec) -> QiecModule
Return the checked module.
Checking and lowering are one step here, because the elaborator produces the kernel module directly, so this unwraps rather than transforms.
| PARAMETER | DESCRIPTION |
|---|---|
checked
|
The result of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecModule
|
The lowered module. |
Source code in src/quivers/dsl/qiec_lowering.py
validate
¶
validate(target: QiecModule) -> None
Recheck a module and confirm it survives serialization.
| PARAMETER | DESCRIPTION |
|---|---|
target
|
The module to validate.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
KernelError
|
If the module fails its recheck, or if a dump and load round trip does not return an equal module. The second is checked because identities downstream are content addressed: a module that changed under serialization would hash differently on the other side of the boundary. |
Source code in src/quivers/dsl/qiec_lowering.py
QvrQiecSource
didactic-model
¶
QvrQiecSource(*, syntax: Module, module_name: str, file_path: str = '<source>', elaborate_programs: bool = True, distribution_families: tuple[DistributionFamily, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), prechecked: QiecModule | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), structures: tuple[StructureDecl, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), spellings: tuple[NameSpelling, ...] = ())
Bases: ValueModel
A parsed QVR projection plus the identity absent from the AST root.
| PARAMETER | DESCRIPTION |
|---|---|
syntax
|
The projected module.
TYPE:
|
module_name
|
The name every stable identity derives from.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
elaborate_programs
|
Whether
TYPE:
|
prechecked
|
A module already checked from declarations of this syntax under the same module name, such as a library shared by many modules and checked from its own file. A computation declaration whose name and origin, apart from the file, match one of its computations is not lowered again: that computation is reused, with the families its lowering generated. The module's independent recheck still checks it.
TYPE:
|
structures
|
The module's structure declarations, which the checked module records beside its computations.
TYPE:
|
spellings
|
How the program's root module writes the names other modules declare, which generated printers write them as.
TYPE:
|
LawReport
didactic-model
¶
LawReport(*, signature: str, instance: str, status: Literal['checked', 'assumed'], reason: str = '')
Bases: Model
How one module met its obligation to a signature's laws.
| ATTRIBUTE | DESCRIPTION |
|---|---|
signature |
The signature.
TYPE:
|
instance |
The module.
TYPE:
|
status |
TYPE:
|
reason |
For an assumed obligation, why it could not be checked.
TYPE:
|
check_constraints
¶
Return every well-formedness violation in module.
Walks the statements in source order, building up the symbol tables (residuated universes, enum sets, free monoids, declared rule / schema / bundle names) incrementally so that out-of-order references are flagged.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to check.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Violation]
|
The findings in source order, empty for a well-formed module. |
Source code in src/quivers/dsl/constraints.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
module_to_source
¶
module_to_source(module: Module) -> str
Serialize a Module AST to canonical .qvr source.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The module to print.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The canonical source, ending in a single newline. |
| RAISES | DESCRIPTION |
|---|---|
EmitError
|
If a node in |
Source code in src/quivers/dsl/emit.py
static_argument_to_source
¶
static_argument_to_source(argument: QiecStaticArgument) -> str
Emit one static argument of an effect or type application.
| PARAMETER | DESCRIPTION |
|---|---|
argument
|
A type, an effect written as type syntax, or an index literal.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The argument's source form, as the module emitter writes it. |
Source code in src/quivers/dsl/emit.py
family_parameter_names
¶
Return the canonical QVR keyword order for family.
| PARAMETER | DESCRIPTION |
|---|---|
family
|
The family name as written in source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...] | None
|
The keyword names in canonical order, or None when no keyword
schema is declared for |
Source code in src/quivers/_family_schemas.py
family_parameterizations
¶
Return every complete keyword schema accepted by family.
| PARAMETER | DESCRIPTION |
|---|---|
family
|
The family name as written in source.
TYPE:
|
canonical
|
The parameter names the family's registry record declares,
used when no schema for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[tuple[str, ...], ...]
|
One tuple of keyword names per accepted parameterization, empty when the family takes no parameters. |
Source code in src/quivers/_family_schemas.py
free_let_callees
¶
free_let_callees(expr: LetExprNode, *, bound: frozenset[str] = frozenset(), extension: LetExprExtension | None = None) -> tuple[str, ...]
Return the free callee names of calls in first-use order.
A call f(...) whose f is not bound by an enclosing lambda
parameter or factor index contributes f.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to scan.
TYPE:
|
bound
|
Names already bound around
TYPE:
|
extension
|
Child/rebuild adapter for binder-free downstream IR nodes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
Each free callee once, in the order of its first occurrence. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the scan reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
free_let_names
¶
free_let_names(expr: LetExprNode, *, bound: frozenset[str] = frozenset(), include_callees: bool = False, extension: LetExprExtension | None = None) -> tuple[str, ...]
Return free value names in first-use order.
Lambda parameters and factor indices bind in their bodies. Call names are declarations by default; callers that model a callee as a host value can include them explicitly.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to scan.
TYPE:
|
bound
|
Names already bound around
TYPE:
|
include_callees
|
Whether the function name of a call counts as a free name.
TYPE:
|
extension
|
Child/rebuild adapter for binder-free downstream IR nodes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
Each free name once, in the order of its first occurrence. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the scan reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
let_expr_children
¶
let_expr_children(expr: LetExprNode, *, extension: LetExprExtension | None = None) -> tuple[LetExprNode, ...]
Return the immediate expression children of expr in source order.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to take apart.
TYPE:
|
extension
|
Child/rebuild adapter for binder-free nodes owned by a downstream IR.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[LetExprNode, ...]
|
The direct subexpressions, empty for a leaf. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
Source code in src/quivers/dsl/let_expr_traversal.py
map_let_expr
¶
map_let_expr(expr: LetExprNode, transform: Callable[[LetExprNode], LetExprNode], *, extension: LetExprExtension | None = None, descend: Callable[[LetExprNode], bool] | None = None) -> LetExprNode
Rebuild expr bottom-up, applying transform at every node.
Each node is first rebuilt over its rewritten children and then
passed to transform, so transform sees a node whose
subexpressions are already rewritten. The rebuild is structural and
does not track binders, so a rewrite of variable names belongs in
substitute_let_expr.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The root of the rewrite.
TYPE:
|
transform
|
The rewrite applied to each rebuilt node.
TYPE:
|
extension
|
Child/rebuild adapter for binder-free downstream IR nodes.
TYPE:
|
descend
|
Whether to rewrite a node's children before applying
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
The rewritten expression. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the rewrite reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
substitute_let_expr
¶
substitute_let_expr(expr: LetExprNode, substitution: Mapping[str, LetExprNode], *, callees: Mapping[str, str] | None = None, index_substitution: Mapping[str, LetExprNode] | None = None, extension: LetExprExtension | None = None) -> LetExprNode
Substitute expressions for free variables in expr without capture.
A lambda parameter or factor binder that would capture a free name of a replacement is renamed to a fresh name first.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The expression to rewrite.
TYPE:
|
substitution
|
The replacement for each free variable name.
TYPE:
|
callees
|
The replacement name for each free callee of a call
TYPE:
|
index_substitution
|
Optional overrides in the direct index positions of an indexing node.
All other positions use
TYPE:
|
extension
|
Child/rebuild adapter for binder-free downstream IR nodes. Extensions add structural cases; scope and capture avoidance remain in this walk.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the rewrite reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | |
walk_let_expr
¶
walk_let_expr(expr: LetExprNode, *, extension: LetExprExtension | None = None) -> Iterator[LetExprNode]
Yield expr and all descendants in preorder.
| PARAMETER | DESCRIPTION |
|---|---|
expr
|
The root of the walk.
TYPE:
|
extension
|
Child/rebuild adapter for binder-free downstream IR nodes.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
LetExprNode
|
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the walk reaches an unsupported let-expression variant. |
Source code in src/quivers/dsl/let_expr_traversal.py
decode_structures
¶
decode_structures(layer: StructureLayer) -> tuple[Statement, ...]
The statements a structure layer encodes, in order.
| PARAMETER | DESCRIPTION |
|---|---|
layer
|
The declarations and the names their references use.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Statement, ...]
|
One statement per declaration. |
| RAISES | DESCRIPTION |
|---|---|
StructureEncodingError
|
If a term does not decode. |
Source code in src/quivers/dsl/structure_terms.py
module_structure_layer
¶
module_structure_layer(module: QiecModule) -> StructureLayer
A checked module's structure layer, with names read from the module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StructureLayer
|
Its structure declarations, and the name of each. |
Source code in src/quivers/dsl/structure_terms.py
split_statement
¶
One statement per name a structure statement declares.
| PARAMETER | DESCRIPTION |
|---|---|
statement
|
A structure statement.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Statement, ...]
|
The statement itself, or, for a statement declaring several independent names, one copy per name. |
Source code in src/quivers/dsl/structure_terms.py
structure_layer
¶
structure_layer(module: Module, *, module_name: str) -> StructureLayer
Encode a module's structure statements as structure declarations.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
module_name
|
The name every identity derives from.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StructureLayer
|
One declaration per declared name of every structure statement, in source order, and the names of everything they refer to. |
| RAISES | DESCRIPTION |
|---|---|
StructureEncodingError
|
If a statement holds a value no structure term represents. |
Source code in src/quivers/dsl/structure_terms.py
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | |
structured_module
¶
structured_module(source: Module, layer: StructureLayer) -> Module
A module whose structure statements are read from a structure layer.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The module the layer encodes, for the statements the layer does not record and for their order.
TYPE:
|
layer
|
Its structure layer.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module with every structure statement replaced by the statements its declarations decode to, in place; a statement that declares several names becomes one statement per name. |
| RAISES | DESCRIPTION |
|---|---|
StructureEncodingError
|
If the layer does not record exactly the module's structure statements in order. |
Source code in src/quivers/dsl/structure_terms.py
parse
¶
parse(source: str | bytes, file_path: str = '<source>') -> Module
Parse .qvr source into a Module.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The source text, or its UTF-8 bytes.
TYPE:
|
file_path
|
The path recorded on diagnostics.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If the source has a syntax error or a node the AST cannot represent. |
Source code in src/quivers/dsl/parser/core.py
parse_file
¶
parse_file(path: str | Path) -> Module
Parse a .qvr file at path.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The file to read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The file's statements in source order. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If the file does not parse. |
Source code in src/quivers/dsl/parser/core.py
compose_deductions
¶
Interpret every composed deduction as one monolithic deduction.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A flat module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module itself when no statement is composed; otherwise the module with every deduction composed, and its deduction signatures, lexicon modules, and exports of them removed (they denote no code of their own). |
| RAISES | DESCRIPTION |
|---|---|
CompositionError
|
If a part is unknown, atoms or rules of different origins share a name, a lexicon entry's category uses an atom its signature lacks, a signature rule applies an atom the signature lacks, or a schema or its instantiation is ill-formed. |
Source code in src/quivers/dsl/deduction_composition.py
classify_extension
¶
classify_extension(module: Module, deduction: DeductionDecl, signature: str) -> ExtensionVerdict
Classify a composed deduction's extension of one of its signatures.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The composed module holding the deduction.
TYPE:
|
deduction
|
A composed deduction.
TYPE:
|
signature
|
A signature it extends.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExtensionVerdict
|
The classification, with the reason or the witness. |
Source code in src/quivers/dsl/deduction_conservativity.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
classify_extensions
¶
classify_extensions(module: Module) -> tuple[ExtensionVerdict, ...]
Classify every extension of a signature by a deduction of a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module; its deductions are composed first.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExtensionVerdict, ...]
|
One verdict per deduction and signature it extends, in order. |
Source code in src/quivers/dsl/deduction_conservativity.py
extension_notes
¶
extension_notes(module: Module) -> tuple[ExtensionVerdict, ...]
The extensions whose generic results do not carry over from the core.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ExtensionVerdict, ...]
|
Every verdict that is neither definitional nor conservative: for
those deductions, a result of generic code typed against
|
Source code in src/quivers/dsl/deduction_conservativity.py
reify_cores
¶
Generate the core families, inclusions, folds, and laws of a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module whose deductions are composed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
The module itself when no extended signature derives a class; otherwise the module with each such signature's item family and its classes, each extension's inclusion and copaired classes, and the naturality law of each fold. |
| RAISES | DESCRIPTION |
|---|---|
ReificationError
|
If two extensions type a core constructor differently, or a fold names more than one target type. |
Source code in src/quivers/dsl/deduction_reification.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
slot_sorts
¶
slot_sorts(decl: DeductionDecl) -> dict[str, tuple[str, ...]]
Each symbol of a deduction and the sorts of its slots.
A slot is Int where it holds a chart position (position_slots)
or a bound variable's number, and an item otherwise. This is the item
family the deduction's elaboration declares.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
A composed deduction.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, tuple[str, ...]]
|
|
Source code in src/quivers/dsl/deduction_reification.py
open_atoms
¶
open_atoms(decl: DeductionDecl) -> frozenset[str]
The atoms a deduction signature's rules never mention.
Nothing in the signature fixes such an atom's arity or the sorts of
its slots: each extension fixes them (_instantiation), and generic
code over the signature requires what its own uses fix.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
A deduction signature's atoms, binders, and rules, as a deduction with no lexicon.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The atoms no rule writes, applied or bare. |
Source code in src/quivers/dsl/deduction_reification.py
slot_classes
¶
slot_classes(decl: DeductionDecl) -> dict[str, tuple[str, ...]]
The slot sorts a deduction signature fixes, and those it leaves open.
A signature has no lexicon of its own, so whether a slot holds a chart
position may be decided only by the deduction extending it: span's
first two slots are positions in a deduction that reads a sentence
through a lexicon and items in one that takes its axioms as input. A
slot is
"int"when the signature's rules make it a position (a numeral fills it, or a variable shared with such a slot);"item"when they fill it with an atom or an application (which no position slot holds), when it is a binder's bound variable, or when a variable connects it with such a slot;"slot<k>"otherwise: one of the open classes, numbered in order of appearance, of slots the rules connect by shared variables. Every slot of a class has one sort in any deduction extending the signature, since a shared variable fills them all, and that sort is the extension's to fix.
| PARAMETER | DESCRIPTION |
|---|---|
decl
|
A deduction signature's atoms, binders, and rules (schema instances included), as a deduction with no lexicon.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, tuple[str, ...]]
|
The sort or class of each slot, by symbol, ordered as |
Source code in src/quivers/dsl/deduction_reification.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
assignments
¶
assignments(rule: SequentRule, instantiation: RuleInstantiation, sorts: Mapping[str, QiecIndexDecl], restrictions: tuple[SchemaConstraint, ...] = ()) -> Iterator[tuple[SchemaValue, ...]]
Every assignment of a schema's parameters an instantiation admits.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The schema.
TYPE:
|
instantiation
|
The
TYPE:
|
sorts
|
The module's index sorts.
TYPE:
|
restrictions
|
Further constraints from an
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
tuple[SchemaValue, ...]
|
One value per parameter, in telescope order, in the order of the domains (numerals ascending, index values in declaration order). |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If a constraint names no parameter, a domain is infinite or unknown, or a condition is ill-formed. |
Source code in src/quivers/dsl/deduction_schemata.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
canonical_rule
¶
canonical_rule(rule: SequentRule, atoms: frozenset[str]) -> str
A rule's premises and conclusion up to the names of its variables.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
A rule.
TYPE:
|
atoms
|
The deduction's atoms; every other identifier (not a numeral) of a pattern is a variable.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The patterns with every variable renamed by first occurrence; two rules with equal renderings derive the same items. |
Source code in src/quivers/dsl/deduction_schemata.py
constraint_location
¶
constraint_location(constraint: SchemaConstraint, line: int, col: int) -> tuple[int, int]
Where a constraint is written, or the given location if unknown.
| PARAMETER | DESCRIPTION |
|---|---|
constraint
|
The constraint.
TYPE:
|
line
|
The location to report when the constraint carries none.
TYPE:
|
col
|
The location to report when the constraint carries none.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int]
|
The line and the column. |
Source code in src/quivers/dsl/deduction_schemata.py
constraint_names
¶
constraint_names(constraint: SchemaConstraint) -> set[str]
The names a constraint mentions.
| PARAMETER | DESCRIPTION |
|---|---|
constraint
|
A constraint.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
set[str]
|
The parameter of a membership; every variable of a condition. |
Source code in src/quivers/dsl/deduction_schemata.py
evaluate_condition
¶
evaluate_condition(node: LetExprNode, environment: Mapping[str, SchemaValue], values: frozenset[str], where: tuple[str, int, int]) -> SchemaValue
Evaluate a constraint over one assignment.
| PARAMETER | DESCRIPTION |
|---|---|
node
|
The expression.
TYPE:
|
environment
|
The parameters' values.
TYPE:
|
values
|
The index values in scope, which a name may spell.
TYPE:
|
where
|
The schema's name and the instantiation's location, for refusals.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SchemaValue
|
The expression's value. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If the expression uses a name that is neither a parameter nor an index value, an operator outside comparisons, arithmetic, and the Boolean connectives, or operands of the wrong kind. |
Source code in src/quivers/dsl/deduction_schemata.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
family_parameter_key
¶
The agenda engine's parameter key of a shared weight family's index.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
An injective spelling without dots: |
Source code in src/quivers/dsl/deduction_schemata.py
index_values
¶
index_values(sorts: Mapping[str, QiecIndexDecl]) -> frozenset[str]
Every nullary index constructor of the module.
| PARAMETER | DESCRIPTION |
|---|---|
sorts
|
The module's index sorts.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The names a constraint may use as values. |
Source code in src/quivers/dsl/deduction_schemata.py
instantiate
¶
instantiate(rule: SequentRule, assignment: tuple[SchemaValue, ...]) -> SequentRule
The instance of a schema at one assignment.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
The schema.
TYPE:
|
assignment
|
One value per parameter, in telescope order.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SequentRule
|
The rule, with no parameters, named |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If a numeral or a Boolean heads an application or stands for a slash, a spine's or a name sequence's length is no numeral, two of them over one sequence variable differ in length, a name sequence is not the first of an application's two arguments, or a sequence variable's names would capture a name the rule already uses. |
Source code in src/quivers/dsl/deduction_schemata.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
render_value
¶
render_value(value: SchemaValue) -> str
The spelling of a parameter value in names and patterns.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/dsl/deduction_schemata.py
schema_parameters
¶
schema_parameters(rule: SequentRule) -> tuple[QiecIndexBinder, ...]
A schema's parameters, refusing a binder that is not over an index sort.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
A rule; a rule with no telescope has no parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecIndexBinder, ...]
|
Its parameters, in telescope order. |
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If the telescope binds a type, an effect, or a row: a schema's parameters range over finite static domains. |
Source code in src/quivers/dsl/deduction_schemata.py
shared_weight_key
¶
shared_weight_key(rule: SequentRule) -> str | None
The weight-family index a rule's shared pragma reads, if any.
| PARAMETER | DESCRIPTION |
|---|---|
rule
|
A rule with no parameters.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
|
| RAISES | DESCRIPTION |
|---|---|
SchemaError
|
If the pragma's value is not a family name or a family applied to numerals and names, or still names a parameter. |
extract_deduction_schema
¶
extract_deduction_schema(compiler: Compiler) -> Schema
Produce a panproto.Schema for the compiler's
deduction-system environment.
Walks the compiler's _deductions registry and emits one
panproto vertex per deduction system, one per rule, one per
atom, and per-premise / per-conclusion pattern vertices. The
returned schema validates against
QVR_DEDUCTION_PROTOCOL and is suitable for
panproto.diff_schemas and
panproto.auto_generate_lens operations over deduction
systems.
| PARAMETER | DESCRIPTION |
|---|---|
compiler
|
A compiler whose
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A schema in the |
Source code in src/quivers/dsl/program_theory.py
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 | |
extract_program_schema
¶
extract_program_schema(compiler: Compiler) -> Schema
Produce a panproto.Schema for a compiled program.
Walks the compiler's resolved environment (objects, spaces, morphisms)
and its checked kernel module (effects, instances, handlers,
computations, and program entry points) and emits a graph of
vertices and edges in the QVR_PROGRAM_PROTOCOL protocol. The
returned schema validates against that protocol and is suitable for
panproto.diff_schemas, panproto.auto_generate_lens, and the rest
of panproto's schema-level operations.
| PARAMETER | DESCRIPTION |
|---|---|
compiler
|
A
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Schema
|
A program-level Schema in the |
Source code in src/quivers/dsl/program_theory.py
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | |
expression_of
¶
expression_of(source: str) -> LetExprNode
Parse one pure expression.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The expression's source, on one line.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LetExprNode
|
Its syntax. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the source is not one expression. |
Source code in src/quivers/dsl/row_inference.py
principal_type
¶
principal_type(expression: LetExprNode, environment: Mapping[str, TypeExpr] | None = None) -> TypeScheme
The principal type of a pure expression.
| PARAMETER | DESCRIPTION |
|---|---|
expression
|
The expression: records, variants,
TYPE:
|
environment
|
The types of the names it may read.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TypeScheme
|
The type with its unsolved type variables named |
| RAISES | DESCRIPTION |
|---|---|
InferenceError
|
If the expression is ill-typed, joins rows that both have a label, or is of a form inference does not cover. |
Source code in src/quivers/dsl/row_inference.py
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 | |
has_qiec_surface
¶
has_qiec_surface(module: Module) -> bool
Return whether a parsed module has anything to elaborate through QIEC.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to inspect.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when at least one statement belongs to the QIEC surface or is a program or deduction the elaboration turns into computations. Callers use this to decide whether the QIEC route runs at all, so a module of other declarations pays nothing for it. |
Source code in src/quivers/dsl/qiec_lowering.py
lower_qvr_to_qiec
¶
lower_qvr_to_qiec(module: Module, *, module_name: str | None = None, file_path: str = '<source>', source_version: str = QVR_SOURCE_VERSION, target_version: str = QIEC_ABI, elaborate_programs: bool = True, families: FamilyCatalog | None = None) -> QiecModule
Check and lower the QIEC projection of one parsed QVR module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module, which may mix QIEC and ordinary declarations.
TYPE:
|
module_name
|
Name the stable identities derive from. None takes it from
TYPE:
|
file_path
|
Path recorded on diagnostics.
TYPE:
|
source_version
|
The source protocol the module is written against.
TYPE:
|
target_version
|
The kernel ABI to lower to.
TYPE:
|
elaborate_programs
|
Whether
TYPE:
|
families
|
Compilation-local custom distribution contracts and native bindings. Only the semantic contracts are retained in the checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecModule
|
The checked, lowered module. |
| RAISES | DESCRIPTION |
|---|---|
QiecDiagnosticError
|
If the source is rejected, with a stable code and a position. The
code |
KernelError
|
If the lowered module fails its independent recheck. |
Source code in src/quivers/dsl/qiec_lowering.py
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 | |
non_qiec_projection
¶
Project declarations consumed by the categorical/probabilistic compiler.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to project.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
A module of everything outside the QIEC surface, in source order. |
Source code in src/quivers/dsl/qiec_lowering.py
qiec_projection
¶
Project QIEC declarations from a module with multiple neighborhoods.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to project.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Module
|
A module of the QIEC statements alone, in source order. The
complement is |
Source code in src/quivers/dsl/qiec_lowering.py
check_module_language
¶
check_module_language(flat: FlatProgram, *, module_name: str = 'source', file_path: str = '<source>', data: dict | None = None) -> QiecModule | None
Check a flat program's module layer through its checking program.
The checking program keeps the abstract families of functor parameters
and sealed modules abstract, includes every functor's body once at its
parameters' signatures, and witnesses every signature match with
generated code (see FlatProgram.checking). Compiling it checks
generic code against signatures alone, client code against sealed
signatures alone, and every match. A program without signatures,
functors, sealing, or module parameters has no checking program.
| PARAMETER | DESCRIPTION |
|---|---|
flat
|
The interpreted module graph.
TYPE:
|
module_name
|
The compiled module's name.
TYPE:
|
file_path
|
The root module's file.
TYPE:
|
data
|
Bindings for
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecModule | None
|
The checked core of the checking program, which holds every functor body once (typed holes included), or None when the program has no checking program. |
| RAISES | DESCRIPTION |
|---|---|
ModuleError
|
With code |
CompileError
|
If the checking program fails to compile for another reason. |
QiecDiagnosticError
|
If QIEC elaboration of the checking program fails for another reason. |
Source code in src/quivers/dsl/__init__.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
check_signature_laws
¶
check_signature_laws(flat: FlatProgram, module: QiecModule) -> tuple[LawReport, ...]
Check each module that matches a signature with laws as a model of them.
A signature's equations form a theory over its abstract families
(sorts) and its computations over them (operations), composed and
checked like a theory declaration; each matching module is checked
as a finite model of it by quivers.dsl.theories.check_instance when
its families are finite, and its obligation is recorded as assumed
otherwise.
| PARAMETER | DESCRIPTION |
|---|---|
flat
|
The interpreted module graph.
TYPE:
|
module
|
The compiled run-time program's checked module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[LawReport, ...]
|
One report per obligation, in match order. |
| RAISES | DESCRIPTION |
|---|---|
ModuleError
|
With code |
Source code in src/quivers/dsl/__init__.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
loads
¶
loads(source: str | bytes, *, data: dict | None = None, modules: Mapping[str, str] | None = None, roots: tuple[str | Path, ...] = ()) -> Program
Compile .qvr source text into a trainable Program.
The source is the root module. Its imports are found in modules
first and then below roots; the module graph is interpreted into
one flat program, which is compiled.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The
TYPE:
|
data
|
Maps string keys to tensors (or tensor-like objects) for
any
TYPE:
|
modules
|
Module sources by dotted module path, for imports.
TYPE:
|
roots
|
Directories imported module paths are relative to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Program
|
The compiled program. |
| RAISES | DESCRIPTION |
|---|---|
ParseError
|
If |
ModuleError
|
If an import names no module, the imports form a cycle, or a name does not resolve. |
CompileError
|
If the flat program does not compile. |
Source code in src/quivers/dsl/__init__.py
load
¶
load(path: str | Path, *, data: dict | None = None, roots: tuple[str | Path, ...] | None = None) -> Program
Load and compile a .qvr file into a trainable Program.
The file is the root module. Its imports are found below roots
(the file's own directory by default); the module graph is
interpreted into one flat program, which is compiled.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The
TYPE:
|
data
|
Maps string keys to tensors for any
TYPE:
|
roots
|
Directories module paths are relative to.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Program
|
The compiled program. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the file cannot be read. |
ParseError
|
If the file or a module it imports does not parse. |
ModuleError
|
If an import names no module, the imports form a cycle, or a name does not resolve. |
CompileError
|
If the flat program does not compile. |
Source code in src/quivers/dsl/__init__.py
lower_flat_to_qiec
¶
lower_flat_to_qiec(flat: FlatProgram, *, module_name: str = 'source', file_path: str = '<source>', elaborate_programs: bool = True, families: FamilyCatalog | None = None) -> QiecModule
Check and lower an interpreted module graph to one QIEC module.
This is the QIEC route of loads and load: the module layer is
checked through the checking program, the flat program is lowered by
lower_qvr_to_qiec, and the laws of every matched signature are
checked against the lowered module.
| PARAMETER | DESCRIPTION |
|---|---|
flat
|
The interpreted module graph (
TYPE:
|
module_name
|
Name the stable identities derive from.
TYPE:
|
file_path
|
The root module's file, recorded on diagnostics.
TYPE:
|
elaborate_programs
|
Whether
TYPE:
|
families
|
Compilation-local custom distribution contracts and native bindings.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecModule
|
The checked, lowered module. |
| RAISES | DESCRIPTION |
|---|---|
ModuleError
|
With code |
QiecDiagnosticError
|
If lowering rejects the flat program; a diagnostic in an imported module names that module's file and line. |
CompileError
|
If the checking program fails to compile. |