diff --git a/Cargo.lock b/Cargo.lock
index 9a33d8af..67e7741c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1906,6 +1906,7 @@ dependencies = [
"downcast-rs",
"fxhash",
"hugr",
+ "hugr-cli",
"hugr-core",
"itertools 0.13.0",
"lazy_static",
@@ -1960,6 +1961,7 @@ dependencies = [
"cool_asserts",
"derive_more 0.99.18",
"hugr",
+ "hugr-cli",
"itertools 0.13.0",
"num_cpus",
"portgraph 0.12.2",
diff --git a/tket2-py/Cargo.toml b/tket2-py/Cargo.toml
index 3c2e8b1b..afe9657b 100644
--- a/tket2-py/Cargo.toml
+++ b/tket2-py/Cargo.toml
@@ -34,6 +34,9 @@ derive_more = { workspace = true }
itertools = { workspace = true }
portmatching = { workspace = true }
strum = { workspace = true }
+# Required to acces the `Package` type.
+# Remove once https://github.com/CQCL/hugr/issues/1530 is fixed.
+hugr-cli = { workspace = true }
[dev-dependencies]
rstest = { workspace = true }
diff --git a/tket2-py/examples/1-Getting-Started.ipynb b/tket2-py/examples/1-Getting-Started.ipynb
index b9c0961a..5a540ed8 100644
--- a/tket2-py/examples/1-Getting-Started.ipynb
+++ b/tket2-py/examples/1-Getting-Started.ipynb
@@ -26,7 +26,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 18,
"id": "25ac0737",
"metadata": {},
"outputs": [
@@ -34,18 +34,34 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Requirement already satisfied: tket2 in /Users/agustinborgna/src/tket2/.venv/lib/python3.12/site-packages (0.0.0a1)\n",
- "Note: you may need to restart the kernel to use updated packages.\n"
+ "\u001b[2mAudited \u001b[1m3 packages\u001b[0m \u001b[2min 2ms\u001b[0m\u001b[0m\n",
+ "⚠️ Warning: `build-backend` in pyproject.toml is not set to `maturin`, packaging tools such as pip will not use maturin to build this project.\n",
+ "🍹 Building a mixed python/rust project\n",
+ "🔗 Found pyo3 bindings\n",
+ "🐍 Found CPython 3.12 at /Users/aborgna/src/tket2/.venv/bin/python\n",
+ "📡 Using build options features from pyproject.toml\n",
+ "📦 Built wheel for CPython 3.12 to /var/folders/3j/ktpgz6yj0gn05q3x3d0qqndw0000gn/T/.tmpGBLlUC/tket2_py-0.0.0-cp312-cp312-macosx_11_0_arm64.whl\n",
+ "✏️ Setting installed package as editable\n",
+ "🛠 Installed tket2-py-0.0.0\n"
]
}
],
"source": [
- "%pip install tket2"
+ "# Install required dependencies\n",
+ "!uv pip install \\\n",
+ " \"pytket>=1.30.0,<2\" \\\n",
+ " \"guppylang>=0.12.0,<0.13\" \\\n",
+ " \"hugr>=0.8.1,<0.9\" \\\n",
+ "\n",
+ "# Uncomment one of these lines depending on whether you are using a published\n",
+ "# version of tket2 or a local build.\n",
+ "#!uv pip install \"tket2>=0.4.0,<0.5\"\n",
+ "!cd ../../ && maturin develop --quiet --uv"
]
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 19,
"id": "0c2a523d",
"metadata": {},
"outputs": [],
@@ -65,18 +81,14 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 20,
"id": "2896f51f",
"metadata": {},
"outputs": [],
"source": [
- "from tket2.circuit import render_circuit_mermaid\n",
- "\n",
- "setattr(\n",
- " Tk2Circuit,\n",
- " \"_repr_markdown_\",\n",
- " lambda self: f\"```mermaid\\n{render_circuit_mermaid(self)}\\n```\"\n",
- ")"
+ "from utils import setup_jupyter_rendering # type: ignore\n",
+ "# NOTE: This requires having `dot` (aka graphviz) installed on your system.\n",
+ "setup_jupyter_rendering()"
]
},
{
@@ -97,35 +109,130 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 21,
"id": "71f02038",
"metadata": {},
"outputs": [
{
"data": {
- "text/markdown": [
- "```mermaid\n",
- "graph LR\n",
- " subgraph 0 [\"(0) DFG\"]\n",
- " direction LR\n",
- " 1[\"(1) Input\"]\n",
- " 2[\"(2) Output\"]\n",
- " 3[\"(3) quantum.tket2.H\"]\n",
- " 4[\"(4) quantum.tket2.CX\"]\n",
- " 1--\"0:0
qubit\"-->3\n",
- " 1--\"1:1
qubit\"-->4\n",
- " 3--\"0:0
qubit\"-->4\n",
- " 4--\"0:0
qubit\"-->2\n",
- " 4--\"1:1
qubit\"-->2\n",
- " end\n",
- "\n",
- "```"
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 11,
+ "execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@@ -154,44 +261,213 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 22,
"id": "3e3c2ed0-892b-42d7-b5e8-1bc81970635b",
"metadata": {},
"outputs": [
{
"data": {
- "text/markdown": [
- "```mermaid\n",
- "graph LR\n",
- " subgraph 0 [\"(0) DFG\"]\n",
- " direction LR\n",
- " 1[\"(1) Input\"]\n",
- " 2[\"(2) Output\"]\n",
- " 3[\"(3) quantum.tket2.QAlloc\"]\n",
- " 4[\"(4) quantum.tket2.H\"]\n",
- " 5[\"(5) quantum.tket2.CX\"]\n",
- " 6[\"(6) quantum.tket2.Measure\"]\n",
- " 7[\"(7) quantum.tket2.Measure\"]\n",
- " 8[\"(8) quantum.tket2.QFree\"]\n",
- " 9[\"(9) quantum.tket2.QFree\"]\n",
- " 1--\"0:0
qubit\"-->4\n",
- " 3--\"0:1
qubit\"-->5\n",
- " 4--\"0:0
qubit\"-->5\n",
- " 5--\"0:0
qubit\"-->6\n",
- " 5--\"1:0
qubit\"-->7\n",
- " 6--\"0:0
qubit\"-->8\n",
- " 6--\"1:0
[]+[]\"-->2\n",
- " 7--\"0:0
qubit\"-->9\n",
- " 7--\"1:1
[]+[]\"-->2\n",
- " end\n",
- "\n",
- "```"
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 12,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -241,46 +517,18 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 23,
"id": "0ffe2aed",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Looking in indexes: https://pypi.org/simple, https://cqcpythonrepository.azurewebsites.net/simple/\n",
- "Requirement already satisfied: pytket in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (1.29.2)\n",
- "Requirement already satisfied: sympy~=1.6 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (1.13.0)\n",
- "Requirement already satisfied: numpy<2.0,>=1.21.4 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (1.26.4)\n",
- "Requirement already satisfied: lark~=1.1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (1.1.9)\n",
- "Requirement already satisfied: scipy~=1.13 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (1.14.0)\n",
- "Requirement already satisfied: networkx>=2.8.8 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (3.3)\n",
- "Requirement already satisfied: graphviz~=0.14 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (0.20.3)\n",
- "Requirement already satisfied: jinja2~=3.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (3.1.4)\n",
- "Requirement already satisfied: types-pkg-resources in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (0.1.3)\n",
- "Requirement already satisfied: typing-extensions~=4.2 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (4.12.2)\n",
- "Requirement already satisfied: qwasm~=1.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pytket) (1.0.1)\n",
- "Requirement already satisfied: MarkupSafe>=2.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from jinja2~=3.0->pytket) (2.1.5)\n",
- "Requirement already satisfied: setuptools in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from qwasm~=1.0->pytket) (70.3.0)\n",
- "Requirement already satisfied: mpmath<1.4,>=1.1.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from sympy~=1.6->pytket) (1.3.0)\n",
- "\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1.2\u001b[0m\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
- "Note: you may need to restart the kernel to use updated packages.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
- "%pip install pytket\n",
- "\n",
"from pytket.circuit import Circuit as PytketCircuit\n",
"from pytket.circuit.display import render_circuit_jupyter"
]
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 24,
"id": "f47e0f2d",
"metadata": {},
"outputs": [
@@ -302,14 +550,14 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-d0df7f0c-89cb-4cb3-b0e2-fe47c40d67ca" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-ae825493-40a5-4dc0-9bef-b75d367aa17e" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
" <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n",
" </div>\n",
@@ -319,7 +567,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "d0df7f0c-89cb-4cb3-b0e2-fe47c40d67ca";\n",
+ " const circuitRendererUid = "ae825493-40a5-4dc0-9bef-b75d367aa17e";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -364,29 +612,129 @@
},
{
"data": {
- "text/markdown": [
- "```mermaid\n",
- "graph LR\n",
- " subgraph 0 [\"(0) FuncDefn\"]\n",
- " direction LR\n",
- " 1[\"(1) Input\"]\n",
- " 2[\"(2) Output\"]\n",
- " 3[\"(3) quantum.tket2.H\"]\n",
- " 4[\"(4) quantum.tket2.CX\"]\n",
- " 1--\"0:0
qubit\"-->3\n",
- " 1--\"1:1
qubit\"-->4\n",
- " 3--\"0:0
qubit\"-->4\n",
- " 4--\"0:0
qubit\"-->2\n",
- " 4--\"1:1
qubit\"-->2\n",
- " end\n",
- "\n",
- "```"
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 14,
+ "execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
@@ -411,33 +759,11 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 25,
"id": "975dbe01",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Looking in indexes: https://pypi.org/simple, https://cqcpythonrepository.azurewebsites.net/simple/\n",
- "Requirement already satisfied: guppylang in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (0.6.2)\n",
- "Requirement already satisfied: graphviz<0.21.0,>=0.20.1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (0.20.3)\n",
- "Requirement already satisfied: hugr<0.5.0,>=0.4.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (0.4.0)\n",
- "Requirement already satisfied: networkx<4.0.0,>=3.2.1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (3.3)\n",
- "Requirement already satisfied: pydantic<3.0.0,>=2.7.0b1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (2.8.2)\n",
- "Requirement already satisfied: typing-extensions<5.0.0,>=4.9.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from guppylang) (4.12.2)\n",
- "Requirement already satisfied: annotated-types>=0.4.0 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.7.0b1->guppylang) (0.7.0)\n",
- "Requirement already satisfied: pydantic-core==2.20.1 in /Users/seyon/ng/tket2proto/.venv/lib/python3.11/site-packages (from pydantic<3.0.0,>=2.7.0b1->guppylang) (2.20.1)\n",
- "\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1.2\u001b[0m\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
- "Note: you may need to restart the kernel to use updated packages.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
- "%pip install guppylang\n",
- "\n",
"from guppylang import guppy\n",
"from guppylang.module import GuppyModule\n",
"from guppylang.prelude import quantum\n",
@@ -451,94 +777,2456 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 26,
"id": "96065d20",
"metadata": {},
"outputs": [
{
"data": {
- "text/markdown": [
- "```mermaid\n",
- "graph LR\n",
- " subgraph 1 [\"(1) DFG\"]\n",
- " direction LR\n",
- " 2[\"(2) Input\"]\n",
- " 27[\"(27) Output\"]\n",
- " 4[\"(4) const:custom:f64(1.5707963267948966)\"]\n",
- " 5[\"(5) LoadConstant\"]\n",
- " 6[\"(6) const:custom:f64(-1.5707963267948966)\"]\n",
- " 7[\"(7) LoadConstant\"]\n",
- " 8[\"(8) quantum.tket2.PhasedX\"]\n",
- " 9[\"(9) const:custom:f64(3.141592653589793)\"]\n",
- " 10[\"(10) LoadConstant\"]\n",
- " 11[\"(11) quantum.tket2.RzF64\"]\n",
- " 12[\"(12) const:custom:f64(1.5707963267948966)\"]\n",
- " 13[\"(13) LoadConstant\"]\n",
- " 14[\"(14) const:custom:f64(-1.5707963267948966)\"]\n",
- " 15[\"(15) LoadConstant\"]\n",
- " 16[\"(16) quantum.tket2.PhasedX\"]\n",
- " 17[\"(17) const:custom:f64(3.141592653589793)\"]\n",
- " 18[\"(18) LoadConstant\"]\n",
- " 19[\"(19) quantum.tket2.RzF64\"]\n",
- " 20[\"(20) quantum.tket2.ZZMax\"]\n",
- " 23[\"(23) quantum.tket2.Measure\"]\n",
- " 24[\"(24) quantum.tket2.QFree\"]\n",
- " 25[\"(25) quantum.tket2.Measure\"]\n",
- " 26[\"(26) quantum.tket2.QFree\"]\n",
- " 2--\"0:0
qubit\"-->8\n",
- " 2--\"1:0
qubit\"-->16\n",
- " 4--\"0:0
float64\"-->5\n",
- " 5--\"0:1
float64\"-->8\n",
- " 6--\"0:0
float64\"-->7\n",
- " 7--\"0:2
float64\"-->8\n",
- " 8--\"0:0
qubit\"-->11\n",
- " 9--\"0:0
float64\"-->10\n",
- " 10--\"0:1
float64\"-->11\n",
- " 11--\"0:0
qubit\"-->20\n",
- " 12--\"0:0
float64\"-->13\n",
- " 13--\"0:1
float64\"-->16\n",
- " 14--\"0:0
float64\"-->15\n",
- " 15--\"0:2
float64\"-->16\n",
- " 16--\"0:0
qubit\"-->19\n",
- " 17--\"0:0
float64\"-->18\n",
- " 18--\"0:1
float64\"-->19\n",
- " 19--\"0:1
qubit\"-->20\n",
- " 20--\"0:0
qubit\"-->23\n",
- " 20--\"1:0
qubit\"-->25\n",
- " 23--\"0:0
qubit\"-->24\n",
- " 25--\"0:0
qubit\"-->26\n",
- " 25--\"1:0
[]+[]\"-->27\n",
- " end\n",
- "\n",
- "```"
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
],
"text/plain": [
- ""
+ "Hugr(root=Node(0), _nodes=[NodeData(op=Module(), parent=None, metadata={'name': 'test'}), NodeData(op=FuncDefn(f_name='my_func', inputs=[Qubit, Qubit], params=[]), parent=Node(0), metadata={}), NodeData(op=Input(types=[Qubit, Qubit]), parent=Node(1), metadata={}), NodeData(op=Output(), parent=Node(1), metadata={}), NodeData(op=CFG(inputs=[Qubit, Qubit]), parent=Node(1), metadata={}), NodeData(op=DataflowBlock(inputs=[Qubit, Qubit], _sum=Unit, extension_delta=[]), parent=Node(4), metadata={}), NodeData(op=Input(types=[Qubit, Qubit]), parent=Node(5), metadata={}), NodeData(op=Output(), parent=Node(5), metadata={}), NodeData(op=ExitBlock(), parent=Node(4), metadata={}), NodeData(op=FuncDefn(f_name='phased_x', inputs=[Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], params=[]), parent=Node(0), metadata={}), NodeData(op=Input(types=[Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(9), metadata={}), NodeData(op=Output(), parent=Node(9), metadata={}), NodeData(op=FuncDefn(f_name='__truediv__', inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], params=[]), parent=Node(0), metadata={}), NodeData(op=Input(types=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])]), parent=Node(12), metadata={}), NodeData(op=Output(), parent=Node(12), metadata={}), NodeData(op=Const(Tuple(FloatVal(v=1.0))), parent=Node(0), metadata={}), NodeData(op=LoadConst(Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)), parent=Node(5), metadata={}), NodeData(op=Const(2), parent=Node(5), metadata={}), NodeData(op=LoadConst(int<6>), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=FuncDefn(f_name='__neg__', inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], params=[]), parent=Node(0), metadata={}), NodeData(op=Input(types=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(20), metadata={}), NodeData(op=Output(), parent=Node(20), metadata={}), NodeData(op=LoadConst(Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=Const(2), parent=Node(5), metadata={}), NodeData(op=LoadConst(int<6>), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Qubit])), instantiation=FunctionType([Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Qubit]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=MakeTuple([]), parent=Node(5), metadata={}), NodeData(op=LoadConst(Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)), parent=Node(5), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(5), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='from_halfturns', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')], [Sum([[], [Opaque(id='rotation', bound=, args=[], extension='tket2.rotation')]])])), binary=False), description='Construct rotation from number of half-turns (would be multiples of π in radians).', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])], [Sum([[], [ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]])]), args=[]), parent=Node(5), metadata={}), NodeData(op=Conditional(sum_ty=Sum([[], [ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]]), other_inputs=[]), parent=Node(5), metadata={}), NodeData(op=Case(inputs=[]), parent=Node(33), metadata={}), NodeData(op=Input(types=[]), parent=Node(34), metadata={}), NodeData(op=Output(), parent=Node(34), metadata={}), NodeData(op=Const(Error(1): Non-finite number of half-turns), parent=Node(0), metadata={}), NodeData(op=LoadConst(error), parent=Node(34), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='panic', signature=OpDefSig(poly_func=PolyFuncType(params=[ListParam(param=TypeTypeParam(bound=)), ListParam(param=TypeTypeParam(bound=))], body=FunctionType([Opaque(id='error', bound=, args=[], extension='prelude'), $0], [$1])), binary=False), description='Panic with input error', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='error', description='Simple opaque error type.', params=[], bound=ExplicitBound(bound=)), args=[])], [ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]), args=[SequenceArg(elems=[]), SequenceArg(elems=[TypeTypeArg(ty=ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[]))])]), parent=Node(34), metadata={}), NodeData(op=Case(inputs=[ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(33), metadata={}), NodeData(op=Input(types=[ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(40), metadata={}), NodeData(op=Output(), parent=Node(40), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='Rz', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Qubit, Opaque(id='rotation', bound=, args=[], extension='tket2.rotation')], [Qubit])), binary=False), description='Rz', misc={'commutation': [[0, 'Z']]}), signature=FunctionType([Qubit, ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])], [Qubit]), args=[]), parent=Node(5), metadata={}), NodeData(op=MakeTuple([]), parent=Node(5), metadata={}), NodeData(op=LoadConst(Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)), parent=Node(5), metadata={}), NodeData(op=Const(2), parent=Node(5), metadata={}), NodeData(op=LoadConst(int<6>), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=LoadConst(Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=Const(2), parent=Node(5), metadata={}), NodeData(op=LoadConst(int<6>), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Qubit])), instantiation=FunctionType([Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [Qubit]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=MakeTuple([]), parent=Node(5), metadata={}), NodeData(op=LoadConst(Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)), parent=Node(5), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(5), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='from_halfturns', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')], [Sum([[], [Opaque(id='rotation', bound=, args=[], extension='tket2.rotation')]])])), binary=False), description='Construct rotation from number of half-turns (would be multiples of π in radians).', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])], [Sum([[], [ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]])]), args=[]), parent=Node(5), metadata={}), NodeData(op=Conditional(sum_ty=Sum([[], [ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]]), other_inputs=[]), parent=Node(5), metadata={}), NodeData(op=Case(inputs=[]), parent=Node(59), metadata={}), NodeData(op=Input(types=[]), parent=Node(60), metadata={}), NodeData(op=Output(), parent=Node(60), metadata={}), NodeData(op=Const(Error(1): Non-finite number of half-turns), parent=Node(0), metadata={}), NodeData(op=LoadConst(error), parent=Node(60), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='panic', signature=OpDefSig(poly_func=PolyFuncType(params=[ListParam(param=TypeTypeParam(bound=)), ListParam(param=TypeTypeParam(bound=))], body=FunctionType([Opaque(id='error', bound=, args=[], extension='prelude'), $0], [$1])), binary=False), description='Panic with input error', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='error', description='Simple opaque error type.', params=[], bound=ExplicitBound(bound=)), args=[])], [ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]), args=[SequenceArg(elems=[]), SequenceArg(elems=[TypeTypeArg(ty=ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[]))])]), parent=Node(60), metadata={}), NodeData(op=Case(inputs=[ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(59), metadata={}), NodeData(op=Input(types=[ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(66), metadata={}), NodeData(op=Output(), parent=Node(66), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='Rz', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Qubit, Opaque(id='rotation', bound=, args=[], extension='tket2.rotation')], [Qubit])), binary=False), description='Rz', misc={'commutation': [[0, 'Z']]}), signature=FunctionType([Qubit, ExtType(type_def=TypeDef(name='rotation', description='rotation type expressed as number of half turns', params=[], bound=ExplicitBound(bound=)), args=[])], [Qubit]), args=[]), parent=Node(5), metadata={}), NodeData(op=MakeTuple([]), parent=Node(5), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='ZZMax', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Qubit, Qubit], [Qubit, Qubit])), binary=False), description='ZZMax', misc={}), signature=FunctionType([Qubit, Qubit], [Qubit, Qubit]), args=[]), parent=Node(5), metadata={}), NodeData(op=MakeTuple([]), parent=Node(5), metadata={}), NodeData(op=FuncDefn(f_name='measure', inputs=[Qubit], params=[]), parent=Node(0), metadata={}), NodeData(op=Input(types=[Qubit]), parent=Node(73), metadata={}), NodeData(op=Output(), parent=Node(73), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Qubit], [Bool])), instantiation=FunctionType([Qubit], [Bool]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Qubit], [Bool])), instantiation=FunctionType([Qubit], [Bool]), type_args=[]), parent=Node(5), metadata={}), NodeData(op=Tag(0), parent=Node(5), metadata={}), NodeData(op=CFG(inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(20), metadata={}), NodeData(op=DataflowBlock(inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], _sum=Unit, extension_delta=[]), parent=Node(79), metadata={}), NodeData(op=Input(types=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(80), metadata={}), NodeData(op=Output(), parent=Node(80), metadata={}), NodeData(op=ExitBlock(), parent=Node(79), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(80), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='fneg', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')], [Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')])), binary=False), description='negation', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), args=[]), parent=Node(80), metadata={}), NodeData(op=MakeTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(80), metadata={}), NodeData(op=Tag(0), parent=Node(80), metadata={}), NodeData(op=CFG(inputs=[Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(9), metadata={}), NodeData(op=DataflowBlock(inputs=[Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], _sum=Unit, extension_delta=[]), parent=Node(88), metadata={}), NodeData(op=Input(types=[Qubit, Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(89), metadata={}), NodeData(op=Output(), parent=Node(89), metadata={}), NodeData(op=ExitBlock(), parent=Node(88), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(89), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(89), metadata={}), NodeData(op=FuncDefn(f_name='__float__', inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], params=[]), parent=Node(0), metadata={}), NodeData(op=Input(types=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(95), metadata={}), NodeData(op=Output(), parent=Node(95), metadata={}), NodeData(op=MakeTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(89), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), type_args=[]), parent=Node(89), metadata={}), NodeData(op=MakeTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(89), metadata={}), NodeData(op=Call(signature=PolyFuncType(params=[], body=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])])), instantiation=FunctionType([Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), type_args=[]), parent=Node(89), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='PhasedX', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Qubit, Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types'), Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')], [Qubit])), binary=False), description='PhasedX', misc={}), signature=FunctionType([Qubit, ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]), ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])], [Qubit]), args=[]), parent=Node(89), metadata={}), NodeData(op=MakeTuple([]), parent=Node(89), metadata={}), NodeData(op=Tag(0), parent=Node(89), metadata={}), NodeData(op=CFG(inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(95), metadata={}), NodeData(op=DataflowBlock(inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)], _sum=Unit, extension_delta=[]), parent=Node(105), metadata={}), NodeData(op=Input(types=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),)]), parent=Node(106), metadata={}), NodeData(op=Output(), parent=Node(106), metadata={}), NodeData(op=ExitBlock(), parent=Node(105), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(106), metadata={}), NodeData(op=Const(3.141592653589793), parent=Node(106), metadata={}), NodeData(op=LoadConst(float64), parent=Node(106), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='fmul', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types'), Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')], [Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')])), binary=False), description='multiplication', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]), ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), args=[]), parent=Node(106), metadata={}), NodeData(op=Tag(0), parent=Node(106), metadata={}), NodeData(op=CFG(inputs=[Qubit]), parent=Node(73), metadata={}), NodeData(op=DataflowBlock(inputs=[Qubit], _sum=Unit, extension_delta=[]), parent=Node(115), metadata={}), NodeData(op=Input(types=[Qubit]), parent=Node(116), metadata={}), NodeData(op=Output(), parent=Node(116), metadata={}), NodeData(op=ExitBlock(), parent=Node(115), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='Measure', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Qubit], [Qubit, Bool])), binary=False), description='Measure', misc={'commutation': [[0, 'Z']]}), signature=FunctionType([Qubit], [Qubit, Bool]), args=[]), parent=Node(116), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='QFree', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Qubit], [])), binary=False), description='QFree', misc={'commutation': []}), signature=FunctionType([Qubit], []), args=[]), parent=Node(116), metadata={}), NodeData(op=MakeTuple([]), parent=Node(116), metadata={}), NodeData(op=Tag(0), parent=Node(116), metadata={}), NodeData(op=CFG(inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])]), parent=Node(12), metadata={}), NodeData(op=DataflowBlock(inputs=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], _sum=Unit, extension_delta=[]), parent=Node(124), metadata={}), NodeData(op=Input(types=[Tuple(ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]),), ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])]), parent=Node(125), metadata={}), NodeData(op=Output(), parent=Node(125), metadata={}), NodeData(op=ExitBlock(), parent=Node(124), metadata={}), NodeData(op=UnpackTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(125), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='convert_s', signature=OpDefSig(poly_func=PolyFuncType(params=[BoundedNatParam(upper_bound=7)], body=FunctionType([Opaque(id='int', bound=, args=[VariableArg(idx=0, param=BoundedNatParam(upper_bound=7))], extension='arithmetic.int.types')], [Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')])), binary=False), description='signed int to float', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='int', description='integral value of a given bit width', params=[BoundedNatParam(upper_bound=7)], bound=ExplicitBound(bound=)), args=[BoundedNatArg(n=6)])], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), args=[BoundedNatArg(n=6)]), parent=Node(125), metadata={}), NodeData(op=ExtOp(_op_def=OpDef(name='fdiv', signature=OpDefSig(poly_func=PolyFuncType(params=[], body=FunctionType([Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types'), Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')], [Opaque(id='float64', bound=, args=[], extension='arithmetic.float.types')])), binary=False), description='division', misc={}), signature=FunctionType([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[]), ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])], [ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), args=[]), parent=Node(125), metadata={}), NodeData(op=MakeTuple([ExtType(type_def=TypeDef(name='float64', description='64-bit IEEE 754-2019 floating-point value', params=[], bound=ExplicitBound(bound=)), args=[])]), parent=Node(125), metadata={}), NodeData(op=Tag(0), parent=Node(125), metadata={})], _links=BiMap({_SubPort(port=OutPort(Node(2), 0), sub_offset=0): _SubPort(port=InPort(Node(4), 0), sub_offset=0), _SubPort(port=OutPort(Node(2), 1), sub_offset=0): _SubPort(port=InPort(Node(4), 1), sub_offset=0), _SubPort(port=OutPort(Node(15), 0), sub_offset=0): _SubPort(port=InPort(Node(16), 0), sub_offset=0), _SubPort(port=OutPort(Node(17), 0), sub_offset=0): _SubPort(port=InPort(Node(18), 0), sub_offset=0), _SubPort(port=OutPort(Node(12), 0), sub_offset=0): _SubPort(port=InPort(Node(19), 2), sub_offset=0), _SubPort(port=OutPort(Node(16), 0), sub_offset=0): _SubPort(port=InPort(Node(19), 0), sub_offset=0), _SubPort(port=OutPort(Node(18), 0), sub_offset=0): _SubPort(port=InPort(Node(19), 1), sub_offset=0), _SubPort(port=OutPort(Node(15), 0), sub_offset=1): _SubPort(port=InPort(Node(23), 0), sub_offset=0), _SubPort(port=OutPort(Node(20), 0), sub_offset=0): _SubPort(port=InPort(Node(24), 1), sub_offset=0), _SubPort(port=OutPort(Node(23), 0), sub_offset=0): _SubPort(port=InPort(Node(24), 0), sub_offset=0), _SubPort(port=OutPort(Node(25), 0), sub_offset=0): _SubPort(port=InPort(Node(26), 0), sub_offset=0), _SubPort(port=OutPort(Node(12), 0), sub_offset=1): _SubPort(port=InPort(Node(27), 2), sub_offset=0), _SubPort(port=OutPort(Node(24), 0), sub_offset=0): _SubPort(port=InPort(Node(27), 0), sub_offset=0), _SubPort(port=OutPort(Node(26), 0), sub_offset=0): _SubPort(port=InPort(Node(27), 1), sub_offset=0), _SubPort(port=OutPort(Node(9), 0), sub_offset=0): _SubPort(port=InPort(Node(28), 3), sub_offset=0), _SubPort(port=OutPort(Node(6), 0), sub_offset=0): _SubPort(port=InPort(Node(28), 0), sub_offset=0), _SubPort(port=OutPort(Node(19), 0), sub_offset=0): _SubPort(port=InPort(Node(28), 1), sub_offset=0), _SubPort(port=OutPort(Node(27), 0), sub_offset=0): _SubPort(port=InPort(Node(28), 2), sub_offset=0), _SubPort(port=OutPort(Node(15), 0), sub_offset=2): _SubPort(port=InPort(Node(30), 0), sub_offset=0), _SubPort(port=OutPort(Node(30), 0), sub_offset=0): _SubPort(port=InPort(Node(31), 0), sub_offset=0), _SubPort(port=OutPort(Node(31), 0), sub_offset=0): _SubPort(port=InPort(Node(32), 0), sub_offset=0), _SubPort(port=OutPort(Node(32), 0), sub_offset=0): _SubPort(port=InPort(Node(33), 0), sub_offset=0), _SubPort(port=OutPort(Node(37), 0), sub_offset=0): _SubPort(port=InPort(Node(38), 0), sub_offset=0), _SubPort(port=OutPort(Node(38), 0), sub_offset=0): _SubPort(port=InPort(Node(39), 0), sub_offset=0), _SubPort(port=OutPort(Node(39), 0), sub_offset=0): _SubPort(port=InPort(Node(36), 0), sub_offset=0), _SubPort(port=OutPort(Node(41), 0), sub_offset=0): _SubPort(port=InPort(Node(42), 0), sub_offset=0), _SubPort(port=OutPort(Node(28), 0), sub_offset=0): _SubPort(port=InPort(Node(43), 0), sub_offset=0), _SubPort(port=OutPort(Node(33), 0), sub_offset=0): _SubPort(port=InPort(Node(43), 1), sub_offset=0), _SubPort(port=OutPort(Node(15), 0), sub_offset=3): _SubPort(port=InPort(Node(45), 0), sub_offset=0), _SubPort(port=OutPort(Node(46), 0), sub_offset=0): _SubPort(port=InPort(Node(47), 0), sub_offset=0), _SubPort(port=OutPort(Node(12), 0), sub_offset=2): _SubPort(port=InPort(Node(48), 2), sub_offset=0), _SubPort(port=OutPort(Node(45), 0), sub_offset=0): _SubPort(port=InPort(Node(48), 0), sub_offset=0), _SubPort(port=OutPort(Node(47), 0), sub_offset=0): _SubPort(port=InPort(Node(48), 1), sub_offset=0), _SubPort(port=OutPort(Node(15), 0), sub_offset=4): _SubPort(port=InPort(Node(49), 0), sub_offset=0), _SubPort(port=OutPort(Node(20), 0), sub_offset=1): _SubPort(port=InPort(Node(50), 1), sub_offset=0), _SubPort(port=OutPort(Node(49), 0), sub_offset=0): _SubPort(port=InPort(Node(50), 0), sub_offset=0), _SubPort(port=OutPort(Node(51), 0), sub_offset=0): _SubPort(port=InPort(Node(52), 0), sub_offset=0), _SubPort(port=OutPort(Node(12), 0), sub_offset=3): _SubPort(port=InPort(Node(53), 2), sub_offset=0), _SubPort(port=OutPort(Node(50), 0), sub_offset=0): _SubPort(port=InPort(Node(53), 0), sub_offset=0), _SubPort(port=OutPort(Node(52), 0), sub_offset=0): _SubPort(port=InPort(Node(53), 1), sub_offset=0), _SubPort(port=OutPort(Node(9), 0), sub_offset=1): _SubPort(port=InPort(Node(54), 3), sub_offset=0), _SubPort(port=OutPort(Node(6), 1), sub_offset=0): _SubPort(port=InPort(Node(54), 0), sub_offset=0), _SubPort(port=OutPort(Node(48), 0), sub_offset=0): _SubPort(port=InPort(Node(54), 1), sub_offset=0), _SubPort(port=OutPort(Node(53), 0), sub_offset=0): _SubPort(port=InPort(Node(54), 2), sub_offset=0), _SubPort(port=OutPort(Node(15), 0), sub_offset=5): _SubPort(port=InPort(Node(56), 0), sub_offset=0), _SubPort(port=OutPort(Node(56), 0), sub_offset=0): _SubPort(port=InPort(Node(57), 0), sub_offset=0), _SubPort(port=OutPort(Node(57), 0), sub_offset=0): _SubPort(port=InPort(Node(58), 0), sub_offset=0), _SubPort(port=OutPort(Node(58), 0), sub_offset=0): _SubPort(port=InPort(Node(59), 0), sub_offset=0), _SubPort(port=OutPort(Node(63), 0), sub_offset=0): _SubPort(port=InPort(Node(64), 0), sub_offset=0), _SubPort(port=OutPort(Node(64), 0), sub_offset=0): _SubPort(port=InPort(Node(65), 0), sub_offset=0), _SubPort(port=OutPort(Node(65), 0), sub_offset=0): _SubPort(port=InPort(Node(62), 0), sub_offset=0), _SubPort(port=OutPort(Node(67), 0), sub_offset=0): _SubPort(port=InPort(Node(68), 0), sub_offset=0), _SubPort(port=OutPort(Node(54), 0), sub_offset=0): _SubPort(port=InPort(Node(69), 0), sub_offset=0), _SubPort(port=OutPort(Node(59), 0), sub_offset=0): _SubPort(port=InPort(Node(69), 1), sub_offset=0), _SubPort(port=OutPort(Node(43), 0), sub_offset=0): _SubPort(port=InPort(Node(71), 0), sub_offset=0), _SubPort(port=OutPort(Node(69), 0), sub_offset=0): _SubPort(port=InPort(Node(71), 1), sub_offset=0), _SubPort(port=OutPort(Node(73), 0), sub_offset=0): _SubPort(port=InPort(Node(76), 1), sub_offset=0), _SubPort(port=OutPort(Node(71), 0), sub_offset=0): _SubPort(port=InPort(Node(76), 0), sub_offset=0), _SubPort(port=OutPort(Node(73), 0), sub_offset=1): _SubPort(port=InPort(Node(77), 1), sub_offset=0), _SubPort(port=OutPort(Node(71), 1), sub_offset=0): _SubPort(port=InPort(Node(77), 0), sub_offset=0), _SubPort(port=OutPort(Node(78), 0), sub_offset=0): _SubPort(port=InPort(Node(7), 0), sub_offset=0), _SubPort(port=OutPort(Node(77), 0), sub_offset=0): _SubPort(port=InPort(Node(7), 1), sub_offset=0), _SubPort(port=OutPort(Node(5), 0), sub_offset=0): _SubPort(port=InPort(Node(8), 0), sub_offset=0), _SubPort(port=OutPort(Node(4), 0), sub_offset=0): _SubPort(port=InPort(Node(3), 0), sub_offset=0), _SubPort(port=OutPort(Node(21), 0), sub_offset=0): _SubPort(port=InPort(Node(79), 0), sub_offset=0), _SubPort(port=OutPort(Node(81), 0), sub_offset=0): _SubPort(port=InPort(Node(84), 0), sub_offset=0), _SubPort(port=OutPort(Node(84), 0), sub_offset=0): _SubPort(port=InPort(Node(85), 0), sub_offset=0), _SubPort(port=OutPort(Node(85), 0), sub_offset=0): _SubPort(port=InPort(Node(86), 0), sub_offset=0), _SubPort(port=OutPort(Node(87), 0), sub_offset=0): _SubPort(port=InPort(Node(82), 0), sub_offset=0), _SubPort(port=OutPort(Node(86), 0), sub_offset=0): _SubPort(port=InPort(Node(82), 1), sub_offset=0), _SubPort(port=OutPort(Node(80), 0), sub_offset=0): _SubPort(port=InPort(Node(83), 0), sub_offset=0), _SubPort(port=OutPort(Node(79), 0), sub_offset=0): _SubPort(port=InPort(Node(22), 0), sub_offset=0), _SubPort(port=OutPort(Node(10), 0), sub_offset=0): _SubPort(port=InPort(Node(88), 0), sub_offset=0), _SubPort(port=OutPort(Node(10), 1), sub_offset=0): _SubPort(port=InPort(Node(88), 1), sub_offset=0), _SubPort(port=OutPort(Node(10), 2), sub_offset=0): _SubPort(port=InPort(Node(88), 2), sub_offset=0), _SubPort(port=OutPort(Node(90), 1), sub_offset=0): _SubPort(port=InPort(Node(93), 0), sub_offset=0), _SubPort(port=OutPort(Node(90), 2), sub_offset=0): _SubPort(port=InPort(Node(94), 0), sub_offset=0), _SubPort(port=OutPort(Node(93), 0), sub_offset=0): _SubPort(port=InPort(Node(98), 0), sub_offset=0), _SubPort(port=OutPort(Node(95), 0), sub_offset=0): _SubPort(port=InPort(Node(99), 1), sub_offset=0), _SubPort(port=OutPort(Node(98), 0), sub_offset=0): _SubPort(port=InPort(Node(99), 0), sub_offset=0), _SubPort(port=OutPort(Node(94), 0), sub_offset=0): _SubPort(port=InPort(Node(100), 0), sub_offset=0), _SubPort(port=OutPort(Node(95), 0), sub_offset=1): _SubPort(port=InPort(Node(101), 1), sub_offset=0), _SubPort(port=OutPort(Node(100), 0), sub_offset=0): _SubPort(port=InPort(Node(101), 0), sub_offset=0), _SubPort(port=OutPort(Node(90), 0), sub_offset=0): _SubPort(port=InPort(Node(102), 0), sub_offset=0), _SubPort(port=OutPort(Node(99), 0), sub_offset=0): _SubPort(port=InPort(Node(102), 1), sub_offset=0), _SubPort(port=OutPort(Node(101), 0), sub_offset=0): _SubPort(port=InPort(Node(102), 2), sub_offset=0), _SubPort(port=OutPort(Node(104), 0), sub_offset=0): _SubPort(port=InPort(Node(91), 0), sub_offset=0), _SubPort(port=OutPort(Node(102), 0), sub_offset=0): _SubPort(port=InPort(Node(91), 1), sub_offset=0), _SubPort(port=OutPort(Node(89), 0), sub_offset=0): _SubPort(port=InPort(Node(92), 0), sub_offset=0), _SubPort(port=OutPort(Node(88), 0), sub_offset=0): _SubPort(port=InPort(Node(11), 0), sub_offset=0), _SubPort(port=OutPort(Node(96), 0), sub_offset=0): _SubPort(port=InPort(Node(105), 0), sub_offset=0), _SubPort(port=OutPort(Node(107), 0), sub_offset=0): _SubPort(port=InPort(Node(110), 0), sub_offset=0), _SubPort(port=OutPort(Node(111), 0), sub_offset=0): _SubPort(port=InPort(Node(112), 0), sub_offset=0), _SubPort(port=OutPort(Node(110), 0), sub_offset=0): _SubPort(port=InPort(Node(113), 0), sub_offset=0), _SubPort(port=OutPort(Node(112), 0), sub_offset=0): _SubPort(port=InPort(Node(113), 1), sub_offset=0), _SubPort(port=OutPort(Node(114), 0), sub_offset=0): _SubPort(port=InPort(Node(108), 0), sub_offset=0), _SubPort(port=OutPort(Node(113), 0), sub_offset=0): _SubPort(port=InPort(Node(108), 1), sub_offset=0), _SubPort(port=OutPort(Node(106), 0), sub_offset=0): _SubPort(port=InPort(Node(109), 0), sub_offset=0), _SubPort(port=OutPort(Node(105), 0), sub_offset=0): _SubPort(port=InPort(Node(97), 0), sub_offset=0), _SubPort(port=OutPort(Node(74), 0), sub_offset=0): _SubPort(port=InPort(Node(115), 0), sub_offset=0), _SubPort(port=OutPort(Node(117), 0), sub_offset=0): _SubPort(port=InPort(Node(120), 0), sub_offset=0), _SubPort(port=OutPort(Node(120), 0), sub_offset=0): _SubPort(port=InPort(Node(121), 0), sub_offset=0), _SubPort(port=OutPort(Node(123), 0), sub_offset=0): _SubPort(port=InPort(Node(118), 0), sub_offset=0), _SubPort(port=OutPort(Node(120), 1), sub_offset=0): _SubPort(port=InPort(Node(118), 1), sub_offset=0), _SubPort(port=OutPort(Node(116), 0), sub_offset=0): _SubPort(port=InPort(Node(119), 0), sub_offset=0), _SubPort(port=OutPort(Node(115), 0), sub_offset=0): _SubPort(port=InPort(Node(75), 0), sub_offset=0), _SubPort(port=OutPort(Node(13), 0), sub_offset=0): _SubPort(port=InPort(Node(124), 0), sub_offset=0), _SubPort(port=OutPort(Node(13), 1), sub_offset=0): _SubPort(port=InPort(Node(124), 1), sub_offset=0), _SubPort(port=OutPort(Node(126), 0), sub_offset=0): _SubPort(port=InPort(Node(129), 0), sub_offset=0), _SubPort(port=OutPort(Node(126), 1), sub_offset=0): _SubPort(port=InPort(Node(130), 0), sub_offset=0), _SubPort(port=OutPort(Node(129), 0), sub_offset=0): _SubPort(port=InPort(Node(131), 0), sub_offset=0), _SubPort(port=OutPort(Node(130), 0), sub_offset=0): _SubPort(port=InPort(Node(131), 1), sub_offset=0), _SubPort(port=OutPort(Node(131), 0), sub_offset=0): _SubPort(port=InPort(Node(132), 0), sub_offset=0), _SubPort(port=OutPort(Node(133), 0), sub_offset=0): _SubPort(port=InPort(Node(127), 0), sub_offset=0), _SubPort(port=OutPort(Node(132), 0), sub_offset=0): _SubPort(port=InPort(Node(127), 1), sub_offset=0), _SubPort(port=OutPort(Node(125), 0), sub_offset=0): _SubPort(port=InPort(Node(128), 0), sub_offset=0), _SubPort(port=OutPort(Node(124), 0), sub_offset=0): _SubPort(port=InPort(Node(14), 0), sub_offset=0)}), _free_nodes=[])"
]
},
- "execution_count": 20,
+ "execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Define a guppy module with a quantum function\n",
+ "from guppylang.prelude.quantum import measure, phased_x, qubit, rz, zz_max\n",
+ "from guppylang.prelude.angles import pi\n",
+ "from guppylang.prelude.builtins import owned\n",
"\n",
"module = GuppyModule(\"test\")\n",
- "module.load(quantum)\n",
+ "module.load_all(quantum)\n",
+ "module.load(pi)\n",
"\n",
"@guppy(module)\n",
- "def my_func(q0: qubit, q1: qubit) -> bool:\n",
- " q0 = phased_x(q0, py(math.pi / 2), py(-math.pi / 2))\n",
- " q0 = rz(q0, py(math.pi))\n",
- " q1 = phased_x(q1, py(math.pi / 2), py(-math.pi / 2))\n",
- " q1 = rz(q1, py(math.pi))\n",
- " q0, q1 = zz_max(q0, q1)\n",
+ "def my_func(q0: qubit @owned, q1: qubit @owned) -> bool:\n",
+ " phased_x(q0, pi / 2, -pi / 2)\n",
+ " rz(q0, pi)\n",
+ " phased_x(q1, pi / 2, -pi / 2)\n",
+ " rz(q1, pi)\n",
+ " zz_max(q0, q1)\n",
" _ = measure(q0)\n",
" return measure(q1)\n",
"\n",
+ "hugr = module.compile()\n",
"circ = guppy_to_circuit(my_func)\n",
- "circ"
+ "hugr.modules[0]\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "id": "24fe2f72",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{\"modules\":[{\"version\":\"live\",\"nodes\":[{\"parent\":0,\"op\":\"Module\"},{\"parent\":0,\"op\":\"FuncDefn\",\"name\":\"my_func\",\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}}},{\"parent\":1,\"op\":\"Input\",\"types\":[{\"t\":\"Q\"},{\"t\":\"Q\"}]},{\"parent\":1,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}]},{\"parent\":1,\"op\":\"CFG\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},{\"parent\":4,\"op\":\"DataflowBlock\",\"inputs\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"other_outputs\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"sum_rows\":[[]],\"extension_delta\":[]},{\"parent\":5,\"op\":\"Input\",\"types\":[{\"t\":\"Q\"},{\"t\":\"Q\"}]},{\"parent\":5,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":1},{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}]},{\"parent\":4,\"op\":\"ExitBlock\",\"cfg_outputs\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}]},{\"parent\":0,\"op\":\"FuncDefn\",\"name\":\"phased_x\",\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}}},{\"parent\":9,\"op\":\"Input\",\"types\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":9,\"op\":\"Output\",\"types\":[{\"t\":\"Q\"}]},{\"parent\":0,\"op\":\"FuncDefn\",\"name\":\"__truediv__\",\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}}},{\"parent\":12,\"op\":\"Input\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}]},{\"parent\":12,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":0,\"op\":\"Const\",\"v\":{\"v\":\"Tuple\",\"vs\":[{\"v\":\"Extension\",\"extensions\":[\"arithmetic.float.types\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"},\"value\":{\"c\":\"ConstF64\",\"v\":{\"value\":1.0}}}]}},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}},{\"parent\":5,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"arithmetic.int.types\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"},\"value\":{\"c\":\"ConstInt\",\"v\":{\"log_width\":6,\"value\":2}}}},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":0,\"op\":\"FuncDefn\",\"name\":\"__neg__\",\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}}},{\"parent\":20,\"op\":\"Input\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":20,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"arithmetic.int.types\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"},\"value\":{\"c\":\"ConstInt\",\"v\":{\"log_width\":6,\"value\":2}}}},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"tket2.rotation\",\"name\":\"from_halfturns\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[],[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":5,\"op\":\"Conditional\",\"other_inputs\":[],\"outputs\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"sum_rows\":[[],[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]],\"extension_delta\":[]},{\"parent\":33,\"op\":\"Case\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":34,\"op\":\"Input\",\"types\":[]},{\"parent\":34,\"op\":\"Output\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":0,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"prelude\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"error\",\"args\":[],\"bound\":\"C\"},\"value\":{\"c\":\"ConstError\",\"v\":{\"signal\":1,\"message\":\"Non-finite number of half-turns\"}}}},{\"parent\":34,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"error\",\"args\":[],\"bound\":\"C\"}},{\"parent\":34,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"panic\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"error\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]},{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":33,\"op\":\"Case\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":40,\"op\":\"Input\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":40,\"op\":\"Output\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"tket2.quantum\",\"name\":\"Rz\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}},{\"parent\":5,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"arithmetic.int.types\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"},\"value\":{\"c\":\"ConstInt\",\"v\":{\"log_width\":6,\"value\":2}}}},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"arithmetic.int.types\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"},\"value\":{\"c\":\"ConstInt\",\"v\":{\"log_width\":6,\"value\":2}}}},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":5,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"tket2.rotation\",\"name\":\"from_halfturns\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[],[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":5,\"op\":\"Conditional\",\"other_inputs\":[],\"outputs\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"sum_rows\":[[],[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]],\"extension_delta\":[]},{\"parent\":59,\"op\":\"Case\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":60,\"op\":\"Input\",\"types\":[]},{\"parent\":60,\"op\":\"Output\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":0,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"prelude\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"error\",\"args\":[],\"bound\":\"C\"},\"value\":{\"c\":\"ConstError\",\"v\":{\"signal\":1,\"message\":\"Non-finite number of half-turns\"}}}},{\"parent\":60,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"error\",\"args\":[],\"bound\":\"C\"}},{\"parent\":60,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"panic\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"error\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]},{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":59,\"op\":\"Case\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":66,\"op\":\"Input\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":66,\"op\":\"Output\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"tket2.quantum\",\"name\":\"Rz\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"tket2.hseries\",\"name\":\"ZZMax\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":5,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":0,\"op\":\"FuncDefn\",\"name\":\"measure\",\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}}},{\"parent\":73,\"op\":\"Input\",\"types\":[{\"t\":\"Q\"}]},{\"parent\":73,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}]},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},{\"parent\":5,\"op\":\"Tag\",\"tag\":0,\"variants\":[[]]},{\"parent\":20,\"op\":\"CFG\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":79,\"op\":\"DataflowBlock\",\"inputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"other_outputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"sum_rows\":[[]],\"extension_delta\":[]},{\"parent\":80,\"op\":\"Input\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":80,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":1},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":79,\"op\":\"ExitBlock\",\"cfg_outputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":80,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":80,\"op\":\"Extension\",\"extension\":\"arithmetic.float\",\"name\":\"fneg\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":80,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":80,\"op\":\"Tag\",\"tag\":0,\"variants\":[[]]},{\"parent\":9,\"op\":\"CFG\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},{\"parent\":88,\"op\":\"DataflowBlock\",\"inputs\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"other_outputs\":[{\"t\":\"Q\"}],\"sum_rows\":[[]],\"extension_delta\":[]},{\"parent\":89,\"op\":\"Input\",\"types\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":89,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":1},{\"t\":\"Q\"}]},{\"parent\":88,\"op\":\"ExitBlock\",\"cfg_outputs\":[{\"t\":\"Q\"}]},{\"parent\":89,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":89,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":0,\"op\":\"FuncDefn\",\"name\":\"__float__\",\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}}},{\"parent\":95,\"op\":\"Input\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":95,\"op\":\"Output\",\"types\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":89,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":89,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":89,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":89,\"op\":\"Call\",\"func_sig\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},\"type_args\":[],\"instantiation\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":89,\"op\":\"Extension\",\"extension\":\"tket2.hseries\",\"name\":\"PhasedX\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":89,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":89,\"op\":\"Tag\",\"tag\":0,\"variants\":[[]]},{\"parent\":95,\"op\":\"CFG\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},{\"parent\":105,\"op\":\"DataflowBlock\",\"inputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"other_outputs\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"sum_rows\":[[]],\"extension_delta\":[]},{\"parent\":106,\"op\":\"Input\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":106,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":1},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":105,\"op\":\"ExitBlock\",\"cfg_outputs\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]},{\"parent\":106,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":106,\"op\":\"Const\",\"v\":{\"v\":\"Extension\",\"extensions\":[\"arithmetic.float.types\"],\"typ\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"},\"value\":{\"c\":\"ConstF64\",\"v\":{\"value\":3.141592653589793}}}},{\"parent\":106,\"op\":\"LoadConstant\",\"datatype\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}},{\"parent\":106,\"op\":\"Extension\",\"extension\":\"arithmetic.float\",\"name\":\"fmul\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":106,\"op\":\"Tag\",\"tag\":0,\"variants\":[[]]},{\"parent\":73,\"op\":\"CFG\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},{\"parent\":115,\"op\":\"DataflowBlock\",\"inputs\":[{\"t\":\"Q\"}],\"other_outputs\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"sum_rows\":[[]],\"extension_delta\":[]},{\"parent\":116,\"op\":\"Input\",\"types\":[{\"t\":\"Q\"}]},{\"parent\":116,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":1},{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}]},{\"parent\":115,\"op\":\"ExitBlock\",\"cfg_outputs\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}]},{\"parent\":116,\"op\":\"Extension\",\"extension\":\"tket2.quantum\",\"name\":\"Measure\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":116,\"op\":\"Extension\",\"extension\":\"tket2.quantum\",\"name\":\"QFree\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":116,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[]}]},{\"parent\":116,\"op\":\"Tag\",\"tag\":0,\"variants\":[[]]},{\"parent\":12,\"op\":\"CFG\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},{\"parent\":124,\"op\":\"DataflowBlock\",\"inputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"other_outputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"sum_rows\":[[]],\"extension_delta\":[]},{\"parent\":125,\"op\":\"Input\",\"types\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]},{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}]},{\"parent\":125,\"op\":\"Output\",\"types\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":1},{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":124,\"op\":\"ExitBlock\",\"cfg_outputs\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}]},{\"parent\":125,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"UnpackTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":125,\"op\":\"Extension\",\"extension\":\"arithmetic.conversions\",\"name\":\"convert_s\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"BoundedNat\",\"n\":6}]},{\"parent\":125,\"op\":\"Extension\",\"extension\":\"arithmetic.float\",\"name\":\"fdiv\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[]},{\"parent\":125,\"op\":\"Extension\",\"extension\":\"prelude\",\"name\":\"MakeTuple\",\"signature\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]},\"description\":\"\",\"args\":[{\"tya\":\"Sequence\",\"elems\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}]}]},{\"parent\":125,\"op\":\"Tag\",\"tag\":0,\"variants\":[[]]}],\"edges\":[[[2,0],[4,0]],[[2,1],[4,1]],[[15,0],[16,0]],[[17,0],[18,0]],[[12,0],[19,2]],[[16,0],[19,0]],[[18,0],[19,1]],[[15,0],[23,0]],[[20,0],[24,1]],[[23,0],[24,0]],[[25,0],[26,0]],[[12,0],[27,2]],[[24,0],[27,0]],[[26,0],[27,1]],[[9,0],[28,3]],[[6,0],[28,0]],[[19,0],[28,1]],[[27,0],[28,2]],[[15,0],[30,0]],[[30,0],[31,0]],[[31,0],[32,0]],[[32,0],[33,0]],[[37,0],[38,0]],[[38,0],[39,0]],[[39,0],[36,0]],[[41,0],[42,0]],[[28,0],[43,0]],[[33,0],[43,1]],[[15,0],[45,0]],[[46,0],[47,0]],[[12,0],[48,2]],[[45,0],[48,0]],[[47,0],[48,1]],[[15,0],[49,0]],[[20,0],[50,1]],[[49,0],[50,0]],[[51,0],[52,0]],[[12,0],[53,2]],[[50,0],[53,0]],[[52,0],[53,1]],[[9,0],[54,3]],[[6,1],[54,0]],[[48,0],[54,1]],[[53,0],[54,2]],[[15,0],[56,0]],[[56,0],[57,0]],[[57,0],[58,0]],[[58,0],[59,0]],[[63,0],[64,0]],[[64,0],[65,0]],[[65,0],[62,0]],[[67,0],[68,0]],[[54,0],[69,0]],[[59,0],[69,1]],[[43,0],[71,0]],[[69,0],[71,1]],[[73,0],[76,1]],[[71,0],[76,0]],[[73,0],[77,1]],[[71,1],[77,0]],[[78,0],[7,0]],[[77,0],[7,1]],[[5,0],[8,0]],[[4,0],[3,0]],[[21,0],[79,0]],[[81,0],[84,0]],[[84,0],[85,0]],[[85,0],[86,0]],[[87,0],[82,0]],[[86,0],[82,1]],[[80,0],[83,0]],[[79,0],[22,0]],[[10,0],[88,0]],[[10,1],[88,1]],[[10,2],[88,2]],[[90,1],[93,0]],[[90,2],[94,0]],[[93,0],[98,0]],[[95,0],[99,1]],[[98,0],[99,0]],[[94,0],[100,0]],[[95,0],[101,1]],[[100,0],[101,0]],[[90,0],[102,0]],[[99,0],[102,1]],[[101,0],[102,2]],[[104,0],[91,0]],[[102,0],[91,1]],[[89,0],[92,0]],[[88,0],[11,0]],[[96,0],[105,0]],[[107,0],[110,0]],[[111,0],[112,0]],[[110,0],[113,0]],[[112,0],[113,1]],[[114,0],[108,0]],[[113,0],[108,1]],[[106,0],[109,0]],[[105,0],[97,0]],[[74,0],[115,0]],[[117,0],[120,0]],[[120,0],[121,0]],[[123,0],[118,0]],[[120,1],[118,1]],[[116,0],[119,0]],[[115,0],[75,0]],[[13,0],[124,0]],[[13,1],[124,1]],[[126,0],[129,0]],[[126,1],[130,0]],[[129,0],[131,0]],[[130,0],[131,1]],[[131,0],[132,0]],[[133,0],[127,0]],[[132,0],[127,1]],[[125,0],[128,0]],[[124,0],[14,0]]],\"metadata\":[],\"encoder\":null}],\"extensions\":[{\"version\":\"0.1.0\",\"name\":\"tket2.futures\",\"extension_reqs\":[],\"types\":{\"Future\":{\"extension\":\"tket2.futures\",\"name\":\"Future\",\"description\":\"A value that is computed asynchronously\",\"params\":[{\"tp\":\"Type\",\"b\":\"A\"}],\"bound\":{\"b\":\"Explicit\",\"bound\":\"A\"}}},\"values\":{},\"operations\":{\"Dup\":{\"extension\":\"tket2.futures\",\"name\":\"Dup\",\"description\":\"Duplicate a Future. The original Future is consumed and two Futures are returned\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"Type\",\"b\":\"A\"}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.futures\",\"id\":\"Future\",\"args\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"V\",\"i\":0,\"b\":\"A\"}}],\"bound\":\"A\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.futures\",\"id\":\"Future\",\"args\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"V\",\"i\":0,\"b\":\"A\"}}],\"bound\":\"A\"},{\"t\":\"Opaque\",\"extension\":\"tket2.futures\",\"id\":\"Future\",\"args\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"V\",\"i\":0,\"b\":\"A\"}}],\"bound\":\"A\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Free\":{\"extension\":\"tket2.futures\",\"name\":\"Free\",\"description\":\"Consume a future without reading it.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"Type\",\"b\":\"A\"}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.futures\",\"id\":\"Future\",\"args\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"V\",\"i\":0,\"b\":\"A\"}}],\"bound\":\"A\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Read\":{\"extension\":\"tket2.futures\",\"name\":\"Read\",\"description\":\"Read a value from a Future, consuming it\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"Type\",\"b\":\"A\"}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.futures\",\"id\":\"Future\",\"args\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"V\",\"i\":0,\"b\":\"A\"}}],\"bound\":\"A\"}],\"output\":[{\"t\":\"V\",\"i\":0,\"b\":\"A\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]}}},{\"version\":\"0.1.0\",\"name\":\"tket2.hseries\",\"extension_reqs\":[\"tket2.futures\",\"arithmetic.float.types\",\"prelude\"],\"types\":{},\"values\":{},\"operations\":{\"LazyMeasure\":{\"extension\":\"tket2.hseries\",\"name\":\"LazyMeasure\",\"description\":\"LazyMeasure\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.futures\",\"id\":\"Future\",\"args\":[{\"tya\":\"Type\",\"ty\":{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}}],\"bound\":\"A\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Measure\":{\"extension\":\"tket2.hseries\",\"name\":\"Measure\",\"description\":\"Measure\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"PhasedX\":{\"extension\":\"tket2.hseries\",\"name\":\"PhasedX\",\"description\":\"PhasedX\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"QAlloc\":{\"extension\":\"tket2.hseries\",\"name\":\"QAlloc\",\"description\":\"QAlloc\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"QFree\":{\"extension\":\"tket2.hseries\",\"name\":\"QFree\",\"description\":\"QFree\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Reset\":{\"extension\":\"tket2.hseries\",\"name\":\"Reset\",\"description\":\"Reset\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Rz\":{\"extension\":\"tket2.hseries\",\"name\":\"Rz\",\"description\":\"Rz\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"ZZMax\":{\"extension\":\"tket2.hseries\",\"name\":\"ZZMax\",\"description\":\"ZZMax\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"ZZPhase\":{\"extension\":\"tket2.hseries\",\"name\":\"ZZPhase\",\"description\":\"ZZPhase\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]}}},{\"version\":\"0.1.0\",\"name\":\"tket2.quantum\",\"extension_reqs\":[],\"types\":{},\"values\":{},\"operations\":{\"CRz\":{\"extension\":\"tket2.quantum\",\"name\":\"CRz\",\"description\":\"CRz\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"CX\":{\"extension\":\"tket2.quantum\",\"name\":\"CX\",\"description\":\"CX\",\"misc\":{\"commutation\":[[0,\"Z\"],[1,\"X\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"CY\":{\"extension\":\"tket2.quantum\",\"name\":\"CY\",\"description\":\"CY\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"CZ\":{\"extension\":\"tket2.quantum\",\"name\":\"CZ\",\"description\":\"CZ\",\"misc\":{\"commutation\":[[0,\"Z\"],[1,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"H\":{\"extension\":\"tket2.quantum\",\"name\":\"H\",\"description\":\"H\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Measure\":{\"extension\":\"tket2.quantum\",\"name\":\"Measure\",\"description\":\"Measure\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"QAlloc\":{\"extension\":\"tket2.quantum\",\"name\":\"QAlloc\",\"description\":\"QAlloc\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"QFree\":{\"extension\":\"tket2.quantum\",\"name\":\"QFree\",\"description\":\"QFree\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Reset\":{\"extension\":\"tket2.quantum\",\"name\":\"Reset\",\"description\":\"Reset\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Rx\":{\"extension\":\"tket2.quantum\",\"name\":\"Rx\",\"description\":\"Rx\",\"misc\":{\"commutation\":[[0,\"X\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Ry\":{\"extension\":\"tket2.quantum\",\"name\":\"Ry\",\"description\":\"Ry\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Rz\":{\"extension\":\"tket2.quantum\",\"name\":\"Rz\",\"description\":\"Rz\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"S\":{\"extension\":\"tket2.quantum\",\"name\":\"S\",\"description\":\"S\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Sdg\":{\"extension\":\"tket2.quantum\",\"name\":\"Sdg\",\"description\":\"Sdg\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"T\":{\"extension\":\"tket2.quantum\",\"name\":\"T\",\"description\":\"T\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Tdg\":{\"extension\":\"tket2.quantum\",\"name\":\"Tdg\",\"description\":\"Tdg\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Toffoli\":{\"extension\":\"tket2.quantum\",\"name\":\"Toffoli\",\"description\":\"Toffoli\",\"misc\":{\"commutation\":[]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"},{\"t\":\"Q\"},{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"},{\"t\":\"Q\"},{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"X\":{\"extension\":\"tket2.quantum\",\"name\":\"X\",\"description\":\"X\",\"misc\":{\"commutation\":[[0,\"X\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Y\":{\"extension\":\"tket2.quantum\",\"name\":\"Y\",\"description\":\"Y\",\"misc\":{\"commutation\":[[0,\"Y\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"Z\":{\"extension\":\"tket2.quantum\",\"name\":\"Z\",\"description\":\"Z\",\"misc\":{\"commutation\":[[0,\"Z\"]]},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Q\"}],\"output\":[{\"t\":\"Q\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"symbolic_angle\":{\"extension\":\"tket2.quantum\",\"name\":\"symbolic_angle\",\"description\":\"Store a sympy expression that can be evaluated to an angle.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"}],\"body\":{\"t\":\"G\",\"input\":[],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]}}},{\"version\":\"0.1.0\",\"name\":\"tket2.result\",\"extension_reqs\":[\"arithmetic.int.types\",\"arithmetic.float.types\"],\"types\":{},\"values\":{},\"operations\":{\"result_array_bool\":{\"extension\":\"tket2.result\",\"name\":\"result_array_bool\",\"description\":\"Report an array of boolean results.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"BoundedNat\",\"bound\":null}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"array\",\"args\":[{\"tya\":\"Variable\",\"idx\":1,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":null}},{\"tya\":\"Type\",\"ty\":{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}}],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_array_f64\":{\"extension\":\"tket2.result\",\"name\":\"result_array_f64\",\"description\":\"Report an array of floating-point results.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"BoundedNat\",\"bound\":null}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"array\",\"args\":[{\"tya\":\"Variable\",\"idx\":1,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":null}},{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}}],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_array_int\":{\"extension\":\"tket2.result\",\"name\":\"result_array_int\",\"description\":\"Report an array of signed integer results.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"BoundedNat\",\"bound\":null},{\"tp\":\"BoundedNat\",\"bound\":7}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"array\",\"args\":[{\"tya\":\"Variable\",\"idx\":1,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":null}},{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"Variable\",\"idx\":2,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":7}}],\"bound\":\"C\"}}],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_array_uint\":{\"extension\":\"tket2.result\",\"name\":\"result_array_uint\",\"description\":\"Report an array of unsigned integer results.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"BoundedNat\",\"bound\":null},{\"tp\":\"BoundedNat\",\"bound\":7}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"prelude\",\"id\":\"array\",\"args\":[{\"tya\":\"Variable\",\"idx\":1,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":null}},{\"tya\":\"Type\",\"ty\":{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"Variable\",\"idx\":2,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":7}}],\"bound\":\"C\"}}],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_bool\":{\"extension\":\"tket2.result\",\"name\":\"result_bool\",\"description\":\"Report a boolean result.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Sum\",\"s\":\"Unit\",\"size\":2}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_f64\":{\"extension\":\"tket2.result\",\"name\":\"result_f64\",\"description\":\"Report a floating-point result.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_int\":{\"extension\":\"tket2.result\",\"name\":\"result_int\",\"description\":\"Report a signed integer result.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"BoundedNat\",\"bound\":7}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"Variable\",\"idx\":1,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":7}}],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"result_uint\":{\"extension\":\"tket2.result\",\"name\":\"result_uint\",\"description\":\"Report an unsigned integer result.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"BoundedNat\",\"bound\":7}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.int.types\",\"id\":\"int\",\"args\":[{\"tya\":\"Variable\",\"idx\":1,\"cached_decl\":{\"tp\":\"BoundedNat\",\"bound\":7}}],\"bound\":\"C\"}],\"output\":[],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]}}},{\"version\":\"0.1.0\",\"name\":\"tket2.rotation\",\"extension_reqs\":[],\"types\":{\"rotation\":{\"extension\":\"tket2.rotation\",\"name\":\"rotation\",\"description\":\"rotation type expressed as number of half turns\",\"params\":[],\"bound\":{\"b\":\"Explicit\",\"bound\":\"C\"}}},\"values\":{},\"operations\":{\"from_halfturns\":{\"extension\":\"tket2.rotation\",\"name\":\"from_halfturns\",\"description\":\"Construct rotation from number of half-turns (would be multiples of π in radians).\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Sum\",\"s\":\"General\",\"rows\":[[],[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}]]}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"radd\":{\"extension\":\"tket2.rotation\",\"name\":\"radd\",\"description\":\"Add two rotations together (experimental).\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"},{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"to_halfturns\":{\"extension\":\"tket2.rotation\",\"name\":\"to_halfturns\",\"description\":\"Convert rotation to number of half-turns (would be multiples of π in radians).\",\"misc\":{},\"signature\":{\"params\":[],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"Opaque\",\"extension\":\"tket2.rotation\",\"id\":\"rotation\",\"args\":[],\"bound\":\"C\"}],\"output\":[{\"t\":\"Opaque\",\"extension\":\"arithmetic.float.types\",\"id\":\"float64\",\"args\":[],\"bound\":\"C\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]}}},{\"version\":\"0.1.0\",\"name\":\"guppylang\",\"extension_reqs\":[],\"types\":{},\"values\":{},\"operations\":{\"partial\":{\"extension\":\"guppylang\",\"name\":\"partial\",\"description\":\"A partial application of a function.\\nGiven arguments [*a],[*b],[*c], represents an operation with type\\n`(*c, *a -> *b), *c -> (*a -> *b)`\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"List\",\"param\":{\"tp\":\"Type\",\"b\":\"A\"}},{\"tp\":\"List\",\"param\":{\"tp\":\"Type\",\"b\":\"A\"}},{\"tp\":\"List\",\"param\":{\"tp\":\"Type\",\"b\":\"A\"}}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"G\",\"input\":[{\"t\":\"R\",\"i\":0,\"b\":\"A\"},{\"t\":\"R\",\"i\":1,\"b\":\"A\"}],\"output\":[{\"t\":\"R\",\"i\":2,\"b\":\"A\"}],\"extension_reqs\":[]},{\"t\":\"R\",\"i\":0,\"b\":\"A\"}],\"output\":[{\"t\":\"G\",\"input\":[{\"t\":\"R\",\"i\":1,\"b\":\"A\"}],\"output\":[{\"t\":\"R\",\"i\":2,\"b\":\"A\"}],\"extension_reqs\":[]}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]},\"unsupported\":{\"extension\":\"guppylang\",\"name\":\"unsupported\",\"description\":\"An unsupported operation stub emitted by Guppy.\",\"misc\":{},\"signature\":{\"params\":[{\"tp\":\"String\"},{\"tp\":\"List\",\"param\":{\"tp\":\"Type\",\"b\":\"A\"}},{\"tp\":\"List\",\"param\":{\"tp\":\"Type\",\"b\":\"A\"}}],\"body\":{\"t\":\"G\",\"input\":[{\"t\":\"R\",\"i\":1,\"b\":\"A\"}],\"output\":[{\"t\":\"R\",\"i\":2,\"b\":\"A\"}],\"extension_reqs\":[]}},\"binary\":false,\"lower_funcs\":[]}}}]}\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(hugr.to_json())"
]
},
{
@@ -546,107 +3234,33 @@
"id": "55974636",
"metadata": {},
"source": [
- "This can be combined with the pytket conversion to obtain a `pytket` circuit from a guppy definition!"
+ "This can be combined with the pytket conversion to obtain a `pytket` circuit from a guppy definition!\n",
+ "\n",
+ "NOTE: guppy -> pytket compatibility is currently broken, while we sync in the latest changes in guppy 0.12."
]
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 28,
"id": "77feb50b",
"metadata": {},
"outputs": [
{
- "data": {
- "text/html": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- " \n",
- "
\n",
- "\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "metadata": {},
- "output_type": "display_data"
+ "ename": "PyTK1ConvertError",
+ "evalue": "Cannot serialize tket2 operation: ExtensionOp(ExtensionOp { def: OpDef { extension: IdentList(\"prelude\"), name: \"MakeTuple\", description: \"MakeTuple operation\", misc: {}, signature_func: PolyFuncTypeBase { params: [List { param: Type { b: Any } }], body: FuncTypeBase { input: TypeRowBase { types: [TypeBase(RowVar(RowVariable(0, Any)), Any)] }, output: TypeRowBase { types: [TypeBase(Sum(General { rows: [TypeRowBase { types: [TypeBase(RowVar(RowVariable(0, Any)), Any)] }] }), Any)] }, extension_reqs: ExtensionSet({}) } }, lower_funcs: [], constant_folder: Some() }, args: [Sequence { elems: [] }], signature: FuncTypeBase { input: TypeRowBase { types: [] }, output: TypeRowBase { types: [TypeBase(Sum(Unit { size: 1 }), Copyable)] }, extension_reqs: ExtensionSet({IdentList(\"prelude\")}) } })",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mPyTK1ConvertError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[28], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m tk1_circ \u001b[38;5;241m=\u001b[39m \u001b[43mcirc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_tket1\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3\u001b[0m render_circuit_jupyter(tk1_circ)\n",
+ "\u001b[0;31mPyTK1ConvertError\u001b[0m: Cannot serialize tket2 operation: ExtensionOp(ExtensionOp { def: OpDef { extension: IdentList(\"prelude\"), name: \"MakeTuple\", description: \"MakeTuple operation\", misc: {}, signature_func: PolyFuncTypeBase { params: [List { param: Type { b: Any } }], body: FuncTypeBase { input: TypeRowBase { types: [TypeBase(RowVar(RowVariable(0, Any)), Any)] }, output: TypeRowBase { types: [TypeBase(Sum(General { rows: [TypeRowBase { types: [TypeBase(RowVar(RowVariable(0, Any)), Any)] }] }), Any)] }, extension_reqs: ExtensionSet({}) } }, lower_funcs: [], constant_folder: Some() }, args: [Sequence { elems: [] }], signature: FuncTypeBase { input: TypeRowBase { types: [] }, output: TypeRowBase { types: [TypeBase(Sum(Unit { size: 1 }), Copyable)] }, extension_reqs: ExtensionSet({IdentList(\"prelude\")}) } })"
+ ]
}
],
"source": [
- "tk1_circ = circ.to_tket1()\n",
- "\n",
- "render_circuit_jupyter(tk1_circ)"
+ "#tk1_circ = circ.to_tket1()\n",
+ "#render_circuit_jupyter(tk1_circ)"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "5c0bd399-1851-4672-90d6-417cf4b31dd2",
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {
@@ -665,7 +3279,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.12.5"
}
},
"nbformat": 4,
diff --git a/tket2-py/examples/2-Rewriting-Circuits.ipynb b/tket2-py/examples/2-Rewriting-Circuits.ipynb
index 89cf7a78..512b1f63 100644
--- a/tket2-py/examples/2-Rewriting-Circuits.ipynb
+++ b/tket2-py/examples/2-Rewriting-Circuits.ipynb
@@ -11,7 +11,32 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\u001b[2K\u001b[2mResolved \u001b[1m22 packages\u001b[0m \u001b[2min 224ms\u001b[0m\u001b[0m \u001b[0m\n",
+ "\u001b[2mUninstalled \u001b[1m1 package\u001b[0m \u001b[2min 17ms\u001b[0m\u001b[0m\n",
+ "\u001b[2K\u001b[2mInstalled \u001b[1m1 package\u001b[0m \u001b[2min 10ms\u001b[0m\u001b[0m \u001b[0m\n",
+ " \u001b[31m-\u001b[39m \u001b[1mguppylang\u001b[0m\u001b[2m==0.12.0\u001b[0m\n",
+ " \u001b[32m+\u001b[39m \u001b[1mguppylang\u001b[0m\u001b[2m==0.10.0\u001b[0m\n"
+ ]
+ }
+ ],
+ "source": [
+ "!uv pip install \\\n",
+ " \"pytket>=1.30.0,<2\" \\\n",
+ " \"tket2>=0.3.0,<0.4\" \\\n",
+ " \"guppylang>=0.10.0,<0.11\" \\\n",
+ " \"hugr>=0.8.1,<0.9\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -51,7 +76,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -59,7 +84,7 @@
"\n",
"# First we define the pattern we want to match, as a Guppy function\n",
"module = GuppyModule(\"m\")\n",
- "module.load(quantum)\n",
+ "module.load_all(quantum)\n",
"@guppy(module)\n",
"def cnots_to_zzphase_lhs(q0: qubit, q1: qubit, angle: float) -> tuple[qubit, qubit]:\n",
" q0, q1 = cx(q0, q1)\n",
@@ -70,7 +95,7 @@
"\n",
"# Then we define the replacement circuit\n",
"module = GuppyModule(\"m\")\n",
- "module.load(quantum)\n",
+ "module.load_all(quantum)\n",
"@guppy(module)\n",
"def cnots_to_zzphase_rhs(q0: qubit, q1: qubit, angle: float) -> tuple[qubit, qubit]:\n",
" q0, q1 = zz_phase(q0, q1, angle)\n",
@@ -91,7 +116,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -119,14 +144,14 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-0197cd96-d6e5-43b1-9bab-ab2e7418f357" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-54c745b9-e485-48de-8464-cb044fa90c2a" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
" <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [1]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [2]]], "op": {"params": ["0.25"], "type": "Rz"}}, {"args": [["q", [1]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"params": ["0.5"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]]}</div>\n",
" </div>\n",
@@ -136,7 +161,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "0197cd96-d6e5-43b1-9bab-ab2e7418f357";\n",
+ " const circuitRendererUid = "54c745b9-e485-48de-8464-cb044fa90c2a";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -204,16 +229,16 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-218e3858-bc07-490d-9e85-504575ba4d33" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-eef7bdf2-4f6a-4bc0-a06f-d90dc378b83a" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
- " <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [1]], ["q", [2]]], "op": {"params": ["0.25"], "type": "ZZPhase"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"params": ["0.5"], "type": "ZZPhase"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]]}</div>\n",
+ " <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [1]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [2]]], "op": {"params": ["0.25"], "type": "Rz"}}, {"args": [["q", [1]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"params": ["0.5"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]]}</div>\n",
" </div>\n",
" <circuit-display-container\n",
" :circuit-element-str="'#circuit-json-to-display'"\n",
@@ -221,7 +246,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "218e3858-bc07-490d-9e85-504575ba4d33";\n",
+ " const circuitRendererUid = "eef7bdf2-4f6a-4bc0-a06f-d90dc378b83a";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -317,16 +342,16 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-2c68e63a-7b61-4310-ad7c-6c082f581fe8" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-3040526a-d4f4-4412-a28f-1cc6f21a9447" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
- " <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [0]]], "op": {"params": ["3.5"], "type": "Rx"}}, {"args": [["q", [1]], ["q", [2]]], "op": {"params": ["0.25"], "type": "ZZPhase"}}, {"args": [["q", [0]]], "op": {"params": ["1.5"], "type": "Rz"}}, {"args": [["q", [1]]], "op": {"params": ["0.5"], "type": "Rz"}}, {"args": [["q", [1]], ["q", [0]]], "op": {"type": "CX"}}, {"args": [["q", [0]]], "op": {"params": ["0.5"], "type": "Rz"}}, {"args": [["q", [0]]], "op": {"params": ["0.5"], "type": "Rx"}}, {"args": [["q", [0]]], "op": {"params": ["0.5"], "type": "Rz"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]]}</div>\n",
+ " <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [1]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [2]]], "op": {"params": ["0.25"], "type": "Rz"}}, {"args": [["q", [1]], ["q", [2]]], "op": {"type": "CX"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"params": ["0.5"], "type": "Rz"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]], ["q", [2]]]}</div>\n",
" </div>\n",
" <circuit-display-container\n",
" :circuit-element-str="'#circuit-json-to-display'"\n",
@@ -334,7 +359,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "2c68e63a-7b61-4310-ad7c-6c082f581fe8";\n",
+ " const circuitRendererUid = "3040526a-d4f4-4412-a28f-1cc6f21a9447";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -416,7 +441,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -445,7 +470,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -474,7 +499,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -500,7 +525,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -521,14 +546,14 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-3181cc0c-b28f-4f89-ad70-506d092ac8ef" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-ca4f032e-a25b-43a9-b39a-803eb4365784" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
" <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [0]]], "op": {"type": "X"}}, {"args": [["q", [1]]], "op": {"type": "Z"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"type": "H"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n",
" </div>\n",
@@ -538,7 +563,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "3181cc0c-b28f-4f89-ad70-506d092ac8ef";\n",
+ " const circuitRendererUid = "ca4f032e-a25b-43a9-b39a-803eb4365784";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -606,14 +631,14 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-4a69d49e-5837-40dc-b958-328c5ea50a86" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-14cae69f-4e0c-4f86-871a-041f96c07945" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
" <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "X"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n",
" </div>\n",
@@ -623,7 +648,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "4a69d49e-5837-40dc-b958-328c5ea50a86";\n",
+ " const circuitRendererUid = "14cae69f-4e0c-4f86-871a-041f96c07945";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -688,7 +713,7 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -709,14 +734,14 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-60a4bd10-1e6f-42c4-91cf-9bc03e3b702b" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-f1d66533-2ded-4e76-bf6a-fd663ef2b50f" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
" <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CZ"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n",
" </div>\n",
@@ -726,7 +751,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "60a4bd10-1e6f-42c4-91cf-9bc03e3b702b";\n",
+ " const circuitRendererUid = "f1d66533-2ded-4e76-bf6a-fd663ef2b50f";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -787,16 +812,16 @@
" <!-- Download Vue 3-->\n",
"<script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vue@3"></script>\n",
"<!-- Download Circuit Renderer with styles -->\n",
- "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.umd.js"></script>\n",
- "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.8/dist/pytket-circuit-renderer.css">\n",
+ "<script type="application/javascript" src="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.umd.js"></script>\n",
+ "<link rel="stylesheet" href="https://unpkg.com/pytket-circuit-renderer@0.9/dist/pytket-circuit-renderer.css">\n",
"</head>\n",
"<body>\n",
"\n",
"\n",
"\n",
- " <div id="circuit-display-vue-container-4cd22cd2-94fe-4b5f-bf42-4ff694dd254d" class="pytket-circuit-display-container">\n",
+ " <div id="circuit-display-vue-container-b05063ab-5a44-4dfb-9613-e3d4d6695a2d" class="pytket-circuit-display-container">\n",
" <div style="display: none">\n",
- " <div id="circuit-json-to-display">{"bits": [], "commands": [{"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]]], "op": {"type": "H"}}, {"args": [["q", [1]]], "op": {"type": "H"}}, {"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n",
+ " <div id="circuit-json-to-display">{"bits": [], "commands": [], "created_qubits": [], "discarded_qubits": [], "implicit_permutation": [[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]]], "phase": "0.0", "qubits": [["q", [0]], ["q", [1]]]}</div>\n",
" </div>\n",
" <circuit-display-container\n",
" :circuit-element-str="'#circuit-json-to-display'"\n",
@@ -804,7 +829,7 @@
" ></circuit-display-container>\n",
" </div>\n",
" <script type="application/javascript">\n",
- " const circuitRendererUid = "4cd22cd2-94fe-4b5f-bf42-4ff694dd254d";\n",
+ " const circuitRendererUid = "b05063ab-5a44-4dfb-9613-e3d4d6695a2d";\n",
" const displayOptions = JSON.parse('{}');\n",
"\n",
" // Script to initialise the circuit renderer app\n",
@@ -875,7 +900,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.12.5"
}
},
"nbformat": 4,
diff --git a/tket2-py/examples/utils/__init__.py b/tket2-py/examples/utils/__init__.py
index 2c74eaa2..0fd73dfc 100644
--- a/tket2-py/examples/utils/__init__.py
+++ b/tket2-py/examples/utils/__init__.py
@@ -1,26 +1,38 @@
"""Some utility functions for the example notebooks."""
-from typing import TYPE_CHECKING, Any
+from hugr import Hugr
from tket2.passes import lower_to_pytket
from tket2.circuit import Tk2Circuit
+from guppylang.definition.function import RawFunctionDef # type: ignore[import-untyped, import-not-found, unused-ignore] # noqa: F401
-if TYPE_CHECKING:
- try:
- from guppylang.definition.function import RawFunctionDef # type: ignore[import-untyped, import-not-found, unused-ignore] # noqa: F401
- except ImportError:
- RawFunctionDef = Any
+def setup_jupyter_rendering():
+ """Set up hugr rendering for Jupyter notebooks."""
-# We need to define this helper function for now. It will be included in guppy in the future.
+ def _repr_hugr(
+ h: Hugr, include=None, exclude=None, **kwargs
+ ) -> dict[str, bytes | str]:
+ return h.render_dot()._repr_mimebundle_(include, exclude, **kwargs)
+
+ def _repr_tk2circ(
+ circ: Tk2Circuit, include=None, exclude=None, **kwargs
+ ) -> dict[str, bytes | str]:
+ h = Hugr.load_json(circ.to_hugr_json())
+ return _repr_hugr(h, include, exclude, **kwargs)
+
+ setattr(Hugr, "_repr_mimebundle_", _repr_hugr)
+ setattr(Tk2Circuit, "_repr_mimebundle_", _repr_tk2circ)
+
+
+# TODO: Should this be part of the guppy API? Or tket2?
def guppy_to_circuit(func_def: RawFunctionDef) -> Tk2Circuit:
"""Convert a Guppy function definition to a `Tk2Circuit`."""
module = func_def.id.module
assert module is not None, "Function definition must belong to a module"
- hugr = module.compile()
- assert hugr is not None, "Module must be compilable"
+ pkg = module.compile()
- json = hugr.to_raw().to_json()
+ json = pkg.to_json()
circ = Tk2Circuit.from_guppy_json(json, func_def.name)
return lower_to_pytket(circ)
diff --git a/tket2-py/src/circuit/tk2circuit.rs b/tket2-py/src/circuit/tk2circuit.rs
index b82d664b..28e6c35c 100644
--- a/tket2-py/src/circuit/tk2circuit.rs
+++ b/tket2-py/src/circuit/tk2circuit.rs
@@ -1,12 +1,15 @@
//! Rust-backed representation of circuits
use std::borrow::{Borrow, Cow};
+use std::mem;
use hugr::builder::{CircuitBuilder, DFGBuilder, Dataflow, DataflowHugr};
use hugr::extension::prelude::QB_T;
+use hugr::extension::{ExtensionRegistry, EMPTY_REG};
use hugr::ops::handle::NodeHandle;
use hugr::ops::{ExtensionOp, NamedOp, OpType};
use hugr::types::Type;
+use hugr_cli::Package;
use itertools::Itertools;
use pyo3::exceptions::{PyAttributeError, PyValueError};
use pyo3::types::{PyAnyMethods, PyModule, PyString, PyTypeMethods};
@@ -94,9 +97,20 @@ impl Tk2Circuit {
/// Decode a HUGR json string to a circuit.
#[staticmethod]
pub fn from_hugr_json(json: &str) -> PyResult {
- let hugr: Hugr = serde_json::from_str(json)
+ let pkg: Package = serde_json::from_str(json)
.map_err(|e| PyErr::new::(format!("Invalid encoded HUGR: {e}")))?;
- Ok(Tk2Circuit { circ: hugr.into() })
+ let mut reg = REGISTRY.clone();
+ let mut hugrs = pkg.validate(&mut reg).map_err(|e| {
+ PyErr::new::(format!("Invalid encoded circuit: {e}"))
+ })?;
+ if hugrs.len() != 1 {
+ return Err(PyValueError::new_err(
+ "Invalid HUGR json: Package must contain exactly one hugr.",
+ ));
+ }
+ Ok(Tk2Circuit {
+ circ: mem::take(&mut hugrs[0]).into(),
+ })
}
/// Load a function from a compiled guppy module, encoded as a json string.
diff --git a/tket2-py/tket2/circuit/build.py b/tket2-py/tket2/circuit/build.py
index 3e328d17..424a9fe0 100644
--- a/tket2-py/tket2/circuit/build.py
+++ b/tket2-py/tket2/circuit/build.py
@@ -1,6 +1,8 @@
from __future__ import annotations
-from hugr.hugr import Hugr
+from typing import Iterable
+
from hugr import tys, ops
+from hugr.ext import Package, Extension
from hugr.ops import ComWire, Command
from hugr.std.float import FLOAT_T
from hugr.build.tracked_dfg import TrackedDfg
@@ -17,10 +19,35 @@ class CircBuild(TrackedDfg):
def with_nqb(cls, n_qb: int) -> CircBuild:
return cls(*[tys.Qubit] * n_qb, track_inputs=True)
- def finish(self) -> Tk2Circuit:
+ def finish_package(
+ self, other_extensions: Iterable[Extension] | None = None
+ ) -> Package:
+ """Finish building the package by setting all the qubits as the output
+ and wrap it in a hugr package with the required extensions.
+
+ Args:
+ other_extensions: Other extensions to include in the package.
+ Returns:
+ The finished package.
+ """
+ import tket2.extensions as ext
+
+ extensions = [
+ ext.rotation(),
+ ext.futures(),
+ ext.hseries(),
+ ext.quantum(),
+ ext.result(),
+ *(other_extensions or []),
+ ]
+
+ return Package(modules=[self.hugr], extensions=extensions)
+
+ def finish(self, other_extensions: list[Extension] | None = None) -> Tk2Circuit:
"""Finish building the circuit by setting all the qubits as the output
and validate."""
- return load_hugr(self.hugr)
+
+ return load_hugr_pkg(self.finish_package(other_extensions))
def from_coms(*args: Command) -> Tk2Circuit:
@@ -40,8 +67,8 @@ def from_coms(*args: Command) -> Tk2Circuit:
return build.finish()
-def load_hugr(h: Hugr) -> Tk2Circuit:
- return Tk2Circuit.from_hugr_json(h.to_json())
+def load_hugr_pkg(package: Package) -> Tk2Circuit:
+ return Tk2Circuit.from_hugr_json(package.to_json())
def load_custom(serialized: bytes) -> ops.Custom:
@@ -61,7 +88,7 @@ def id_circ(n_qb: int) -> Tk2Circuit:
@dataclass(frozen=True)
class QuantumOps(ops.Custom):
- extension: tys.ExtensionId = "quantum.tket2"
+ extension: tys.ExtensionId = "tket2.quantum"
_OneQbSig = tys.FunctionType.endo([tys.Qubit])
diff --git a/tket2-py/tket2/extensions/__init__.py b/tket2-py/tket2/extensions/__init__.py
new file mode 100644
index 00000000..aeec8f22
--- /dev/null
+++ b/tket2-py/tket2/extensions/__init__.py
@@ -0,0 +1,42 @@
+"""Hugr extension definitions for tket2 circuits."""
+# This will be moved to a separate python library soon.
+
+import pkgutil
+import functools
+
+from hugr._serialization.extension import Extension as PdExtension
+from hugr.ext import Extension
+
+
+@functools.cache
+def rotation() -> Extension:
+ return load_extension("tket2.rotation")
+
+
+@functools.cache
+def futures() -> Extension:
+ return load_extension("tket2.futures")
+
+
+@functools.cache
+def hseries() -> Extension:
+ return load_extension("tket2.hseries")
+
+
+@functools.cache
+def quantum() -> Extension:
+ return load_extension("tket2.quantum")
+
+
+@functools.cache
+def result() -> Extension:
+ return load_extension("tket2.result")
+
+
+def load_extension(name: str) -> Extension:
+ replacement = name.replace(".", "/")
+ json_str = pkgutil.get_data(__name__, f"_json_defs/{replacement}.json")
+ assert json_str is not None, f"Could not load json for extension {name}"
+ # TODO: Replace with `Extension.from_json` once that is implemented
+ # https://github.com/CQCL/hugr/issues/1523
+ return PdExtension.model_validate_json(json_str).deserialize()
diff --git a/tket2/Cargo.toml b/tket2/Cargo.toml
index a74a16f3..2de4c6e6 100644
--- a/tket2/Cargo.toml
+++ b/tket2/Cargo.toml
@@ -65,6 +65,10 @@ bytemuck = { workspace = true }
crossbeam-channel = { workspace = true }
tracing = { workspace = true }
zstd = { workspace = true, optional = true }
+# Required to acces the `Package` type.
+# Remove once https://github.com/CQCL/hugr/issues/1530 is fixed.
+hugr-cli = { workspace = true }
+
[dev-dependencies]
rstest = { workspace = true }
diff --git a/tket2/src/extension.rs b/tket2/src/extension.rs
index e5fe8e61..eabf63e1 100644
--- a/tket2/src/extension.rs
+++ b/tket2/src/extension.rs
@@ -4,13 +4,12 @@
use crate::serialize::pytket::OpaqueTk1Op;
use crate::Tk2Op;
-use hugr::extension::prelude::PRELUDE;
use hugr::extension::simple_op::MakeOpDef;
use hugr::extension::{
CustomSignatureFunc, ExtensionId, ExtensionRegistry, SignatureError, Version,
};
use hugr::hugr::IdentList;
-use hugr::std_extensions::arithmetic::float_types::EXTENSION as FLOAT_TYPES;
+use hugr::std_extensions::STD_REG;
use hugr::types::type_param::{TypeArg, TypeParam};
use hugr::types::{CustomType, PolyFuncType, PolyFuncTypeRV};
use hugr::Extension;
@@ -57,15 +56,13 @@ pub static ref TKET1_EXTENSION: Extension = {
res
};
-/// Extension registry including the prelude, TKET1 and Tk2Ops extensions.
-pub static ref REGISTRY: ExtensionRegistry = ExtensionRegistry::try_new([
+/// Extension registry including the prelude, std, TKET1, and Tk2Ops extensions.
+pub static ref REGISTRY: ExtensionRegistry = ExtensionRegistry::try_new(
+ STD_REG.iter().map(|(_, e)| e.to_owned()).chain([
TKET1_EXTENSION.to_owned(),
- PRELUDE.to_owned(),
TKET2_EXTENSION.to_owned(),
- FLOAT_TYPES.to_owned(),
rotation::ROTATION_EXTENSION.to_owned()
-]).unwrap();
-
+])).unwrap();
}
diff --git a/tket2/src/ops.rs b/tket2/src/ops.rs
index 7e57aeb5..4d1798c9 100644
--- a/tket2/src/ops.rs
+++ b/tket2/src/ops.rs
@@ -272,7 +272,7 @@ pub(crate) mod test {
#[test]
fn tk2op_properties() {
for op in Tk2Op::iter() {
- // The exposed name should start with "quantum.tket2."
+ // The exposed name should start with "tket2.quantum."
assert!(op.exposed_name().starts_with(&EXTENSION_ID.to_string()));
let ext_op = op.into_extension_op();
diff --git a/tket2/src/serialize/guppy.rs b/tket2/src/serialize/guppy.rs
index 491d8501..c51e4a7d 100644
--- a/tket2/src/serialize/guppy.rs
+++ b/tket2/src/serialize/guppy.rs
@@ -1,13 +1,15 @@
//! Load pre-compiled guppy functions.
use std::path::Path;
-use std::{fs, io};
+use std::{fs, io, mem};
use hugr::ops::{NamedOp, OpTag, OpTrait, OpType};
use hugr::{Hugr, HugrView};
+use hugr_cli::Package;
use itertools::Itertools;
use thiserror::Error;
+use crate::extension::REGISTRY;
use crate::{Circuit, CircuitError};
/// Loads a pre-compiled guppy file.
@@ -31,7 +33,12 @@ pub fn load_guppy_json_reader(
reader: impl io::Read,
function: &str,
) -> Result {
- let hugr: Hugr = serde_json::from_reader(reader)?;
+ let pkg: Package = serde_json::from_reader(reader)?;
+ let mut hugrs = pkg.validate(&mut REGISTRY.clone())?;
+ if hugrs.len() != 1 {
+ return Err(CircuitLoadError::InvalidNumHugrs(hugrs.len()));
+ }
+ let hugr = mem::take(&mut hugrs[0]);
find_function(hugr, function)
}
@@ -48,7 +55,7 @@ pub fn load_guppy_json_reader(
/// - If the root of the HUGR is not a module operation.
/// - If the function is not found in the module.
/// - If the function has control flow primitives.
-fn find_function(hugr: Hugr, function_name: &str) -> Result {
+pub fn find_function(hugr: Hugr, function_name: &str) -> Result {
// Find the root module.
let module = hugr.root();
if !OpTag::ModuleRoot.is_superset(hugr.get_optype(module).tag()) {
@@ -139,4 +146,10 @@ pub enum CircuitLoadError {
/// Error loading the circuit.
#[error("Error loading the circuit: {0}")]
CircuitLoadError(#[from] CircuitError),
+ /// Error validating the loaded circuit.
+ #[error("{0}")]
+ ValError(#[from] hugr_cli::validate::ValError),
+ /// The encoded HUGR package must have a single HUGR.
+ #[error("The encoded HUGR package must have a single HUGR, but it has {0} HUGRs.")]
+ InvalidNumHugrs(usize),
}