{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "aVqb4qlbXjI-"
},
"source": [
"##### Copyright 2020 The OpenFermion Developers"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"cellView": "form",
"execution": {
"iopub.execute_input": "2020-12-07T23:37:45.882468Z",
"iopub.status.busy": "2020-12-07T23:37:45.881820Z",
"iopub.status.idle": "2020-12-07T23:37:45.883707Z",
"shell.execute_reply": "2020-12-07T23:37:45.884130Z"
},
"id": "Dk8ubIqnXl2B"
},
"outputs": [],
"source": [
"#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "kybNYuM7YeyH"
},
"source": [
"# Lowering qubit requirements using binary codes"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cuXwrTlaXtYo"
},
"source": [
"\n",
" \n",
" \n",
" \n",
" \n",
"

"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "TtLEYcV8Yp1t"
},
"source": [
"## Setup\n",
"\n",
"Install the OpenFermion package:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2020-12-07T23:37:45.889439Z",
"iopub.status.busy": "2020-12-07T23:37:45.888792Z",
"iopub.status.idle": "2020-12-07T23:38:01.452215Z",
"shell.execute_reply": "2020-12-07T23:38:01.451584Z"
},
"id": "5cbe6b680387"
},
"outputs": [],
"source": [
"try:\n",
" import openfermion\n",
"except ImportError:\n",
" !pip install -q git+https://github.com/quantumlib/OpenFermion.git@master#egg=openfermion"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4cc6d04dc630"
},
"source": [
"## Introduction\n",
"\n",
"Molecular Hamiltonians are known to have certain symmetries that are not taken into account by mappings like the Jordan-Wigner or Bravyi-Kitaev transform. The most notable of such symmetries is the conservation of the total number of particles in the system. Since those symmetries effectively reduce the degrees of freedom of the system, one is able to reduce the number of qubits required for simulation by utilizing binary codes (arXiv:1712.07067). \n",
"\n",
"We can represent the symmetry-reduced Fermion basis by binary vectors of a set $\\mathcal{V} \\ni \\boldsymbol{\\nu}$, with $ \\boldsymbol{\\nu} = (\\nu_0, \\, \\nu_1, \\dots, \\, \\nu_{N-1} ) $, where every component $\\nu_i \\in \\lbrace 0, 1 \\rbrace $ and $N$ is the total number of Fermion modes. These binary vectors $ \\boldsymbol{\\nu}$ are related to the actual basis states by: $$\n",
"\\left[\\prod_{i=0}^{N-1} (a_i^{\\dagger})^{\\nu_i} \\right] \\left|{\\text{vac}}\\right\\rangle \\, ,\n",
"$$ where $ (a_i^\\dagger)^{0}=1$. The qubit basis, on the other hand, can be characterized by length-$n$ binary vectors $\\boldsymbol{\\omega}=(\\omega_0, \\, \\dots , \\, \\omega_{n-1})$, that represent an $n$-qubit basis state by:\n",
"$$ \\left|{\\omega_0}\\right\\rangle \\otimes \\left|\\omega_1\\right\\rangle \\otimes \\dots \\otimes \\left|{\\omega_{n-1}}\\right\\rangle \\, . $$ \n",
"Since $\\mathcal{V}$ is a mere subset of the $N$-fold binary space, but the set of the vectors $\\boldsymbol{\\omega}$ spans the entire $n$-fold binary space we can assign every vector $\\boldsymbol{\\nu}$ to a vector $ \\boldsymbol{\\omega}$, such that $n