stuff for stabilizer state classes

This commit is contained in:
Daniel Knüttel 2019-11-20 19:23:52 +01:00
parent 99f96c4fa9
commit ef901f46ca

View File

@ -6,17 +6,12 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"import matplotlib.pyplot as plt\n",
"from itertools import product\n", "from itertools import product\n",
"from functools import reduce\n", "from collections import defaultdict\n",
"from operator import iconcat\n",
"import sympy\n",
"i = sympy.I\n",
"exp = sympy.exp\n",
"M = sympy.Matrix\n",
"simplify = sympy.simplify\n",
"from sympy.physics.quantum.dagger import Dagger\n",
"\n", "\n",
"sympy.init_printing()" "from pyqcs import CZ, GenericGate, State, H\n",
"from pyqcs.graph.util import C_L"
] ]
}, },
{ {
@ -25,128 +20,252 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"I = M([[1, 0], [0, 1]])\n", "%matplotlib inline"
"X = M([[0, 1], [1, 0]])\n",
"Y = M([[0, -i], [i, 0]])\n",
"Z = M([[1, 0], [0, -1]])\n",
"O = M([[0, 0], [0, 0]])"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"(0.5000000000000001+0j)*|0b0> + (0.5000000000000001+0j)*|0b1> + (0.5000000000000001+0j)*|0b10> + (0.5000000000000001+0j)*|0b11>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"H = M([[1, 1], [1, -1]]) / sympy.sqrt(2)\n", "plus_state_state_2 = (H(0) | H(1)) * State.new_zero_state(2)\n",
"S = M([[1, 0], [0, i]])\n" "plus_state_state_2"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.5000000000000001+0j)*|0b0> + (0.5000000000000001+0j)*|0b1> + (0.5000000000000001+0j)*|0b10> + (-0.5000000000000001-0j)*|0b11>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plus_state_state_2_cz = CZ(0, 1) * plus_state_state_2\n",
"plus_state_state_2_cz"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"s2m = {\"H\": H, \"S\": S}\n", "circuits = [GenericGate(0, C_L[c0]) | GenericGate(1, C_L[c1]) for c0,c1 in product(range(24), range(24))]"
"def evalstr(s):\n",
" m = I\n",
" \n",
" for c in s:\n",
" m *= s2m[c]\n",
" \n",
" m.simplify()\n",
" return m"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAG8AAAA/CAYAAADuS5aXAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGWklEQVR4Ae1bi3HUMBDNZSgAUsLRAZ8Ojg6SEhI6gKECBjqAFlIC0AGhA9IBIR0c7ykrjaTzR469kizOMzrrr3162rUt3W5OTk52CN8Q4ut2v98/jzOP6bwzsNlsbjDii45RL554mW+8OKN3UfqYLDMDlxj2LBraKJsjD1r2PaqgnsSq2o8NArk2Y3XWVA7M15D3fExmixv3X3Fd9HHPvNO4IFcaAlxhrLcUcijkkifHOIL52xBeW5Yij9O8lMoL17mAoLGpHhwC4J+iwhna3Q5WrLdwMuYhKEXIAwnvINQXCiaEfBAht3K/BEHGNEja3ljvD8Jnm7GWu4+ZMk/E3QtzhxLM1Z4/WQLGo+kwYyH+xcZ5Zxrht5/XQhyYHGaL08c1BTfq/kUwz82s5GFQat25FRxxMrbz0tQ+5r2weWu/A0uAmXgE46Nwo60hL6vZFFPxBsL7z7q3EOYn0fRdaMcFxm+d12h70VevxvwezBR1FHcKnkU1DwNSc666tAX5nxDcahuoE5hNaceXFS7Zp13tSuZBplmYKTsuzk2Auw8T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zd0BdrlTnsyDtTX8si9vnSGPcSZhScPXJjbHKkSeCJ3nUQFC7MkmYDTyVqM6LCDIlYfKIoyWxmHgPcNVMHlcqVxCFdloVCyx1qFVB8OuhjJpb3IsIMiRhEvKIPcDEtI+rL456RvOyHwlhYHfhNbo5L6IcmDAGyct/JOSYe4hk86iJxtVMZsM0+pEuH5k/gPbgAHVgBrgBG/wbDP3QRHReKOMJwqIXxlc/3NXClCr7KHno6B6zOvvfXakCLcqgcmelMZ0q4zt2rzgDo5qnOHZn12KmZx+VdHaeOVMbS3XkYX5VnTMy86eKpUazqeqckZk8VSw1kqfqnJGZPFUs1ZlNvME144iijaVGzXPKgQc+t8645TT7U8V1WiiigaVa8gB2i3luwhFFC0t1ZpOKYcHC7KzeEUUTS3WaJ2B5NLJ6RxRtLEVPFahl8QXA3DE/2EctvRUVy5mS1sIi/RY/VTiYA5DUjCOKNhZnNsFm7NTBs7bjVXgGwMtNzA1EMpaJZpORVx0y3mHlBMc6HXWOWcozAOL4uXTWMczPf3VNWc9gofJvAAAAAElFTkSuQmCC\n",
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right]$"
],
"text/plain": [
"⎡ √2⋅ √2⎤\n",
"⎢ ──── ──⎥\n",
"⎢ 2 2 ⎥\n",
"⎢ ⎥\n",
"⎢-√2⋅ √2⎥\n",
"⎢────── ──⎥\n",
"⎣ 2 2 ⎦"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"evalstr(\"HSHSSH\")" "resulting_states = [c * s for c,s in product(circuits, (plus_state_state_2, plus_state_state_2_cz))]"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"image/png": "iVBORw0KGgoA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pQ8lN1j62ex0WRsTM1hC5OwKSBeWcLG5jeaxBI3tS1MPM8Rp2WezW80iSRuFltkrSp4IJCnWe4nc4eMvEnnLb38kq5z2MLJyF5VqOwGSc9mo8nYQJnTFiFswmZ7U4jW6s7HwhaAl4c2N6hURTmFNSV+69DxG6MoLIt01J+LZrAAxOmv13WHqM8/AMxjWc93eaBGAAAAAElFTkSuQmCC\n",
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right]$"
],
"text/plain": [
"⎡√2 √2⋅ ⎤\n",
"⎢── ──── ⎥\n",
"⎢2 2 ⎥\n",
"⎢ ⎥\n",
"⎢√2 -√2⋅ ⎥\n",
"⎢── ──────⎥\n",
"⎣2 2 ⎦"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"evalstr(\"HS\")" "def get_equivalent_states(s, resulting_states):\n",
" for i,test in enumerate(resulting_states):\n",
" if(test == s):\n",
" yield i\n",
" \n",
"equivalent_states = [list(get_equivalent_states(s, resulting_states)) for s in resulting_states]"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [],
"source": [
"equivalent_state_counts = [len(e) - 1 for e in equivalent_states]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAHkAAAA/CAYAAADE+2c4AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFIklEQVR4Ae2cjXXTMBSFEw4DQEcIGwAjpBuUEQIbwGECTkeAFRihsEHLBjACdIPwXdc2qurGJNF7UizrHNWW/6R7r96TLeV1uVgs1uQrcpx+bbfbF/HBuVwmA8vl8oaWvRxo3ZunwcHzYF+7v6PyXCybg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2JqZp9qhF4Gtbbsv8/wD4NeA77fHPw78V2aeaY+Hx312Tu34t9r5k2Q7MA/8Wbs19acRcTE9XqfMfAH4XeDfgVMM/rkfpt/rtGC16zLx67XILzD4CQU6nlMfYt9rEfEa4PPARzLz28PHcvCf5d689jUi3gmczszDGz2WDk0x+LH6E5l5NfDfDG4PnNXDddrE4I8Sbgd+ArgY2Lmhg1oDfVuX5UTE3cAZ4IG1+Px9iH1v/yxDRLyKQegfyMyH2u6XImJbO74NON3292GebwTeFREnGPyV07cAfwhcEhELv6A3PO6zc2rHXwf8x3oOeAVOAicz81B7/DkG8e/zOr0V+Fpmzmfmd4GHGKxdn9dpwWrXpQ/rRUR8AHgn8N72HzHoeE59iH0v/yxDRARwH/BsZn586NABYOEVAbsZ3Mtf2P/+9qqC64BvDf24OhEy867MfENmzjBYh7/LzPcCTwC3tdMWz2lhrre18yfqO7HMfBH4RkRc2XbdCDxDj9eJwe2b6yLix9rX4cKcertOQ1a7Lo8BN0XEpvYTz01t38SIiJ0Mbo2+KzP/Z+jQAeD29mqp7cAVwD8yahM3+gmYFT6hcQuDV7M8B9y90eNZ4ZjfxOBHzKeAJ9vbLQzuhR4EjgF/C2xu5weD/xnMc8BXgNmNnsMy87uBH7wa5/L2RXgc+Evgorb/1e3x8Xb88o0e9xJzuQqYa2v1VwxetdHrdQJ+C/gqcAT4cwav6OjVOgEPMnjO4bsMfgK7Y5R1YXAf/Hh7+/kJnNNxBvfgFzpx79D5d7c5HQVuHtq/6ib65xIkqYA+3MaRJI3J2EtSAcZekgow9pJUgLGXpAKMvSQVYOwlqYD/A7L+9YiFeC50AAAAAElFTkSuQmCC\n",
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right]$"
],
"text/plain": [ "text/plain": [
"⎡ √2 -√2 ⎤\n", "<Figure size 432x288 with 1 Axes>"
"⎢ ── ────⎥\n",
"⎢ 2 2 ⎥\n",
"⎢ ⎥\n",
"⎢-√2 -√2 ⎥\n",
"⎢──── ────⎥\n",
"⎣ 2 2 ⎦"
] ]
}, },
"execution_count": 8, "metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.bar(range(len(resulting_states)), equivalent_state_counts)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"clusters = set((tuple(sorted(v)) for v in equivalent_states))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{15, 23}"
]
},
"execution_count": 11,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"evalstr(\"SSHSS\")" "set(equivalent_state_counts)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1152"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(equivalent_states)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAD4CAYAAAANbUbJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAM+UlEQVR4nO3db4xlZX3A8e+vjGCLRna7k81WobM0hGTfFMiEQjSGiuKCRjQhDRuja4vZppVEW5NmKS/avsP+sX+SRtwW6qZBqlUoG9RSuiUxTZptZ1uKC7jdBde6ZGGH2qppX9TVX1/cZ9brdIeZuffMzD37+36SyZx7zpk5z8MzfJk5984QmYkk6fz2Ixs9AEnS2jP2klSAsZekAoy9JBVg7CWpgKn1vNiWLVtyZmZmPS8pSb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erta5v21PtvNjoOSyaz+taGGPR/t6uU4v9N1rgpto6vb2P6wTMLArjqtYF2AV8cmj/D503CXNadOw9wANt+4dat7BOozaxD7dxFr5wF5xs+3qj/Vh8NXAI2JqZp9qhF4Gtbbsv8/wD4NeA77fHPw78V2aeaY+Hx312Tu34t9r5k2Q7MA/8Wbs19acRcTE9XqfMfAH4XeDfgVMM/rkfpt/rtGC16zLx67XILzD4CQU6nlMfYt9rEfEa4PPARzLz28PHcvCf5d689jUi3gmczszDGz2WDk0x+LH6E5l5NfDfDG4PnNXDddrE4I8Sbgd+ArgY2Lmhg1oDfVuX5UTE3cAZ4IG1+Px9iH1v/yxDRLyKQegfyMyH2u6XImJbO74NON3292GebwTeFREnGPyV07cAfwhcEhELv6A3PO6zc2rHXwf8x3oOeAVOAicz81B7/DkG8e/zOr0V+Fpmzmfmd4GHGKxdn9dpwWrXpQ/rRUR8AHgn8N72HzHoeE59iH0v/yxDRARwH/BsZn586NABYOEVAbsZ3Mtf2P/+9qqC64BvDf24OhEy867MfENmzjBYh7/LzPcCTwC3tdMWz2lhrre18yfqO7HMfBH4RkRc2XbdCDxDj9eJwe2b6yLix9rX4cKcertOQ1a7Lo8BN0XEpvYTz01t38SIiJ0Mbo2+KzP/Z+jQAeD29mqp7cAVwD8yahM3+gmYFT6hcQuDV7M8B9y90eNZ4ZjfxOBHzKeAJ9vbLQzuhR4EjgF/C2xu5weD/xnMc8BXgNmNnsMy87uBH7wa5/L2RXgc+Evgorb/1e3x8Xb88o0e9xJzuQqYa2v1VwxetdHrdQJ+C/gqcAT4cwav6OjVOgEPMnjO4bsMfgK7Y5R1YXAf/Hh7+/kJnNNxBvfgFzpx79D5d7c5HQVuHtq/6ib65xIkqYA+3MaRJI3J2EtSAcZekgow9pJUgLGXpAKMvSQVYOwlqYD/A7L+9YiFeC50AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"resulting_states_after_cz = [CZ(0, 1) * s for s in resulting_states]\n",
"equivalent_states_after_cz = [list(get_equivalent_states(s, resulting_states_after_cz)) for s in resulting_states_after_cz]\n",
"equivalent_state_counts_after_cz = [len(e) - 1 for e in equivalent_states_after_cz]\n",
"\n",
"plt.bar(range(len(resulting_states)), equivalent_state_counts_after_cz)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{15, 23}"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clusters_after_cz = set((tuple(sorted(v)) for v in equivalent_states))\n",
"set(equivalent_state_counts_after_cz)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clusters == clusters_after_cz"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"resulting_states_after_cz_C_L = [c*s for c,s in product(circuits, resulting_states)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"equivalent_states_after_cz_C_L = [list(get_equivalent_states(s, resulting_states_after_cz_C_L)) for s in resulting_states_after_cz_C_L]\n",
"equivalent_state_counts_after_cz_C_L = [len(e) - 1 for e in equivalent_states_after_cz_C_L]\n",
"\n",
"plt.bar(range(len(resulting_states_after_cz_C_L)), equivalent_state_counts_after_cz_C_L)\n",
"plt.show()"
] ]
} }
], ],