Skip to content

Instantly share code, notes, and snippets.

@mtrencseni
Created September 11, 2024 17:20
Show Gist options
  • Save mtrencseni/de13f766911aaaf5bfd5d4636c109dbb to your computer and use it in GitHub Desktop.
Save mtrencseni/de13f766911aaaf5bfd5d4636c109dbb to your computer and use it in GitHub Desktop.
def generate_composite():
composite = {}, {}
return composite
def split(composite):
left = {'value': composite[0]}
right = {'value': composite[1]}
# we enable both left and right parts to peek at each other
# in physics, this is called action-at-a-distance
left['other'] = right
right['other'] = left
return left, right
def measure_A_H(q):
# the particle remembers which measurement was performed and what the result was
# in itself, this is not cheating
q['measure'] = 'H'
q['result'] = 1
return q['result']
def measure_A_T(q):
q['measure'] = 'T'
q['result'] = 1
return q['result']
def measure_B_H(q):
# always return what Alice measured
q['result'] = q['other']['result']
return q['result']
def measure_B_T(q):
# condition on which measurement Alice performced and use her result
q['result'] = q['other']['result'] if q['other']['measure'] == 'H' else -1*q['other']['result']
return q['result']
bell_experiment(N=1000*1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment