{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "pmm5uV8cQQN6"
   },
   "source": [
    "# Exercise 7\n",
    "\n",
    "\n",
    "## 1\n",
    "\n",
    "Given the ability to perform `cx` and `h` gates, and given a supply of auxiliary qubits in state $|0\\rangle$, show that it is possible to perform `x` gates with arbitrarily high probability of success."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "CJyxxSDUQQN9"
   },
   "source": [
    "## 2\n",
    "\n",
    "A general $n$-qubit state can be written\n",
    "\n",
    "$$\n",
    "| \\psi \\rangle = \\sum_x c_x |x\\rangle = \\sum_x \\Re (c_x) |x\\rangle +  i \\Im (c_x) |x\\rangle,\n",
    "$$\n",
    "\n",
    "where the $|x\\rangle$ here denote the $n$-qubit Z basis states.\n",
    "\n",
    "For each such state we can write an equivalent state for which all amplitudes are real. Since the complex nature of the amplitudes effectively adds an extra degree of superposition to the state, we need to add an extra qubit to the system to encode the same information. The $n+1$ qubit state $| \\tilde \\psi \\rangle$ equivalent to $| \\psi \\rangle$ is then\n",
    "\n",
    "$$\n",
    "| \\tilde \\psi \\rangle = \\sum_x \\Re (c_x) |x\\rangle \\otimes |0\\rangle +  \\Im (c_x) |x\\rangle \\otimes |1\\rangle.\n",
    "$$\n",
    "\n",
    "Note that the $i$ in $| \\psi \\rangle$ is replaced by the $|1\\rangle$ state on the extra qubit in $| \\tilde \\psi \\rangle$.\n",
    "\n",
    "a) For each $n$ qubit unitary $U$ we can define an equivalent $n+1$ qubit unitary $\\tilde U$, such that\n",
    "\n",
    "$$\n",
    "\\tilde U (|x\\rangle \\otimes |0\\rangle) = \\widetilde{U |x\\rangle}, \\,\\, \\forall x\n",
    "$$\n",
    "\n",
    "Write the effects of $\\tilde U (|x\\rangle \\otimes |0\\rangle)$ and $\\tilde U (|x\\rangle \\otimes |1\\rangle)$ in terms of $U$.\n",
    "\n",
    "b) Show that any two gates $\\tilde U$ and $\\tilde V$ will combine equivalently to their counterparts $U$ and $V$, i.e.,\n",
    "\n",
    "$$\n",
    "\\tilde U \\tilde V = \\widetilde{U V}.\n",
    "$$\n",
    "\n",
    "c) The controlled-$S$ gate is a two qubit gate which applies a phase of $i$ when the two qubits are in the state $|11\\rangle$ and acts trivially otherwise. Find the equivalent gate acting on real states, and express it in terms of gates that we have seen already during the course."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3\n",
    "\n",
    "a) Given all Clifford gates and any an additional non-Clifford, universal quantum computation can be perfomed. Given this fact, show that the controlled-$S$ and Hadamard are a universal gate set.\n",
    "\n",
    "b) Show that the Toffoli and Hadamard can simulate universal quantum computation on real states."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "collapsed_sections": [],
   "name": "Exercise_4.ipynb",
   "provenance": [],
   "version": "0.3.2"
  },
  "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.9.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
