Skip to content

Commit 12897cd

Browse files
Add Ket, rm quantum_utils, fix test, break examples
1 parent 1dfb986 commit 12897cd

7 files changed

Lines changed: 91 additions & 356 deletions

File tree

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BellPolytopes"
22
uuid = "38bdb6f4-c11c-4b2a-9c62-3601ea4ec58a"
3-
authors = ["ZIB AISST"]
43
version = "0.2.0"
4+
authors = ["ZIB AISST"]
55

66
[deps]
77
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
@@ -16,6 +16,7 @@ Tullio = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc"
1616
[compat]
1717
Combinatorics = "1"
1818
FrankWolfe = "0.6"
19+
Ket = "0.7.0"
1920
LinearAlgebra = "1"
2021
Polyhedra = "0.8"
2122
Printf = "1"
@@ -26,7 +27,8 @@ Tullio = "0.3"
2627
julia = "1.9"
2728

2829
[extras]
30+
Ket = "412c778c-4733-41d8-b706-9e072557ba34"
2931
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3032

3133
[targets]
32-
test = ["Test"]
34+
test = ["Ket", "Test"]

examples/CHSH.jl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
# Bipartite example recovering the CHSH inequality together with a local model
22
using BellPolytopes
33
using FrankWolfe
4+
using Ket
45
using LinearAlgebra
56

67
N = 2 # bipartite scenario
8+
function mes(v::Matrix{T}) where {T <: Real}
9+
σ = gellmann(T, 2)
10+
res = Vector{Measurement{Complex{T}}}(undef, size(v, 1))
11+
for i in axes(v, 1)
12+
tmp = v[i, 1] * σ[2] + v[i, 2] * σ[3] + v[i, 3] * σ[4]
13+
res[i] = [(σ[1] - tmp) / 2, (σ[1] + tmp) / 2]
14+
end
15+
return res
16+
end
717
# Bloch vectors of the measurements to be performed on Alice's side
8-
measurements_vecA = [1 0 0; 0 0 1]
18+
vecA = [1 0 0; 0 0 1]
19+
mesA = mes(vecA)
920
# Bloch vectors of the measurements to be performed on Bob's side
10-
measurements_vecB = [1 0 1; 1 0 -1] / sqrt(2)
11-
rho = rho_singlet() # shared state
21+
vecB = [1 0 1; 1 0 -1] / sqrt(2)
22+
mesB = mes(vecB)
23+
rho = state_psiminus() # shared state
1224
_, lower_bound, upper_bound, local_model, bell_inequality =
13-
nonlocality_threshold([measurements_vecA, measurements_vecB], N; rho=rho)
25+
nonlocality_threshold([measurements_vecA, measurements_vecB], N; rho)
1426

1527
println("Correlation matrix")
16-
p = correlation_tensor([measurements_vecA, measurements_vecB], N; rho=rho, marg=false)
28+
p = tensor_correlation(rho, mesA, mesB; marg=false)
1729
display(p)
1830

1931
println()

examples/Werner.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# Bipartite example showing a better resistance to noise than the CHSH inequality
22
using BellPolytopes
33
using FrankWolfe
4+
using Ket
45
using LinearAlgebra
56

67
N = 2 # bipartite scenario
78
# Bloch vectors of the measurements to be performed by all parties
89
# obtained with https://github.com/sebastiendesignolle/polyhedronisme
9-
measurements_vec = polyhedronisme("../polyhedra/polyhedronisme-SASuSAuO.obj", 33)
10-
rho = rho_singlet() # shared state
11-
p = correlation_tensor(measurements_vec, N; rho=rho, marg=false)
10+
v = polyhedronisme("../polyhedra/polyhedronisme-SASuSAuO.obj", 33)
11+
σ = gellmann(2)
12+
mes = [[(σ[1] - v[i, 1] * σ[2] - v[i, 2] * σ[3] - v[i, 3] * σ[4]) / 2, (σ[1] + v[i, 1] * σ[2] + v[i, 2] * σ[3] + v[i, 3] * σ[4]) / 2] for i in axes(v, 1)]
13+
rho = state_psiminus() # shared state
14+
p = tensor_correlation(rho, mes, N; marg=false)
1215
@time x, ds, primal, dual_gap, as, M, β =
1316
bell_frank_wolfe(p; v0=1 / sqrt(2), verbose=3, epsilon=1e-4, mode_last=0, nb_last=10^6, callback_interval=10^5)
1417
# v_c ≤ 0.704914
1518
# As such, the function above gets this last bound heuristically
1619
# Change mode_last to 1 to check the exact bound (takes a few minutes)
20+
# Alternatively, use local_bound from Ket to compute it in parallel
1721

1822
println()

src/BellPolytopes.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ using Random
99
using Serialization
1010
using Tullio
1111

12-
include("quantum_utils.jl")
1312
include("types.jl")
1413
include("fw_methods.jl")
1514
include("utils.jl")

src/bell_frank_wolfe.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Returns:
1616
Optional arguments:
1717
- `o`: same type as `p`, corresponds to the noise to be added, by default the center of the polytope,
1818
- `prob`: a boolean, indicates if `p` is a corelation or probability array,
19-
- `marg`: a boolean, indicates if `p` contains marginals,
19+
- `marg`: a boolean, indicates if `p` contains marginals (by convention in the last index of each dimension),
2020
- `v0`: the visibility used to make a nonlocal `p` closer to the local polytope,
2121
- `epsilon`: the tolerance, used as a stopping criterion (when the primal value or the dual gap go below its value), by default 1e-7,
2222
- `verbose`: an integer, indicates the level of verbosity from 0 to 3,

src/quantum_utils.jl

Lines changed: 0 additions & 287 deletions
This file was deleted.

0 commit comments

Comments
 (0)