Created by Vincent Russo. Supported by the Unitary Fund.

- Open source library for studying common objects in quantum information.
- Tools for entanglement theory, nonlocal games, quantum state distinguishability, etc.
- More "computer science" less "physics" focused.

Quantum information consists of:

States

Channels

Measurements

States

Channels

Measurements

**States**: Data to be processed.**Channels**: Operations to perform.**Measurements**: Result of operations on data.

- Generalization of linear programming.
- Powerful tool with many applications in quantum information..
- SDPs are efficiently solvable (polynomial time).
- Software packages for solving SDPs exist (cvxpy).

```
from toqito.states import bell
bell(0)
[[0.70710678],
[0. ],
[0. ],
[0.70710678]]
```

$$\texttt{bell(0)} = \frac{1}{\sqrt{2}} \left( |00 \rangle + |11 \rangle \right)$$

```
from toqito.states import bell
# Density matrices corresponding to Bell states.
rho_0 = bell(0) * bell(0).conj().T
rho_1 = bell(1) * bell(1).conj().T
```

$$\rho_0 = \frac{1}{2} \left( |0\rangle \langle 0| + |0 \rangle \langle 1 | + |1 \rangle \langle 0| + |1 \rangle \langle 1|\right)$$

$$\rho_1 = \frac{1}{2} \left( |0\rangle \langle 0| - |0 \rangle \langle 1 | - |1 \rangle \langle 0| + |1 \rangle \langle 1|\right)$$

```
from toqito.states import bell
from toqito.channels import partial_trace, partial_transpose
from toqito.matrix_ops import tensor
from toqito.state_props import is_pure
from toqito.state_metrics import fidelity
# Density matrices corresponding to Bell states.
rho_0 = bell(0) * bell(0).conj().T
rho_1 = bell(1) * bell(1).conj().T
# Compute tensor product of density matrices.
sigma = tensor(rho_0, rho_1)
# Trace out Alice's subsystem of the state.
partial_trace(sigma, sys=[1, 3], dim=[2, 2, 2, 2])
[[0.25 0. 0. 0. ]
[0. 0.25 0. 0. ]
[0. 0. 0.25 0. ]
[0. 0. 0. 0.25]]
# Compute partial transpose of rho_0.
partial_transpose(rho_0)
[[0.5 0. 0. 0. ]
[0. 0. 0.5 0. ]
[0. 0.5 0. 0. ]
[0. 0. 0. 0.5]]
# Check if rho_0 is a pure state.
is_pure(rho_0)
True
# Fidelity between states rho_0 and rho_1.
fidelity(rho_0, rho_1)
0
# Fidelity between identical states.
fidelity(rho_0, rho_0)
1
```

Play cooperatively. Cannot communicate once game begins.

Gives questions. Takes answers. Decides fate.

- Referee gives "x" to Alice and "y" to Bob.
- Alice responds with "a" and Bob responds with "b".
- Referee decides fate based on questions (x,y) and answers (a,b).

$$ a \oplus b = x \land y$$

```
import numpy as np
from toqito.nonlocal_games.xor_game import XORGame
# The probability matrix.
prob_mat = np.array([[1/4, 1/4], [1/4, 1/4]])
# The predicate matrix.
pred_mat = np.array([[0, 0], [0, 1]])
```

Classical and quantum value of the CHSH game.

```
import numpy as np
from toqito.nonlocal_games.xor_game import XORGame
# The probability matrix.
prob_mat = np.array([[1/4, 1/4], [1/4, 1/4]])
# The predicate matrix.
pred_mat = np.array([[0, 0], [0, 1]])
# Define CHSH game from matrices.
chsh = XORGame(prob_mat, pred_mat)
# Classical value of the CHSH game.
# Value of 0.75 which is 3/4.
chsh.classical_value()
0.75
# Quantum value of the CHSH game.
# Value is 0.8536 \approx cos^2(pi/8).
chsh.quantum_value()
0.8535533
```

- The CHSH game is an XOR game.
- XOR games are a subset of nonlocal games.
- Calculating the quantum value of general nonlocal games is hard.

State randomly selected from set. What state was given?

**LOCC**: difficult to handle mathematically: difficult to design protocols/prove bounds.**SEP**: nicer structure than LOCC; optimizing over this set is NP-hard.**PPT**: nice structure; efficient optimization via SDP.

```
from toqito.states import bell
from toqito.state_opt import state_distinguishability
from toqito.state_opt import ppt_distinguishability
from toqito.state_opt import symmetric_extension_hierarchy
# Define the list of states.
states = [bell(0), bell(1), bell(2), bell(3)]
# Probability with which the state is selected.
probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]
# Distinguishing via global measurements.
state_distinguishability(states, probs)
1
# Distinguishing via PPT measurements.
ppt_distinguishability(states, probs)
0.5
# Hierarchy of SDPs converge to separable value (for some level).
symmetric_extension_hierarchy(states, probs, level=2)
0.5
```

Distinguishing Bell states via global, PPT, and separable measurements.

```
from toqito.states import bell
from toqito.state_opt import state_distinguishability
from toqito.state_opt import ppt_distinguishability
from toqito.state_opt import symmetric_extension_hierarchy
# Define the list of states.
states = [bell(0), bell(1), bell(2), bell(3)]
# Probability with which the state is selected.
probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]
# Distinguishing via global measurements.
state_distinguishability(states, probs)
1
# Distinguishing via PPT measurements.
ppt_distinguishability(states, probs)
0.5
# Hierarchy of SDPs converge to separable value (for some level).
symmetric_extension_hierarchy(states, probs, level=2)
0.5
```

It is known that distinguishing the Bell states via PPT, SEP, and LOCC yields 1/2.

- GitHub: vprusso/toqito

- Website: vprusso.github.io/toqito

- Documentation toqito.readthedocs.io