-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from vprusso/state_exclusion_improve
Update and improvements to state exclusion code and applications.
- Loading branch information
Showing
16 changed files
with
246 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
"""Test random_state_vector.""" | ||
import numpy as np | ||
import pytest | ||
|
||
from toqito.rand import random_state_vector | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
"""Test random_unitary.""" | ||
import numpy as np | ||
import pytest | ||
|
||
from toqito.matrix_props import is_unitary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
"""Test state_exclusion.""" | ||
import numpy as np | ||
import pytest | ||
|
||
from toqito.states import bell | ||
from toqito.matrices import standard_basis | ||
from toqito.state_opt import state_exclusion | ||
|
||
|
||
def test_conclusive_state_exclusion(): | ||
"""Conclusive state exclusion for single vector state.""" | ||
e_0, e_1 = standard_basis(2) | ||
states = [ | ||
1 / np.sqrt(2) * (np.kron(e_0, e_0) + np.kron(e_1, e_1)), | ||
1 / np.sqrt(2) * (np.kron(e_0, e_0) - np.kron(e_1, e_1)), | ||
1 / np.sqrt(2) * (np.kron(e_0, e_1) + np.kron(e_1, e_0)), | ||
1 / np.sqrt(2) * (np.kron(e_0, e_1) - np.kron(e_1, e_0)), | ||
] | ||
# No probabilities provided | ||
primal_value, _ = state_exclusion(vectors=states, probs=None, primal_dual="primal") | ||
np.testing.assert_equal(np.isclose(primal_value, 0), True) | ||
e_0, e_1 = standard_basis(2) | ||
|
||
dual_value, _ = state_exclusion(vectors=states, probs=None, primal_dual="dual") | ||
np.testing.assert_equal(np.isclose(dual_value, 0), True) | ||
|
||
# Probabilities provided | ||
primal_value, _ = state_exclusion( | ||
vectors=states, probs=[1 / 4, 1 / 4, 1 / 4, 1 / 4], primal_dual="primal" | ||
) | ||
np.testing.assert_equal(np.isclose(primal_value, 0), True) | ||
@pytest.mark.parametrize("vectors, probs, solver, primal_dual, expected_result", [ | ||
# Bell states (default uniform probs with primal). | ||
([bell(0), bell(1), bell(2), bell(3)], None, "cvxopt", "primal", 0), | ||
# Bell states (default uniform probs with dual). | ||
([bell(0), bell(1), bell(2), bell(3)], None, "cvxopt", "dual", 0), | ||
# Bell states uniform probs with primal. | ||
([bell(0), bell(1), bell(2), bell(3)], [1/4, 1/4, 1/4, 1/4], "cvxopt", "primal", 0), | ||
# Bell states uniform probs with dual. | ||
([bell(0), bell(1), bell(2), bell(3)], [1/4, 1/4, 1/4, 1/4], "cvxopt", "dual", 0), | ||
]) | ||
def test_conclusive_state_exclusion(vectors, probs, solver, primal_dual, expected_result): | ||
val, _ = state_exclusion(vectors=vectors, probs=probs, solver=solver, primal_dual=primal_dual) | ||
assert abs(val- expected_result) <=1e-8 | ||
|
||
dual_value, _ = state_exclusion( | ||
vectors=states, probs=[1 / 4, 1 / 4, 1 / 4, 1 / 4], primal_dual="dual" | ||
) | ||
np.testing.assert_equal(np.isclose(dual_value, 0), True) | ||
|
||
@pytest.mark.parametrize("vectors, probs, solver, primal_dual", [ | ||
# Bell states (default uniform probs with dual). | ||
([bell(0), bell(1), bell(2), e_0], None, "cvxopt", "dual"), | ||
]) | ||
def test_state_exclusion_invalid_vectors(vectors, probs, solver, primal_dual): | ||
with pytest.raises(ValueError): | ||
state_exclusion(vectors=vectors, probs=probs, solver=solver, primal_dual=primal_dual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"""Check if set of states are antidistinguishable.""" | ||
import numpy as np | ||
from toqito.state_opt import state_exclusion | ||
|
||
|
||
def is_antidistinguishable(states: list[np.ndarray]) -> bool: | ||
r""" | ||
Check whether a collection of vectors are antidistinguishable or not [TK18]_. | ||
The ability to determine whether a set of quantum states are antidistinguishable can be obtained via the state | ||
exclusion SDP [BJOP14]_ such that we ignore the associated probabilities with which the states are chosen from the set of | ||
vectors. | ||
Examples | ||
======== | ||
The set of Bell states are an example of antidistinguishable states. Recall that the Bell states are defined as: | ||
.. math:: | ||
u_1 = \frac{1}{\sqrt{2}} \left(|00\rangle + |11\rangle\right), &\quad | ||
u_2 = \frac{1}{\sqrt{2}} \left(|00\rangle - |11\rangle\right), \\ | ||
u_3 = \frac{1}{\sqrt{2}} \left(|01\rangle + |10\rangle\right), &\quad | ||
u_4 = \frac{1}{\sqrt{2}} \left(|01\rangle - |10\rangle\right). | ||
It can be checked in :code`toqito` that the Bell states are antidistinguishable: | ||
>>> from toqito.states import bell | ||
>>> from toqito.state_props import is_antidistinguishable | ||
>>> | ||
>>> bell_states = [bell(0), bell(1), bell(2), bell(3)] | ||
>>> is_antidistinguishable(bell_states) | ||
True | ||
Consider the following measurement operators | ||
.. math:: | ||
M_i = \frac{1}{3}\left(\mathbb{I}_{\mathcal{X} - u_i u_i^*\right) | ||
for all :math:`1 \leq i \leq 4`. It can be verified that these constitute a valid set of POVMs, that is | ||
:math:`\sum_{i=1}^4 M_i = \mathbb{I}_{\mathcal{X}}` and :math:`M_i \in \text{Pos}(\mathcal{X})` for all :math:`1 | ||
\leq i \leq 4`. It may also be verified that | ||
.. math:: | ||
\sum_{i=1}^4 \langle M_i, u_i u_i^* \rangle = 0, | ||
and hence, the Bell states are antidistinguishable. | ||
References | ||
========== | ||
.. [TK18] Heinosaari, Teiko, and Oskari Kerppo. | ||
"Antidistinguishability of pure quantum states." | ||
Journal of Physics A: Mathematical and Theoretical 51.36 (2018): 365303. | ||
https://arxiv.org/abs/1804.10457 | ||
.. [BJOP14] Bandyopadhyay, Somshubhro, Jain, Rahul, Oppenheim, Jonathan, Perry, Christopher | ||
"Conclusive exclusion of quantum states" | ||
Physical Review A 89.2 (2014): 022336. | ||
arXiv:1306.4683 | ||
:param states: A set of vectors consisting of quantum states to determine the antidistinguishability of. | ||
:return: :code:`True` if the vectors are antidistinguishable; :code:`False` otherwise. | ||
""" | ||
probs = [1] * len(states) | ||
|
||
# The dual problem is less computationally intensive to compute in comparison to primal. | ||
opt_val, _ = state_exclusion(vectors=states, probs=probs, primal_dual="dual") | ||
return np.isclose(opt_val, 0) |
Oops, something went wrong.