.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/extended_nonlocal_games/enlg_chsh.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_extended_nonlocal_games_enlg_chsh.py: The CHSH extended nonlocal game ===================================== Following our analysis of the BB84 game, let us now define another important extended nonlocal game, :math:`G_{CHSH}`. This game is defined by a winning condition reminiscent of the standard CHSH nonlocal game. .. GENERATED FROM PYTHON SOURCE LINES 11-52 Let :math:`\Sigma_A = \Sigma_B = \Gamma_A = \Gamma_B = \{0,1\}`, define a collection of measurements :math:`\{V(a,b|x,y) : a \in \Gamma_A, b \in \Gamma_B, x \in \Sigma_A, y \in \Sigma_B\} \subset \text{Pos}(\mathcal{R})` such that .. math:: \begin{aligned} V(0,0|0,0) = V(0,0|0,1) = V(0,0|1,0) = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}, \\ V(1,1|0,0) = V(1,1|0,1) = V(1,1|1,0) = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}, \\ V(0,1|1,1) = \frac{1}{2}\begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix}, \\ V(1,0|1,1) = \frac{1}{2} \begin{pmatrix} 1 & -1 \\ -1 & 1 \end{pmatrix}, \end{aligned} define .. math:: V(a,b|x,y) = \begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix} for all :math:`a \oplus b \not= x \land y`, and define :math:`\pi(0,0) = \pi(0,1) = \pi(1,0) = \pi(1,1) = 1/4`. In the event that :math:`a \oplus b \not= x \land y`, the referee's measurement corresponds to the zero matrix. If instead it happens that :math:`a \oplus b = x \land y`, the referee then proceeds to measure with respect to one of the measurement operators. This winning condition is reminiscent of the standard CHSH nonlocal game. We can encode :math:`G_{CHSH}` in a similar way using :code:`numpy` arrays as we did for :math:`G_{BB84}`. .. GENERATED FROM PYTHON SOURCE LINES 52-85 .. code-block:: Python :lineno-start: 53 # Define the CHSH extended nonlocal game. import numpy as np # The dimension of referee's measurement operators: dim = 2 # The number of outputs for Alice and Bob: a_out, b_out = 2, 2 # The number of inputs for Alice and Bob: a_in, b_in = 2, 2 # Define the predicate matrix V(a,b|x,y) \in Pos(R) chsh_pred_mat = np.zeros([dim, dim, a_out, b_out, a_in, b_in]) # V(0,0|0,0) = V(0,0|0,1) = V(0,0|1,0). chsh_pred_mat[:, :, 0, 0, 0, 0] = np.array([[1, 0], [0, 0]]) chsh_pred_mat[:, :, 0, 0, 0, 1] = np.array([[1, 0], [0, 0]]) chsh_pred_mat[:, :, 0, 0, 1, 0] = np.array([[1, 0], [0, 0]]) # V(1,1|0,0) = V(1,1|0,1) = V(1,1|1,0). chsh_pred_mat[:, :, 1, 1, 0, 0] = np.array([[0, 0], [0, 1]]) chsh_pred_mat[:, :, 1, 1, 0, 1] = np.array([[0, 0], [0, 1]]) chsh_pred_mat[:, :, 1, 1, 1, 0] = np.array([[0, 0], [0, 1]]) # V(0,1|1,1) chsh_pred_mat[:, :, 0, 1, 1, 1] = 1 / 2 * np.array([[1, 1], [1, 1]]) # V(1,0|1,1) chsh_pred_mat[:, :, 1, 0, 1, 1] = 1 / 2 * np.array([[1, -1], [-1, 1]]) # The probability matrix encode \pi(0,0) = \pi(0,1) = \pi(1,0) = \pi(1,1) = 1/4. chsh_prob_mat = np.array([[1 / 4, 1 / 4], [1 / 4, 1 / 4]]) .. GENERATED FROM PYTHON SOURCE LINES 86-91 Example: The unentangled value of the CHSH extended nonlocal game ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Similar to what we did for the BB84 extended nonlocal game, we can also compute the unentangled value of :math:`G_{CHSH}`. .. GENERATED FROM PYTHON SOURCE LINES 91-103 .. code-block:: Python :lineno-start: 92 # Calculate the unentangled value of the CHSH extended nonlocal game import numpy as np from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame # Define an ExtendedNonlocalGame object based on the CHSH game. chsh = ExtendedNonlocalGame(chsh_prob_mat, chsh_pred_mat) # The unentangled value is 3/4 = 0.75 print("The unentangled value is ", np.around(chsh.unentangled_value(), decimals=2)) .. rst-class:: sphx-glr-script-out .. code-block:: none The unentangled value is 0.75 .. GENERATED FROM PYTHON SOURCE LINES 104-105 We can also run multiple repetitions of :math:`G_{CHSH}`. .. GENERATED FROM PYTHON SOURCE LINES 105-117 .. code-block:: Python :lineno-start: 106 # The unentangled value of CHSH under parallel repetition. import numpy as np from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame # Define the CHSH game for two parallel repetitions. chsh_2_reps = ExtendedNonlocalGame(chsh_prob_mat, chsh_pred_mat, 2) # The unentangled value for two parallel repetitions is (3/4)**2 \approx 0.5625 print("The unentangled value for two parallel repetitions is ", np.around(chsh_2_reps.unentangled_value(), decimals=2)) .. rst-class:: sphx-glr-script-out .. code-block:: none The unentangled value for two parallel repetitions is 0.56 .. GENERATED FROM PYTHON SOURCE LINES 118-128 Note that strong parallel repetition holds as .. math:: \omega(G_{CHSH})^2 = \omega(G_{CHSH}^2) = \left(\frac{3}{4}\right)^2. Example: The non-signaling value of the CHSH extended nonlocal game ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To obtain an upper bound for :math:`G_{CHSH}`, we can calculate the non-signaling value. .. GENERATED FROM PYTHON SOURCE LINES 128-140 .. code-block:: Python :lineno-start: 129 # Calculate the non-signaling value of the CHSH extended nonlocal game. import numpy as np from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame # Define an ExtendedNonlocalGame object based on the CHSH game. chsh = ExtendedNonlocalGame(chsh_prob_mat, chsh_pred_mat) # The non-signaling value is 3/4 = 0.75 print("The non-signaling value is ", np.around(chsh.nonsignaling_value(), decimals=2)) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/toqito/envs/latest/lib/python3.11/site-packages/scs/__init__.py:83: UserWarning: Converting A to a CSC (compressed sparse column) matrix; may take a while. warn( The non-signaling value is 0.75 .. GENERATED FROM PYTHON SOURCE LINES 141-148 As we know that :math:`\omega(G_{CHSH}) = \omega_{ns}(G_{CHSH}) = 3/4` and that .. math:: \omega(G) \leq \omega^*(G) \leq \omega_{ns}(G) for any extended nonlocal game, :math:`G`, we may also conclude that :math:`\omega^*(G) = 3/4`. .. GENERATED FROM PYTHON SOURCE LINES 150-162 As we know that :math:`\omega(G_{CHSH}) = \omega_{ns}(G_{CHSH}) = 3/4` and that .. math:: \omega(G) \leq \omega^*(G) \leq \omega_{ns}(G) for any extended nonlocal game, :math:`G`, we may also conclude that :math:`\omega^*(G_{CHSH}) = 3/4`. So far, both the BB84 and CHSH examples have demonstrated cases where the unentangled and standard quantum values are equal. In the next tutorial, :ref:`sphx_glr_auto_examples_extended_nonlocal_games_enlg_mub.py` we will explore a game based on mutually unbiased bases that exhibits a strict quantum advantage, where :math:`\omega(G) < \omega^*(G)`. .. GENERATED FROM PYTHON SOURCE LINES 164-168 References ---------- .. footbibliography:: .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.239 seconds) .. _sphx_glr_download_auto_examples_extended_nonlocal_games_enlg_chsh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: enlg_chsh.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: enlg_chsh.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: enlg_chsh.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_