22import warnings
33import numpy as np
44
5- from inflation import InflationProblem
5+ from inflation import InflationProblem , InflationLP
66from inflation .symmetry_utils import (discover_distribution_symmetries ,
77 group_elements_from_generators )
88
@@ -24,17 +24,19 @@ def setUpClass(cls):
2424 bellScenario = InflationProblem ({"Lambda" : ["A" , "B" ]},
2525 outcomes_per_party = [2 , 2 ],
2626 settings_per_party = [2 , 2 ],
27- inflation_level_per_source = [1 ])
27+ inflation_level_per_source = [1 ],
28+ classical_sources = 'all' )
2829
2930 triangle = InflationProblem ({"Lambda" : ["A" , "B" ],
3031 "Mu" : ["B" , "C" ],
3132 "Sigma" : ["C" , "A" ]},
3233 outcomes_per_party = [2 , 2 , 2 ],
3334 inflation_level_per_source = [2 , 1 , 1 ])
3435
36+ PRbox_symmetries = discover_distribution_symmetries (PR_box ,
37+ bellScenario )
38+
3539 def test_discover (self ):
36- PRbox_symmetries = discover_distribution_symmetries (self .PR_box ,
37- self .bellScenario )
3840 # Order: (a=0,x=0), (a=1,x=0), (a=0,x=1), (a=1,x=1),
3941 # (b=0,y=0), (b=1,y=0), (b=0,y=1), (b=1,y=1)
4042 # There's five symmetries: flip parties, flip X, flip Y, and flip the
@@ -60,7 +62,7 @@ def test_discover(self):
6062 swapped = [symm [4 :] + symm [:4 ] for symm in symmetries ]
6163 symmetries = symmetries + swapped
6264 self .assertSetEqual (set (map (tuple , symmetries )),
63- set (map (tuple , PRbox_symmetries )),
65+ set (map (tuple , self . PRbox_symmetries )),
6466 "Failed to discover the symmetries of the PR box." )
6567
6668 def test_discover_inflation (self ):
@@ -89,3 +91,24 @@ def test_group_elements_from_generators(self):
8991 self .assertSetEqual (set (map (tuple , elements )),
9092 set (map (tuple , truth )),
9193 "Failed to generate S3 from generators." )
94+
95+ def test_desymmetrized_certificate (self ):
96+ self .bellScenario .add_symmetries (self .PRbox_symmetries )
97+ lp = InflationLP (self .bellScenario , verbose = 0 )
98+ lp .set_distribution (self .PR_box )
99+ lp .solve ()
100+ certificate = lp .desymmetrize_certificate ()
101+ truth = {
102+ 'P[A_0=0]' : 0.125 , 'P[A_0=1]' : 0.125 , 'P[A_1=0]' : 0.125 , 'P[A_1=1]' : 0.125 ,
103+ 'P[B_0=0]' : 0.125 , 'P[B_0=1]' : 0.125 , 'P[B_1=0]' : 0.125 , 'P[B_1=1]' : 0.125 ,
104+ 'P[A_0=0 B_0=0]' : - 0.1875 , 'P[A_0=0 B_0=1]' : 0.0625 ,
105+ 'P[A_0=0 B_1=0]' : - 0.1875 , 'P[A_0=0 B_1=1]' : 0.0625 ,
106+ 'P[A_0=1 B_1=1]' : - 0.1875 , 'P[A_0=1 B_1=0]' : 0.0625 ,
107+ 'P[A_0=1 B_0=1]' : - 0.1875 , 'P[A_0=1 B_0=0]' : 0.0625 ,
108+ 'P[A_1=0 B_0=0]' : - 0.1875 , 'P[A_1=0 B_0=1]' : 0.0625 ,
109+ 'P[A_1=0 B_1=1]' : - 0.1875 , 'P[A_1=0 B_1=0]' : 0.0625 ,
110+ 'P[A_1=1 B_1=0]' : - 0.1875 , 'P[A_1=1 B_1=1]' : 0.0625 ,
111+ 'P[A_1=1 B_0=1]' : - 0.1875 , 'P[A_1=1 B_0=0]' : 0.0625 }
112+ self .assertDictEqual (certificate , truth ,
113+ "Failed to desymmetrize the CHSH inequality." )
114+
0 commit comments