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 3(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 1,1b1,q1 for Alice and 2,2b2,q2 are Bob.
The classical bits are each the result of the toss of a fair coin. But these are not yet revealed to Alice/Bob.
The qubits of Alice/Bob are entangled so that ||12=12(||00+||11)|q1q2=12(|00+|11).
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 1,2z1,z2
They win if 12=12b1b2=z1z2.
The best they can do without the aid of qubits is a winning probability of 0.750.75 that can be obtained by simply each responding with a 00(the only way they lose is if 1=2=1b1=b2=1 which is assumed to happen with 1/41/4 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 alice_response(qcircuit, b1, qbit, cbit) that inputs a the coin toss result for alice b1, 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 bob_response(qcircuit, b2, qbit, cbit) for Bob.
this is what I have so far:
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
def create_entangled_state(qc):
qc.h(0) # Apply Hadamard to the first qubit
qc.cx(0,1)
def alice_response(qc, b1, qbit, cbit):
# If Alice's bit is 1, apply Hadamard
if b1==1:
qc.h(qbit) # Create superposition
# Measure the qubit
qc.measure(qbit, cbit)
def bob_response(qc, b2, qbit, cbit):
# If Bob's bit is 1, apply Y gate
if b2==1:
qc.y(qbit) # Change measurement basis
# Measure the qubit
qc.measure(qbit, cbit)
this is the test cell that I can't change. My code won't pass the 'create_and_run_circuit(False, True):
from qiskit import transpile, Aer, QuantumRegister, ClassicalRegister, QuantumCircuit
def create_and_run_circuit(b1, b2):
# let's collect the counts for b1=1, b2=1
qbits11= QuantumRegister(2, 'qbit')
cbits11= ClassicalRegister(2,'z')
# create the bell state
print(f'Circuit for b1={b1} and b2={b2}')
qc_11= QuantumCircuit(qbits11, cbits11)
qc_11.h(qbits11[0])
qc_11.cx(qbits11[0], qbits11[1])
qc_11.barrier()
alice_response(qc_11, b1, qbits11[0], cbits11[0])
bob_response(qc_11, b2, qbits11[1], cbits11[1])
display(qc_11.draw('mpl', style='iqp'))
# simulate
# test
simulator = Aer.get_backend('aer_simulator')
circ11= transpile(qc_11, simulator)
# Run and get counts
result = simulator.run(qc_11).result()
counts = result.get_counts(circ11)
print(counts)
return counts
success_count =0
counts = create_and_run_circuit(True, True)
assert '01' in counts, 'Your result for b1= True and b2= True must have non-zero amplitude for |01>'
assert '10' in counts, 'Your result for b1= True and b2= True must have non-zero amplitude for |10>'
success_count +=(counts['01']+ counts['10'])
counts = create_and_run_circuit(True, False)
assert '00' in counts, 'Your result for b1= True and b2= False must have non-zero amplitude for |01>'
assert '11' in counts, 'Your result for b1= True and b2= False must have non-zero amplitude for |10>'
success_count +=(counts['00']+ counts['11'])
counts = create_and_run_circuit(False, True)
assert '00' in counts, 'Your result for b1= False and b2= True must have non-zero amplitude for |01>'
assert '11' in counts, 'Your result for b1= False and b2= True must have non-zero amplitude for |10>'
success_count +=(counts['00']+ counts['11'])
counts = create_and_run_circuit(False, False)
assert '00' in counts, 'Your result for b1= False and b2= False must have non-zero amplitude for |01>'
assert '11' in counts, 'Your result for b1= False and b2= False must have non-zero amplitude for |10>'
success_count +=(counts['00']+ counts['11'])
print(f'Probability of Alice/Bob Winning is estimated to be: {success_count/(4*1024)}')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!