Question: Problem 3 ( Alice , Bob and Bell's Inequality ) In this problem, we will implement the protocol between Alice and Bob that was described
Problem Alice Bob and Bell's Inequality
In this problem, we will implement the protocol between Alice and Bob that was described in the video lecture on Bell's inequality. We would like you to examine that lecture video before attempting it
Alice and Bob are each given a classical bit and a qubit bq for Alice and bq are Bob.
The classical bits are each the result of the toss of a fair coin. But these are not yet revealed to AliceBob
The qubits of AliceBob are entangled so that qq
At a given moment in time, each of them gets to know their own bits.
They need to respond back with answers in the form of classical bits zz
They win if bbzz
The best they can do without the aid of qubits is a winning probability of that can be obtained by simply each responding with a the only way they lose is if bb which is assumed to happen with probability
We showed a protocol in the video that allows them to beat the classical probability limit Your goal is to implement that as part of a quantum circuit.
Implement the function aliceresponseqcircuit b qbit, cbit that inputs a the coin toss result for alice b Alice's qubit qbit entangled with Bob's but that does not matter here and a classical bit to measure into. There is no need to return any results: we will take care of that in the testing code where we will read the classical bit as cbit as Alice's response.
Implement similarly the function bobresponseqcircuit b qbit, cbit for Bob.
this is what I have so far:
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def createentangledstateqc:
qch # Apply Hadamard to the first qubit
qccx
def aliceresponseqc b qbit, cbit:
# If Alice's bit is apply Hadamard
if b:
qchqbit # Create superposition
# Measure the qubit
qcmeasureqbit cbit
def bobresponseqc b qbit, cbit:
# If Bob's bit is apply Y gate
if b:
qcyqbit # Change measurement basis
# Measure the qubit
qcmeasureqbit cbit
this is the test cell that I can't change. My code won't pass the 'createandruncircuitFalse True:
from qiskit import transpile, Aer, QuantumRegister, ClassicalRegister, QuantumCircuit
def createandruncircuitb b:
# let's collect the counts for b b
qbits QuantumRegister 'qbit'
cbits ClassicalRegisterz
# create the bell state
printfCircuit for bb and bb
qc QuantumCircuitqbits cbits
qchqbits
qccxqbits qbits
qcbarrier
aliceresponseqc b qbits cbits
bobresponseqc b qbits cbits
displayqcdrawmpl style'iqp'
# simulate
# test
simulator Aer.getbackendaersimulator'
circ transpileqc simulator
# Run and get counts
result simulator.runqcresult
counts result.getcountscirc
printcounts
return counts
successcount
counts createandruncircuitTrue True
assert in counts, 'Your result for b True and b True must have nonzero amplitude for
assert in counts, 'Your result for b True and b True must have nonzero amplitude for
successcount counts counts
counts createandruncircuitTrue False
assert in counts, 'Your result for b True and b False must have nonzero amplitude for
assert in counts, 'Your result for b True and b False must have nonzero amplitude for
successcount counts counts
counts createandruncircuitFalse True
assert in counts, 'Your result for b False and b True must have nonzero amplitude for
assert in counts, 'Your result for b False and b True must have nonzero amplitude for
successcount counts counts
counts createandruncircuitFalse False
assert in counts, 'Your result for b False and b False must have nonzero amplitude for
assert in counts, 'Your result for b False and b False must have nonzero amplitude for
successcount counts counts
printfProbability of AliceBob Winning is estimated to be: successcount
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
