Example #1
0
    def testSingletBetweenAlice1AndBobAndLocalOtherwiseIsNotInPolytope(self):
        scenario = SequentialBellScenario([[2, 2], [2, 2]], [2, 2])
        alice1blochVectors = [[1, 0, 0], [0, 1, 0]]
        alice1Observables = list(
            map(lambda bloch: createQubitObservable(bloch),
                alice1blochVectors))
        alice1Krauss = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), alice1Observables))

        bobUnBlochVectors = [[-1, -1, 0], [-1, 1, 0]]
        bobObservables = list(
            map(lambda bloch: createQubitObservable(bloch), bobUnBlochVectors))
        bobEffects = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), bobObservables))

        psi = createMaxEntState(2)

        expectedCorrelations = {((x1, x2), y, (a1, a2), b): int(
            (a2 == 0)) * ((qt.tensor(alice1Krauss[x1][a1], bobEffects[y][b]) *
                           psi * psi.dag()).tr())
                                for ((x1, x2), y, (a1, a2),
                                     b) in scenario.getTuplesOfEvents()}
        expectedBehaviour = Behaviour(scenario, expectedCorrelations)
        poly = SequentialBellPolytope(scenario)
        self.assertFalse(poly.contains(expectedBehaviour.getProbabilityList()))
Example #2
0
    def testRandProjMeasBetweenAlice1andBob(self):
        scenario = SequentialBellScenario([[2, 2], [2, 2]], [2, 2])
        alice1blochVectors = [[1, 0, 0], [0, 1, 0]]
        alice1Observables = list(
            map(lambda bloch: createQubitObservable(bloch),
                alice1blochVectors))
        alice1Krauss = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), alice1Observables))

        phases = [
            np.random.uniform(-np.pi / 2, np.pi / 2),
            np.random.uniform(-np.pi / 2, np.pi / 2)
        ]
        alice2blochVectors = [[np.sin(theta), 0,
                               np.cos(theta)] for theta in phases]
        alice2Observables = list(
            map(lambda bloch: createQubitObservable(bloch),
                alice2blochVectors))
        alice2Effects = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), alice2Observables))

        phasesBob = [
            np.random.uniform(-np.pi / 2, np.pi / 2),
            np.random.uniform(-np.pi / 2, np.pi / 2)
        ]
        bobVectors = [[np.sin(theta), 0, np.cos(theta)] for theta in phasesBob]
        bobObservables = list(
            map(lambda bloch: createQubitObservable(bloch), bobVectors))
        bobEffects = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), bobObservables))

        aux = alice1Krauss
        alice1Krauss = alice2Effects
        alice2Effects = aux

        psi = createMaxEntState(2)
        rho = psi * psi.dag()
        expectedCorrelations = {}
        for x1 in range(2):
            for a1 in range(2):
                postMeasrmntState = qt.tensor(
                    alice1Krauss[x1][a1], qt.qeye(2)) * rho * (qt.tensor(
                        alice1Krauss[x1][a1], qt.qeye(2))).dag()
                for x2, y, a2, b in product(range(2), repeat=4):
                    expectedCorrelations[(x1, x2), y, (a1, a2), b] = (
                        qt.tensor(alice2Effects[x2][a2], bobEffects[y][b]) *
                        postMeasrmntState).tr().real
        expectedBehaviour = Behaviour(scenario, expectedCorrelations)

        poly = BellPolytopeWithOneWayCommunication(
            SequentialBellPolytope(scenario))
        self.assertTrue(poly.contains(expectedBehaviour.getProbabilityList()),
                        'phases:' + str(phases[0]) + ', ' + str(phases[1]))
Example #3
0
    def testCHSHBetweenAlice1AndBobAndIdentityInAlice2IsInPolytope(self):
        scenario = SequentialBellScenario([[2, 2], [2, 2]], [2, 2])
        alice1blochVectors = [[1, 0, 0], [0, 1, 0]]
        alice1Observables = list(
            map(lambda bloch: createQubitObservable(bloch),
                alice1blochVectors))
        alice1Krauss = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), alice1Observables))

        alice2Effects = [[qt.qeye(2), 0 * qt.qeye(2)],
                         [qt.qeye(2), 0 * qt.qeye(2)]]

        bobUnBlochVectors = [[-1, -1, 0], [-1, 1, 0]]
        bobObservables = list(
            map(lambda bloch: createQubitObservable(bloch), bobUnBlochVectors))
        bobEffects = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), bobObservables))

        psi = createMaxEntState(2)

        rho = psi * psi.dag()
        expectedCorrelations = {}
        for x1 in range(2):
            for a1 in range(2):
                postMeasrmntState = qt.tensor(
                    alice1Krauss[x1][a1], qt.qeye(2)) * rho * (qt.tensor(
                        alice1Krauss[x1][a1], qt.qeye(2))).dag()
                for x2, y, a2, b in product(range(2), repeat=4):
                    expectedCorrelations[(x1, x2), y, (a1, a2), b] = (
                        qt.tensor(alice2Effects[x2][a2], bobEffects[y][b]) *
                        postMeasrmntState).tr().real
        expectedBehaviour = Behaviour(scenario, expectedCorrelations)

        poly = BellPolytopeWithOneWayCommunication(
            SequentialBellPolytope(scenario))
        self.assertTrue(poly.contains(expectedBehaviour.getProbabilityList()))
Example #4
0
    alice1outputs = [2, 2]
    alice2outputs = [2, 2, 3]
    bobOutputs = [2, 2]
    scenario = SequentialBellScenario([alice1outputs, alice2outputs],
                                      bobOutputs)

    epsilon = np.pi / 4 - 0.1
    plus = 1 / np.sqrt(2) * (qt.basis(2, 0) + qt.basis(2, 1))
    minus = 1 / np.sqrt(2) * (qt.basis(2, 0) - qt.basis(2, 1))
    Kplus = np.cos(epsilon) * plus * plus.dag() + np.sin(
        epsilon) * minus * minus.dag()
    Kminus = -np.cos(epsilon) * minus * minus.dag() + np.sin(
        epsilon) * plus * plus.dag()

    alice1Krauss = [
        projectorsForQubitObservable(createQubitObservable([0, 0, 1])),
        [Kplus, Kminus]
    ]

    alice2blochVectors = [[0, 0, 1], [1, 0, 0]]
    alice2Observables = list(
        map(lambda bloch: createQubitObservable(bloch), alice2blochVectors))
    alice2Effects = list(
        map(
            lambda qubitObservable: projectorsForQubitObservable(
                qubitObservable), alice2Observables))
    trineAlice2 = [[0, 0, 1],
                   [np.sin(2 * np.pi / 3), 0,
                    np.cos(2 * np.pi / 3)],
                   [np.sin(4 * np.pi / 3), 0,
                    np.cos(4 * np.pi / 3)]]
Example #5
0
    def testMeasurementsOverSeparableStateAreLocal(self):
        alice1outputs = [2, 2]
        alice2outputs = [2, 3]
        bobOutputs = [2, 2]
        scenario = SequentialBellScenario([alice1outputs, alice2outputs],
                                          bobOutputs)

        epsilon = 0
        plus = 1 / np.sqrt(2) * (qt.basis(2, 0) + qt.basis(2, 1))
        minus = 1 / np.sqrt(2) * (qt.basis(2, 0) - qt.basis(2, 1))
        Kplus = np.cos(epsilon) * plus * plus.dag() + np.sin(
            epsilon) * minus * minus.dag()
        Kminus = -np.cos(epsilon) * minus * minus.dag() + np.sin(
            epsilon) * plus * plus.dag()

        alice1Krauss = [
            projectorsForQubitObservable(createQubitObservable([0, 0, 1])),
            [Kplus, Kminus]
        ]

        alice2blochVectors = [[0, 0, 1]]
        alice2Observables = list(
            map(lambda bloch: createQubitObservable(bloch),
                alice2blochVectors))
        alice2Effects = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), alice2Observables))
        trineAlice2 = [[0, 0, 1],
                       [np.sin(2 * np.pi / 3), 0,
                        np.cos(2 * np.pi / 3)],
                       [np.sin(4 * np.pi / 3), 0,
                        np.cos(4 * np.pi / 3)]]
        paulies = [qt.sigmax(), qt.sigmay(), qt.sigmaz()]
        alice2Effects.append(
            list(
                map(
                    lambda bloch: effectForQubitPovm(
                        1 / 3, sum([paulies[i] * bloch[i] for i in range(3)])),
                    trineAlice2)))

        mu = np.arctan(np.sin(2 * epsilon))
        bobUnBlochVectors = [[np.sin(mu), 0, np.cos(mu)],
                             [-np.sin(mu), 0, np.cos(mu)]]
        bobObservables = list(
            map(lambda bloch: createQubitObservable(bloch), bobUnBlochVectors))
        bobEffects = list(
            map(
                lambda qubitObservable: projectorsForQubitObservable(
                    qubitObservable), bobObservables))

        psi = qt.tensor(qt.basis(2, 0), qt.basis(2, 0))
        rho = psi * psi.dag()
        expectedCorrelations = {}
        for x1, x2, y in product(range(len(alice1outputs)),
                                 range(len(alice2outputs)),
                                 range(len(bobOutputs))):
            for a1, a2, b in product(range(alice1outputs[x1]),
                                     range(alice2outputs[x2]),
                                     range(bobOutputs[y])):
                postMeasrmntState = qt.tensor(
                    alice1Krauss[x1][a1], qt.qeye(2)) * rho * (qt.tensor(
                        alice1Krauss[x1][a1], qt.qeye(2))).dag()
                expectedCorrelations[(x1, x2), y, (a1, a2), b] = (
                    qt.tensor(alice2Effects[x2][a2], bobEffects[y][b]) *
                    postMeasrmntState).tr().real

        expectedBehaviour = Behaviour(scenario, expectedCorrelations)

        polytope = BellPolytopeWithOneWayCommunication(
            SequentialBellPolytope(scenario))

        self.assertTrue(
            polytope.contains(expectedBehaviour.getProbabilityList()))
Example #6
0

if __name__ == '__main__':
    n = 4

    outputsAliceSequence = [2 for _ in range(n)]
    outputsBob = [2 for _ in range(n)] + [3]

    phi = lambda j: (j - 1) * np.pi / n
    phiprime = lambda j: (2 * j - 1) * np.pi / (2 * n)

    psi = createMaxEntState(2)

    aliceEffects = [
        projectorsForQubitObservable(
            createQubitObservable([np.sin(phi(j)), 0,
                                   np.cos(phi(j))])) for j in range(1, n + 1)
    ]

    bobEffects = [
        projectorsForQubitObservable(
            createQubitObservable(
                [np.sin(phiprime(j)), 0,
                 np.cos(phiprime(j))])) for j in range(1, n + 1)
    ]

    bobPostMeasurmentStates = [[
        1 / ((qt.tensor(effect, qt.qeye(2)) * psi * psi.dag()).tr()) *
        (qt.tensor(effect, qt.qeye(2)) * psi).ptrace(1)
        for effect in measurement
    ] for measurement in aliceEffects]
    usdState1 = bobPostMeasurmentStates[0][0]
Example #7
0
import numpy as np
from _functools import reduce
import qutip as qt
from bellpolytope import BellPolytope
from bellscenario import BellScenario
from qutipauxfunc import createQubitObservable, projectorsForQubitObservable,\
    effectForQubitPovm, addEffectsForAbortOutcomes, createMaxEntState,\
    computeDistributionFromStateAndEffects
    
if __name__ == '__main__':
    
    outputsAlice = [3,3,3,3]
    outputsBob = [3,3,3,5]
    
    aliceBlochVectors = [[1,1,1],[1,-1,-1],[-1,1,-1],[-1,-1,1]]
    aliceObservables = list(map(lambda bloch : createQubitObservable(bloch),aliceBlochVectors))
    aliceEffects = list(map(lambda qubitObservable : projectorsForQubitObservable(qubitObservable),aliceObservables))
    
    bobObservables=[qt.sigmax(),qt.sigmay(),qt.sigmaz()]
    bobEffects = list(map(lambda qubitObservable : projectorsForQubitObservable(qubitObservable),bobObservables))
    
    bobEffects += [list(map(lambda bloch : 
                           effectForQubitPovm(1/4, createQubitObservable(bloch)),aliceBlochVectors))]
    
    aliceEffects = addEffectsForAbortOutcomes(aliceEffects,2)
    bobEffects = addEffectsForAbortOutcomes(bobEffects,2)
    
    psi=createMaxEntState(2)
    
    scenario=BellScenario(outputsAlice,outputsBob)
    poly = BellPolytope(scenario)