View on GitHub
Open this notebook in GitHub to run it yourself
Implementation in Expressions
If an expression is defined using a modulo operation, the output size is set recursively to all of its subexpressions. But if for some sub-expressions, another modulo operation is used, the sub-expression’s output_size is determined by the minimal value between the output_size of the sub-expression and the expression. See this example: . The result of expression is saved on a two-qubit register, and the results of expressions and are saved using three qubits each.Example
This example generates a quantum program that adds two five-qubit arguments: a on qubits 0-4, and b on qubits 5-- The adder result should have been calculated on a 6-qubit register. However, the modulo operation decides that the output register of the adder only contains its two least significant qubits. Thus, the adder result is written to a two-qubit register, on qubits 10-
Output: