Let’s use the heat of the Squid Game to understand the most beautiful yet still unexplained phenomena in quantum mechanics, shall we?

If you don’t have any prior knowledge of quantum mechanics and quantum logic gates, please read until the topic “Plot Twist”.

Quantum entanglement is a strange phenomena which is quite difficult to wrap our heads around. If we separate two entangled electrons by an arbitrary distance ( even galaxies apart ) and measure the spin of a single electron, the other electron immediately takes the opposite spin. But, until we do some measurements, these electrons are in a superposition of both spin states. Which means there’s an equal chance to get either spin up or down reading when we measure the first qubit.  

So how can this happen? The first way is that the particle we measure first, should immediately transfer the measurement result to the other particle so that it can take the opposite spin. This enables faster than light communication, which violates the universal speed limit enforced by Einstein’s causality principle. Eintein refused to accept this and called this “spooky action at a distance”.

The second way is the use of hidden variables. When the entagled pair of electrons is created, their DNA should contain the information to choose a specific spin direction when measured. This is called the hidden variable theory. But John Stewart Bell later created some experiments that showed this hidden variable theory is also invalid.

Lets create a new game for Squid Game, derived from the above Bell experiments.

Game Design

Before the start of the game, all the players should be separated into pairs. Each pair can discuss a strategy before playing the game. If they win, both players will proceed, and if they fail, both players will be eliminated. To play the game, each player pair is separated into two rooms. They each can’t see the other one or talk with the other one. Once both of them are situated and ready, a guard comes and provides each of them with a number 0 or 1. Upon receiving the number from the guard, players should also provide a number back to the guard, either 0 or 1 (within a given amount of time if needed). Let’s take the players as a and b and the inputs they get as x and y.

If the above equation is satisfied, the player pair is considered to have won. Otherwise, they are eliminated.

Let’s have a look at some sample scenarios.

Players a and b’s strategy is to to give the same number they receive as the answer. Let’s see how this plan will work.

As you can see their plan is really bad. It has only 25% win probability. ( sometimes stupid people becomes lucky 🙂 )

Meanwhile, players p and q decide the following. Player p will always answer with 0, no matter what the input is. Player q will return the input as the output. 

Their plan is way better with 75% win probability.

Now, take out a pencil and paper and try out some of your own stratergies. Try to see if you can beat the 75% probability. ( seriously, if you can beat it please comment the stratergy 🙂 )

Plot twist

Now, let’s introduce some changes to this game. From now onwards, player pairs can share an entangled pair of qubits. The input they receive is also in the form of qubits. Once the input qubit is received, they can apply any single or multi-qubit gate (s), do the measurements, and inform the final result. Still, they still can’t communicate with each other.

Lets program this

from matplotlib import pyplot as plt
import numpy as np
from qiskit import *
from qiskit.circuit.library.standard_gates import XGate
# Creating the circuit with 4 classical bits and 4 qbits
qc = QuantumCircuit(4,4)
# Creating the entanglement between players qubits
qc.h(1)
qc.cx(1,0)
# Applying X gate power raised to (-0.25)
new_gate = XGate().power(-0.25)
qc.append(new_gate, [0])
qc.barrier()
# Initialize input qubits randomly
qc.h(2)
qc.h(3)
qc.barrier()
# Players applying a controlled sqrt(x) gate to their qubits
# taking input qubits as controllers
qc.csx(2,0)
qc.csx(3,1)
qc.barrier()
# Players measure their qubits and inform the result to guards
qc.measure(0,0)
qc.measure(1,1)
# measuring the input qubits to calculate xy
qc.measure(2,2)
qc.measure(3,3)
# un-comment the following line to display the circuit.
display(qc.draw(output='mpl'))
# Executing the circuit in a simulator 1000 times
result = execute(qc,Aer.get_backend('qasm_simulator'),shots=1000).result()
# Calculate the XOR of measurement results
winCount = 0
for key, value in result.get_counts().items():
# calculate xy
xy = int(key[0]) * int(key[1])
# calculate xor of player outputs
xor = int(key[2], 2) ^ int(key[3], 2)
# count as a win of xy = xor of player outputs
if xy == xor:
winCount += value
print("Win probability : ", winCount/10)
view raw SquidGame.py hosted with ❤ by GitHub

q0 and q1 are the qubits we share between the players. First we entangle them and apply the x^-0.25 gate to one of them. q2 and q3 qubits are the qubits of guards given to the players. We apply the H gate to each of them so that those qubits can be 0,1 with equal probability.

As you can see, this time we achieved 85% win probability. which is more than the maximum 75% win rate we can achieve using the classical algorithms.

But this is sus isn’t it ? Those Hadammard gates we apply to the qubits of guards might be tampering with the results. Can we provide qubits which are in |0> and |1> states randomly without using Hadamard gates ?

Yes we can, let’s try that

from matplotlib import pyplot as plt
import numpy as np
from random import randrange
from qiskit import *
from qiskit.circuit.library.standard_gates import XGate
numPairs = 1000
winCount = 0
for pair in range(numPairs):
# Creating the circuit with 4 classical bits and 4 qbits
qc = QuantumCircuit(4,4)
# Creating the entanglement between players qubits
qc.h(1)
qc.cx(1,0)
# Applying X gate power raised to (-0.25)
new_gate = XGate().power(-0.25)
qc.append(new_gate, [0])
qc.barrier()
# Initialize input qubits randomly
toss1 = randrange(10)
if toss1 > 4:
qc.x(2)
toss2 = randrange(10)
if toss2 > 4:
qc.x(3)
qc.barrier()
# Players applying a controlled sqrt(x) gate to their qubits
# taking input qubits as controllers
qc.csx(2,0)
qc.csx(3,1)
qc.barrier()
# Players measure their qubits and inform the result to guards
qc.measure(0,0)
qc.measure(1,1)
# measuring the input qubits to calculate xy
qc.measure(2,2)
qc.measure(3,3)
# un-comment the following line to display the circuit.
#display(qc.draw(output='mpl'))
# Executing the circuit in a simulator once
result = execute(qc,Aer.get_backend('qasm_simulator'),shots=1).result()
# Calculate the XOR of measurement results
for key, value in result.get_counts().items():
# calculate xy
xy = int(key[0]) * int(key[1])
# calculate xor of player outputs
xor = int(key[2], 2) ^ int(key[3], 2)
# count as a win of xy = xor of player outputs
if xy == xor:
winCount += value
print("Win probability : ", winCount/10)
view raw SquidGame2.py hosted with ❤ by GitHub

This time we are generating random numbers and depending on the resuts, apply X gate to the guard’s qubits. This removes the equal superposition created by Hadamard gates and gives us clean |0> and |1> qubits.

After running this program you can see the win percentage left unchanged. Still we can achieve >85% win probability.

So, how can we explain this ?

I still don’t know :p

But someday in future I will 🙂

Lets meet with the explanation in a future blog.

Thank You!