constraints#
Constraint evaluation modules.
This module provides per-AIR constraint evaluation that replaces the generic expression binary interpreter. Each AIR has its own ConstraintModule that evaluates the constraint polynomial directly in readable Python code.
For AIRs without hand-written modules, the bytecode adapter provides a fallback using compiled expression bytecode. The BYTECODE_AIRS dict controls which AIRs use bytecode vs hand-written modules.
Zisk AIRs are auto-discovered from the proving key at ZISK_PROVING_KEY_DIR. All discovered AIRs without hand-written modules are registered for bytecode evaluation.
Submodules#
Attributes#
Functions#
|
Get constraint module instance for an AIR. |
Package Contents#
- constraints.CONSTRAINT_REGISTRY: dict[str, type[base.ConstraintModule]][source]#
- constraints.get_constraint_module(air_name: str, expressions_bin: str | None = None) base.ConstraintModule[source]#
Get constraint module instance for an AIR.
When expressions_bin is provided (from AirConfig), prefers hand-written modules in CONSTRAINT_REGISTRY to avoid naming collisions between pilouts that share an AIR name (e.g., SpecifiedRanges appears in both Simple pilout and Zisk). Falls back to BytecodeConstraintModule with the provided path if no hand-written module exists.
Without expressions_bin, checks BYTECODE_AIRS first (allowing bytecode override for validation), then falls back to hand-written modules in CONSTRAINT_REGISTRY.
- Args:
air_name: Name of the AIR (e.g., ‘SimpleLeft’, ‘Lookup2_12’) expressions_bin: Optional path to .bin bytecode. When provided, takes priority
over BYTECODE_AIRS to prevent cross-pilout naming collisions.
- Returns:
ConstraintModule instance for the AIR
- Raises:
KeyError: If no constraint module is registered for the AIR (and no expressions_bin)