Miden VM decoder AIR constraints
In this section we describe AIR constraints for Miden VM program decoder. These constraints enforce that the execution trace generated by the prover when executing a particular program complies with the rules described in the previous section.
To refer to decoder execution trace columns, we use the following names (these are the same names as in the previous section). Additionally, we denote the register containing the value at the top of the stack as .
| Columns | Registers |
|---|---|
| -- | |
| -- | |
full_batch | |
batch_size_code | |
| -- |
We assume that the VM exposes a flag per operation which is set to when the operation is executed, and to otherwise. The notation for such flags is . For example, when the VM executes a PUSH operation, flag . All flags are mutually exclusive - i.e., when one flag is set to all other flags are set to . The flags are computed based on values in op_bits columns.
AIR constraints for the decoder involve operations listed in the table below. For each operation we also provide the degree of the corresponding flag and the effect that the operation has on the operand stack (however, in this section we do not cover the constraints needed to enforce the correct transition of the operand stack).
| Operation | Flag | Degree | Effect on stack |
|---|---|---|---|
JOIN | 5 | Stack remains unchanged. | |
SPLIT | 5 | Top stack element is dropped. | |
LOOP | 5 | Stack remains unchanged. | |
REPEAT | 4 | Top stack element is dropped. | |
SPAN | 5 | Stack remains unchanged. | |
RESPAN | 4 | Stack remains unchanged. | |
DYN | 5 | Top stack element is dropped. | |
DYNCALL | 5 | Top stack element is dropped. | |
CALL | 4 | Stack remains unchanged. | |
SYSCALL | 4 | Stack remains unchanged. | |
END | 4 | When exiting a loop block, top stack element is dropped; otherwise, the stack remains unchanged. | |
HALT | 4 | Stack remains unchanged. | |
PUSH | 5 | An immediate value is pushed onto the stack. | |
EMIT | 7 | Stack remains unchanged. |
We also use the control flow flag
exposed by the VM, which is set to for the control-flow operations
SPAN, JOIN, SPLIT, LOOP, END, REPEAT, RESPAN, HALT, DYN, DYNCALL, CALL,
and SYSCALL (and otherwise). It has degree .
As described previously, the prover supplies parts of the program by populating trace cells non-deterministically. Typed LogUp messages bind those values to the block hash, block stack, and op-group virtual tables. Local transition constraints select the required insertions and removals, while lookup closure and the program-hash boundary contribution bind the execution trace to the claimed program.
In the sections below, we describe constraints according to their logical grouping. However, we start out with a set of general constraints which are applicable to multiple parts of the decoder.
General constraints
When SPLIT operation is executed, the top of the operand stack must contain a binary value:
When a DYN operation is executed, the second half of the hasher registers
() must be set to (the first half holds the callee digest):
A REPEAT operation requires at the top of the operand stack:
On each transition, REPEAT must follow an END whose marks the completed node as a loop
body. The block-hash relation authenticates this flag on the END row:
LOOP cannot transition directly to END; that would skip the body if its body-hash
multiplicity were zero:
The first row has no predecessor, so it cannot be a REPEAT operation:
When RESPAN operation is executed, we need to make sure that the block ID is incremented by :
When END operation is executed and we are exiting a loop block (i.e., is_loop, value which is stored in , is ), the value at the top of the operand stack must be :
A HALT instruction can be followed only by another HALT instruction:
When a HALT operation is executed, block address column must be :
Values in op_bits columns must be binary (i.e., either or ):
We also use two extra columns (, ) for degree reduction in the operation flag computation:
Since selects prefix 101, selects prefixes 100 and 11. The two terms below
select disjoint opcode groups: the first forces for prefixes 100 and 11, and the
second rejects opcode under prefix 101:
Prefix 11 also requires :
When the value in in_span column is set to , control flow operations cannot be executed on the VM, but when in_span flag is , only control flow operations can be executed on the VM:
Block hash computation constraints
As described previously, when the VM starts executing a new block, it also initiates computation of the block's hash. There are two separate methodologies for computing block hashes.
For join and split blocks, the hash is computed directly from the hashes of the block's children. The prover provides these child hashes non-deterministically by populating registers . For loop blocks, only the loop body hash is provided in and the remaining registers are set to (padding to a full 8-element block). For dyn, the first half holds the callee digest read from memory and the second half of the hasher registers () is constrained to ; the digest itself may be the zero word. The callee digest participates in the memory and block-hash messages, while the domain-separated DYN hash request uses an all-zero input block. The hasher is initialized using the hash controller, and we use the controller-row address as the block's ID. A controller row overlays both the compression input and its output chaining value; for these framed block-hash operations, that value is the block digest read by END at the same address.
For basic blocks, the hash is computed by absorbing a linear sequence of instructions (organized into operation groups and batches) into the hasher and then returning the result. The prover provides operation batches non-deterministically by populating registers . Similarly to other blocks, the hasher is initialized using the hash controller at the start of the block, and we use the address of the first controller row as the ID of the first operation batch in the block. As we absorb additional operation batches into the hasher (by executing RESPAN), the next batch uses the next controller row, so the batch address is incremented by . We read the result from that final controller row when the END operation is executed for the block.
Chiplets bus constraints
The decoder communicates with the hash, memory, and kernel-ROM chiplets through typed LogUp messages. Each decoder request has multiplicity ; the owning chiplet supplies the matching message with positive multiplicity. The shared LogUp recurrence and cross-AIR closure are described in the linked overview.
In constructing values for decoder bus requests, we use the typed hasher message format described in the hasher chiplet. Let be the domain-separated prefix for message kind . A message is reduced as
The message kind selects a distinct prefix for a full-state initialization, next-block absorption, or four-Felt result/CV return. Decoder block-hash messages use node index zero. Let denote the opcode value. Let denote the Eidos two-to-one chaining word derived from that opcode, and let denote the basic-block chaining word derived from its logical operation-group count.
To simplify constraint description, we define the following values:
For the other typed chiplet messages below, write
and
In the above, is set to when a control flow operation that signifies the initialization of a control block is being executed on the VM (only those control blocks that don't do any concurrent requests to the chiplets bus). Otherwise, it is set to . An exception is made for the DYN, DYNCALL, CALL and SYSCALL operations, since although they initialize a control block, they also run another concurrent bus request, and so are handled separately.
When a control block initializer (JOIN, SPLIT, or LOOP) is executed, the decoder removes
. The opcode-derived Eidos chaining word domain-separates the new hash.
SYSCALL removes both and the following kernel-ROM request:
The values contain the root hash of the procedure being called.
Similar to SYSCALL, CALL is handled separately, since in addition to communicating with the hash chiplet, it must also initialize the frame memory pointer (stored in memory at constant address fmpaddr with constant value fmpinit):
In the above, represents a "write element" memory request equivalent to mem[fmpaddr] = fmpinit (in pseudo-code) in the new memory context (i.e. the memory context of the callee). The VM uses and .
CALL removes and as two separate interactions.
Similar to SYSCALL and CALL, DYN and DYNCALL are handled separately, since in addition to communicating with the hash chiplet they must also issue a memory read operation for the hash of the procedure being called.
DYN removes and ; DYNCALL additionally removes
. The hash request carries an all-zero block and the opcode-derived chaining word,
while binds the callee digest in to the memory word at .
represents a memory word read request from address
, where the result is placed in the first half of the decoder hasher trace.
Note that similar to CALL, DYNCALL also creates a new memory context, and hence
must also initialize the fmp.
When SPAN is executed, a new hasher is initialized and the contents of are
absorbed into it. The input CV is , which binds the logical operation-group count.
The decoder removes on that row.
When RESPAN is executed, the contents of (which contain the new operation batch)
are absorbed into the hasher. The decoder removes on that row.
When END is executed, the hash result is copied into registers . The decoder
removes on that row. Together, these operation-gated negative contributions require the
hasher, memory, and kernel-ROM traces to provide every requested typed message.
Block stack table constraints
As described previously, block stack table keeps track of program blocks currently executing on the VM. Thus, whenever the VM starts executing a new block, an entry for this block is added to the block stack table. And when execution of a block completes, it is removed from the block stack table.
The BlockStackTable message has two tagged variants. A continuation is
; a caller frame is
. The caller-frame tag prevents its encoding from
colliding with a continuation whose saved payload is zero. Operation flags gate these signed
interactions:
JOIN,SPLIT,SPAN, andDYNadd .LOOPadds . Its do-while semantics makeis_loopunconditionally one.CALLandSYSCALLadd , saving the caller state.DYNCALLadds ; and hold the post-shift stack depth and overflow address.RESPANremoves and adds , replacing the current batch ID while preserving its parent.ENDremoves a continuation or a caller frame according to its entry-kind selectors.
When END executes, indicates a LOOP continuation and indicates that the
operation restores a caller frame. Both selectors are constrained to be boolean and mutually
exclusive, while is fixed to zero. If , the operation removes .
If , it removes , binding the restored caller state to
the saved entry.
The booleanity and mutual-exclusion constraints have degree ; the zeroing constraint has degree .
Adds have multiplicity and removals have multiplicity . LogUp closure requires every completed block to cancel the entry created when that block began.
Block hash table constraints
As described previously, when the VM starts executing a new program
block, it adds hashes of the block's children to the block hash table. When the VM finishes
executing a block, it removes the block's hash from the table. The table is therefore updated by
JOIN, SPLIT, LOOP, DYN, DYNCALL, CALL, SYSCALL, and END. SPAN does not
affect the table because a basic block has no children.
Define the typed BlockHashTable message
whose encoded payload is [hash[0..4], parent, is_first, is_loop_body]. The two JOIN children
are
Graphically, this looks like so:

Operation flags gate the following positive contributions:
JOINadds both messages above.SPLITadds the first message when and the second when .LOOPadds with multiplicitygroup_count, the number of body executions. Its do-while semantics require at least one body execution.REPEATadds no block-hash entry; each bodyENDmust remove a copy of the hash committed byLOOP.DYN,DYNCALL,CALL, andSYSCALLadd .
When END operation is executed, the hash of the completed block is removed from the block
hash table. We differentiate between the first and second child of a JOIN by looking at
the next opcode: if the next operation is not END, REPEAT, RESPAN, or HALT, then this
block is the first child and is_first_child = 1. RESPAN is included defensively — no single
constraint forbids END → RESPAN, so excluding it would let an adversarial trace inject a
false-positive is_first_child = 1. The is_loop_body flag is read from .
Thus, END removes
Adds have multiplicity and the END removal has multiplicity . The verifier also adds
as a boundary contribution. At the root END, the local constraints
reduce the removal to that same message, binding the decoded execution to the public program hash.
Basic block
Basic block constraints ensure proper decoding of basic blocks. In addition to the block stack table constraints and block hash table constraints described previously, decoding of basic blocks requires constraints described below.
In-span column constraints
The in_span column (denoted as ) marks rows which execute non-control flow
operations. This is enforced by the control-flow constraint
, so for non-control flow operations and
otherwise. Semantically, this means is 1 throughout basic blocks and 0 on
control-flow rows. The transition constraints below enforce the legal state
transitions into and out of basic blocks.
Here includes SPAN, JOIN, SPLIT, LOOP, END, REPEAT, RESPAN, HALT,
DYN, DYNCALL, CALL, and SYSCALL.
We require that the VM starts outside a basic block. Since and is binary, is also binary.
On each transition, SPAN and RESPAN are followed by an in-span row. An
in-span row remains inside unless the next operation is END or RESPAN:
The first-row constraint above handles the start of the trace separately from this transition rule.
Block address constraints
When we are inside a basic block, values in block address columns (denoted as ) must remain the same. The same is true when executing REPEAT, which re-enters the same loop parent for another body iteration. This can be enforced with the following constraint:
This preservation constraint covers in-span rows and REPEAT. For the remaining control-flow
operations, the prover supplies the next block address subject to their operation-specific
constraints. In particular, RESPAN increments by , as specified above.
When an in-span row is followed by END, this constraint copies into the END row, keeping
the address of the current span batch.
Group count constraints
The group_count column (denoted as ) is used to keep track of the number of operation groups which remains to be executed in a basic block.
In the beginning of a basic block (i.e., when SPAN operation is executed), the prover sets the value of non-deterministically. This value is subsequently decremented according to the rules described below. By the time we exit the basic block (i.e., when END operation is executed), the value in must be .
The rules for decrementing values in the column are as follows:
- The count cannot be decremented by more than in a single row.
- When an operation group is fully executed (which happens when inside a basic block), the count is decremented by .
- When
SPAN,RESPAN, orPUSHoperations are executed, the count is decremented by .
Note that these rules imply that the PUSH operation (or any operation with an immediate value) cannot be the last operation in an operation group (otherwise the count would have to be decremented by ).
To simplify the description of the constraints, we will define the following variable:
Using this variable, we can describe the constraints against the column as follows:
Inside a basic block, group count can either stay the same or decrease by one:
When group count is decremented inside a basic block, either must be (we consumed all operations in a group) or we must be executing an operation with an immediate value:
Notice that the above constraint does not preclude and from being true at the same time. If this happens, op group decoding constraints (described here) will force that the operation following the operation with an immediate value is a NOOP.
When executing a SPAN, a RESPAN, or an operation with an immediate value, group count must be decremented by :
If the next operation is either an END or a RESPAN, group count must remain the same:
When an END operation is executed, group count must be :
Op group decoding constraints
Inside a basic block, register is used to keep track of operations to be executed in the current operation group. The value of this register is set by the prover non-deterministically at the time when the prover executes a SPAN or a RESPAN operation, or when processing of a new operation group within a batch starts. The picture below illustrates this.

In the above:
- The prover sets the value of non-deterministically at row . The value is set to an operation group containing operations
op0throughop8. - As we start executing the group, at every row we "remove" the least significant operation from the group. This can be done by subtracting opcode of the operation from the group, and then dividing the result by .
- By row the group is fully executed. This decrements the group count and set
op_indexto (constraints againstop_indexcolumn are described in the next section). - At row we start executing the next group with operations
op9throughop11. In this case, the prover populates with the group having its first operation (op9) already removed, and sets theop_bitsregisters to the value encodingop9. - By row this group is also fully executed.
To simplify the description of the constraints, we define the following variables:
is just an opcode value implied by the values in op_bits registers. is a flag which is set to when the group count within a basic block does not change. We multiply it by to make sure the flag is when we are about to end decoding of an operation batch. Note that flag is mutually exclusive with , , and flags as these three operations decrement the group count.
Using these variables, we can describe operation group decoding constraints as follows:
When a SPAN, a RESPAN, or an operation with an immediate value is executed or when the group count does not change, the value in should be decremented by the value of the opcode in the next row.
Notice that when the group count does change, and we are not executing , , or operations, no constraints are placed against , and thus, the prover can populate this register non-deterministically.
When we are in a basic block and the next operation is END or RESPAN, the current value in column must be .
Op index constraints
The op_index column (denoted as ) tracks index of an operation within its operation group. It is used to ensure that the number of operations executed per group never exceeds . The index is zero-based, and thus, the possible set of values for is between and (both inclusive).
To simplify the description of the constraints, we will define the following variables:
The value of is set to when we are about to start executing a new operation group (i.e., group count is decremented but we did not execute an operation with an immediate value). Using these variables, we can describe the constraints against the column as follows.
When executing SPAN or RESPAN operations the next value of op_index must be set to :
When starting a new operation group inside a basic block, the next value of op_index must be set to . Note that we multiply by to exclude the cases when the group count is decremented because of SPAN or RESPAN operations:
When inside a basic block but not starting a new operation group, op_index must be incremented by . Note that we multiply by to exclude the cases when we are about to exit processing of an operation batch (i.e., the next operation is either END or RESPAN):
Values of op_index must be in the range .
Op batch encoding constraints
The full_batch and batch_size_code columns specify how many operation groups are present
in an operation batch. Let denote full_batch, let denote batch_size_code, and let
. The valid encodings are:
| Encoding | Meaning |
|---|---|
| 8 groups | |
| 4 groups | |
| 2 groups | |
| with | 1 group |
| with | Inactive row |
The following constraints restrict the pair to these encodings. The two inactive-row constraints directly pin each committed value to zero when the encoding is inactive.
The four batch-size selectors are derived as follows:
- .
- .
- .
- .
Their degrees are , , , and , respectively. They sum to , so the shared
encoding selects one group on SPAN and RESPAN rows and selects no group on inactive
rows.
Design rationale
The value is simply the field value assigned to the 2-group case; this encoding does not use signed integer arithmetic. The values , , and are distinct in the trace field, and the constraint permits exactly those values.
The 8-group case gets its own Boolean flag because it controls the largest op-group lookup. The remaining three active sizes share the short-batch code. The product constraint excludes mixed encodings, while the two separate inactive-row constraints ensure that neither value can be non-zero when the encoding is inactive.
When we have at most 4 groups in a batch, registers should be set to 's.
When we have at most 2 groups in a batch, registers and should also be set to 's.
When we have 1 group in a batch, register should also be set to .
Op group table constraints
Op group table is used to ensure that all operation groups in a given batch are consumed before a new batch is started (i.e., via a RESPAN operation) or the execution of a basic block is complete (i.e., via an END operation). The op group table is updated according to the following rules:
An entry is the typed message
When a SPAN or a RESPAN operation is executed, we compute the values of the rows to be added to the op group table as follows:
The batch-size flags select the required prefix of these messages: zero for a one-group batch, one for a two-group batch, three for a four-group batch, or seven for an eight-group batch. Each selected message is added with multiplicity . The batch address comes from the next row's block address .
When a deferred group or immediate is consumed, the decoder removes
For PUSH, the group value is the immediate at . Otherwise it combines with the
next opcode. The batch address and group position come from the current and values.
We also define a flag which is set to when a group needs to be removed from the op group table.
Thus, a group is removed with multiplicity exactly when its count is decremented inside a
basic block. Multiplying by excludes the decrements performed by SPAN and RESPAN.
LogUp closure requires every deferred group added at batch setup to be consumed.