{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Lookup table of the Local Clifford Group for local graph complementation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25460 characters]\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & i\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & -1\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}1 & 0\\\\0 & - i\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\\\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2} i}{2}\\\\\\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} - \\frac{i}{2}\\\\\\frac{1}{2} - \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2} i}{2} & \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & 1\\\\i & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & i\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & \\frac{\\sqrt{2} i}{2}\\\\- \\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2}}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & - \\frac{1}{2} + \\frac{i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}0 & -1\\\\1 & 0\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{\\sqrt{2}}{2} & - \\frac{\\sqrt{2}}{2}\\\\- \\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2} i}{2}\\end{matrix}\\right], \\  \\left[\\begin{matrix}\\frac{1}{2} - \\frac{i}{2} & \\frac{i \\left(-1 + i\\right)}{2}\\\\- \\frac{1}{2} + \\frac{i}{2} & \\frac{i \\left(-1 + i\\right)}{2}\\end{matrix}\\right]\\right]$"
      ],
      "text/plain": [
       "⎡⎡√2   √2 ⎤                  ⎡ √2     √2  ⎤  ⎡√2   √2⋅ⅈ ⎤           ⎡ √2   √2⋅\n",
       "⎢⎢──   ── ⎥                  ⎢ ──     ──  ⎥  ⎢──   ──── ⎥           ⎢ ──   ───\n",
       "⎢⎢2    2  ⎥  ⎡1  0⎤  ⎡1  0⎤  ⎢ 2      2   ⎥  ⎢2     2   ⎥  ⎡1  0 ⎤  ⎢ 2     2 \n",
       "⎢⎢        ⎥, ⎢    ⎥, ⎢    ⎥, ⎢            ⎥, ⎢          ⎥, ⎢     ⎥, ⎢         \n",
       "⎢⎢√2  -√2 ⎥  ⎣0  ⅈ⎦  ⎣0  1⎦  ⎢√2⋅ⅈ  -√2⋅ⅈ ⎥  ⎢√2  -√2⋅ⅈ ⎥  ⎣0  -1⎦  ⎢√2⋅ⅈ   √2\n",
       "⎢⎢──  ────⎥                  ⎢────  ──────⎥  ⎢──  ──────⎥           ⎢────   ──\n",
       "⎣⎣2    2  ⎦                  ⎣ 2      2   ⎦  ⎣2     2   ⎦           ⎣ 2     2 \n",
       "\n",
       "ⅈ⎤  ⎡√2  -√2 ⎤           ⎡ √2   -√2 ⎤  ⎡√2  -√2⋅ⅈ ⎤  ⎡ √2   -√2⋅ⅈ ⎤  ⎡1   ⅈ  1\n",
       "─⎥  ⎢──  ────⎥           ⎢ ──   ────⎥  ⎢──  ──────⎥  ⎢ ──   ──────⎥  ⎢─ + ─  ─\n",
       " ⎥  ⎢2    2  ⎥  ⎡1  0 ⎤  ⎢ 2     2  ⎥  ⎢2     2   ⎥  ⎢ 2      2   ⎥  ⎢2   2  2\n",
       " ⎥, ⎢        ⎥, ⎢     ⎥, ⎢          ⎥, ⎢          ⎥, ⎢            ⎥, ⎢        \n",
       " ⎥  ⎢√2   √2 ⎥  ⎣0  -ⅈ⎦  ⎢√2⋅ⅈ  √2⋅ⅈ⎥  ⎢√2   √2⋅ⅈ ⎥  ⎢√2⋅ⅈ   -√2  ⎥  ⎢1   ⅈ  1\n",
       " ⎥  ⎢──   ── ⎥           ⎢────  ────⎥  ⎢──   ──── ⎥  ⎢────   ──── ⎥  ⎢─ - ─  ─\n",
       " ⎦  ⎣2    2  ⎦           ⎣ 2     2  ⎦  ⎣2     2   ⎦  ⎣ 2      2   ⎦  ⎣2   2  2\n",
       "\n",
       "   ⅈ⎤  ⎡ √2   √2⎤          ⎡  √2     √2 ⎤          ⎡ 1   ⅈ   1   ⅈ⎤          ⎡\n",
       " - ─⎥  ⎢ ──   ──⎥          ⎢  ──     ── ⎥          ⎢ ─ - ─   ─ + ─⎥          ⎢\n",
       "   2⎥  ⎢ 2    2 ⎥  ⎡0  1⎤  ⎢  2      2  ⎥  ⎡0  1⎤  ⎢ 2   2   2   2⎥  ⎡0  ⅈ⎤  ⎢\n",
       "    ⎥, ⎢        ⎥, ⎢    ⎥, ⎢            ⎥, ⎢    ⎥, ⎢              ⎥, ⎢    ⎥, ⎢\n",
       "   ⅈ⎥  ⎢-√2   √2⎥  ⎣1  0⎦  ⎢-√2⋅ⅈ   √2⋅ⅈ⎥  ⎣ⅈ  0⎦  ⎢  1   ⅈ  1   ⅈ⎥  ⎣1  0⎦  ⎢\n",
       " + ─⎥  ⎢────  ──⎥          ⎢──────  ────⎥          ⎢- ─ + ─  ─ + ─⎥          ⎢\n",
       "   2⎦  ⎣ 2    2 ⎦          ⎣  2      2  ⎦          ⎣  2   2  2   2⎦          ⎣\n",
       "\n",
       "  √2    √2⋅ⅈ⎤  ⎡ 1   ⅈ     1   ⅈ⎤           ⎡  √2     -√2  ⎤  ⎡ 1   ⅈ   ⅈ⋅(-1 \n",
       "  ──    ────⎥  ⎢ ─ - ─   - ─ + ─⎥           ⎢  ──     ──── ⎥  ⎢ ─ - ─   ──────\n",
       "  2      2  ⎥  ⎢ 2   2     2   2⎥  ⎡0  -1⎤  ⎢  2       2   ⎥  ⎢ 2   2       2 \n",
       "            ⎥, ⎢                ⎥, ⎢     ⎥, ⎢              ⎥, ⎢               \n",
       "-√2⋅ⅈ   -√2 ⎥  ⎢  1   ⅈ    1   ⅈ⎥  ⎣1  0 ⎦  ⎢-√2⋅ⅈ   -√2⋅ⅈ ⎥  ⎢  1   ⅈ  ⅈ⋅(-1 \n",
       "──────  ────⎥  ⎢- ─ + ─  - ─ + ─⎥           ⎢──────  ──────⎥  ⎢- ─ + ─  ──────\n",
       "  2      2  ⎦  ⎣  2   2    2   2⎦           ⎣  2       2   ⎦  ⎣  2   2      2 \n",
       "\n",
       "+ ⅈ)⎤⎤\n",
       "────⎥⎥\n",
       "    ⎥⎥\n",
       "    ⎥⎥\n",
       "+ ⅈ)⎥⎥\n",
       "────⎥⎥\n",
       "    ⎦⎦"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sympy\n",
    "\n",
    "M = sympy.Matrix\n",
    "simplify = sympy.simplify\n",
    "sqrt = sympy.sqrt\n",
    "i = sympy.I\n",
    "\n",
    "from sympy.physics.quantum import Dagger\n",
    "\n",
    "sympy.init_printing()\n",
    "H = simplify(M([[1, 1], [1, -1]]) / sqrt(2))\n",
    "S = M([[1, 0], [0, i]])\n",
    "C_L = [H, S]\n",
    "basis_vectors = [M([1, 0]), M([0, 1])]\n",
    "\n",
    "def getitem(m, i, j):\n",
    "    # Note that sympy uses an extremely weird way to store the matrices,\n",
    "    # in particular the internal representation is vastly different from what\n",
    "    # is printed. For instance the H matrix is stored as a Mul object\n",
    "    # (even after using simplify) instead of a matrix. \n",
    "    # Therefore m[i][j] will NOT work. This is a workaround.\n",
    "    return (Dagger(basis_vectors[i]) * m * basis_vectors[j])[0]\n",
    "\n",
    "def is_known(C_L, a):\n",
    "    for c in C_L:\n",
    "        test = c * Dagger(a)\n",
    "        if(simplify(getitem(test, 0, 1)) != 0):\n",
    "            continue\n",
    "        if(simplify(getitem(test, 0, 0) / getitem(test, 1, 1)) == 1):\n",
    "            return True\n",
    "    return False\n",
    "for i in range(5):\n",
    "    for m in (H, S):\n",
    "        for c in C_L:\n",
    "            c = simplify(c*m)\n",
    "            if(is_known(C_L, c)):\n",
    "                continue\n",
    "            C_L.append(c)\n",
    "C_L"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import exp,pi, I as i\n",
    "\n",
    "siZ = exp(i*pi/4)*Dagger(S)\n",
    "smiX = simplify(M([[1, -i], [-i, 1]]) / sqrt(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def eval_str(s):\n",
    "    result = M([[1, 0], [0, 1]])\n",
    "    for c in s:\n",
    "        if(c == \"s\"):\n",
    "            result *= siZ\n",
    "        if(c == \"x\"):\n",
    "            result *= smiX\n",
    "    return result\n",
    "\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHQAAAA1CAYAAACQns/uAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFf0lEQVR4Ae2cj3XUOBDGszwKyDs6WDoIUMGFDoAOODo4XirgcR1ABzzSQaCCu6QD6ICQDsL3WzR7slZreW3Z1u5K7ykrj0fyzHyakfxnsri/vz+p5XAs8GAMVRaLxfUY49Yx0xZYiOU0xibPvYvRK60MC8hporjhoXjTz6C+7yO2LvJC9W+q31/H56rXqj+D3w8+X23vZIHP4g5x+2wh97k8cuHVNzsN3W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ApW/tImsuQM91sdh3qvaRFOdr6WABefCgHKDBIVcCsAVPFfusMcVX7HmnJ0sL4fabvGzj0xzHQ4qIfX81eQ5QDg81sMwbfVDMa7uA7vcrsX3hQOTTzY28HoFJFGJjOGsO0GAP7Wh5S6HoyF4Wm8BaSiJyPinsFxrfFrvzReQA5QDUvHClbfDHvNdCUHB6ukMXDr/qirtEi5fySj7HvNWv3aYQdsOv/IrJARoMqBQtMscjnCrIKVqv11WuLyn4li0QpncQbovIAcqxhmK74nI8EGqEwtoJcLH9QiMMd722xsqaA5QL0OJyPLoatCufC9ln4v9EHx3bY04Ot4LpeTV8WwuTRHVwDlAWQCVIcTkeWy3X/8QqKUm68uqLTdI3byjAJeyuCxNAlbWVNXiyMngN9SQtKsfDkytLU0Dy7+2oPJjHm9brKG0HIMCuN4Ci935431fobIBKeNaVcPfXV64i+0nHrc+kdW7jQcMcSmQJuXMIXq8Zt4B56JKQ4bM4j/NJtV2QBUK8JNoKP17HsLizyPuF/2s7efz3BajtdgsIUJ5MNTZiOv7yCyjWjW+RDHHDAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}e^{\\frac{i \\pi}{4}} & 0\\\\0 & - i e^{\\frac{i \\pi}{4}}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡ ⅈ⋅π         ⎤\n",
       "⎢ ───         ⎥\n",
       "⎢  4          ⎥\n",
       "⎢ℯ        0   ⎥\n",
       "⎢             ⎥\n",
       "⎢          ⅈ⋅π⎥\n",
       "⎢          ───⎥\n",
       "⎢           4 ⎥\n",
       "⎣ 0    -ⅈ⋅ℯ   ⎦"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eval_str(\"s\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEIAAAAzCAYAAAAjKt6MAAAACX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E2kOHKPegkCTEmpKBGy8ERX3aOiGigcticnpXpDY6D+sxxWiJBpK0QUIvwILh4hfOivxkI2II80ya/F4/1cLto4gUtfF8ofV0DG5h8Y3m3ea2xiTwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}i & 0\\\\0 & - i\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡ⅈ  0 ⎤\n",
       "⎢     ⎥\n",
       "⎣0  -ⅈ⎦"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eval_str(\"ss\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_product_index(a):\n",
    "    for i,c in enumerate(C_L):\n",
    "        test = c * Dagger(a)\n",
    "        if(simplify(getitem(test, 0, 1)) != 0):\n",
    "            continue\n",
    "        if(simplify(getitem(test, 0, 0) / getitem(test, 1, 1)) == 1):\n",
    "            return i\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from itertools import product\n",
    "from collections import defaultdict\n",
    "\n",
    "results = defaultdict(set)\n",
    "\n",
    "def recursive_xs_products(length):\n",
    "    if(length == 1):\n",
    "        yield \"x\"\n",
    "        yield \"s\"\n",
    "    else:\n",
    "\n",
    "        for p in recursive_xs_products(length - 1):\n",
    "            yield p\n",
    "            yield p + \"x\"\n",
    "            yield p + \"s\"\n",
    "    \n",
    "    \n",
    "for p in recursive_xs_products(5):\n",
    "    results[get_product_index(eval_str(p))] |= {p}\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "defaultdict(set,\n",
       "            {12: {'ssssx', 'x', 'xssss', 'xxxxx'},\n",
       " 14: {'sxxs', 'xx'},\n",
       " 22: {'xs'},\n",
       " 6: {'ssxss', 'sxsxs', 'sxxsx', 'xsxxs', 'xxx'},\n",
       " 16: {'sssxx', 'sxxss', 'xxs'},\n",
       " 20: {'sxs', 'xsx'},\n",
       " 19: {'ssxxx', 'xss', 'xxssx'},\n",
       " 2: {'ssss', 'xxxx'},\n",
       " 3: {'xxxs'},\n",
       " 17: {'sxss', 'xsxs', 'xxsx'},\n",
       " 21: {'ssxx', 'xxss'},\n",
       " 9: {'ssxs', 'sxsx', 'xsxx'},\n",
       " 5: {'ss', 'xssx'},\n",
       " 15: {'xsss'},\n",
       " 8: {'s', 'sssss', 'sxxxx', 'xxxxs'},\n",
       " 13: {'sxsss', 'xsxss', 'xxsxs', 'xxxsx'},\n",
       " 11: {'ssx', 'xssxx', 'xxxss'},\n",
       " 1: {'sss', 'sxssx', 'xssxs', 'xsxsx', 'xxsxx'},\n",
       " 18: {'ssxxs', 'sxx', 'xxsss'},\n",
       " 7: {'sssxs', 'ssxsx', 'sxsxx', 'xsxxx'},\n",
       " 0: {'sxxxs', 'xsssx'},\n",
       " 23: {'sx'},\n",
       " 4: {'sxxx'},\n",
       " 10: {'sssx'}})"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "lookup_table = [min(v) for k,v in sorted(results.items(), key=lambda x:x[0])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['sxxxs',\n",
       " 'sss',\n",
       " 'ssss',\n",
       " 'xxxs',\n",
       " 'sxxx',\n",
       " 'ss',\n",
       " 'ssxss',\n",
       " 'sssxs',\n",
       " 's',\n",
       " 'ssxs',\n",
       " 'sssx',\n",
       " 'ssx',\n",
       " 'ssssx',\n",
       " 'sxsss',\n",
       " 'sxxs',\n",
       " 'xsss',\n",
       " 'sssxx',\n",
       " 'sxss',\n",
       " 'ssxxs',\n",
       " 'ssxxx',\n",
       " 'sxs',\n",
       " 'ssxx',\n",
       " 'xs',\n",
       " 'sx']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lookup_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIUAAAA/CAYAAADOiwsvAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGhklEQVR4Ae2ci3HcNhCGJU0KcFTCpQM76UDuQCpBcgfOuIKM04HTgkpw3IGVDuwO4qiDy/fTAAzy+DySwPKBGRyeBPf/sVyQBPcuLy4ubogfidXw9Xg8/lKt3MvrYODy8vIJJC9r0Nz9FFW+jvLKfquU9+K6GLgHznUFUmEcglJgFf6udMheRJuPXUIg92VXnzW1w8kjeG67MHXxQvs/1TEY+1l1V9UGK2UEfECWNwLXFq3Im0IOx8nHNj582xh5gqUYM8hMx94BsLqktZ4K0l7Q4ZrjvrZ2XG5jEk5MKgWT+5Z5+6C5cxP9zs3jwaX3THxh6lzZJ+r3L/FPX7GWNOZEmAbwchYnN5wDjo/6MRGRRyaykIX8B59XqjLxS1y3hTyYAyeehxj3FLwwxn/EW3P3FNUrAiEfqJPi+vCezIG6uscp32dVaQ0nwjcbL6aWD8DrnuA1V0B8L/GGus9ioSk4pZGS/Maxd039lljfwImgtPIylpOkywdgdF/wEJs+n6deVuDGl+tS16e0fLg6KZTWlxd1x1muQ+ZRnAgbQdwFXlx5ECccUywfpMUbTcad/37CnUvCn0wedQJQWjerMtEua/BFfX0beRGqY/XsHkjx7dZTZNZFeTYnwkco8UL5LE44Lr1S+Ani5HrF+t6XHTDdQL6M6+I8bQKqN25BISrtansb1y0pj+yDORE+QiMvtA3ihP5ZlUJXdbAW5FutBO0C/ugnmbyujENUDmZSbb5+SSlyD+JE2MQBsZYX6gdzwj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rSEgdzGPufHmF9shMzepgzDm0IzppwMxm/ygHXMXdYh0wy5g7lQJynwE1+mtqC5NUNzlz1i0V89WcpOxjL5OBTkuRGpZbrvpsGacWbdbzWcJtTilgPpkj7ayzPHxwM7gtLh/ZtoyHz+OkR5jBbVEpWreMJ50GW4OZwW1u+eCOfZMOxpZwW7QU4frl5muTDsa5cZtVCog5oB2bczC2gNvc8iEz4YnBpG7KwdgKbnOWwhGzOQdjS7iz7pKGm4coAznaqdN+Syks9ZVxCURLwQJuJ0P2XdITmpj8ZI60JyfPWGEJd1g+0JKqM6++ddjDShlgvp+qcw7UwkJr+VDm1xrs39DeTf/5WA0nq6lCIfS4f10D6PP/t9B4FuktIPAAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}- \\frac{\\sqrt{2} i}{2} & - \\frac{\\sqrt{2} i}{2}\\\\- \\frac{\\sqrt{2} i}{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": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eval_str(\"sxxxs\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPcAAABECAYAAABd0qOIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAKPklEQVR4Ae1djXHcKBTOZlyAzyX4OnDiDpwO7HEF9nWQzFXgsTtI0kGSDuzrIE4HSQdJ3MHe9ymggefVLrASAj2YYQUISXzf46HHj9jVer1+0VxjoDGwPAZezgFptVo9zvHcOZ6pCWsIv1r4KA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Psl4slRCwpK3T0HcQ6m8Wuwkr8AS8bLCzViDiVMIzcTYr4C7/aDLVcEX/mZpZswetiA4vSXu0ca+938vHORb3CNmEMrjkZu5sKcQ7m5FK4zE9wKAMUeXB/u5qsxDGGqwxwqJ43czIX5f7HpoAC9xU9KAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\frac{i e^{\\frac{i \\pi}{4}}}{2} + \\frac{e^{\\frac{i \\pi}{4}}}{2} & \\frac{i e^{\\frac{i \\pi}{4}}}{2} + \\frac{e^{\\frac{i \\pi}{4}}}{2}\\\\\\frac{i e^{\\frac{i \\pi}{4}}}{2} + \\frac{e^{\\frac{i \\pi}{4}}}{2} & - \\frac{e^{\\frac{i \\pi}{4}}}{2} - \\frac{i e^{\\frac{i \\pi}{4}}}{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡   ⅈ⋅π    ⅈ⋅π      ⅈ⋅π    ⅈ⋅π ⎤\n",
       "⎢   ───    ───      ───    ─── ⎥\n",
       "⎢    4      4        4      4  ⎥\n",
       "⎢ⅈ⋅ℯ      ℯ      ⅈ⋅ℯ      ℯ    ⎥\n",
       "⎢────── + ────   ────── + ──── ⎥\n",
       "⎢  2       2       2       2   ⎥\n",
       "⎢                              ⎥\n",
       "⎢   ⅈ⋅π    ⅈ⋅π     ⅈ⋅π      ⅈ⋅π⎥\n",
       "⎢   ───    ───     ───      ───⎥\n",
       "⎢    4      4       4        4 ⎥\n",
       "⎢ⅈ⋅ℯ      ℯ       ℯ      ⅈ⋅ℯ   ⎥\n",
       "⎢────── + ────  - ──── - ──────⎥\n",
       "⎣  2       2       2       2   ⎦"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eval_str(\"xsssx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "lookup_table_lengths = [len(l) for l in lookup_table]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAnQAAAAVCAYAAADPXnMZAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIs0lEQVR4Ae1dgXHcNhCUNClAUTpwOrCsDpQOpEkHdgdRDXYHSglROpBdQWJ3IHcQ+ztQdvkA5wjyf/gkbumnDjN4gnjylre3BCAQfJ2enJz8gfwOmen2+fn5y7YYn8FAMBAMBAPBQDAQDAQDPyIDp6ennfHbGS7yF+R3GMj9agdzOPB16QDqzpFflfWxHwzUZEClPRVOTW7Cli8DSk0osXxZ01tfI3dKn5RYenW8HESM2T5w7AaP/0a++GmP658Q9HN8n2fsWGa63G7qfAKDA8Q8Q0gM7r/HRX6sg7DbShI1B7MZf/fBM75R4fASvbBSnO4SDW+w/YZ8B+6yPtJXVTYS7eFKVTgtKSk+D6i4BHeb9gungpcehi7XCytpL9+j3m2EUhNKrDZkXnFqAUzBEWsR7ujaSnyS8Ce+d43y/OKUfJL0hVOw3oOFa3QuJzaj7inl57Tlcef2mLll2kO+t3aw/xaZmDe23qMMDPr44GHb2lThENMDCzY5yO7whH3qgYA97Vjfp5Rh0117hitiuWk84VDnHMTdI39OeFXvpV08A0uiccNnRye7rmtsPa5f2kYkvtw1YfiSYFm+j10TS3JnsKvq3NiV6EGhc/W9azVu+KwaJ/gk6wsPwcKxzTgO221hgIyqRJT2E+F8/tsZvGGfDTjrPg+dU6sO9ont3tmpcAyf1X2CDxyM9AYgqPvOXCsm2Q7xctlzq8KxPgAza77Hpz2uRjlhVdfD0LV5YRm+2j/wUOfWRsC2RHvkUImVYwZMSbuX/HPDWoK7Nfmk4C9pbVX9O3lD7rXdqKveFx6ChWObAd0ZCksmPq7bpNxcB24a7rumNGXewfUAVOHw2p2xrgHxHRjsSG3iY/FYV2kZ+UHKznroeOmMtUgb0XFwJTvOceqwpMTqADvurNEnR7poepF71zlOyr7wYKxFB3QYvH1E/p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5, \\  4, \\  4, \\  5, \\  4, \\  5, \\  5, \\  3, \\  4, \\  2, \\  2\\right]$"
      ],
      "text/plain": [
       "[5, 3, 4, 4, 4, 2, 5, 5, 1, 4, 4, 3, 5, 5, 4, 4, 5, 4, 5, 5, 3, 4, 2, 2]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lookup_table_lengths"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAOCAYAAAASVl2WAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAWUlEQVQYGWP4//8/AwwzMDAYAfFdIBaAibEwMjIKAAVmA/E7IDYBYiUgRgCYShANBGVADGLATWACieIDowogoUMwHBhBQQyMj9VA9aA4AcUFiL4HxOeA+DQAT1cpCApe64MAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 1$"
      ],
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_product_index(Dagger(siZ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAOCAYAAAAWo42rAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA00lEQVQoFXWSgQ2CQAxF74gDEEfADYwjMAKJG7iKYQRHMIwgK8gGsoHBDfD940oaEpqU9v/+a3sX4jzPwVuMsfWY/IlmCBJmcQX5wWvHdeKECxIzkT1kbwSxxMeEc7cGoB1K67aNNvaNaNoWPT6ktiGciQMXUbziX/yEd4jXVbSHxqrrzXcBT3gjTmZC8PICFqk9cInLAvJHIltut+T21RQ1utjzSGQHTORj5YU6uWejPU+NYndH7ZyEKQnhhbhVnrEmrLeOmUwj8w9hKxwh79QHFf8zQq2xR+TPOQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 6$"
      ],
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_product_index(Dagger(smiX))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "def str2vops(s):\n",
    "    c2v = {'s': 1, 'x': 6}\n",
    "    result = [c2v[c] for c in s]\n",
    "    return result + ([0] * (5 - len(result)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 9776 characters]\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\left[ 1, \\  6, \\  6, \\  6, \\  1\\right], \\  \\left[ 1, \\  1, \\  1, \\  0, \\  0\\right], \\  \\left[ 1, \\  1, \\  1, \\  1, \\  0\\right], \\  \\left[ 6, \\  6, \\  6, \\  1, \\  0\\right], \\  \\left[ 1, \\  6, \\  6, \\  6, \\  0\\right], \\  \\left[ 1, \\  1, \\  0, \\  0, \\  0\\right], \\  \\left[ 1, \\  1, \\  6, \\  1, \\  1\\right], \\  \\left[ 1, \\  1, \\  1, \\  6, \\  1\\right], \\  \\left[ 1, \\  0, \\  0, \\  0, \\  0\\right], \\  \\left[ 1, \\  1, \\  6, \\  1, \\  0\\right], \\  \\left[ 1, \\  1, \\  1, \\  6, \\  0\\right], \\  \\left[ 1, \\  1, \\  6, \\  0, \\  0\\right], \\  \\left[ 1, \\  1, \\  1, \\  1, \\  6\\right], \\  \\left[ 1, \\  6, \\  1, \\  1, \\  1\\right], \\  \\left[ 1, \\  6, \\  6, \\  1, \\  0\\right], \\  \\left[ 6, \\  1, \\  1, \\  1, \\  0\\right], \\  \\left[ 1, \\  1, \\  1, \\  6, \\  6\\right], \\  \\left[ 1, \\  6, \\  1, \\  1, \\  0\\right], \\  \\left[ 1, \\  1, \\  6, \\  6, \\  1\\right], \\  \\left[ 1, \\  1, \\  6, \\  6, \\  6\\right], \\  \\left[ 1, \\  6, \\  1, \\  0, \\  0\\right], \\  \\left[ 1, \\  1, \\  6, \\  6, \\  0\\right], \\  \\left[ 6, \\  1, \\  0, \\  0, \\  0\\right], \\  \\left[ 1, \\  6, \\  0, \\  0, \\  0\\right]\\right]$"
      ],
      "text/plain": [
       "[[1, 6, 6, 6, 1], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [6, 6, 6, 1, 0], [1, 6, 6,\n",
       " 6, 0], [1, 1, 0, 0, 0], [1, 1, 6, 1, 1], [1, 1, 1, 6, 1], [1, 0, 0, 0, 0], [1\n",
       ", 1, 6, 1, 0], [1, 1, 1, 6, 0], [1, 1, 6, 0, 0], [1, 1, 1, 1, 6], [1, 6, 1, 1,\n",
       " 1], [1, 6, 6, 1, 0], [6, 1, 1, 1, 0], [1, 1, 1, 6, 6], [1, 6, 1, 1, 0], [1, 1\n",
       ", 6, 6, 1], [1, 1, 6, 6, 6], [1, 6, 1, 0, 0], [1, 1, 6, 6, 0], [6, 1, 0, 0, 0]\n",
       ", [1, 6, 0, 0, 0]]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[str2vops(s) for s in lookup_table]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'sssxs'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lookup_table[7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['sxxxs',\n",
       " 'sss',\n",
       " 'ssss',\n",
       " 'xxxs',\n",
       " 'sxxx',\n",
       " 'ss',\n",
       " 'ssxss',\n",
       " 'sssxs',\n",
       " 's',\n",
       " 'ssxs',\n",
       " 'sssx',\n",
       " 'ssx',\n",
       " 'ssssx',\n",
       " 'sxsss',\n",
       " 'sxxs',\n",
       " 'xsss',\n",
       " 'sssxx',\n",
       " 'sxss',\n",
       " 'ssxxs',\n",
       " 'ssxxx',\n",
       " 'sxs',\n",
       " 'ssxx',\n",
       " 'xs',\n",
       " 'sx']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lookup_table"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
