コード例 #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()))
コード例 #2
0
 def testPRCorrBetweenAlice1andBobAndLocalOtherwiseIsNotInPolytope(self):
     scenario = SequentialBellScenario([[2, 2], [2, 2]], [2, 2])
     expectedCorrelations = {
         ((x1, x2), y, (a1, a2), b):
         1 / 2 * int((a2 == 0) & (x1 * y == (a1 + b) % 2))
         for ((x1, x2), y, (a1, a2), b) in scenario.getTuplesOfEvents()
     }
     expectedBehaviour = Behaviour(scenario, expectedCorrelations)
     poly = SequentialBellPolytope(scenario)
     self.assertFalse(poly.contains(expectedBehaviour.getProbabilityList()))
コード例 #3
0
import numpy as np
from bellpolytope import BellPolytope
from bellscenario import BellScenario
from bellpolytopewithonewaycomm import BellPolytopeWithOneWayCommunication
from ppl import Variable, Generator_System, C_Polyhedron, point
from sequentialbellpolytope import SequentialBellPolytope
from sequentialbellscenario import SequentialBellScenario

if __name__ == '__main__':

    outputsAliceSeq = [[2, 2], [2, 2]]
    outputsBob = [2, 2]
    scenario = SequentialBellScenario(outputsAliceSeq, outputsBob)

    variables = [Variable(i) for i in range(len(scenario.getTuplesOfEvents()))]
    gs = Generator_System()

    for v in BellPolytopeWithOneWayCommunication(
            SequentialBellPolytope(scenario)).getGeneratorForVertices():
        prob = v.getProbabilityList()
        gs.insert(point(sum(prob[i] * variables[i] for i in range(len(prob)))))

    poly = C_Polyhedron(gs)
    constraints = poly.constraints()

    for constraint in constraints:
        inequality = str(constraint.inhomogeneous_term().__float__()) + ' '
        for coef in constraint.coefficients():
            inequality = inequality + str(-coef.__float__()) + ' '
        print(inequality)