"The **GHZ Game** quantum kata is a series of exercises designed\n",
"to get you familiar with the GHZ game.\n",
"\n",
"In it three players (Alice, Bob and Charlie) try to win the following game:\n",
"\n",
"Each of them is given a bit (r, s and t respectively), and\n",
"they have to return new bits (a, b and c respectively) so\n",
"that r ∨ s ∨ t = a ⊕ b ⊕ c. The input bits will have\n",
"zero or two bits set to true and three or one bits set to false.\n",
"The trick is, the players can not communicate during the game.\n",
"\n",
"* You can read more about the GHZ game in the [lecture notes](https://cs.uwaterloo.ca/~watrous/CPSC519/LectureNotes/20.pdf) by John Watrous. \n",
"* Another description can be found in the [lecture notes](https://staff.fnwi.uva.nl/m.walter/physics491/lecture1.pdf) by Michael Walter.\n",
"\n",
"Each task is wrapped in one operation preceded by the description of the task.\n",
"Each task has a unit test associated with it, which initially fails.\n",
"Your goal is to fill in the blank (marked with the `// ...` comments)\n",
"with some Q# code that solves the task. To verify your answer, run the cell using Ctrl/⌘+Enter.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To begin, first prepare this notebook for execution (if you skip this step, you'll get \"Syntax does not match any known patterns\" error when you try to execute Q# code in the next cells):"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%package Microsoft.Quantum.Katas::0.6.1905.301"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> The package versions in the output of the cell above should always match. If you are running the Notebooks locally and the versions do not match, please install the IQ# version that matches the version of the `Microsoft.Quantum.Katas` package.\n",
"> <details>\n",
"> <summary><u>How to install the right IQ# version</u></summary>\n",
"> For example, if the version of `Microsoft.Quantum.Katas` package above is 0.6.1905.301, the installation steps are as follows:\n",
"In the quantum version of the game, the players still can not\n",
"communicate during the game, but they are allowed to share \n",
"qubits from an entangled triple before the start of the game.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.1. Entangled triple\n",
"\n",
"**Input:** An array of three qubits in the $|000\\rangle$ state.\n",
"\n",
"**Goal:** Create the entangled state $|\\Phi\\rangle = \\frac{1}{2} \\big(|000\\rangle - |011\\rangle - |101\\rangle - |110\\rangle \\big)$ on these qubits."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%kata T21_CreateEntangledTriple_Test \n",
"\n",
"operation CreateEntangledTriple (qs : Qubit[]) : Unit {\n",
" // ...\n",
" fail \"Task 2.1 not implemented yet\";\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Task 2.2. Quantum strategy\n",
"\n",
"**Inputs:**\n",
"\n",
" 1. The input bit for one of the players (r, s or t),\n",
"\n",
" 2. That player's qubit of the entangled triple shared between the players.\n",
"\n",
"**Goal:** Measure the qubit in the Z basis if the bit is 0 (false), or the X basis if the bit is 1 (true), and return the result.\n",
"\n",
"The state of the qubit after the operation does not matter."
This kata covers the Greenberger-Horne-Zeilinger game (often abbreviated as GHZ game),
a well-known example of a nonlocal (entanglement) game.
You can [run the GHZ Game kata as a Jupyter Notebook](https://mybinder.org/v2/gh/Microsoft/QuantumKatas/master?filepath=GHZGame%2FGHZGame.ipynb)!
In a nonlocal game, several cooperating players play a game against a referee answering the referee's questions. The players are free to share information
(and even qubits!) before the game starts, but are forbidden from communicating
with each other afterwards. Nonlocal games show that quantum entanglement can be
@ -12,4 +14,4 @@ purely classical strategy.
#### Theory
* [Lecture 1](https://staff.fnwi.uva.nl/m.walter/physics491/lecture1.pdf) by Michael Walter.
* [Lecture 20](https://cs.uwaterloo.ca/~watrous/CPSC519/LectureNotes/20.pdf) by John Watrous.
* [Lecture 20](https://cs.uwaterloo.ca/~watrous/CPSC519/LectureNotes/20.pdf) by John Watrous.
" This kata starts with writing quantum oracles which implement classical functions, and continues to introduce the Bernstein–Vazirani and Deutsch–Jozsa algorithms.\n",