{'fraction_non_alphanumeric': 0.034305374067519066, 'fraction_numerical': 0.008286881585258945, 'mean_word_length': 4.320601953709407, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Linear game non-contextuality and Bell inequalities - a graph-theoretic approach

We study the classical and quantum values of one- and two-party linear games, an important class of unique games that generalizes the well-known XOR games to the case of non-binary outcomes. We introduce a ``constraint graph"associated to such a game, with the constraints defining the linear game represented by an edge-coloring of the graph. We use the graph-theoretic characterization to relate the task of finding equivalent games to the notion of signed graphs and switching equivalence from graph theory. We relate the problem of computing the classical value of single-party anti-correlation XOR games to finding the edge bipartization number of a graph, which is known to be MaxSNP hard, and connect the computation of the classical value of more general XOR-d games to the identification of specific cycles in the graph. We construct an orthogonality graph of the game from the constraint graph and study its Lov\'{a}sz theta number as a general upper bound on the quantum value even in the case of single-party contextual XOR-d games. Linear games possess appealing properties for use in device-independent applications such as randomness of the local correlated outcomes in the optimal quantum strategy. We study the possibility of obtaining quantum algebraic violation of these games, and show that no finite linear game possesses the property of pseudo-telepathy leaving the frequently used chained Bell inequalities as the natural candidates for such applications. We also show this lack of pseudo-telepathy for multi-party XOR-type inequalities involving two-body correlation functions.


Introduction
Quantum mechanics provides various resources. One of them is quantum non-locality [1,16]. Given the ability to perform measurements on a bipartite quantum state, one can obtain correlations which do not have a classical explanation in that they can not be predetermined before the measurements. To ensure this, one can perform statistical tests for quantum non-locality [1], known as the Bell inequalities, the famous CHSH [49] inequality being a prominent example. The applications of non-locality go beyond quantum theory [28,37], reaching as far as device-independent security against a so called non-signaling adversary-a person possibly empowered with more than quantum resources, but still obeying the no-faster-than-light communication principle [50]. Another application of quantum non-locality is to communication complexity [4], where the use of quantum non-local correlations lowers the communication cost of evaluating a function using distributed computers.
Bell non-locality is a special case of the general phenomenon called contextuality. This phenomenon which had been discovered first by Kochen and Specker [38] demonstrates the incompatibility of quantum theory with 'outcome noncontextuality', i.e., any assignment of outcomes to quantum observables in a manner independent of the other observables that are measured alongside. In consequence even for a single quantum system, sometimes a measurement can be said to create the outcomes, instead of merely revealing preexisting ones. Quite a long history of research on contextuality has led to various non-contextuality inequalities [5,18,19,38,52], Bell inequalities being a special case. Quantum contextuality has for long been studied as a fundamental quantum property, reaching recently a connection to a resource which is required for universal quantum computing [39,40] and quantum cryptography [2].
Two-party Bell inequalities have also been studied in theoretical computer science in terms of two-prover interactive-proof systems, commonly referred to as 'non-local games' [20] between two players and a referee. In this formulation one can let the players pre-share quantum data (an entangled quantum state) and the use of outcomes of measurements on it can lead to a higher probability of winning the game than in the case of classical shared randomness. Even higher success probability may be obtained, when the players are provided with a general system (device) which is only required to satisfy the no-signaling principle. In this framework, the main quantity of interest is the winning probability of the game or in general the amount of violation of a Bell inequality. In the case of a single player, the Bell inequality becomes a non-contextuality inequality or simply a constraint satisfaction problem (see e.g. [48] and references therein).
In general it is NP-hard to find the classical value of a general constraint satisfaction problem with many variables per constraint [9][10][11], so one considers special classes of games. A celebrated class of games is the socalled unique games with two players. These are games where for each pair of questions by the referee (x, y) and for any answer of one player a there exists only one answer of the other player b which leads to winning. In other words, the winning constraints are permutations: one-to-one mappings of the answers of one player into acceptable answers of the other: ( ) . Computing the exact classical value of a unique game is known to be NP hard [12]. Moreover, it is conjectured, that it is even NP hard to distinguish whether a unique game has classical probability of winning almost 1, or close to zero. This conjecture, known as the Unique Games Conjecture, has vast consequences for many questions in computer science [13]. On the other hand, it is known that the quantum winning probability of the unique game can be approximated to within a constant factor in polynomial time [17], in particular for a unique game with quantum value  -1 , one can find in polynomial time (in the number of inputs and outputs of the game) an entangled strategy which achieves value at least  -1 6 for the game. A subclass of unique games are the so-called XOR games for two players, where the players return binary answers and the winning constraint for the game only depends on the XOR of the players' answers. Computing the classical value of even this simplest class of unique game turns out be NP hard [12], however it is known from the results of [20,26] that the exact quantum value of the two-party XOR game can be computed in polynomial time. It is notable that the XOR games are equivalent to correlation based Bell inequalities for two outcomes and have also been extensively studied in the physics literature [36,49,51]. As such, virtually all applications of quantum non-locality such as in device-independent cryptography [28,37] or randomness generation [29] use two-player XOR games or their multi-party generalization in terms of GHZ paradoxes [36].
While XOR games have found widespread use, recently there has been much interest in developing applications of higher-dimensional entanglement [6][7][8] for which Bell inequalities with more than two outcomes are naturally suited. Therefore, both for fundamental reasons as well as for these applications, the study of Bell and non-contextuality inequalities with more outcomes is crucial. In this regard, a well-known class of Bell inequalities with more than two outcomes is the class of CGLMP inequalities [3] which have been extensively studied in the literature. In this paper, we study a different class of Bell inequalities which come from a natural generalization of XOR games which we call generalized XOR (GXOR) games or XOR-d games [46]. These games in the two-party scenario belong to the class of unique games, and can be seen to be a subclass of the well-known linear games [12,17]. Such games in the case of two ternary inputs per party appeared first in the context of experiments [27], the specific example of the generalized CHSH game was studied in [43,45,46] and a general bound on the quantum value of linear games was proposed in [17,46]. In this paper, we introduce a graph-theoretic characterization of these games, and apply it to the problem of finding the maximal classical and quantum values of such games.
The paper is organized as follows. The section 2 introduces some graph-theoretic notions and subsequently establishes the formulation of XOR games in graph-theoretic terms We then describe an axiomatic generalization of the XOR games in terms of two properties and show that the previously defined class of XOR-d games [12,46] is the unique class which satisfies these properties. We subsequently establish the graph-theoretic characterization of the subset of XOR-d games and illustrate this with the example of games with ternary outputs. In section 3, we use the graph-theoretic formalism established in previous sections to identify when two games can be considered equivalent, in particular we establish a relation to the graph-theoretic notion of signed graphs and switching equivalence. Then in section 4 we study the classical value of these generalized XOR-d games in a graph-theoretical manner. Our results in this section include a characterization of the complexity (as MaxSNP-hard) of computing the classical value of the simplest class of XOR games, namely single-party anticorrelation games. In the next section 5, we study the quantum value of these games, in particular we establish that the well-known Lovász theta number of the orthogonality graph of a contextuality game only gives an upper bound to its quantum value, unlike in the previously considered scenario of non-contextuality inequalities involving rank-one projectors. XOR-d games have the important property that their optimal quantum strategies involve locally random and correlated outcomes, thus permitting them to be ideal candidates for deviceindependent applications. In section 6, we prove that no non-trivial finite XOR-d game for prime d can be perfectly won with a quantum strategy, thus providing evidence that the frequently used chained Bell inequalities might indeed be the best candidates for such applications. We also extend the result to multi-party 'partial' XOR games which involve only two-body correlation functions, showing that such Bell inequalities cannot achieve algebraic violation. The final section 7 is devoted to a numerical analysis of the classical and quantum values (using semi-definite programming) of games with upto three ternary inputs per party. We end with conclusions and some open problems.

Graph-theoretic formulation of generalized XOR games
The aim of this section is to introduce the Generalized XOR games in a graph theoretical manner. In order to do it, let us first recall some graph-theoretic notions. We then formulate the binary outcome XOR games in terms of graphs with two types of edges corresponding to correlated and anti-correlated answers in section 2.2. Specifically, the constraints will be represented by two differently labeled edges on a graph with vertices representing the questions to the players so that the graph is a bipartite graph. We then define the main objects of study-the winning probabilities of a game given classical, quantum and super-quantum resources respectively. In section 2.3, we define the generalized XOR (XOR-d) games and establish their graph-theoretic formulation. The constraints of the game are represented by colored edges (with more than two colors), we illustrate this with the example of games with ternary answers. We then use the graph-theoretic formulation to also represent a single player contextuality game. This is simply a constraint satisfaction problem: the constraints of the game still being represented by colored edges, but with no bi-partition on the vertices.

Notions from graph theory
In this subsection we list some basic notions from graph theory, which are used in what follows.
where E(G) is a set of unordered pairs (u, v) of elements from V(G). An element of V is called a vertex and an element of E is called an edge. Two vertices Î u v V , are said to be adjacent if they are connected by an edge.
Definition 6. A chordless cycle in a graph G is a cycle in which no two vertices are connected by an edge which does not belong to the cycle.

Definition 7.
A complete graph is a graph in which every two vertices are adjacent. The complete graph with n vertices is denoted as K . n Definition 8. A clique is a set Ì A V in which every pair of vertices is adjacent.
Definition 9. Ì A V is said to be an independent set if it contains no adjacent vertices.
can be partitioned into two independent sets.
Definition 11. A graph G is connected if, for every pair of vertices ,there exists a path formed by edges in G connecting u and v.
Definition 12. A (connected) component of a graph G is a maximal connected subgraph of G.

XOR games
The XOR game involves a referee and two players: Alice and Bob. The referee asks questions Î x X to Alice and Î y Y to Bob according to an input probability distribution ( ) p x y , . Each player has two possible answers , 0,1 respectively. Whether the players win or lose depends solely on the XOR of their outputs: Å a b, where ⊕ denotes addition modulo 2. To give an example, in the famous CHSH game, the players win if · Å = a b x y, i.e., when the XOR of their answers equals the AND of the questions, with a b x y , , , being binary. XOR games are equivalent to correlation Bell inequalities with binary outcomes, since the correlation functions  x y , are simply given by In the game, the players can have access to certain resources. Three types of resources are usually considered. The first are classical corresponding to shared randomness between the players. The second are quantum, i.e., access to a bipartite entangled quantum state, and the set of measurements that can be performed on it by each player. And finally one also considers super-quantum resources, which correspond to access to a general device with inputs and outputs with the only constraint being that the device does not allow for signaling between the players. All the three resources have a common mathematical formulation as a conditional probability distribution ( | ) P a b x y , , from a certain set: classical (C), quantum (Q) and super-quantum ( ) SQ , and in general Ì Ì C Q SQ. The no-signaling condition is expressed mathematically as in other words, the conditional probability distribution of each player is independent of the other party's input.
The main object of study in XOR games is the winning probability of the players, which is written as: , is the indicator function reporting if the answers are correct (for XOR games ( | ) V a b x y , , only depends on Å a b). For example, in the case of the CHSH game ( | ) = V a b x y , , 1if · Å = a b x yand is set to 0 otherwise. The three quantities are accordingly called the classical, quantum and super-quantum value of the game.

Graph-theoretic formulation of XOR games
We are now ready to present the formulation of XOR games in graph-theoretic terms An XOR game is represented by a graph G with a specific edge-labeling that denotes the winning constraints of the game. The inputs, i.e., the questions asked by the referee, are represented by the vertices of a graph G. Two inputs are adjacent in the graph (i.e., connected by an edge) if and only if the corresponding measurements can be performed simultaneously. The winning constraint ( | ) V a b x y , , in equation (2) is represented by two types of edges-a solid edge corresponding to Å = a b 0 (perfect correlations between the players) and a dashed edge corresponding to Å = a b 1 (perfect anti-correlations between the players) that connect the inputs x and y. A Bell inequality is thus represented by a bipartite graph (with the bi-partition corresponding to the two players).
Every XOR game is a unique game i.e. for every pair of questions (x, y) and an answer of one player a there is a unique answer b of the second player that leads to winning. For this reason, we can also depict the two kinds of correlations as permutations of the set of outcomes. Correlations are denoted by the identity  (i.e. ( ) ) p = a a ) and anti-correlations by the transposition ( ) 01 (i.e. ( ) p = Å a a 1 mod 2) (see figure 1). We can formally define this as a labeling ( ) , 0 1 of the edges of graph G. For an XOR game depicted by a graph G with an edge-labeling K, we use ( ) w G K , S to denote the winning probability of the game using the resource set S under a uniform input distribution.
Having established graphical notation for the correlations between the Alice's and Bob's outputs of a game, we can present the graph representing the simplest XOR game, namely the CHSH one (see figure 2 above).

Generalized XOR (XOR-d) Games
In the generalization of XOR games to games with d outcomes, we abstract two properties of the XOR game: we require a set of d permutations 1 to describe the possible winning constraints in the game and impose that these permutations satisfy two salient properties: • (P1) Each permutation is symmetric with respect to exchange of players, i.e. the permutations are their own inverse.
appears exactly once in the set of permutations (in particular, each permutation assigns a different ( ) p a for each given We abstract these two properties, as a way to characterize a unique game that when restricted to d=2, is equivalent to the usual binary XOR game. The physical motivation behind the above conditions is that the definition involves just correlations between the outputs and does not involve local terms Moreover, thanks to property (P1), the graph of a game is not directed.
For instance, observe that the following set of permutations defining the XOR-d game satisfies the above properties. For each answer a of Alice, consider an answer of Bob as where p i satisfies relation: d where d is the number of possible answers for both players. Thus all permutations p i belong to the set where S d is the set of permutations of the set [ ] d . Restricting our interest to the above winning strategies, we see, that any game based on them is unique. In fact, the games defined by equation (3) are a subclass of the wellknown class of linear games which are defined as follows.
Definition 13. A linear game g l is one in which two parties Alice and Bob receive questions Î x X, Î y Y according to some probability distribution ( ) q x y , and respond with answers where G is a finite abelian group with group operation +. The winning constraints in the game are given by .
The XOR-d games defined by the winning constraints of the form equation (3) are now seen to be a subclass of the linear games with associated group  d , i.e. the cyclic group on d letters with the operation addition modulo d. Let us now prove that for prime d, up to local relabeling of answers the above set of permutations in equation (3) is the only one which satisfies the two properties (P1) and (P2), i.e., that the two properties (P1) and (P2) completely characterize the XOR-d game in this case. Theorem 1. For prime d, up to local relabeling of answers by the parties, the only games which satisfy the properties P 1 and P 2 are those given by equation (3).  proof. The case of d=2 is clear, since the only permutations are the identity and the transposition, forming the group  2 and this gives the XOR game, which is a special case of equation (3). For prime  d 3, we observe that the permutations that obey P 1 clearly have cycles of length at most two, i.e., they consist of fixed points and transpositions only. Let us first note that a permutation consisting of an even number of fixed points cannot be part of the set of permutations considered, because the permutations consists only of transpositions besides the fixed points. Also, a permutation consisting of an odd (greater than one) number of fixed points cannot be part of the set of permutations considered. This is because of the requirement that there be d permutations in the set and each permutation consists of at least one fixed point due to the previous considerations, so that having a permutation with more than one fixed point in the set leads to a contradiction with P 2 . We therefore see that each permutation in the set of d permutations contains exactly one (distinct) fixed point.
Let us now show that the set of permutations satisfying P P , 1 2 give rise to a group structure on the output alphabets A B , of the two parties. In other words, given the set of d permutations { } = P L i satisfying P P , 1 2 we want to show that the sets A B , are in fact a finite abelian group G of size d. Firstly, note that P 1 implies The game is defined by the winning constraints ( ) = P b a i and ( ) = P a b i due to P 1 . We want to rewrite the winning constraints as + = a b ifor some group operation 1 . We know by P 2 that each permutation P Î L i sends the element 0 to a different element, so that we may label the permutation P i by the element it maps 0 onto, i.e., ( ) P = i 0 i . Given such a set L, we define the group operation + by 1 . The set of d elements is clearly closed under this operation and the commutativity ( ) ( ) that is imposed by P 1 implies associativity of the operation. The element 0 is seen to be the identity satisfying ( ) for all a. We can thus identify the output sets A and B with a finite abelian group G of size d with the group operation +. For prime d, the statement is then seen to be a consequence of the fact that any group of prime order is isomorphic to the cyclic group  d with group operation given by addition modulo d. The isomorphism is equivalent to a local relabeling of the outputs by the two parties. , The generalized XOR-d game is represented by a graph G in analogous fashion to the XOR game. Namely, the vertices of the graph represent the inputs in the game and an edge between two vertices denotes that the corresponding measurements can be performed simultaneously. In the graph-theoretic representation of XORd games, we will use the notion of 'colors' to denote the edge-labelings that represent the winning constraints (permutations) in the game. We now also see the effect of the properties (P1) and (P2) characterizing the XOR-d game. While the graph-theoretic approach can also be applied to general unique games, most nonlinear games have to be represented by a directed graph, as the permutations defining the winning constraints need not be their own inverse. In figure 3, we show an example of a game for a ternary output game with three possible winning permutations: red corresponding to p 0 , blue corresponding to p 1 and green corresponding to p 2 .
Note that the above formulation also naturally encompasses games with a single player, i.e., noncontextuality inequalities. In this case, the game scenario is simply a constraint satisfaction problem and is represented by a simple graph that is no longer constrained to be bipartite. The vertices still correspond to questions by the referee and the edge-labeling d denotes the permutations defining the winning constraints of the game. The value of the single-player game (for a uniform input distribution) is simply and is 0 otherwise, | | E is the number of edges in the graph and S is the classical, quantum or super-quantum set of boxes. It is worth noting that in the single-party scenario, a set of where ρ is a quantum state and P Q , (a) Classical value. A well-known convexity argument shows that the optimal classical value of the game is obtained when the outcomes a b , are assigned to the inputs x y , in a deterministic manner. In terms of graphs, this can be formally described as follows. Consider the assignment of deterministic values i.e., if the values of the assignment do not satisfy the winning constraint defined by the color (permutation) associated with the edge, we say that there is a contradiction. Then the minimal number of contradictions over all deterministic vertex assignments for a graph G with a given edge-labeling . This quantity characterizes the classical value of the game: Super-quantum is the set of all conditional probability distributions (referred to also as behaviors or boxes) ( | ) which are consistent, i.e., they satisfy the criterion that the marginal distribution ( | ) P a x i i is consistenly defined for each vertex x i of the graph in a manner independent of the context (clique of the graph) in which it appears. More precisely, they satisfy the following condition: with an uncolored (gray) edge e and (c) (G,K)-with a colored e. The graphs (a), (b) show that while gray edges do not affect the classical value, they can potentially affect the quantum value of a game. Definition 14. For a given graph , and for the set of vertices In the case of a bipartite graph G with the bi-partition of V(G) being the set of inputs of the two parties, the above consistency condition is nothing but the no-signaling condition given in equation (1). With super-quantum resources, for any graph G and edge labeling K, one readily gets that e for all edges i.e. the maximally correlated distribution (according to the permutation p e ) over all outcomes at the edge. Then, by definition all constraints are satisfied with probability 1, hence as desired. Moreover, since the marginal distribution at each vertex for the above strategy is simply given by ( | ) = P a x d 1 , we have that equation (9) is a well-defined super-quantum box.

XOR-d games for partial functions
In this section, we consider the possibility of XOR-d games corresponding to partial functions ( ) f x y , , i.e., where the winning constraints are only defined for a subset of input pairs (x, y). We incorporate this in the graphtheoretic formulation by simply allowing the edge-labeling to leave some edges uncolored. However, since the measurements corresponding to the two vertices in the uncolored edge might still be required to commute, we depict these as gray edges. An important example where such edges naturally arise is the Braunstein-Caves Chained Bell inequality [51]. This inequality concerns a game with N 2 inputs which has numbers from the set 2 2 for Alice and from the set 2 1 for Bob. However, the winning constraints are only defined for N 2 neighboring pairs {( 1 mod 2 N : 0, ,2 1 and only these enter the chained Bell expression. The corresponding graph has N 2 edges forming a cycle. But all of Alice's measurements commute with all of Bob's measurements, so that the additional gray edges are added. This distinguishes the chained Bell inequality in the two-party scenario from the N 2 cycle contextuality game [52] which is simply depicted by the cyclic graph C 2N .
In the partial function XOR-d game, we have a sub-graph denote that the observables represented by the vertices x and y must commute, but they do not have to satisfy any other constraints. The success probability in the game is thus given as Clearly, in the classical case the minimum number of contradictions for a given , .
C C This is not necessarily true for the quantum case, since vertices connected by a gray edge still have to commute. Nevertheless, we have the following straightforward general dependencies.
K e for any edge Ï ¢ e E , the following inequalities are true: where g C and g Q denote un-normalized classical and quantum values, that is ( (6), respectively. Since finding quantum value g Q is a hard task, in most cases we provide only an upper bound on g Q , denoted as g 3 2 . This is the maximal value of the given game obtained (numerically) from a semidefinite programming set which approximates the set of quantum boxes. The notation comes from the fact that g 3 2 is obtained by the semidefinite program which in the well-known NPA hierarchy [14] appears between the first and the second level of the hierarchy, denoted as well as + Q AB

1
. This level of the hierarchy corresponds to the set of almost quantum correlations. For an example of a graph with gray edges, see figure 4.

Equivalent games
In this section, we use the graph-theoretic approach to find non-equivalent games both in the single-and twoparty scenario. Two games are equivalent when they can be transformed into each other by operations which do not change the winning probability, i.e., ( ) w G c and ( ) w G q are equal for these games. The operation transforms the edge labeling of one game graph into that of the other.

Equivalent XOR games using signed graphs
The XOR game graphs are in fact equivalent to the well-known class of signed graphs [53], i.e., graphs with 'positive' and 'negative' edges. Positive edges correspond to edges labeled with identity (correlations) and negative to edges labeled with ( ) 01 (anti-correlations). Signed graphs are much studied in literature due to their extensive use in modeling social processes [54] and also because of their interesting connections with classical mathematical systems. A cycle in a signed graph is said to be balanced if it contains an even number of negative edges, a signed graph itself is said to be balanced if all of its cycles are balanced.
A marking of a signed graph is a function , with respect to a marking μ is the operation of changing the sign of every edge label of G to its opposite whenever its end vertices are of opposite signs. Formally, we have that equivalent XOR games correspond to switching equivalent signed graphs. Switching equivalent signed graphs ( ) G K ,

Equivalent XOR-d games: labeled graph equivalence
We now generalize the notion of signed graph equivalence from [53] to find equivalent XOR-d games both in the single-and two-party scenarios. We consider two labeled graphs ( ) G K , 1 1 and ( ) G K , 2 2 to be equivalent if one can be obtained from the other by isomorphism between G 1 and G 2 , replacing a directed edge uv labeled with π with an edge vu labeled with p -1 , and switching operations ( ) s s v, which we define below. In terms of games, switchings correspond to local operations such as relabeling of outputs by the players.
For any graph G and edge-labeling if , , replace Note that the above operation applies not only to XOR-d games, but to all unique games. In fact, labeled graphs representing some nonlinear unique games may be equivalent to some XOR-d games. If we wish to obtain only XOR-d games equivalent to a given XOR-d game, we have to limit the permutations σ used in the switching operations to the set of such permutations s Î S d that sp Î L d for all p Î L d . Since for every p p Î L , s v, 012 applied (multiple times) for each Î v V, and their automorphic copies (see figure 5). The above notion can also be extended to include graphs with uncolored edges. In this case the switching operation ( ) s s v, changes the color ( ) p = K e with sp (or ps -1 as for p Î L d , s Î ¢ L d there is sp ps = -1 ) for all colored edges incident to v, while uncolored edges remain unaffected. It is easy to see that the equivalence still preserves all relevant properties of the game.

Classical value
The graph theoretic approach is also useful for studying the classical values of XOR, XOR-d and other unique games. As we have seen, the classical value of an XOR-d game (for both Bell and non-contextuality inequalities) defined by a graph G with edge-labeling K obeys where b C denotes the minimum number of contradictions over all deterministic vertex-assignments. To study this number we will use, in particular, a graph constructed from the graph G and edge-coloring K which we simply call KG.

XOR games
We can characterize the contradiction number (and hence the classical value) of a general XOR game (with one or two parties) in a graph-theoretic manner as follows.
is equal to the minimal number of edges which need to be removed from G so that the resulting graph does not contain any cycle with an odd number of dashed ( ) 01 edges.
Expressed in terms of labeled graphs, this states that a graph G with edge-labeling ( )  K E G S : 2 has a consistent vertex-assignment if and only if it has no cycles with an odd number of edges labeled with ( ) 01 . Thus, if and only if there are no such cycles in the graph. The problem of calculating the classical value of a XOR game, and ( ) b G K , , C is known to be NP-hard [12]. The proof of the statement follows directly from the fact that every unbalanced cycle leads to a contradiction, and from the following characterization of balanced signed graphs in [53].

Fact 1 [57]
. A signed graph is balanced if and only if its set of vertices can be partitioned into two disjoint subsets in such a way that each positive edge joins two vertices in the same subset while each negative edge joins two vertices from different subsets.

Complexity of computing the classical value for single color XOR games
We now consider a subclass of XOR games in which the winning constraints only ask for anti-correlations between the outcomes. This type of game is represented by a graph in which all the edges are dashed (i.e. labeled by the permutation ( ) p = 01 ). Clearly, all bipartite graphs with such a labeling are satisfiable, i.e., the corresponding Bell inequalities have classical value one. Thus, single color games are trivial in the Bell scenario and only relevant in a scenario of contextual games. Also, for general graphs if the edges are all solid (labeled by the identity) then clearly, the game is won by a classical strategy. We now characterize the classical value of contextuality games corresponding to single ( ) 01 color non-bipartite graphs, as we shall see computing the classical value is hard even in this simplest possible scenario. Proof. Clearly, a bipartite graph with only dashed edges is satisfiable: one can assign value 0 to all vertices in one partition, and value 1 to the vertices in the other partition. To see the converse, recall that a graph is bipartite if and only if it does not contain an odd cycle. Now, if a graph ¢ G obtained from G by removal of edges is not bipartite, it must contain an odd cycle. An odd cycle of ( ) 01 edges clearly contains a contradiction for every vertex assignment. , Thus, determining the classical value of a single color contextuality XOR game is equivalent to finding the edge-bipartization number ( ) b c 2 of the corresponding graph. This problem is known to be MaxSNP-hard [21]. It can be approximated to a factor of ( ) n O log in polynomial time, where n is the total number of vertices (see [22]). Also, note that assuming the Unique Games Conjecture, it is NP-hard to approximate Edge Bipartization within any constant factor [13].
Note that for the corresponding single color subclass for XOR-d games, the edge-bipartization number only gives an upper bound on ( ) b G K , C (a lower bound on the classical value). Since all cycles of even length in such graphs have b = 0 C , removing all cycles of odd length will result in a graph without contradictions. However, this is not always an optimal solution. For example, considering C 5 (the cycle graph of length 5) labeled with any single permutation p Î L 3 , we find that ( ) b = 1 C 2 while clearly b = 0 C since a vertex assignment satisfying such a winning constraint can always be found (by assigning the same value to all vertices according to π).

XOR-d games
The classical value of the specific XOR-d game called the CHSH-d game has been studied in [43,44] using techniques from algebraic geometry. In this section we study the classical value of generalized XOR-d games using graph-theoretic methods. Clearly, if the game graph is cycle-free (forms a tree), then any set of winning constraints for this graph can be satisfied. Hence it must be the presence of the cycles, which disallows satisfiability. Just like an unbalanced cycle in an XOR game graph leads to a contradiction, there are also 'bad' cycles in XOR-d game graphs. These are the cycles for which no consistent vertex-assignment exists that satisfies all the winning constraints in the cycle. There are 'good' cycles in an XOR-d game graph analogous to the balanced cycles in the binary XOR case, for which any consistent vertex assignment satisfying the winning constraint is admissible. However, in the case of XOR-d game graphs, we encounter new 'ugly' cycles, for which only certain particular vertex assignments satisfy the cycle (see figure 6). It then becomes a non-trivial question to study how many edges one needs to remove in order to make a graph satisfiable, as for instance in the figure 7 removing a bridge (a single edge connecting two components) of the graph can lead to a better result than a brute-force removal of one edge per each 'ugly' cycle.

The Good, bad and the ugly cycles
We say that a cycle C in a graph G with edge-labeling  K E S : d is bad if it has no vertex-assignment that satisfies the constraints and good if it has d such assignments (i.e. the largest possible number), otherwise the cycle is ugly. We denote by ξ with the corresponding subscript (g, b, u) the number of good, bad and ugly cycles respectively. Clearly, any bad cycle has to be removed to make the graph satisfiable, while also removing all the ugly cycles necessarily leaves a satisfiable graph. Now, if there are no ugly cycles ( ( , 0 u , we can leave at least one ugly cycle. This is because the single ugly subgraph has an assignment, which determines a consistent assignment for the whole graph. Therefore, we have the following observation. Observation 2. For any XOR-d game graph G with edge-labeling K using d colors, if ( ) It is clear that a graph with only one cycle can have at most one contradiction. Whether or not there is a contradiction can be determined through the composition of all permutations assigned to the cycle's edges. We define a permutation ( ) ( ) ( ) p = K e K e K e ... , Theorem 3. A cycle C t has a consistent vertex-assignment for a given edge-labeling K if and only if p C t has at least one fixed point.
Proof. It is easy to see, that for a vertex-assignment It follows that the number of contradictions in a given graph is at most the number of cycles. It may, however, be greater than the number of bad cycles.

The graph KG
To study the number of contradictions and consistent vertex-assignments in a given graph G with edge-labeling ( )  K E G S : d , we define the graph KG, described in more detail in [25]. This graph is constructed as follows.
of d vertices.
(2) Connect two vertices For an example of the graph KG for G being a particular cycle graph and K being a particular set of permutations, see figure 8. For a connected graph G the assignment number ( ) b ¢ G K , C is equal to the number of connected components of KG isomorphic to G. Each such component contains exactly one vertex from the set corresponding to a given vertex. Thus, a consistent vertex-assignment exists if and only if there exists a vertex v i not connected to any , : It follows that the contradiction numbers ( , are the same. Analogously these graphs have the same ( ) b ¢ G K , C . This fact holds true even for some nonlinear, but unique games. If G is a bipartite graph and  K E L : d (i.e., a XOR-d game) every cycle in G has either 0 or d consistent vertex-assignments. Furthermore, in [25] the following theorem is proved: We will now consider a type of game in which each of the two players has d possible answers. This game corresponds to the complete bipartite graph K s t , with an edge-labeling  K E L : . d Thus, to find the classical bounds we search for the minimal set of edges which need to be deleted so that there are no more induced cycles with contradictions. In the case of K 3,3 and smaller bipartite graphs, by theorem 5 to make it good, we need only to delete edges until all remaining cycles of length 4 are good. For all possible edge-labelings of K , 3,3 with three colors in 74.07% of cases b = 2 C and in 2.5% of cases b = 3.

Quantum value : Lovász theta as an upper bound for a single-party contextuality game
For two-party XOR games, the theorem of Tsirelson [26] and the subsequent analysis in [20] gives an efficient semi-definite programming method to compute the exact quantum value. For general XOR-d games however, this is no longer the case and the semi-definite programming hierarchy of [14] has to be applied. It is at present unknown whether the quantum value of these Bell inequalities can be obtained at some particular level of the hierarchy. An efficiently computable upper bound on the quantum value of general XOR-d and other linear game Bell inequalities was proposed in [46] and subsequently generalized to the multi-party scenario in [47].
For single-party contextuality, in [19], it was shown that the quantum value of any non-contextuality inequality involving projectors represented in an orthogonality graph Γ is given by the (weighted) Lovász theta number ( ) q G w of the orthogonality graph. Analogously, the classical value of the inequality is given by the (weighted) independence number ( ) a G w of the orthogonality graph. While calculating the independence number of an arbitrary graph is a well-known NP hard problem, calculating the Lovász theta number can be achieved by means of a semi-definite program. As such, in the scenario of single-party contextuality as studied in the traditional 'Kochen-Specker' scenario [38] involving yes-no questions represented by projectors in quantum theory, the quantum value was exactly and efficiently computable by an SDP. Therefore, for the singleparty XOR games and their generalization to XOR-d studied so far, one might wonder whether the quantum value is still efficiently computable. The answer to this question turns out to be negative even in the single party scenario.
Let us first describe for a given single-party contextuality game represented by a commutation graph G, the method of constructing the corresponding orthogonality graph Γ, from which we might hope to calculate the quantum value. and ,..., . We thus see that each maximal clique C i (G) of size k of the commutation graph G corresponds to a d k sized maximal clique˜( ) G C i of the orthogonality graph Γ.
Each of the probabilities ( x y x y , appearing in the game expression can be expressed (as marginals) in terms of the probabilities ( | ) P l l A A ,..., ,..., , so that the game expression can be written as a weighted sum of probabilities of the events appearing in the graph Γ. An orthonormal representation of a graph Γ is a set of unit vectors | ñ . The weighted Lovász theta number of the graph Γ was defined by Lovász as [24] ( ) | | | ( ) associated to the vertex v enters the game expression. An example of a commutation graph G and its corresponding orthogonality graph Γ is shown in figure 9.
It is important to note however that for the general non-contextuality game (both in the XOR and XOR-d scenario) involving observables in a commutation graph G, it may no longer be the case that the ( ) q G w of the corresponding orthogonality graph gives the quantum value. While a numerical check for some of the commutation graphs illustrated in figure 11 in section 7 finds that ( ) q G w is in fact equal to the quantum value, it may be that in general just as in the case of Bell inequalities, the weighted Lovász theta number only gives an upper bound to the quantum value of general non-contextuality inequalities. This was also noted in [23], that in general even for non-contextuality inequalities one needs a hierarchy of semi-definite programs analogous to the well-known semi-definite programming hierarchy [14] for Bell scenarios, an n-partite Bell inequality here being represented by an n-partite commutation graph. The analysis of contextuality games via the notion of hyper-graphs with each hyper-edge representing a context was performed in [23] where such an analog of the NPA hierarchy for contextuality was described.
3 and correlations between A 1 and A 4 . The game is represented here by its commutation graph G (on the left) and the corresponding orthogonality graph Γ (on the right) which represents exclusivity relations among events occurring in the game. Figure 10. The only non-equivalent single-color graphs with 6 vertices for which the classical value is not equal to g 3 2 . Note that all the edges here denote anti-correlations, for simplicity, the dashed edges have been replaced by solid ones. Figure 11. Colors on these figures are used only in order to visualize certain subgraphs. Figure (a) (top row) depicts non-equivalent single color graphs, with very small difference between g 3 2 and g C compared to the typical case. All these graphs contain a chordless cycle of length at least 4, marked in red. Figure (b) (bottom row) depicts all the non-equivalent single-color graphs with 7 vertices for which g g = + 0.25 . Note that all these graphs are chordal, and admit a joint probability distribution so that the g g = Q C for these graphs. They also all contain K 5 as an induced subgraph, marked in blue.
6. XOR-d games for device-independent applications: pseudo-telepathy XOR-d games are a natural class of Bell inequalities to consider for device-independent applications. Indeed, the class of XOR-d games for binary outcomes (i.e., the XOR games) have been used in most of the deviceindependent protocols constructed so far, (the CHSH Bell inequality for quantum key distribution [41], the Braunstein-Caves chained Bell inequalities for randomness amplification [30] and key distribution against nosignaling adversaries [28], as well as the multi-party XOR games for randomness expansion [29] as well as randomness amplification [32,33]). XOR-d games have the important property of being uniform [17], i.e., there exists an optimal quantum strategy for these games where each party's local outcomes are uniformly distributed. This can be seen from the fact that for any quantum strategy for a game with d outcomes, Alice and Bob can make use of a shared random variable r uniformly distributed over { } d 0 ,..., 1 to obtain a quantum strategy with locally random outcomes that achieves the same success probability for the game. Simply Alice performs + a r d mod and Bob performsb r d mod preserving the value of + a b d mod while simultaneously randomizing their outcomes. In certain cases, such as the particular example of the CHSH game with ternary outputs in [34] or the binary XOR games, locally random (and correlated) outcomes appear naturally in the optimal quantum strategy. As such, it is natural to look for device-independent protocols for randomness or secure key generation that use these Bell inequalities.
Pseudo-telepathy is an interesting application of quantum correlations to the field of communication complexity. By means of quantum correlations, two (or more) players are able to accomplish a distributed task with no communication at all, which would be impossible using classical strategies alone. Stated in technical terms, these are games G which have ( ) Pseudo-telepathy games have also found use in certain device-independent protocols [32,33] for amplification of arbitrarily weak sources of randomness. In this section, we study the possibility of obtaining pseudo-telepathy within the class of two-party XOR-d games.
The Braunstein-Caves chained Bell inequalities (which correspond to XOR games for partial functions) have the property that their quantum value approaches 1 as the number of inputs increases and indeed, this property was very crucial in their use in device-independent applications [28,30,31]. While one might asymptotically approach unity with increasing number of measurement settings, for real experimental applications, it is extremely important to find Bell inequalities with finite number of inputs and outputs from which randomness or secure key can be extracted. XOR-d games being the paradigmatic example of Bell inequalities for which optimal quantum strategies involve locally random outcomes, a natural question is to ask whether finite XOR-d games exist which achieve pseudo-telepathy. Our result states that for both total as well as partial functions, while one might asymptotically approach 1, no finite XOR-d game with prime d number of outcomes exists for which ( ) This generalizes the recent result for total XOR-d functions in [46] and for binary XOR functions in [20]. Theorem 6. No finite two-party XOR-d game G corresponding to a (partial or total) function ( ) f x y , for prime d number of outputs can be a pseudo-telepathy game, i.e., if ( ) proof. Let G be a finite two-party XOR-d game for prime number of outputs d, corresponding to function ( ) f x y , for input pairs (x, y) and let ( ) By sharing a uniformly distributed random variable r (specifically by local operations + a r d mod andb r d mod ), the two parties Alice and Bob can obtain an optimal quantum strategy which has locally random outputs. Let this optimal quantum strategy be given by , . This also implies due to the fact that the XOR-d game is a unique game, that for every input pair (x, y) which has a positive probability in the game, i.e., ( where ζ is the lth root of unity, so that we have To prove that this classical strategy achieves ( ) w = G 1 c for the game, we have to show that for the quantum strategy these values of ( ) ( ) a x b y , , . Evaluating this quantity, we obtain so that equation (22) cannot hold and we have obtained a contradiction.
Therefore, we have that ( ( ) ( )| ) = P a x b y x y , , 0so that the classical strategy given in equation (19)

Multi-party pseudo-telepathy
For more than two party non-locality scenarios, the well-known GHZ paradoxes [36] show that it is possible to have XOR games corresponding to partial functions for which ( ) Indeed, the GHZ paradoxes such as the Mermin inequality have been used in device-independent protocols for randomness amplification [32,33] and randomness expansion [29]. While these involve m-party correlation functions, recently it has been of interest to consider Bell inequalities involving two-party correlation functions [35] that are much easier to measure experimentally.
As such, we extend the considerations of the previous subsection to the scenario of 'partial' XOR games that involve two-party correlation functions alone and investigate whether pseudo-telepathy is possible in this scenario. These are games for m parties with inputs ( ) where ( ) A x i i are observables for party i and input x i with eigenvalues±1. Note that this generalization to many parties is not strictly a unique game since some of parties are not required to output unique outcomes.
Theorem 7. No m-party XOR game G involving two-body correlators can be a pseudo-telepathy game, i.e., if Proof. The proof follows similarly to that of the previous theorem. Let G be an m-party binary outcome XOR game involving two-body correlation functions and having ( ) As in the previous theorem, the optimal quantum strategy given by the shared entangled state |  yñ Î Ä = While this generalization to many parties is not strictly a unique game so that we cannot precisely identify the non-zero probabilities, we still have for each set of inputs

Explicit examples and numerical results
In this section we provide classical, the almost quantum value (denoted by g 3 2 ) [14] and the quantum values for small XOR-d games in both the single-party contextuality and two-party Bell scenario. We choose one graph from each equivalence class, since the equivalence relation preserves the classical, quantum and superquantum values of the game. One interesting sub-class of games is those that have no quantum advantage. Since , it follows that any game G with ( ) . This makes use of a construction of a joint probability distribution from [15] where it was shown that all chordal graphs, i.e., graphs containing no chordless cycles of length 4 or more, have ( ) . Finally, as we have seen in section 5 the Lovász θ function of the orthogonality graph representing the game also gives an upper bound on the quantum value that is in general worse than ( ) g G 3 2 . Clearly, if ( ( )) ( ) G. ) and the complete graph K 5 (g g = » 6, 6.25 ). It is straightforward to see that the classical and quantum values of any complete graph must be equal: for a complete graph, the quantum probabilities [ | |] y y ñá A Tr a x are obtained from a set of mutually commuting observables A a x , since all vertices are adjacent with each other in the clique. This implies that any such quantum box can be described by a single joint probability distribution for all observables simultaneously. Hence, any quantum box can equivalently be described by this classical distribution, so that the quantum value of the game is equal to the classical one. It is also known, that for C 5 the quantum and classical values are different [52]. These facts imply finally, that C 5 is the only 5-vertex graph for a single color XOR game in which g g ¹ .  . For four out of these g g = + 0.25. All edges in those graphs lie in cliques of size 3 or more, and we construct an explicit joint probability distribution following [15] which implies that g g = Q C . It is important to note, that in figure 11 below we use colors for different purpose than in other figures, that is not to depict one of the 3 kinds of permutations as in figure 3, but to visualize certain subgraphs of a given graph. Cl . Bipartite graphs (the first three) represent Bell's inequalities, others correspond to contextual games.

Two and three color XOR-3 games
We have calculated the classical and almost quantum values for all equivalence classes of 3 color (XOR-3) games defined by small connected graphs without vertices of degree 1. Adding such a vertex to any graph G simply increases both classical and quantum values by 1, since the additional constraint is always satisfiable. Every XOR-3 game graph with five or less vertices for which the values are different is equivalent to one of the graphs in figure 12.
7.2. Two-party XOR-3 Bell inequalities 7.2.1. Total function ternary input XOR-3 games Every bipartite 3 color (XOR-3) game on six vertices for which the g 3 2 value is higher than classical is equivalent to one of the graphs in figure 13. In this case, we have also calculated the quantum value by optimizing over twoqutrit states and observables. In each case of ternary input-output Bell inequalities, except the CHSH-3 scenario considered in [34,43] we find that the quantum value calculated for qutrits matches (up to numerical precision) the almost quantum value of the SDP hierarchy [14]. . In each of these cases, an optimization over two-qutrit states and observables shows a) K 4,2 Bellʼs inequalities b) K 3,3 Bellʼs inequalities. Note that the third graph from left falls into the CHSH-d class of Bell inequalities considered in [34,43]. (c) Other graphs. In each of the games in (b), (c) except the CHSH-3 game, an optimization over two-qutrit states and observables shows that the quantum value is in fact equal to the g 3 2 value up to numerical precision.

Partial function ternary input XOR-3 games
We have also calculated classical and g 3 2 values for some small (5 vertices and bipartite with 6 vertices) XOR-3 game graphs with uncolored edges, i.e., those corresponding to partial functions. We conjecture that these are the only 3-colored graphs with uncolored edges for which classical and quantum values may be different. Figure 14 depicts all possibly non-classical classes of 3-colored graphs with 5 vertices, and bipartite graphs with 6 vertices, in which every vertex is incident to at least two colored edges.
Note that the set only includes one chain (i.e. the graph K 3,3 in which only a 6-cycle is colored). All labelings of C 6 with three colors are equivalent to either ( ) ( ) = K e 01 for all Î e E(good) or ( ) ( ) = K e 12 1 and ( ) ( ) = K e 01 for { } Îe E e . 1 Interestingly, this is not necessarily the case for 4 and more colors. Thus, all labelings of the same graph with 2 or three colors in which only a 6-cycle is colored must also form exactly two equivalence classes. As explained in the beginning of this section, vertices of degree 1 do not matter in graphs for total function games. However, even though we do not count uncolored edges as constraints, vertices incident to one or more uncolored edge and only one colored edge do need to be considered. If ( ) Î v V G is incident to only one colored edge, the classical value of the game is equal to ( The quantum value, however, may differ from ( { }) g -+ G v 1.

Q
A possible example where the g 3 2 value differs is presented in figure 4. Figure 14. Three-colored XOR-d graphs with uncolored edges such that g g ¹ C 3 2 . Note, like in the two-colored case, that the set includes only one chain (marked with ' * ').

Conclusions
We have studied the generalization of XOR games to arbitrary number of outcomes known as XOR-d games which belongs to the well-known class of unique games called linear games. We first abstracted two paradigmatic properties of the XOR games and showed that for odd values of d, the unique class of games that obey these two properties were the earlier studied class of linear games. In both the contextuality and nonlocality scenarios, we introduced a graph-theoretical description of these games in terms of edge labelings with colors representing different permutations. There followed a natural relation between equivalent classes of games and the graph-theoretic notion of switching equivalence and signed graphs. We also studied the classical value of these games in terms of graph-theoretic parameters. In particular, computing the classical value of single-party anti-correlation XOR games was related to finding the edge bipartization number of a graph, which is known to be MaxSNP hard. Computing the classical value of more general XOR-d games was related to the identification of specific bad and ugly cycles in the graph. Studying classical value can be done in many ways, in particular here we have studied it via three types of cycles in a graph-the so called good cycles which satisfy all vertex assignments, the bad cycles for which no assignment leads to satisfiability, and interestingly the ugly ones, which makes the problem of satisfaction difficult, as they satisfy some but not all vertex assignments. Another graph theoretical tool is the graph KG-a permutation graph of the game graph G. This tool will be heavily used in [25], here we showed that it allows for testing whether a given graph corresponds to a game that can be won with probability 1 using classical resources.
We also studied the quantum value of these games using the Lovász theta number of the corresponding orthogonality graph. We show how the constraint graph representing the game can be used to construct the orthogonality graph and find that its Lovász theta number still gives only an upper bound on the quantum value even for single-party contextuality XOR-d games. An important property of the XOR-d game Bell inequalities is that for these, an optimal quantum strategy can be found for which the outcomes of each party are uniformly distributed and correlated. This makes these games ideal candidates for device-independent applications. Indeed XOR games, in particular the Braunstein-Caves chained Bell inequalities have found widespread use in such tasks. We showed that for both partial and total functions, no finite XOR-d game (for prime number of outcomes) exhibits the property of pseudo-telepathy, i.e., maximum algebraic violation of such Bell inequalities cannot be obtained in quantum theory. We also extended the result to multi-party 'partial' XOR games which involve only two-body correlation functions, showing that such Bell inequalities cannot achieve algebraic violation.
An interesting question is to develop this framework to get more analytical bounds such as in [43]. It would also be important to study more general unique games using a similar approach. Given that finite XOR-d games do not exhibit pseudo-telepathy, an important open question is whether the chained Bell inequalities and their generalization to many outcomes are the class of XOR-d games that exhibit the best asymptotic rate of convergence of the quantum value to unity. Numerical studies for small size games indicates that apart from the CHSH-d games considered earlier, the quantum value for ternary output games is achieved at the level + AB 1 of the SDP hierarchy from [14]. It would be interesting to investigate whether a sub-class of the XOR-d games can be proved to achieve optimality at particular intermediate levels of the hierarchy.