From bff218ba3e15e52b5b9b528dc380b92ca32f5cf2 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 15:39:33 +0200 Subject: [PATCH 1/9] wip --- .../quantum_conditional_entropy.jl | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl new file mode 100644 index 000000000..e8bcee2c6 --- /dev/null +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -0,0 +1,87 @@ +# # Continuity of the quantum conditional entropy +# +# The quantum conditional entropy is given by +# +# ```math +# S(A|B)_\rho := S(\rho^{AB}) - S(\rho^{B}) +# ``` +# +# where $S$ is the von Neumann entropy, +# +# ```math +# S(\rho) := - \text{tr}(\rho \log \rho) +# ``` +# +# and $\rho$ is a positive semidefinite trace-1 matrix (density matrix). +# +# Here, $\rho^{AB}$ represents an operator on the tensor product of two finite-dimensional Hilbert spaces $A$ and $B$ (with dimensions $d_A$ and $d_B$ respectively), so we can regard $\rho_{AB}$ as a matrix on the vector space $\mathbb{C}^{d_Ad_B}$. Moreover, $\rho^B$ denotes the partial trace of $\rho^{AB}$ over the system $A$, so $\rho^B$ is a matrix on $\mathbb{C}^{d_B}$. +# +# One question is how much can $S(A|B)_\rho$ vary between two density matrices $\rho$ and $\sigma$ as a function of the trace-distance $\text{trdist}(\rho, \sigma) := \|\rho-\sigma\|_1 = \frac{1}{2} \text{tr}\left(\sqrt{(\rho-\sigma)^\dagger (\rho-\sigma)}\right)$ (i.e. 1/2 of the nuclear norm). Here the trace distance is meaningful as it is the quantum analog to the total variation distance, and has an inteprepration in terms of the maximal possible probability to distinguish between $\rho$ and $\sigma$ by measurement. +# +# The Alicki-Fannes-Winter (AFW) bound (https://arxiv.org/abs/1507.07775v6 Lemma 2) states that if $\rho$ and $\sigma$ are density matrices, then $\text{trdist}(\rho, \sigma) \leq \varepsilon \leq 1$, then +# +# ```math +# | S(A|B)_\rho - S(A|B)_\sigma| \leq 2 \varepsilon \log d_A + (1 + \varepsilon) h \left(\frac{\varepsilon}{1+\varepsilon}\right) +# ``` +# +# where $h(x) = -x\log x - (1-x)\log(1-x)$ is the binary entropy. +# +# We can illustrate this bound by computing +# +# ```math +# \max_{\rho} S(A|B)_\rho - S(A|B)_\sigma +# ``` +# +# for a fixed state $\sigma$, and comparing to the AFW bound. +# +# We will choose $d_A=d_B=2$, and $\sigma$ as the maximally entangled state: +# +# ```math +# \sigma = \frac{1}{2}\begin{pmatrix}1 & 0 & 0 & 1\\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 1\\\end{pmatrix} +# ```math +# +# First, we can formulate the conditional entropy in terms of the relative entropy using the relationship +# +# ```math +# S(A|B)_\rho = - D(\rho_^{AB} \| I_A \otimes \rho^B) +# ```math +# +# where $D$ is the quantum relative entropy. Thus: + +using Convex +using LinearAlgebra: I + +function quantum_conditional_entropy(ρ_AB, d_A, d_B) + ρ_B = partialtrace(ρ_AB, 1, [d_A, d_B]) + return -quantum_relative_entropy(ρ_AB, kron(I(d_A), ρ_B)) +end + +# Now we setup the problem data: + +ϵ = 0.1 +d_A = d_B = 2 +σ_AB = 0.5 * [ + 1 0 0 1 + 0 0 0 0 + 0 0 0 0 + 1 0 0 1 +] + +# And we build and solve problem itself + +using SCS + +ρ_AB = HermitianSemidefinite(d_A * d_B) +add_constraint!(ρ_AB, tr(ρ_AB) == 1) + +add_constraint!(ρ_AB, 0.5 * nuclearnorm(ρ_AB - σ_AB) ≤ ϵ) +problem = maximize(quantum_conditional_entropy(ρ_AB, d_A, d_B)) +solve!(problem, SCS.Optimizer; silent=true) + +# We can then check the observed difference in relative entropies: + +difference = evaluate(quantum_conditional_entropy(ρ_AB, d_A, d_B) - quantum_conditional_entropy(σ_AB, d_A, d_B)) + +# We can compare to the bound: +h(x) = -x*log(x) - (1-x)*log(1-x) +2 * ϵ * log(d_A) + (1 + ϵ) * h(ϵ/(1+ϵ)) From b52359e9e4ad23df533599b35c226e2a62e1230b Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 15:44:19 +0200 Subject: [PATCH 2/9] wip --- .../quantum_conditional_entropy.jl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl index e8bcee2c6..e2d9814ed 100644 --- a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -76,7 +76,7 @@ add_constraint!(ρ_AB, tr(ρ_AB) == 1) add_constraint!(ρ_AB, 0.5 * nuclearnorm(ρ_AB - σ_AB) ≤ ϵ) problem = maximize(quantum_conditional_entropy(ρ_AB, d_A, d_B)) -solve!(problem, SCS.Optimizer; silent=true) +solve!(problem, SCS.Optimizer; silent_solver=true) # We can then check the observed difference in relative entropies: @@ -84,4 +84,14 @@ difference = evaluate(quantum_conditional_entropy(ρ_AB, d_A, d_B) - quantum_con # We can compare to the bound: h(x) = -x*log(x) - (1-x)*log(1-x) -2 * ϵ * log(d_A) + (1 + ϵ) * h(ϵ/(1+ϵ)) +bound = 2 * ϵ * log(d_A) + (1 + ϵ) * h(ϵ/(1+ϵ)) + +# In fact, in this case we know the maximizer is given by + +ρ_max = σ_AB*(1-ϵ) + ϵ*(I(d_A*d_B) - σ_AB)/(d_A*d_B-1) + +# We can check that `ρ_AB` obtained the right value: + +norm(evaluate(ρ_AB) - ρ_max) + +# Here we see a result within the expected tolerances of SCS. From 841d90ed87f7ea452aa458914a2872b2a8602f78 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 16:25:20 +0200 Subject: [PATCH 3/9] optimize `permutedims_matrix` --- src/reformulations/partialtranspose.jl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/reformulations/partialtranspose.jl b/src/reformulations/partialtranspose.jl index eff599cfc..64c1f3d85 100644 --- a/src/reformulations/partialtranspose.jl +++ b/src/reformulations/partialtranspose.jl @@ -51,13 +51,10 @@ Returns a matrix `M` so that for any vector `v` of length `prod(dims)`, `M*v == vec(permutedims(reshape(v, dims), p))`. """ function permutedims_matrix(dims, p) - d, n = prod(dims), length(dims) - dense = reshape( - PermutedDimsArray( - reshape(LinearAlgebra.I(d), (dims..., dims...)), - (p..., (n+1:2n)...), - ), - (d, d), - ) - return SparseArrays.sparse(dense) + d = prod(dims) + # Generalization of https://stackoverflow.com/a/60680132 + rows = 1:d + cols = vec(permutedims(reshape(rows, dims), p)) + data = ones(Int, d) + return SparseArrays.sparse(rows, cols, data, d, d) end From 704d5a9abb47f1af65c2f65dc3ca98581cffa517 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 16:25:25 +0200 Subject: [PATCH 4/9] update example --- .../quantum_conditional_entropy.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl index e2d9814ed..4d4b786ae 100644 --- a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -76,19 +76,22 @@ add_constraint!(ρ_AB, tr(ρ_AB) == 1) add_constraint!(ρ_AB, 0.5 * nuclearnorm(ρ_AB - σ_AB) ≤ ϵ) problem = maximize(quantum_conditional_entropy(ρ_AB, d_A, d_B)) -solve!(problem, SCS.Optimizer; silent_solver=true) +solve!(problem, SCS.Optimizer; silent_solver = false) # We can then check the observed difference in relative entropies: -difference = evaluate(quantum_conditional_entropy(ρ_AB, d_A, d_B) - quantum_conditional_entropy(σ_AB, d_A, d_B)) +difference = evaluate( + quantum_conditional_entropy(ρ_AB, d_A, d_B) - + quantum_conditional_entropy(σ_AB, d_A, d_B), +) # We can compare to the bound: -h(x) = -x*log(x) - (1-x)*log(1-x) -bound = 2 * ϵ * log(d_A) + (1 + ϵ) * h(ϵ/(1+ϵ)) +h(x) = -x * log(x) - (1 - x) * log(1 - x) +bound = 2 * ϵ * log(d_A) + (1 + ϵ) * h(ϵ / (1 + ϵ)) # In fact, in this case we know the maximizer is given by -ρ_max = σ_AB*(1-ϵ) + ϵ*(I(d_A*d_B) - σ_AB)/(d_A*d_B-1) +ρ_max = σ_AB * (1 - ϵ) + ϵ * (I(d_A * d_B) - σ_AB) / (d_A * d_B - 1) # We can check that `ρ_AB` obtained the right value: From 1387cee10e84260fb6371722427d4852a3f43cc8 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 16:36:49 +0200 Subject: [PATCH 5/9] up --- .../quantum_conditional_entropy.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl index 4d4b786ae..6bfd65f81 100644 --- a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -74,8 +74,11 @@ using SCS ρ_AB = HermitianSemidefinite(d_A * d_B) add_constraint!(ρ_AB, tr(ρ_AB) == 1) -add_constraint!(ρ_AB, 0.5 * nuclearnorm(ρ_AB - σ_AB) ≤ ϵ) -problem = maximize(quantum_conditional_entropy(ρ_AB, d_A, d_B)) +problem = maximize( + quantum_conditional_entropy(ρ_AB, d_A, d_B), + 0.5 * nuclearnorm(ρ_AB - σ_AB) ≤ ϵ, +) + solve!(problem, SCS.Optimizer; silent_solver = false) # We can then check the observed difference in relative entropies: From 0ca5947ff64441358694877caee1def1c0e8350c Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 17:05:57 +0200 Subject: [PATCH 6/9] appease vale --- .../quantum_conditional_entropy.jl | 2 +- docs/styles/config/vocabularies/jump-dev/accept.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl index 6bfd65f81..0438eb30d 100644 --- a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -16,7 +16,7 @@ # # Here, $\rho^{AB}$ represents an operator on the tensor product of two finite-dimensional Hilbert spaces $A$ and $B$ (with dimensions $d_A$ and $d_B$ respectively), so we can regard $\rho_{AB}$ as a matrix on the vector space $\mathbb{C}^{d_Ad_B}$. Moreover, $\rho^B$ denotes the partial trace of $\rho^{AB}$ over the system $A$, so $\rho^B$ is a matrix on $\mathbb{C}^{d_B}$. # -# One question is how much can $S(A|B)_\rho$ vary between two density matrices $\rho$ and $\sigma$ as a function of the trace-distance $\text{trdist}(\rho, \sigma) := \|\rho-\sigma\|_1 = \frac{1}{2} \text{tr}\left(\sqrt{(\rho-\sigma)^\dagger (\rho-\sigma)}\right)$ (i.e. 1/2 of the nuclear norm). Here the trace distance is meaningful as it is the quantum analog to the total variation distance, and has an inteprepration in terms of the maximal possible probability to distinguish between $\rho$ and $\sigma$ by measurement. +# One question is how much can $S(A|B)_\rho$ vary between two density matrices $\rho$ and $\sigma$ as a function of the trace-distance $\text{trdist}(\rho, \sigma) := \|\rho-\sigma\|_1 = \frac{1}{2} \text{tr}\left(\sqrt{(\rho-\sigma)^\dagger (\rho-\sigma)}\right)$ (that is, half of the nuclear norm). Here the trace distance is meaningful as it is the quantum analog to the total variation distance, and has an interpretation in terms of the maximal possible probability to distinguish between $\rho$ and $\sigma$ by measurement. # # The Alicki-Fannes-Winter (AFW) bound (https://arxiv.org/abs/1507.07775v6 Lemma 2) states that if $\rho$ and $\sigma$ are density matrices, then $\text{trdist}(\rho, \sigma) \leq \varepsilon \leq 1$, then # diff --git a/docs/styles/config/vocabularies/jump-dev/accept.txt b/docs/styles/config/vocabularies/jump-dev/accept.txt index 4c8a33f04..c68276ea2 100644 --- a/docs/styles/config/vocabularies/jump-dev/accept.txt +++ b/docs/styles/config/vocabularies/jump-dev/accept.txt @@ -5,6 +5,7 @@ docstring [Dd]ualize [Dd]ualization [Ee]lementwise +entropies [Ee]num injective nonconvex @@ -54,5 +55,6 @@ Nemirovski Skaf Udell Vandenberghe +von Neumann Watrous Zeng From de4a227c56f1f0bfa1ea000edffb02aba7e58703 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 17:24:43 +0200 Subject: [PATCH 7/9] fix --- docs/styles/config/vocabularies/jump-dev/accept.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/styles/config/vocabularies/jump-dev/accept.txt b/docs/styles/config/vocabularies/jump-dev/accept.txt index c68276ea2..30b3fa00a 100644 --- a/docs/styles/config/vocabularies/jump-dev/accept.txt +++ b/docs/styles/config/vocabularies/jump-dev/accept.txt @@ -52,9 +52,10 @@ Markowitz Mohan Namkoong Nemirovski +Neumann Skaf Udell Vandenberghe -von Neumann +von Watrous Zeng From 22f97fb3d9dfbd52a899bb4192acec6e35354d83 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 17:50:07 +0200 Subject: [PATCH 8/9] Update docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl --- .../quantum_conditional_entropy.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl index 0438eb30d..923d542a9 100644 --- a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -43,7 +43,7 @@ # First, we can formulate the conditional entropy in terms of the relative entropy using the relationship # # ```math -# S(A|B)_\rho = - D(\rho_^{AB} \| I_A \otimes \rho^B) +# S(A|B)_\rho = - D(\rho^{AB} \| I_A \otimes \rho^B) # ```math # # where $D$ is the quantum relative entropy. Thus: From 7b10c2720b9c3f9dac93b7c01b41d9996c371096 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Sat, 18 May 2024 18:25:59 +0200 Subject: [PATCH 9/9] cleanup a little --- .../quantum_conditional_entropy.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl index 923d542a9..cd048881f 100644 --- a/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl +++ b/docs/src/examples/optimization_with_complex_variables/quantum_conditional_entropy.jl @@ -18,7 +18,7 @@ # # One question is how much can $S(A|B)_\rho$ vary between two density matrices $\rho$ and $\sigma$ as a function of the trace-distance $\text{trdist}(\rho, \sigma) := \|\rho-\sigma\|_1 = \frac{1}{2} \text{tr}\left(\sqrt{(\rho-\sigma)^\dagger (\rho-\sigma)}\right)$ (that is, half of the nuclear norm). Here the trace distance is meaningful as it is the quantum analog to the total variation distance, and has an interpretation in terms of the maximal possible probability to distinguish between $\rho$ and $\sigma$ by measurement. # -# The Alicki-Fannes-Winter (AFW) bound (https://arxiv.org/abs/1507.07775v6 Lemma 2) states that if $\rho$ and $\sigma$ are density matrices, then $\text{trdist}(\rho, \sigma) \leq \varepsilon \leq 1$, then +# The Alicki-Fannes-Winter (AFW) bound ([*Winter 2015*](https://arxiv.org/abs/1507.07775v6), Lemma 2) states that if $\rho$ and $\sigma$ are density matrices, then $\text{trdist}(\rho, \sigma) \leq \varepsilon \leq 1$, then # # ```math # | S(A|B)_\rho - S(A|B)_\sigma| \leq 2 \varepsilon \log d_A + (1 + \varepsilon) h \left(\frac{\varepsilon}{1+\varepsilon}\right) @@ -43,10 +43,10 @@ # First, we can formulate the conditional entropy in terms of the relative entropy using the relationship # # ```math -# S(A|B)_\rho = - D(\rho^{AB} \| I_A \otimes \rho^B) +# S(A|B)_\rho = - D(\rho^{AB} \| I^A \otimes \rho^B) # ```math # -# where $D$ is the quantum relative entropy. Thus: +# where $D$ is the quantum relative entropy and $I^A$ is the $d_A$-dimensional identity matrix. Thus: using Convex using LinearAlgebra: I