示例#1
0
    def test_ffl_game_classical_value_rep_2(self):
        """Classical value for the FFL game for 2 reps."""
        prob_mat, pred_mat = self.ffl_nonlocal_game()

        ffl = NonlocalGame(prob_mat, pred_mat, 2)
        res = ffl.classical_value()
        expected_res = 2 / 3
        self.assertEqual(np.isclose(res, expected_res), True)
示例#2
0
    def test_ffl_game_quantum_value_lower_bound_value_rep_2(self):
        """Lower bound on quantum value for the FFL game for 2 reps."""
        prob_mat, pred_mat = self.ffl_nonlocal_game()

        ffl = NonlocalGame(prob_mat, pred_mat, 2)
        res = ffl.quantum_value_lower_bound()
        expected_res = 2 / 3
        self.assertLessEqual(np.isclose(res, expected_res), True)
示例#3
0
    def test_chsh_game_classical_value(self):
        """Classical value for the CHSH game."""
        prob_mat, pred_mat = self.chsh_nonlocal_game()

        chsh = NonlocalGame(prob_mat, pred_mat)
        res = chsh.classical_value()
        expected_res = 3 / 4
        self.assertEqual(np.isclose(res, expected_res), True)
示例#4
0
    def test_chsh_game_nonsignaling_value_rep_2(self):
        """Non-signaling value for the CHSH game for 2 reps."""
        prob_mat, pred_mat = self.chsh_nonlocal_game()

        chsh = NonlocalGame(prob_mat, pred_mat, 2)
        res = chsh.nonsignaling_value()
        expected_res = 1
        self.assertEqual(np.isclose(res, expected_res, atol=0.5), True)
示例#5
0
    def test_ffl_game_nonsignaling_value_rep_2(self):
        """Non-signaling value for the FFL game for 2 reps."""
        prob_mat, pred_mat = self.ffl_nonlocal_game()

        ffl = NonlocalGame(prob_mat, pred_mat, 2)
        res = ffl.nonsignaling_value()
        expected_res = 2 / 3
        self.assertEqual(np.isclose(res, expected_res, atol=0.5), True)
示例#6
0
    def test_chsh_lower_bound(self):
        """Calculate the lower bound on the quantum value for the CHSH game."""
        prob_mat, pred_mat = self.chsh_nonlocal_game()
        chsh = NonlocalGame(prob_mat, pred_mat)
        res = chsh.quantum_value_lower_bound()

        # It may be possible for the lower bound to not be equal to the correct
        # quantum value (as it may get stuck in a local minimum), but it should
        # never be possible for the lower bound to attain a value higher than
        # the true quantum value.
        self.assertLessEqual(np.isclose(res, np.cos(np.pi / 8) ** 2, rtol=1e-02), True)
示例#7
0
    def test_chsh_game_classical_value_rep_2(self):
        r"""
        Classical value for the CHSH game for 2 reps.

        Note that for classical strategies, it is known that parallel repetition
        does *not* hold for the CHSH game, that is:

        w_c(CHSH \land CHSH) = 10/16 > 9/16 = w_c(CHSH) w_c(CHSH).
        """
        prob_mat, pred_mat = self.chsh_nonlocal_game()

        chsh = NonlocalGame(prob_mat, pred_mat, 2)
        res = chsh.classical_value()
        expected_res = 10 / 16
        self.assertEqual(np.isclose(res, expected_res), True)