Note
Click here to download the full example code
Separability and Entanglement Testing¶
Demonstrates how to use toqito to determine whether a quantum state is separable or entangled. Covers product states, Bell states, PPT entangled states, Werner states, and random density matrices.
Overview¶
Determining whether a quantum state is separable or entangled is one of the most fundamental problems in quantum information theory. A bipartite state \(\rho \in \text{D}(\mathcal{H}_A \otimes \mathcal{H}_B)\) is separable if it can be written as a convex combination of product states:
Otherwise, the state is entangled.
Note
Determining separability is NP-hard in general
1. The is_separable function in |toqito⟩
applies a hierarchy of increasingly powerful tests, returning
True (separable) or False (entangled) based on which test
provides a definitive answer.
The hierarchy of checks¶
The is_separable function runs through 13 tests in order:
- Trivial cases — one subsystem has dimension 1
- Pure states — Schmidt rank check
- Separable ball — closeness to maximally mixed state
- PPT criterion — necessary condition; sufficient for 2×2 and 2×3
- Plücker coordinates — 3×3 rank-4 PPT states
- Low-rank criteria — Horodecki et al. (2000)
- Reduction criterion
- Realignment / CCNR
- Rank-1 perturbation of identity
- 2×N specific checks — Johnston, Hildebrand
- Decomposable maps — Ha-Kye, Breuer-Hall witnesses
- Symmetric extension hierarchy — SDP-based (DPS)
Let's see these in action.
Example: Separable product state¶
A product state \(\rho = \rho_A \otimes \rho_B\) is always separable.
import numpy as np
from toqito.state_props import is_separable
# |+><+| ⊗ I/2
rho_a = np.array([[1, 1], [1, 1]]) / 2
rho_b = np.eye(2) / 2
rho_product = np.kron(rho_a, rho_b)
sep, reason = is_separable(rho_product)
print(f"Product state is separable: {sep} (reason: {reason})")
Out:
Example: Entangled Bell state¶
The Bell state \(|\Phi^+\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)\) is maximally entangled. The PPT criterion immediately detects this.
from toqito.states import bell
rho_bell = bell(0) @ bell(0).conj().T
sep, reason = is_separable(rho_bell)
print(f"Bell state is separable: {sep} (reason: {reason})")
Out:
Example: Werner states¶
Werner states are a one-parameter family that interpolates between separable and entangled:
For two qubits, a Werner state is separable if and only if \(p \leq 1/3\) (by the PPT criterion).
from toqito.states import bell
phi_plus = bell(0) @ bell(0).conj().T
identity_4 = np.eye(4) / 4
# Separable Werner state (p = 0.2)
werner_sep = 0.2 * phi_plus + 0.8 * identity_4
sep, reason = is_separable(werner_sep)
print(f"Werner(p=0.2) is separable: {sep} (reason: {reason})")
# Entangled Werner state (p = 0.5)
werner_ent = 0.5 * phi_plus + 0.5 * identity_4
sep, reason = is_separable(werner_ent)
print(f"Werner(p=0.5) is separable: {sep} (reason: {reason})")
Out:
Werner(p=0.2) is separable: True (reason: lies within the Gurvits-Barnum separable ball)
Werner(p=0.5) is separable: False (reason: NPT (Peres-Horodecki PPT criterion))
Example: Random density matrices¶
A random density matrix sampled from the Hilbert-Schmidt measure is
generically entangled for dimensions larger than 2×2. We can verify
this with |toqito⟩.
from toqito.rand import random_density_matrix
# Random 4x4 density matrix (2-qubit system)
rho_random = random_density_matrix(4, seed=42)
sep, reason = is_separable(rho_random)
print(f"Random state is separable: {sep} (reason: {reason})")
Out:
Example: States near the maximally mixed state¶
The Gurvits-Barnum separable ball criterion guarantees that states sufficiently close to \(I/d\) are separable. The maximally mixed state itself is trivially separable.
Maximally mixed state
rho_mixed = np.eye(4) / 4
sep, reason = is_separable(rho_mixed)
print(f"Maximally mixed state is separable: {sep} (reason: {reason})")
# Small perturbation of maximally mixed — still in the separable ball
rho_near_mixed = np.eye(4) / 4 + 0.001 * np.diag([1, -1, -1, 1])
rho_near_mixed = rho_near_mixed / np.trace(rho_near_mixed)
sep, reason = is_separable(rho_near_mixed)
print(f"Near-mixed state is separable: {sep} (reason: {reason})")
Out:
Maximally mixed state is separable: True (reason: lies within the Gurvits-Barnum separable ball)
Near-mixed state is separable: True (reason: lies within the Gurvits-Barnum separable ball)
The symmetric extension hierarchy¶
When the simpler criteria are inconclusive, is_separable falls back
to the symmetric extension (DPS) hierarchy 2.
This is an SDP-based test: if a state has a \(k\)-symmetric extension
for all \(k\), it is separable. If it fails at any level \(k\), it is
entangled.
The level parameter controls how many levels to check (default: 2).
Higher levels are more powerful but computationally more expensive.
mkdocs_gallery_thumbnail_path = 'figures/quantum_state_distinguish.svg'
Total running time of the script: ( 0 minutes 0.007 seconds)
Download Python source code: separability.py
Download Jupyter notebook: separability.ipynb
Gallery generated by mkdocs-gallery
-
Leonid Gurvits and Howard Barnum. Largest separable balls around the maximally mixed bipartite quantum state. Physical Review A, Dec 2002. URL: http://dx.doi.org/10.1103/PhysRevA.66.062311, doi:10.1103/physreva.66.062311. ↩
-
Andrew C. Doherty, Pablo A. Parrilo, and Federico M. Spedalieri. Complete family of separability criteria. Physical Review A, 69(2):022308, 2004. doi:10.1103/PhysRevA.69.022308. ↩