QIEC lowering¶
The exact QVR to QIEC lowering.
qiec_lowering
¶
Exact QVR to QIEC lowering.
Quivers owns this adapter. Didactic orders and negotiates its stages and checks the first-order indexed-family projection. Name resolution, stable identity, effect elaboration, runtime checking, and the QIEC ABI remain source-language responsibilities.
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.
QIEC_STATEMENT_TYPES
module-attribute
¶
QIEC_STATEMENT_TYPES = (surface.QiecIndexDecl, surface.QiecFamilyDecl, surface.QiecEffectDecl, surface.QiecEffectInstanceDecl, surface.QiecHandlerDecl, surface.QiecComputationDecl)
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.
QvrQiecSource
dataclass
¶
QvrQiecSource(syntax: Module, module_name: str, file_path: str = '<source>', elaborate_programs: bool = True)
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:
|
CheckedQvrQiec
dataclass
¶
CheckedQvrQiec(module: QiecModule)
The checked result passed between Didactic's ordered stages.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The kernel module the stages produced.
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
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
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
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
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) -> 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:
|
| 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. |