Homotopical approach to quantum contextuality

We consider the phenomenon of quantum mechanical contextuality, and specifically parity-based proofs thereof. Mermin's square and star are representative examples. Part of the information invoked in such contextuality proofs is the commutativity structure among the pertaining observables. We investigate to which extent this commutativity structure alone determines the viability of a parity-based contextuality proof. We establish a topological criterion for this, generalizing an earlier result by Arkhipov.


Introduction
Contextuality is a characteristic feature of quantum mechanics [1,2] that distinguishes quantum from classical physics. It rules out the description of quantum phenomena by so-called noncontextual hidden variable models, in which each observable has a pre-determined value which is merely revealed by the act of measurement. Such models are either internally inconsistent, or fail to reproduce the predictions of quantum mechanics.
What leads to paradoxes under too stringent assumptions about physical reality becomes a commodity if these assumptions are not made: contextuality is also a resource in quantum computation. For two models of quantum computation-quantum computation with magic states [3] and measurement-based quantum computation [4]-it has been shown that a quantum speedup can occur only if contextuality is present [5][6][7][8][9][10][11][12].
At its core, contextuality is about the interplay between local consistency and global inconsistency [13]; and therefore topological methods are particularly suited to discuss it. Presently four approaches to contextuality have been described that employ topology: the topos approach by Döring and Isham [14,15], the approach based on Čech cohomology by Abramsky and coworkers [16], the geometric approach by Arkhipov [17], and the approach based on cohomology of chain complexes [18]. For other approaches to contextuality see [19][20][21][22][23] and for refinements of the Čech cohomology approach see [24][25][26][27].
In this paper we unify the approach of Arkhipov and the approach based on chain complexes, thereby generalizing one of Arkhipov's results [17]. Both [17] and [18] are concerned with so-called parity-based contextuality proofs, of which Mermin's square and star are representative examples [28]. Generally, a parity-based contextuality proof is a set of linear constraints on hypothetical value assignments that has no solution. Although concerned with the same type of contextuality proof, [17] and [18] use different abstractions and address slightly different questions.
Ref. [18] asks: Does a given set O of observables produce a parity-based contextuality proof? The first step in answering this question is in extracting the essential information of the set O of observables, in terms of a chain complex C that captures the commutativity structure within O, and a cocycle β that captures the phase information of product relations among commuting elements in O. Then, a parity-based contextuality proof arises in the setting specified by O if and only if the cocycle β is cohomologically nontrivial, [β] = 0.
Arkhipov [17] invokes a different abstraction and addresses a different question. Rather than a chain complex, [17] defines an intersection graph G, with the edges labeling observables and the vertices labeling contexts. Again, G captures the commutativity structure among the observables involved. The counterpart to the cocycle β of [18] is a sign function defined on the vertices of G. Arkhipov's question is, in a sense, the reverse of the above; namely: Given the intersection graph G, does there exist a corresponding set O of observables that produces a parity-based contextuality proof? This question has a surprisingly simple-and topological-answer. Namely, the intersection graph G can give rise to a paritybased contextuality proof if and only if G is nonplanar.
In [17], rather than a set O of observables, the intersection graph G is the primary object. The broader significance of this is that a geometrical object encoding commutativity relations among observables emerges at the base of quantum mechanical contextuality. In this paper, we seek generalizations of Arkhipov's results to a greater variety of physical settings and to understand the structure of the emerging geometric objects.
We now summarize how the two abovedescribed approaches [17] and [18] are unified, how one of Arkhipov's results is thereby generalized, and why such a generalization is desirable. First, we observe that the intersection graph G employed in [17] is defined only for settings in which each observable in O is part of no more than two contexts. This is a consequence of the simple fact that an edge in a graph has no more than two end points.
The extension of Arkhipov's results to settings with observables contributing to more than two contexts is, for example, relevant for the discussion of contextuality in measurement-based quantum computation (MBQC). In the standard MBQC setting [4], applied to evaluation of Boolean functions on m input bits [10], there are 2 m measurement contexts overall. Each local observable measurable in the process, chosen from a set of 2, appears in one half of these contexts. Therefore, each such observable appears in more than two measurement contexts whenever m > 2.
Our main result is that one direction of Arkhipov's result can be generalized in the formalism of [18] based on a chain complex C, with no bounds on the number of contexts that any given observable can appear in. Specifically, a complex C can yield a parity-based contextuality proof only if the topological space X C corresponding to C is not simply connected, i.e., only if π 1 (X C ) = 1. For example, in the case of Arkhipov the complex C can be described by a closed surface Σ g of some genus g together with a cell structure on it. The intersection graph G corresponds to the dual cell structure of Σ g . Vanishing of the fundamental group coincides with the planarity of the intersection graph in this case. Also, in [17] all observables are constrained to have eigenvalues ±1, whereas the present treatment permits operators with eigenvalues e 2πi/d , for any d ≥ 2.
The remainder of this paper is organized as follows. In Section 2 we introduce magic arrangements and explain the connection to the notion of contextuality. Section 3 we introduce the basic tools: topological realizations and path operators. Section 4 contains our main result (Theorem 4.6). In Section 4 we study topological realizations via the fundamental sequence of homotopy groups. Then in Section 5 we move on to define a representation of the fundamental group of a topological realization and use this to refine our main result (Corollary 5.6). Section 6 is on the algorithmic approach [29,30] to parity-based contextuality proofs and how it relates to the topological approach presented in this paper.

Magic arrangements
Many proofs of contextuality of quantum mechanics employ fixed sets of observables to find obstructions to the existence of non-contextual value assignments.
Two key examples are Mermin's square and star [28]. However, the existence of the obstruction does not depend on the precise choice of the observables; for example, conjugating each observable in the set by the same unitary produces an equivalent proof. Rather, it depends only on which subsets of observables commute, and how commuting observables multiply. In Arkhipov's formulation, this information makes up the so-called "arrangement", and the commutativity part of it the socalled "intersection graph" of the arrangement.
The definition of the intersection graph is as follows. Given a fixed set of observables for a contextuality proof, such as Mermin's square or star, these observables become the edges of the intersection graph, and the sets of commuting observables, i.e., the contexts, become the vertices of the intersection graph. Thus, two edges have the same vertex as end point if and only if the corresponding observables commute. To stick with the above examples, the intersection graphs of Mermin's square and star (see Fig. (2)) are the bipartite complete graph K 3,3 and the complete graph K 5 , respectively.
Central in [17] is the notion of "magic" arrangements. They appear in the context of nonlocal games [31], cooperative strategies that demonstrate contextuality as a resource for winning with high probability. An arrangement is magic if the edges of its intersection graph can be populated with Hermitian operators with eigenvalues ±1, but not with numbers ±1. The significance of this notion is that every magic arrangement gives rise to a proof of contextuality. Formally, a set of contraints among quantum observables is specified, and a contextuality proof would be a demonstration of the failure to satisfy these constraints by predetermined outcome assignments to the observables.
The relevant basic notions can be formalized as follows. Let L be a finite set, and M denote a collection of subsets of L. The elements of M are called contexts. Together the pair (L, M) can be regarded as a hypergraph with vertices L and edges M. We will call such a pair an arrangement. We will allow operator inverses to appear in the constraints. Therefore we are given a sign function : L → {±1}. The triple (L, M, ) will be referred to as a signed arrangement 1 . We sometimes drop from notation and simply write (L, M).
Arrangements can be used to define operator constraints. Operator constraints are determined by a function τ : M → Z d where d ≥ 2. A quantum realization of (L, M, , τ ) is a function T : L → U (n) for some n such that • Each operator satisfies (T a ) d = I.
• In each context the operators {T a | a ∈ C} pairwise commute.
• For each context C ∈ M the operators satisfy the constraint We say an arrangement is (classically) quantum realizable if (L, M, , τ ) has a (classical) quantum realization for some τ . An arrangement is called 1 This terminology is different than Arkhipov's. magic if it is quantum realizable but not classically realizable. When the arrangement satisfies the property that each observable is contained in exacly two contexts one can define the intersection graph. Can it be judged from the intersection graph of an arrangement alone whether the arrangement is magic? Arkipov answers this question in an affirmative way, and provides the following characterization.

Theorem A. An arrangement is magic if and only if its intersection graph is non-planar.
A shortcoming of this result is that the intersection graph is defined only when each observable appears in no more than two contexts (edges have only two end points). Our generalization removes this restriction: Observables can appear in arbitrarily many contexts. The geometrical object underlying our construction is a 2-dimensional cell complex, or more algebraically the associated chain complex. In the special case where Arkhipov's result applies, i.e., when each observable is only contained in two contexts, then the intersection graph and the chain complex are related by a duality.

Operator realization
Given a signed arrangement (L, M, ) we will introduce the notion of a topological realization. The idea is to encode the operator relations Eq. (1) in a topological way. For this construction we do not require the operators to commute in each context. Therefore we relax the notion of a quantum realization by removing the commutativity requirement.
An operator realization for (L, M, , τ ) is a function T : L → U (n) such that (T a ) d = I for all a ∈ L and satisfies Eq. (1) for each context. In this case for Eq. (1) to make sense we order the elements of each context C and write {a 1 , a 2 , · · · , a n } for the elements. Then Eq. (1) can be written as

Chain complex of an arrangement
We would like to introduce a chain complex before starting our discussion of a topological real-ization. This algebraic construction associated to a given arrangement will capture the constraints Eq. (1) using a chain complex. We define a chain complex D * (M) whose 2chains, 1-chains, and 0-chains are given as , and D 0 = Z d together with the boundary maps for each context C = {a 1 , a 2 , · · · , a k }. The corresponding cochain complex is denoted by D * (M).

Topological realizations
We can construct a topological space that realizes the chain complex D * (M). The construction can be given as a cell complex consisting of elementary pieces called n-cells. An n-cell is an ndisk which geometrically corresponds to vectors of length ≤ 1 in the Euclidean space R n . The construction starts with a collection of 0-cells i.e. points, and proceeds by gluing the boundary of the cells in a prescribed way -see Appendix §A.
To realize the chain complex D * (M) we start with a single point, and glue from both end points a 1-cell for each a ∈ L to this single vertex. Then for each context C we glue a 2-cell (disk) whose boundary traverses the loops labeled by C = {a 1 , · · · , a k } with orientation given by the sign function . The ordering of the elements is dictated by the constraints Eq. (3) that is the boundary of the 2-cell is glued along the labels a 1 , a 2 , · · · , a n respecting the order.
Let us denote the resulting space by X sing , emphasizing that it has a single vertex. Now the chain complex (with Z d coefficients) C * (X sing ) is exactly the chain complex D * (M) introduced earlier. For spaces it is customary to denote the homology and cohomology groups by H * (X, Z d ) and H * (X, Z d ), respectively.
Our space X sing consists of a single vertex. We will be interested in other spaces that can be obtained by a similar process that is used to construct X sing but with possibly using more than one vertex, although the edges and faces are kept the same. So a topological realization of an arrangement is a connected cell complex X which has 1-cells labeled by a ∈ L and 2-cells labeled by C ∈ M. The disk labeled by C has its boundary divided into segments labeled by its elements and oriented by (for example as in Fig. (1)). In fact, this construction gives a special type of a cell complex, namely, a combinatorial cell complex. This means that the attaching map of a 2-cell maps an edge on the boundary homeomorphically to the corresponding edge on the 1-skeleton. See Appendix §A for a definition of a combinatorial cell complex, and basic properties. By construction there is a map C * (X) → D * (M) of chain complexes. Since the 1-cells and 2-cells are isomorphic this map induces an isomorphism on second cohomology. As a consequence we can regard the class [τ ] as living in H 2 (X, Z d ).
To motivate this definition we relate it to Arkhipov's construction of the intersection graph. In the special type of scenarios that Arkhipov considers one can define an intersection graph G from the given data of the hypergraph. Then there is a closed oriented surface Σ g of genus g into which the graph can be embedded. The surface with minimum g determines whether G is planar or not. The minimum value of g is zero, that is when Σ g is a sphere, if and only if the graph is planar. The embedding problem can be thought of possible ways of obtaining a surface from the graph by adding faces (gluing disks). Our framework is dual in the sense that given the embedding G ⊂ Σ g we consider the dual graph G and regard the vertices of Σ g as glued faces to this dual graph. Therefore X corresponds to the surface Σ g with the cell decomposition determined by G .

Example 3.2.
The intersection graph of the Mermin square and star examples correspond to the graphs K 3,3 and K 5 . They can be embedded in a torus as displayed in Fig. (2). Here the boundary of the square region is identified in a way to obtain a torus. This can be achieved by identifying parallel edges with the same orientation. The torus has a cell structure given by triangles or rectangular shapes. The graphs (depicted in blue) live on the torus in such a way that their vertices match one-to-one with the 2cells of the torus. These graphs are non-planar, that is the self-intersection cannot be avoided by moving the edges. We can embed them into a torus, but there is no way to embed them into a plane (or a sphere). To illustrate the definition of a topological real-ization let us consider the Mermin square example. The triple (L, M, ) specifying the arrangement is given by M consists of 6 contexts given by the 2-cells. Each context consists of 3 observables. Our 2cells are topologically equivalent to triangles in this case. Observables label the edges of the triangles. Since each operator squares to identity the sign does not have an effect on the operator constraints. However, to be able to specify the topological realization we need to make a choice. We make our choice so that the topological realization gives a torus (We will come back to other possible choices, see Fig. ( 5)). The operator constraints are given by 6 equations that look like X 1 X 2 (XX) = I, Z 1 Z 2 (ZZ) = I,... Only one of them multiply to −I, namely (XX)(ZZ)(Y Y ) = −I. Therefore τ : M → Z 2 assigns 0's to every context, except this latter one, which is assigned 1. Alternatively we can see τ as a 2cochain on the torus, this time interpreted as assigning values in Z 2 to each triangle. For Mermin star L consists of 10 observables and M consists of 5 contexts. Each context has 4 observables. Thus our 2-cells are rectangular shapes in this case. Similarly τ assigns values in Z 2 to contexts, and the corresponding 2-cells, determined by the products of the observables in each context.

Path operators
Our topological realization X encodes operator relations by the attaching maps of the 2-cells. These attaching maps are nice so that our space is a combinatorial cell complex. For this purpose in this section we will assume that X is a combinatorial 2-complex. See §A for the definition of combinatorial complexes and combinatorial maps.
Recall that an operator realization is a function T : L → U (n) and we can think of L as the labels for the edges in a topological realization X. Fix a vertex v of X for the rest of the discussion. For us a path at v is represented by a combinatorial map p : S 1 → X for some cell structure on S 1 . In other words, p traverses a sequence of edges a (a 1 ) 1 , · · · , a (a k ) k of X where (a i ) = ±1 specifies the orientation. Its image can be just the vertex v as well. We define a path operator If the image is just v we set T p to be the identity matrix I.
Given two paths p, q we can define the product path p · q which means traversing p first and then q. In the combinatorial language if q is specified by the sequence of edges b then the product would be given by a . By definition of the path operator we have Another elementary property is that changing orientation of the path amounts to inverting the operator T p −1 = T −1 p , again by definition.

Example 3.3.
Consider two 2-cells that share a common path as in Fig. (3). Let us orient both cells clockwise. Regarding the 2-cell as 2-chains the common path p 2 gets a plus sign from the left cell and a minus sign from the right cell. The sum of the chains is geometrically represented by the face F obtained by merging the cells. F comes with the clockwise orientation hence it corresponds to the relation that is obtained by multiplying the two constraints and F 2 are oriented clockwise. We can cancel the operators in two different ways: which possibly gives different results. The problem is that after canceling T a (or T b ) we cannot cancel the remaining operator.

Dragging along a path
We introduce a deformation of a map along a path that will be useful for certain constructions related to homotopy groups. This is a standard trick in algebraic topology. Let D 2 denote the unit disk in R 2 , and S 1 denote its boundary. We give a base point * to D 2 that lies in the boundary, for example we can set (1, 0) as the base point. Given a map g : D 2 → X and a path β from w = g( * ) to a fixed vertex v ∈ X we define a new mapg β : D 2 → X that is obtained by deforming g by dragging the point w backwards along the path β. We refer tog =g β as the deformation of g along β. If α is the loop at w given by the image of the boundary under g theng β maps the boundary of the disk to the loop β · α · β −1 at v. For a more technical definition see [33, page 341].
Similarly, we can deform a map f : S 1 → X by dragging along a path and writef for the resulting map.

Fundamental sequence
The key topological tool for studying 2dimensional cell complexes is the fundamental sequence. Let X 1 denote the 1-skeleton of X, the oriented graph on which we glue the disks. There is an exact sequence of homotopy groups We describe the groups in this sequence: • π 1 (X) is the fundamental group of X. It is defined with respect to a vertex v ∈ X, and consists of homotopy classes of maps f : S 1 → X that carries the base point * ∈ S 1 to v.
• Second homotopy group π 2 (X) is the homotopy classes of maps h : • The relative homotopy group π 2 (X, X 1 ) consists of homotopy classes of maps g : Exactness means that at each consecutive map · · · α → A β → · · · in the fundamental sequence, the kernel of β is equal to the image of α. The most interesting map in the exact sequence is the boundary map ∂. It is defined on an element Φ : D 2 → X by restriction onto the boundary: hence as a result one obtains a map S 1 → X 1 i.e. an element of the fundamental group of X 1 .
We start by describing π 1 (X 1 ). Recall that X 1 is an oriented graph. Let T ⊂ X 1 be a maximal tree. T consists of all the vertices but it avoids loops. In particular, it is contractible. Select a vertex v ∈ T as a base point. For each remaining edge e i , 1 ≤ i ≤ n, choose paths p i and q i in T that connects the two vertices of e i , the source and the target, to the vertex v. Consider the loop a i = p i · e i · q i that consists of traversing p i , e i , q i . Then π 1 (X 1 , v) is the free group generated by the homotopy classes of loops a i : a n ). 2) for the explanation of the tuple (L, M, , τ ). The difference comes form the orientation of the boundary edges. The resulting spaces are distinct: a torus X 1 = T and a projective plane X 2 = RP 2 . The maximal trees are given by T 1 = {e 8 , e 9 } and T 2 = {e 2 , e 8 , e 9 }. Note that adding an extra edge to these trees creates a loop. The main difference between the two cases is the number of vertices on the boundary. X 1 has a single vertex v 1 on the boundary and X 2 has two given by v 1 , v 2 . In both cases we need to construct the loops a i form the edges e i outside the maximal tree.
• For X 1 the loops at v 1 can be chosen as follows: Therefore π 1 ((X 1 ) 1 ) is the free group F 7 on 7 generators, where (X 1 ) 1 is the 1-skeleton of X 1 .
• For X 2 with base point v 1 we can choose: In this case for the 1-skeleton (X 2 ) 1 the fundamental group π 1 ((X 2 ) 1 ) is the free group F 6 on 6 generators.
Next we move to π 2 (X, X 1 ). First we show that each characteristic map Φ j : D 2 → X, 1 ≤ j ≤ m, can be interpreted as an element of the relative homotopy group. Choose a path β j in T from the point Φ j ( * ) to v. LetΦ j : D 2 → X denote the deformation of Φ j along β j . Theñ Φ j satisfies the requirements for a map to be in the relative homotopy group. Thus its homotopy class [Φ j ] belongs to π 2 (X, X 1 ). Fig. (5) the 2-cells in both cases are labeled by C j . Let us consider the torus case. We think of C 1 as a map Φ 1 : D 2 → X where the base point * ∈ D 2 is mapped to v 1 , the boundary ∂D 2 traverses e 1 · e 2 · e −1 9 , and the interior of the disk is mapped homeomorphically to the face C 1 . We orient each face in the clockwise direction. In this case we do not need to drag the characteristic map along a path since each face contains the base point v 1 . In the RP 2 case there are faces not containing the base point v 1 , such as C 2 and C 5 . We can connect them to v 1 by dragging along the path e 9 . So after dragging we think of C 2 as a mapΦ 2 : D 2 → X whose boundary traverses e 9 · e −1 2 · e 3 · e −1 8 · e −1 9 . We do a similar construction for C 5 .

Action of the fundamental group
There is an action of π 1 (X 1 ) on the relative homotopy group. Let γ be a loop in X 1 based at v and Φ : D 2 → X be a map representing an element of the relative homotopy group. Then the map γΦ obtained from the action of γ on Φ is given by the deformationΦ γ of Φ along γ. The boundary map ∂ respects this action in the sense that ∂(γΦ) = γ · ∂Φ · γ −1 .
Now we can conclude our description of the relative homotopy group. The key technical tool is the approximation result given in Lemma A.1 of §A. This result reduces considerations to combinatorial maps. As a result the relative homotopy group π 2 (X, X 1 ) is generated by Combining this with the fundamental exact sequence gives us a presentation of the fundamental group π 1 (X) as well as a description of π 2 (X) in terms of the characteristic maps of the 2-cells of X.

Example 4.3.
As we know that the gluing in Fig. (5) produces a torus and a projective plane we can calculate what the fundamental group is in each case: Now the fundamental sequence is giving us a presentation for these groups. That is we have This can be verified by considering all the relations imposed by the characteristic maps.

Evaluation on a disk
We study the evaluation of the coycle τ on a disk and relate it to the path operator associated to the boundary. We assume that (L, M, , τ ), which we used to construct X, has an operator realization T : L → U (n).
Recall that the 2-cells of X encodes the operator relations in Eq. (1). We express this using the characteristic map. Given a map g : Y → X we write g * τ for the pullback of the cocycle. We will apply this construction to characteristic maps. Let Φ j : D 2 → X denote the characteristic map of the 2-cell that corresponds to the context C j ∈ M. We rewrite Eq. (1) using the path operator notation: Here Φ * j τ means that the cocyle τ is regarded as a 2-cocycle on D 2 via the map Φ j . Therefore we can evaluate it on the whole disk to obtain the number Φ * j τ (D 2 ). Another point is that the action of a path γ on the characteristic map does not change the operator as a consequence of Eq. (5) and Eq. (6).
The key observation is a generalization of Eq. (6). Instead of evaluating τ on a disk using a characteristic map Φ j we consider the general case of a cellular map g : D 2 → X. We can ask about the result of evaluating the cochain g * τ on the whole disk. The result turns out to be exactly the path operator associated to the loop g(∂D 2 ). Lemma 4.4. For a combinatorial map g : D 2 → X we have Proof. By definition of a combinatorial map, g satisfies the two properties • on some 2-cells g acts as a (signed) characteristic map Φ ± j l , 1 ≤ l ≤ r, • the remaining 2-cells are product cells and they are collapsed to a 1-cell or a 0-cell.
A product cell (define more precisely in §A) is a rectangular region with horizontal boundary components h 1 , h 2 and vertical boundary components v 1 , v 2 . Parallel boundary components are oriented in the same direction. Without loss of generality we can assume g collapses the vertical direction of this cell. Therefore T v 1 and T v 2 are both equal to the identity operator. On the other hand T h 1 = T h 2 . Therefore the operator assigned to the boundary of a product cell is given by the identity operator. We can remove the product cells one by one to obtain Note that D 2 is a compact space, and there are only finitely many cells. Therefore the elimination process eventually terminates. Using Eq. (6) for each j l gives us the evaluation of g * τ on the whole disk since the product cells do not contribute to the evaluation.

Non-magic arrangements
A connected space whose fundamental group is trivial is called a simply connected space [33]. We will consider a simply connected topological realization X. Since X is a 2-dimensional cell complex Hurewicz theorem [33,Corollary 4.33] implies that X is homotopy equivalent to a wedge sum of 2-spheres. Wedge sum means that the spheres are glued as a single point. For a pair of spheres the resulting space is denoted by S 2 ∨ S 2 . Therefore we need to understand how τ evaluates on spheres. So we consider a map h : S 2 → X.
The cochain h * τ defined on the sphere only depends on the homotopy class of h. That is if h is another such map homotopic to h then h * τ = h * τ . This is the homotopy invariance of cohomology. In the following we will approximate an arbitrary map by a combinatorial map to be able to apply Lemma 4.4. Roughly, the idea is to think of a sphere as composed of two disks glued along their boundary and use Lemma 4.4 for each disk to conclude that evaluation of τ on each piece is the same as the product of the operators on the boundary. Since the boundary of the disks are oriented oppositely these products cancel out exactly. Proof. The fundamental sequence Eq. (4) implies that [h] ∈ π 2 (X) can be written as an element [Φ] in the relative homotopy group π 1 (X, X 1 ) such that ∂[Φ] = 1 in π 1 (X 1 ). Moreover by Lemma A.1 we can first deform ∂Φ to a combinatorial loop, and then we can deform the resulting map to a combinatorial map on the whole disk. Thus h is homotopic to a combinatorial map Φ : D 2 → X such that ∂Φ is a contractible loop in the 1skeleton X 1 . Since homotopic maps induce the same map in cohomology we have h * τ = Φ * τ and applying Lemma 4.4 to Φ we obtain It remains to calculate T ∂Φ(D 2 ) . As a consequence of contractability of ∂Φ there exists a map Φ : D 2 → X 1 ⊂ X that extends the combinatorial map ∂Φ. Up to homotopy we can assumeΦ is also combinatorial (Lemma A.1). The cell structure on D 2 consists of only product cells since the image ofΦ is a path. Now we can apply Lemma 4.4 toΦ: since product cells do not contribute to the evaluation of the cocycle.
Now we come to our generalization of Arkhipov's result on restricted arrangements, i.e. each observable belongs exactly to two contexts, that the arrangement is magic only if the intersection graph is non-planar. Theorem 4.6. If an arrangement (L, M) is topologically realizable by a simply connected space X then it is non-magic.
Proof. Non-magic means that either there is no quantum realization or if there is one then we need to show that it has a classical realization. Suppose that there is a quantum realization for some τ . As we observed above X can be continuously deformed into a wedge of spheres S 2 ∨ · · · ∨ S 2 . This decomposes the cohomology as By Lemma 4.5 the cocycle τ vanishes on each sphere. This implies that [τ ] = 0, or equivalently, there exists a function c : L → Z d such that dc = τ . This function gives the desired classical realization.
Remark 4.7. In fact Theorem 4.6 is more general. Stated for operator realizations it says that if (L, M, , τ ) can be topologically realized by a simply connected space and it has an operator realization then it can also be classically realized.

Representation of the fundamental group
In this section we reinterpret Lemma 4.4 and produce a projective representation of π 1 (X). This refined approach will allow us to improve Theorem 4.6.

Definition of the representation
Let T : L → U (n) be an operator realization for the data (L, M, , τ ). Given a topological realization X of the signed arrangement (L, M) we can consider the assignment p → T p from a loop S 1 → X (combinatorial map) at v to the unitary matrices. Lemma 4.4 says that if p is homotopic to q, written as p ∼ q, then the disk H : D 2 → X which realizes this homotopy (see  Here the homotopy p ∼ q is thought of as a map from the disk that sends the upper half of the boundary to p and the lower half to q. As a result we obtain that T p and T q differ by a scalar, written as T p ∼ ω T q . So modulo the scalar subgroup ω we obtain a well-defined homomorphism where [T p ] denotes the equivalence class of the operator under ∼ ω .

Linearization
An equivalent way of thinking about this representation is to consider the fundamental sequence (see Eq. 4) of X: This makes the construction more concrete since T 0 can be chosen more specifically using the isomorphism π 1 (X 1 ) ∼ = F (a 1 , · · · , a n ). We set T 0 (a i ) = T a i and extend it to a homomorphism on the free group.
Given a function α : {a 1 , · · · , a k } → Z d let us define a new homomorphism T α : π 1 (X 1 ) → U (n) by setting T α (a i ) = ω α(a i ) T 0 (a i ). Let Im ∂ denote the image of the homomorphism ∂. Proof. Assume that the liftT exists. Let us writē a i for the image of a generator under the quotient map ρ : π 1 (X 1 ) → π 1 (X). ThenT (ā i ) has to be ω α(a i ) T 0 (a i ) for some α(a i ) ∈ Z d by commutativity of the diagram in Eq. (8). We can set T α a i = ω α(a i ) T a i . Then T α =T • ρ and we obtain that T α (Im ∂) =T •ρ(Im ∂) = I by exactness i.e. ρ ∂ is the identity map.
Conversely, if there exists α such that T α maps the image of ∂ to I that means T α descends to a homomorphismT : π 1 (X) → U (n) which turns out to be a lift of T . Here we use the presentation of π 1 (X) given by the upper row of Eq. (8).

Classical realization as linearization
We describe the link between the projective representation of the fundamental group and the classical realization problem. This result will be used to generalize Theorem 4.6.

Lemma 5.2. Suppose that p, q are two loops in
Proof. The idea is similar to the proof of Lemma 4.5. Let H : D 2 → X 1 denote the map that realizes the homotopy between p and q. We can assume H is combinatorial as usual. Composing H with the inclusion X 1 ⊂ X we can apply As π 2 (X, X 1 ) is generated by the homotopy classes of the elements γΦ j the image of ∂ is generated by ∂(γΦ j ). We can expand this element as a word in the generators a 1 , · · · , a k of the free group, say as a sequence a 1 i 1 · · · a r ir where l = ±1. Then applying Lemma 5.2 to the homotopic paths ∂(γΦ j ) and a 1 i 1 · · · a r ir and using Eq. (7) gives For notational simplification we write T i for T a i , and τ j for τ (C j ) (also means Φ * j τ (D 2 )). We start with the torus case. With our choice of a i loops the relations imposed by the characteristic maps can be written as If we multiply these equations in the given order then we end up with the equation We can verify this on Mermin square. In the projective plane case we get more information from the loop relations. They are given by Using these equations we obtain: Comparing the two expressions for T 7 we obtain In particular we see that T 0 : π(X 1 ) → U (n) has image given by an abelian group since all the T i commute with each other. Now let us consider different cases for d: • d = 2: When ω = −1 Eq. (10) becomes T 2 4 = ±1. First assume that T 4 = 1, in other words, τ i = 0. This means that [τ ] = 0 in H 2 (X, Z 2 ) and thus we have a classical realization. Note that the projective representation lifts to a linear representation in this case. Since each T i has order 2 the image of T 0 is an elementary abelian 2-group. We can simply send This defines a group homomorphismT : π 1 (X) → U (n). For the other case where T 4 = −1. We have [τ ] = 0 and thus no classical realization exists. This is the case for the Mermin star: where we used the usual operator realization.
• d odd: Eq. (10) has an interesting consequence. We can invert 2 to obtain and therefore T i ∼ ω I for all i. Therefore for any operator realization T the loop operators turns out to be a scalar. To solve the classical realization problem we can use the assignment: e i → T a i , which is a scalar, and the rest of the edges e / ∈ T maps to 1. This assignment satisfies the required relations and is a valid classical realization. From the representation point of view, we have that T : π 1 (X) → U (n)/ ω is the trivial representation for any operator realization T . Therefore a lift always exists.

Remark 5.4.
This illustrates the benefit of rewriting the operator relations as loop relations. As we also observed there is a strong connection between linearization of the projective representation and the existence of classical realization. Next we make this connection precise.
Theorem 5.5. The data (L, M, τ ) together with an operator realization T : L → U (n) induces a projective representation T : π 1 (X) → U (n)/ ω such that the following are equivalent: • There exists a classical realization of (L, M, τ ).
• T can be lifted to a linear representation.
Proof. Suppose that T lifts to a linear represen-tationT : π 1 (X) → U (n). By Lemma 5.1 for some α we have T α (Im ∂) = I. Using α let us define a classical realization c : L → Z d by setting c(e i ) = −α(a i ) for each edge e i corresponding to the generator a i , and set c(a) = 0 for the remaining labels in L. Recall that a i were originally defined form edges e i that lie outside of the maximal tree T . We claim that c is a classical realization for τ . We regard c as an operator realization C : L → U (1). This way we can apply the results obtained for operator realizations. We need to check that dc(C j ) = τ (C j ). In terms of operator realizations this is equivalent to showing C Φ j (∂D 2 ) = T Φ j (∂D 2 ) as a consequence of Lemma 4.4 and the definition of C. Applying Eq. (9) to both C and T (taking γ the trivial path) we can replace ∂Φ j with the homotopic path a 1 i 1 · · · a r ir . Now we calculate since a 1 i 1 · · · a r ir = ∂[Φ j ] lies in the image of ∂. Conversely, let c : L → Z d be a classical realization. Let α(a i ) = −c(e i ) and consider the operators T α . Lemma 5.1 implies that to show that there exits a lift it suffices to check that T α (a 1 i 1 · · · a r ir ) = I for any product a 1 i 1 · · · a r ir that lies in the image of ∂. Since c is a classical realization Lemma 4.4 implies that C a 1 Using Eq. (11) we find that T α (a 1 i 1 · · · a r ir ) = I.
Corollary 5.6. If (L, M) has a topological realization X such that π 1 (X) is a finite group whose order is coprime to d then any operator realizable τ is classically realizable.
Proof. Let T be an operator realization of τ . By Theorem 5.5 it suffices to show that there exists a liftT : π 1 (X) → U (n). Let G denote the quotient group T (π 1 (X)). Similarly G is a finite group and its order is coprime to d. To see that the liftT exists it suffices to show that any extension splits. The extension splits as a consequence of the Schur-Zassenhaus theorem [34,Theorem 7.41]. This theorem says that when the order of the quotient group G is coprime to the order of the kernel ω then every extension splits.
As we have observed in Example 5.3 that for projective plane realization of the Mermin square and d is odd any operator relation has a classical solution. From the corollary we see that this is, in fact, a direct consequence of the fact that π 1 (RP 2 ) = Z 2 which implies H 2 (RP 2 , Z d ) = 0 when d is odd.
6 Quantum realizations and the algorithmic approach 6

.1 Quantum realization
We have defined the operator realization without the requirement that the operators in each context must commute. Therefore a quantum realization is an operator realization such that for each context C ∈ M the operators {T a | a ∈ C} pairwise commute. We would like to understand the effect of the commutativity requirement on the topological realizations.
We will modify our definition of a topological realization to accommodate the extra requirement imposed by commutativity. For an operator realization we constructed a cell complex X sing with a single vertex. Given the constraints the definition of this cell complex is unique. Then we defined a topological realization X to be a cell complex with the same set of 1-cells and 2-cells but except possibly more than just a single vertex. The way the 2-cells are glued in the new complex must be compatible with X sing i.e. comes with a map of cell complexes X → X sing . Under this map the multiple vertices are identified to a single vertex.
When we pass to quantum realizations, due to the commutativity condition, the definition of X sing is no longer unique since we can always permute the labels in a given context. Alternatively if we fix X sing then we can allow a more flexible notion of a topological realization that takes commutativity into account. We choose the latter approach. Definition 6.1. Given a quantum realization and a fixed choice of X sing , a commutative topological realization is a cell complex X together with a map of chain complexes r * : C * (X) → C * (X sing ) such that r 1 : C 1 (X) → C 1 (X sing ) and r 2 : C 2 (X) → C 2 (X sing ) are isomorphisms.
As it is reflected in this definition the commutation requirement "abelianizes" the geometric requirement of having a map of cell complexes to just having a map of chain complexes. This relaxation amounts for the freedom of permuting the labeling within contexts when we realize it topologically. To compare the two versions, for a fixed choice of X sing a topological realization asks for a map of cell complexes X → X sing , whereas a commutative topological realization only requires a map of chain complexes C * (X) → C * (X sing ).

Orientation reversing
A typical example of a commutative topological realization that is not allowed in the operator realization case can be obtained by reversing the orientation of each cell. For a cell complex X let us denote byX the cell complex obtained from X by reversing the orientation of its edges, and reversing the orientation of its 2-cells. If X → X sing is a cellular map, contracting all vertices to a single vertex, there may not be a cellular map X → X sing . But there is a map of chain complexes C * (X) → C * (X sing ), send a generator corresponding to an edge or a face to its negative. Therefore X →X is an operation that is available only for the quantum realizations. Example 6.2. Let us consider the Mermin square example. In Fig. (7) we see two choices of orientations for the cells. Let X sing denote the complex obtained from X by identifying all the vertices. We see thatX does not admit a cellular map to X sing . The reason is that, for example, the top cell is glued in the wrong order: ACD −1 versus AD −1 C. But when we pass to chain complexes the order does not matter, and a chain map exists. Next we illustrate an application of the orientation reversing operation to deduce that the Mermin square arrangement is non-magic for d odd. Suppose that there is a quantum realization T for a given τ . Note that on a 2-cell Φ j : D 2 → X and its orientation reversed versionΦ j : D 2 →X the evaluation of τ gives the same result since the operators placed on the edges of the boundary pairwise commute. Therefore evaluation of τ on the whole surface is the same in both cases. Let us write τ (X) for this common value. At the boundary we get two different equations Combining them we obtain ω 2τ (X) = 1.
But when d is odd, this equation implies that τ (X) = 0. Equivalently, the arrangement is nonmagic.

Raising constraints to a power
Another special feature of quantum realizations is that given a constraint and a natural number m we can take the m-th power of both sides. Using commutativity we obtain a new constraint This is a very useful property which allows one to concentrate on a prime divisor of d. Thus if {T a } is a quantum realization for (L, M, , τ ) then also {T m a } is a quantum realization for the same arrangement.
We are interested in quantum realizations with T d a = I for a fixed d. To emphasize dependence on d let us denote a quantum realization by (T, d).
Let p i denote the prime divisors of d so that we can write For a fixed j let us write d j for the product of p α i i where i = j. So that we have d j = d/p α j j . We can raise each operator T a to the d j -th power T d j a . We will write (T d j , p α j j ) for the resulting quantum realization. Our construction was in such a way that the new operators have order given by a prime power. This follows from Similarly τ can be broken into prime power pieces. For a context C we define τ j (C) to be the product d j τ (C). We write τ j for the resulting assignment M → Z p α j j .
Our goal is to "glue" a given set of classical realizations for each "prime" piece τ j to construct a classical realization for τ . • τ j is classically realizable for each prime divisor p j of d.
Proof. One direction is immediate. Namely given a classical realization c : M → Z d for τ we can simply set c j (C) = d j c(C) to obtain a classical realization for τ j as a consequence of pairwise commutativity of operator constrains in each context. Conversely, given classical realizations c j we would like to construct a global c that works for d. Recall that we have d = t i=1 p α i i . The abelian group Z d factors into a product Z p α 1 1 × · · · × Z p α t t .
(For example Z 6 = Z 2 × Z 3 .) Regard d j , after reducing mod p α j j , as an element of Z p α j j . Therefore θ = (d 1 , · · · , d t ) specifies an element in Z d . We want to construct a multiplicative inverse to θ. This can be done component-wise. Let w j be the multiplicative inverse of d j in the group Z p α j j . Then the element w = (w 1 , · · · , w t ) is the inverse of θ i.e. θw = 1 in Z d . This equation can also be written as Therefore we can write Hence the classical realization defined by will be a classical realization for τ .
As a consequence of this observation for quantum realizations we can always restrict to the prime power case. This restriction also simplifies any algorithmic approach that checks whether a given arrangement is magic or not. Next we will explain the interplay between the topological and algorithmic approaches. We start with the relatively simpler scenario of one-relator groups.

One-relator groups
A convenient way of describing a group is to write down a presentation. A presentation consists of a set of generators and a set of relations. If there is a presentation consisting of only a single relation then the group is called a one-relator group. For example, the fundamental sequence in Eq. (4) is a presentation of the fundamental group π 1 (X). This group is not necessarily a one-relator group. When we restrict our setting to Arkhipov's where only certain types of arrangements are allowed the fundamental group becomes a surface group, in particular a one-relator group.
Let us suppose each observable belongs to exactly two contexts for the moment. Then the intersection graph G can be embedded into a closed surface Σ g of minimal genus. We can use this surface as a topological realization in our framework. Its fundamental group is given by and we have a single relation given by the vanishing of the product of the commutators. Moreover we can apply Lemma 4.4 to this situation. The surface Σ g can be obtained from a disk whose edges are labeled by We can think of this as a (combinatorial) map D 2 → Σ g identifying the boundary with the sequence of loops in the surface described by the partitioning of the boundary. For a set of operator constraints Lemma 4.4 applies to give that is evaluation of τ on the whole surface can be computed from the product of the operators on the boundary, which is given by the product of the commutators. Note that this is the relation defining the fundamental group of the surface realizing the operator constraints. Alternatively, we can read this equality in terms of the product of the constraints Now the restriction that each observable belongs to two contexts (or more generally even number of contexts) implies that the existence of a classical realization forces the right-hand side of Eq. (13) to be equal to 1. This is an AvN type of argument [25].

Solution group
It is possible to assign an abstract group for a set of operator constraints [29,30]. We will consider the quantum case by imposing the commutativity constraint in each context. Recall that L denotes the label set, i.e. the union of the contexts in M, also corresponds to the set of edges of a topological realization, and τ is a function M → Z d . The solution group G is generated by g a where a ∈ L, and J satisfying • [J, g a ] = 1 for all a ∈ L; • [g a , g b ] = 1 for all a, b ∈ C and C ∈ M; 2 • For each C ∈ M there is a relation of the form a∈C g a = J τ (C) .
We denote the quotient group G/ J byḠ. We can think of this as a central extension of groups Note that J replaces the role of ωI in the unitary group.
Going back to the restricted setting of Arkhipov the algorithmic approach as explained in [29] decides about existence of classical realizations by checking the right-hand side of Eq. (13) in the solution group. That is existence of a classical realization is equivalent to the condition that the product of the constrains satisfy C∈M a∈C 2 For operator realizations we remove this condition.
where it is also assumed that d = 2. The equivalence of the two conditions is proved in [17,Proposition 10 & 11]. We would like to generalize this result by making a connection to Theorem 5.5. The projective representation defined there can be modified by replacing the unitary group U (n) by the solution group. Given a (combinatorial) path p specified by a sequence of edges a (a i ) i in X we define the group element Then the assignment [p] → g p gives a group homomorphism θ : π 1 (X) →Ḡ.
Then Theorem 5.5 takes the following form.
Corollary 6.4. The following conditions are equivalent: • There exists a classical realization for the set of constraints; • θ : π 1 (X) →Ḡ lifts to a homomorphismθ : This result is the generalization of the equivalence between the existence of a classical realization and the product of all the constraints being equal to 1, that holds in the restricted setting of Arkhipov. To illustrate this we consider the onerelator case of surface groups. Eq. (13), obtained from Lemma 4.4, also holds in G, that is we have

General case
So far we have looked at the relationship between the topological approach and the algorithmic approach in the restricted types of contexts and the case where d = 2. For arbitrary d and arbitrary collection of contexts the algorithmic approach breaks down. That is checking the value of the product of all the constraints in the solution group does not indicate anything about classical realizability. Our approach solves this problem. We can interpret Corollary 6.4 as follows. For a fixed choice of topological realization X the fundamental group π 1 (X) has a specific presentation π 1 (X) = a 1 , · · · , a n | r 1 , · · · , r m with generators a i and relations r j . In the general case the fundamental group is not necessarily a one-relator group i.e. m ≥ 1. Corollary 6.4 says that we need to check whetherθ lifts to G, that is equivalently we need to check whether the relations r i also hold in G. If we write r i as an equation w i = 1 for some word w i then one needs to verify in the group G the following set of equations:θ This can be checked, for example, using the Knuth-Bendix algorithm [35,Chapter 12]. There is an extra freedom here, that is the choice of X. A different topological realization will change the relations r i to some other relations. Among these different choices some of them would be more favorable in verifying Eq. (16) algorithmically.

Conclusion
The goal of this work is to extend Arkhipov's result on magic arrangements. In the restricted scenario where each observable belongs to exactly two contexts Arkhipov studied contextuality using the intersection graph. For arbitrary arrangements this graph theoretical tool is not available. We have overcome this difficulty by introducing the notion of a topological realization. In this formulation we showed that an arrangement is magic, in other words contextual, only if the fundamental group of the topological realization is non-trivial. We refined this approach further by defining a projective representation of the fundamental group. A classical realization for the given set of constraints can be regarded as a linearization of the representation. When the fundamental group is finite divisibility of its order by a prime divisor of d is required in order to have a magic arrangement. Moreover, quantum realizations can be studied one prime at a time, that is we loose no generality by restricting d to be a prime power. All these observations can be combined with the algorithmic approach that can be utilized by the Knuth-Bendix algorithm for instance. Dialing through different topological realizations produce different sets of relations, generalizing one-relation surface groups, whose verification is expected to vary in efficiency. Thus both approaches can be combined to study magic arrangements.
A Appendix: Topology of 2-dimensional complexes In this section we describe some properties of cell complexes. In particular, we describe combinatorial complexes and combinatorial maps, which are the main technical tools to study the topology of 2dimensional cell complexes. Notation: Following [33] we write A ⊂ B or A ⊃ B for set-theoretic containment, not necessarily proper. As a map an inclusion (monomorphism) is denoted by → and a surjection (epimorphism) is denoted by .

A.1 Cell complexes
Let D n denote the unit disk in R n , and S n denote its boundary ∂D n . A cell complex is constructed in the following way [33]: 1. Start with a set X 0 , called the set of 0-cells.
2. Construct the n-skeleton X n by attaching n-cells to X n−1 via the attaching maps φ j : ∂D n j → X n−1 .
Each cell has a characteristic map denoted by Φ j : D n j → X. A typical example is the following cell structure of a torus T . Let T 0 consist of a single point { * }. Glue two 1-cells using the attaching maps ∂D 1 → T 0 by sending both boundary points to * . The resulting object is the 1-skeleton T 1 and it is a bouquet of two circles, call these two loops α and β. Finally glue a 2-cell using the attaching map ∂D 2 → T 1 by sending the boundary to the loop α · β · α −1 · β −1 .
A map f : X → Y between cell complexes is called cellular if f (X n ) ⊂ Y n . It is well known that any map is homotopic to a cellular map. For our purposes we need maps that have nicer properties than cellular maps in the sense that they are more combinatorial.

A.2 Combinatorial maps
We will describe combinatorial maps only for 2-complexes [32, Chapter II, §1.2]. These types of cell complexes are more rigid in structure and can be manipulated much easier. We need the notion of a product cell. We say a cellular map f : X → Y is combinatorial if • Every 1-cell of X is either mapped homeomorphically onto a 1-cell of Y or collapsed to a 0-cell • Every 2-cell of X is either mapped homeomorphically onto a 2-cell of Y or it is a product cell that is collapsed to a 1-cell or a 0-cell.
A 2-complex is called combinatorial if the attaching map of every 2-cell is combinatorial. In this type of cell complexes the behavior of the attaching maps is simpler. But still the homotopy type captures all possible 2-dimensional cell complexes. Topological realizations introduced in the text are examples of combinatorial complexes. The rigidity of such complexes will be immensely useful to understand the relationship between path operators and the cocycle τ determining the product constraints. Up to homotopy cellular maps are always combinatorial as a consequence of the following technical Lemma. • For a given map f : S 1 → X 1 there is a cell structure on S 1 such that f is homotopic to a combinatorial map.
• Let g : D 2 → X be a map such that the restriction to the boundary is combinatorial. Then there is a cell structure on D 2 , extending the one on its boundary, such that g is homotopic (relative to the boundary) to a combinatorial map.