Two-qubit states, separability and the spin entanglement witness (Bose et al. 2017)
DefinitionBMV2017_defsShared vocabulary of the mission. Each test mass carries a qubit ( or , or ); two-qubit objects are indexed with mass 1 first. Defines the Pauli matrices; the evolved state (Eq. (2), spin form on p. 3, global phase omitted); product vectors; ; the partial trace over mass 2 and the reduced-state purity ; separable states (finite convex combinations of products of density matrices); the witness (p. 3); and its variant with each spin's operators conjugated by (p. 4).
import Mathlib
import Definitions.Def_PeresTerno_kraus_basics
/-!
# The spin entanglement witness for quantum gravity
Definitions for the mission drafted from S. Bose, A. Mazumdar, G. W. Morley, H. Ulbricht,
M. Toroš, M. Paternostro, A. A. Geraci, P. F. Barker, M. S. Kim and G. Milburn,
*A Spin Entanglement Witness for Quantum Gravity*, Phys. Rev. Lett. 119, 240401 (2017),
arXiv:1707.06050v1.
Each test mass `j = 1, 2` carries a qubit: the orbital states `|L⟩, |R⟩` (Eqs. (1)–(2)),
or after the Stern–Gerlach interferometry the spin states `|↑⟩, |↓⟩` (p. 3). Both are encoded
as `Fin 2` with `0 ↦ |L⟩ / |↑⟩` and `1 ↦ |R⟩ / |↓⟩`. Two-qubit vectors and matrices are
indexed by `Qubit × Qubit`, the first component being mass 1.
-/
namespace BMV2017
open Matrix
open scoped Kronecker ComplexOrder
noncomputable section
/-- A qubit: `0 ↦ |L⟩` (or `|↑⟩`), `1 ↦ |R⟩` (or `|↓⟩`). -/
abbrev Qubit := Fin 2
/-- Pauli matrix `σ_x`. -/
def σx : Matrix Qubit Qubit ℂ := !![0, 1; 1, 0]
/-- Pauli matrix `σ_y`. -/
def σy : Matrix Qubit Qubit ℂ := !![0, -Complex.I; Complex.I, 0]
/-- Pauli matrix `σ_z` (`|↑⟩` has eigenvalue `+1`). -/
def σz : Matrix Qubit Qubit ℂ := !![1, 0; 0, -1]
/-- Eq. (2) (and the spin state on p. 3, overall phase omitted): the two-qubit state
`½ (|00⟩ + e^{iΔφ_LR} |01⟩ + e^{iΔφ_RL} |10⟩ + |11⟩)`, with `α = Δφ_LR` and `β = Δφ_RL`. -/
def psiEnd (α β : ℝ) : Qubit × Qubit → ℂ :=
fun p => (1 / 2 : ℂ) *
(!![1, Complex.exp (α * Complex.I); Complex.exp (β * Complex.I), 1] : Matrix Qubit Qubit ℂ)
p.1 p.2
/-- A two-qubit vector factorizes as `u ⊗ w`. -/
def IsProductVector (v : Qubit × Qubit → ℂ) : Prop :=
∃ u w : Qubit → ℂ, ∀ i j, v (i, j) = u i * w j
/-- The density matrix `|v⟩⟨v|` of a vector `v`. -/
def pureDM (v : Qubit × Qubit → ℂ) : Matrix (Qubit × Qubit) (Qubit × Qubit) ℂ :=
Matrix.of fun p q => v p * star (v q)
/-- Partial trace over the second qubit: `(Tr₂ ρ)_{ij} = ∑ₖ ρ_{(i,k),(j,k)}`
(the reduced state of mass 1). -/
def ptrace₂ (ρ : Matrix (Qubit × Qubit) (Qubit × Qubit) ℂ) : Matrix Qubit Qubit ℂ :=
Matrix.of fun i j => ∑ k, ρ (i, k) (j, k)
/-- The purity `Tr ρ₁²` of the reduced state `ρ₁ = Tr₂ |v⟩⟨v|` of mass 1 (real part). -/
def reducedPurity (v : Qubit × Qubit → ℂ) : ℝ :=
(ptrace₂ (pureDM v) * ptrace₂ (pureDM v)).trace.re
/-- Separable two-qubit state: a finite convex combination `∑ᵢ pᵢ ρᵢ^{(1)} ⊗ ρᵢ^{(2)}` of
products of density matrices. -/
def IsSeparable (ρ : Matrix (Qubit × Qubit) (Qubit × Qubit) ℂ) : Prop :=
∃ (n : ℕ) (p : Fin n → ℝ) (ρ₁ ρ₂ : Fin n → Matrix Qubit Qubit ℂ),
(∀ i, 0 ≤ p i) ∧ ∑ i, p i = 1 ∧
(∀ i, PeresTerno.IsDensityMatrix (ρ₁ i)) ∧ (∀ i, PeresTerno.IsDensityMatrix (ρ₂ i)) ∧
ρ = ∑ i, (p i : ℂ) • (ρ₁ i ⊗ₖ ρ₂ i)
/-- p. 3: the entanglement witness
`𝒲(ρ) = |⟨σ_x^{(1)} ⊗ σ_z^{(2)}⟩ − ⟨σ_y^{(1)} ⊗ σ_y^{(2)}⟩|`, with `⟨O⟩ = Tr(ρ O)`. -/
def witness (ρ : Matrix (Qubit × Qubit) (Qubit × Qubit) ℂ) : ℝ :=
‖(ρ * (σx ⊗ₖ σz)).trace - (ρ * (σy ⊗ₖ σy)).trace‖
/-- The local phase rotation `diag(1, e^{iθ})` of one spin. -/
def phaseRot (θ : ℝ) : Matrix Qubit Qubit ℂ := !![1, 0; 0, Complex.exp (θ * Complex.I)]
/-- p. 4: the witness with each spin's operators readjusted by a local phase rotation,
`σ ↦ R(θ)† σ R(θ)` with `R(θ) = diag(1, e^{iθ})` (`θ₁` for mass 1, `θ₂` for mass 2):
`|⟨σ_x^{θ₁} ⊗ σ_z^{θ₂}⟩ − ⟨σ_y^{θ₁} ⊗ σ_y^{θ₂}⟩|`. With `θ₁ = θ₂ = 0` it is `witness`. -/
def witnessRot (θ₁ θ₂ : ℝ) (ρ : Matrix (Qubit × Qubit) (Qubit × Qubit) ℂ) : ℝ :=
‖(ρ * (((phaseRot θ₁)ᴴ * σx * phaseRot θ₁) ⊗ₖ ((phaseRot θ₂)ᴴ * σz * phaseRot θ₂))).trace -
(ρ * (((phaseRot θ₁)ᴴ * σy * phaseRot θ₁) ⊗ₖ ((phaseRot θ₂)ᴴ * σy * phaseRot θ₂))).trace‖
end
end BMV2017
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Read-back: Def_BMV2017_defs.lean (namespace BMV2017)
Conventions used throughout. The single-qubit index set is (two elements). The file's comments say stands for or , and for or . The code itself only uses the labels . Two-qubit vectors are arbitrary functions , written . Two-qubit matrices are arbitrary complex matrices indexed by , written . In a pair the first entry is "qubit 1" and the second is "qubit 2". The Kronecker product is , so acts on qubit 1 and on qubit 2. is the ordinary matrix trace (the sum of diagonal entries). is complex conjugation, is the conjugate transpose, and is the complex modulus. Real numbers that appear inside are viewed as complex numbers. None of the definitions below assume normalization, Hermiticity or positivity unless this read-back says so.
Imported definition used here (PeresTerno.IsDensityMatrix). A square complex matrix is called a density matrix when two conditions hold. First, is positive semidefinite in Mathlib's sense, which means is Hermitian and (as a real number) for every complex vector . Second, .
Qubit
is defined as the two-element index type (Fin 2). It has no further structure beyond being this index set.
σx, σy, σz
These are three fixed complex matrices indexed by . Row and column come first:
So, for example, , , and .
psiEnd
For real parameters , is the two-qubit vector defined by , where
Written out entry by entry:
In ket notation this is , with the first index being qubit 1. The parameter is attached to "qubit 1 in state 0, qubit 2 in state 1", and to "qubit 1 in state 1, qubit 2 in state 0". No overall phase factor is included. The vector has Euclidean norm for every .
IsProductVector
For a two-qubit vector , is the proposition that there exist one-qubit vectors with
This is the statement . The vectors and are not required to be nonzero or normalized. In particular, the zero vector counts as a product vector (take ).
pureDM
For any two-qubit vector (normalized or not), is the matrix :
Its trace is , which need not equal .
ptrace₂
For any matrix indexed by , is the matrix
This is the partial trace over the second factor, so the result is indexed by qubit 1. No assumption is made on .
reducedPurity
For a two-qubit vector , is the real number
that is, the real part of the trace of the square of the reduced matrix on qubit 1. The vector is not normalized first. For a general the value scales like : for example, it is for , and it is for a product vector. Only for unit vectors is it the usual purity.
IsSeparable
For a complex matrix indexed by , is the proposition that there exist the following data:
- a natural number ;
- real weights ;
- complex matrices and ;
such that all of these hold:
- for every , and ;
- every and every is a density matrix (Hermitian, positive semidefinite, trace );
- , where acts on the first factor (qubit 1) and on the second.
The number of terms is finite but unbounded. The case is formally allowed, but it cannot satisfy . As a consequence, any separable is itself a density matrix.
witness
For any complex matrix indexed by , is the real number
Here acts on qubit 1 and on qubit 2 in the first term, and acts on both qubits in the second. The order inside each trace is first, then the operator. The outer bars denote the modulus of the complex difference; no real part is taken. is not required to be a density matrix (any matrix is accepted). For non-Hermitian the two traces may be non-real.
phaseRot
For a real , is the diagonal matrix
where the phase sits on index .
witnessRot
For real and any complex matrix indexed by , define for . Then
In each Kronecker product the -rotated operator is on qubit 1 and the -rotated operator is on qubit 2. Computing these products explicitly gives
So the factor on qubit 2 does not depend on , and enters only through . As with , the outer bars are the complex modulus, is unrestricted, and .