The Sheaf-Theoretic Structure Of Non-Locality and Contextuality

We use the mathematical language of sheaf theory to give a unified treatment of non-locality and contextuality, in a setting which generalizes the familiar probability tables used in non-locality theory to arbitrary measurement covers; this includes Kochen-Specker configurations and more. We show that contextuality, and non-locality as a special case, correspond exactly to obstructions to the existence of global sections. We describe a linear algebraic approach to computing these obstructions, which allows a systematic treatment of arguments for non-locality and contextuality. We distinguish a proper hierarchy of strengths of no-go theorems, and show that three leading examples --- due to Bell, Hardy, and Greenberger, Horne and Zeilinger, respectively --- occupy successively higher levels of this hierarchy. A general correspondence is shown between the existence of local hidden-variable realizations using negative probabilities, and no-signalling; this is based on a result showing that the linear subspaces generated by the non-contextual and no-signalling models, over an arbitrary measurement cover, coincide. Maximal non-locality is generalized to maximal contextuality, and characterized in purely qualitative terms, as the non-existence of global sections in the support. A general setting is developed for Kochen-Specker type results, as generic, model-independent proofs of maximal contextuality, and a new combinatorial condition is given, which generalizes the `parity proofs' commonly found in the literature. We also show how our abstract setting can be represented in quantum mechanics. This leads to a strengthening of the usual no-signalling theorem, which shows that quantum mechanics obeys no-signalling for arbitrary families of commuting observables, not just those represented on different factors of a tensor product.


Introduction
Non-locality and contextuality are fundamental features of physical theories, which contradict the intuitions underlying classical physics. In particular, they are prominent features of quantum mechanics, and the goal of the classical no-go theorems of Bell [1], Kochen-Specker [2], etc is to show that they are necessary features of any theory whose experimental predictions agree with those of quantum mechanics. 4 maximal non-locality. We use this equivalence to characterize maximal contextuality, and in particular maximal non-locality, in terms of a Boolean satisfiability problem naturally associated with a probabilistic model, for the case of dichotomic measurements, and more generally in terms of a constraint satisfaction problem (CSP).
• We apply our linear algebraic methods of constructing global sections to the issue of giving local hidden-variable realizations using negative probabilities [14][15][16][17]. We show that there is an equivalence between the existence of such realizations and the no-signalling property.
• We give a general perspective on the Kochen-Specker-type theorems as generic (modelindependent) proofs of strong contextuality. We show the general combinatorial structure of these results, and make connections to graph theory, leading to the notion of Kochen-Specker graphs, defined in purely graph-theoretic terms.
• We prove a general result (theorem 8.1) which shows a strict equivalence between the realization of a system by a factorizable hidden-variable model, and the existence of a global section which glues together a certain compatible family on a presheaf. Factorizability is a general property, which subsumes both Bell locality and a form of non-contextuality at the level of distributions as special cases. This means that the whole issue of non-locality and contextuality can be translated into a canonical mathematical form, in terms of obstructions to the existence of certain global sections. This opens up the possibility of applying the powerful methods of sheaf theory to the study of the structure of these notions.
• We show in detail how the abstract setting we use can be represented in quantum mechanics; hence our results apply to all the standard situations. One interesting point that emerges from this is that the property of compatibility of a family of sections on a presheaf corresponds to a form of no-signalling [18]. This form of no-signalling subsumes, but is more general than, the usual notion; it applies to arbitrary families of commuting observables, not just to those represented on different factors of a tensor product. We therefore prove a generalized no-signalling theorem, showing that quantum mechanics does satisfy this more general property.
The remainder of this paper is organized as follows. The basic setting is motivated and laid out in section 2. The correspondence between global sections and (deterministic) local hidden variables is explained in section 3. The linear algebraic method for constructing global sections (or determining their non-existence) is presented in section 4, together with the results relating to the Bell and Hardy models. The equivalence between no-signalling and the existence of local hidden-variable realizations with negative probabilities is proved in section 5. Strong contextuality, the results relating to the GHZ models and the hierarchy between Bell, Hardy and GHZ, and the connections with maximal non-locality, are presented in section 6. The general combinatorial structure of Kochen-Specker-type theorems is studied in section 7. In section 8, we prove our general result relating factorizable hidden-variable models to the existence of global sections. Representations in quantum mechanics, and the generalized form of no-signaling, are treated in section 9. Section 10 contains a postlude, summarizing what has been done, discussing related work and describing some further directions.
The mathematical background needed to read this paper is quite modest. In particular, only the bare definitions of category and functor are required. A brief appendix reviews these definitions.

A basic scenario
Our starting point is the idealized situation depicted in the following diagram. There are several agents or experimenters, who can each select one of several different measurements to carry out, and observe one of several different outcomes. These agents may or may not be spatially separated. When a system is prepared in a certain fashion and measurements are selected, some corresponding outcomes will be observed. These individual occurrences or 'runs' of the system are the basic events. Repeated runs allow relative frequencies to be tabulated, which can be summarized by a probability distribution on events for each selection of measurements. We shall call such a family of probability distributions, one for each choice of measurements, an empirical model.
As an example of such a model, consider the following table. Each row of the table specifies a probability distribution on events for a given choice of measurements, i.e. on the set O C where the row is indexed by C. For example, the event {a → 0, b → 1} is specified to have the probability 1/8. 6 The basic ingredients of our formalism will be the measurement contexts, the events and the distributions on events. A model of a particular measurement scenario will be given by specifying a set of measurements X , a family M of measurement contexts, and for each context C ∈ M, a distribution on the events O C .
We shall now proceed to formalize these ideas. Simple as this setting may seem, it does have significant mathematical structure, which our formalization will enable us to articulate.

Events
We shall fix a set X of measurements. We shall also fix a set O of possible outcomes for each measurement 4 . Throughout this paper, we shall assume that X and O are finite.
For each set of measurements U ⊆ X , a section over U is a function s : U → O. Such a section describes the event in which the measurements in U were carried out, and the outcome s(m) was observed for each m ∈ U .
We shall write E : U → O U for the assignment of the set of sections over U to each set of measurements U . There is also a natural action by restriction. If U ⊆ U , there is a map Altogether, this says that E is a presheaf , i.e. a functor E : P(X) op −→ Set. E has an important additional property. Suppose we are given a family of sets {U i } i∈I with i∈I U i = U ; that is, the family {U i } is a cover of U . Suppose, moreover, that we are given a family of sections {s i ∈ E(U i )} i∈I , which is compatible in the following sense: for all i, j ∈ I , Then there is a unique section s ∈ E(U ) such that s|U i = s i for all i ∈ I . This says that we can glue together local data that are compatible in the sense of agreeing on overlaps; moreover, this glued section is uniquely determined. This gluing property is known as the sheaf condition; it says that E is a sheaf, which we shall refer to as the sheaf of events.
The fact that this sheaf condition holds for E is quite trivial, since we are simply looking at functions on a discrete space; we can always glue together partial functions which agree on their overlaps, just by taking the union of their graphs.

Distributions
To capture the idea that empirically we observe statistical rather than deterministic behavior in microphysical systems, we shall consider distributions on events. It will be advantageous to allow some generality in the notion of distribution we shall consider, by taking the algebra of probabilistic 'weights' as a parameter.
A commutative semiring is a structure (R, +, 0, ·, 1), where (R, +, 0) and (R, ·, 1) are commutative monoids, and moreover multiplication distributes over addition: There are three main examples of semirings which will be of interest: the reals (R, +, 0, ×, 1), the non-negative reals (R 0 , +, 0, ×, 1) and the Booleans We fix a semiring R. Given a set X , the support of a function φ : X → R is the set of x ∈ X such that φ(x) = 0. We write supp(φ) for the support of φ. An R-distribution on X is a function d : X → R which has finite support, and is such that Note that the finite support condition ensures that this sum is well defined. We write D R (X ) for the set of R-distributions on X .
In the case of the semiring R 0 , this is the set of probability distributions with finite support on X . In the case of the Booleans B, it is the set of non-empty finite subsets of X ; thus possibilistic or relational models [19,20] are also covered. In the case of the reals R, it is the set of signed measures with finite support, allowing for 'negative probabilities' [14][15][16][17].
Given a function f : X → Y , we define This is easily seen to be functorial: so we have a functor D R : Set −→ Set. 5 We can compose this functor with the event sheaf E : P(X) op −→ Set, to form a presheaf D R E : P(X) op −→ Set, which assigns to each set of measurements U the set D R (E(U )) of distributions on U -sections. It is worth writing out the functorial action of this presheaf explicitly. Given U ⊆ U we have a map where for each s ∈ E(U ): Thus d|U is the marginal of the distribution d, which assigns to each section s in the smaller context U the sum of the weights of all sections s in the larger context which restrict to s.

Measurement covers
A crucial point is that it may not be possible, in general, to carry out all measurements together. This is implicit in the idea that each agent makes a choice of measurement from 8 several alternatives; only the measurements that are chosen are actually carried out. In the situation where the agents are spatially separated, and the measurements that each carries out are localized to their own site, the measurements at the different parts can be carried out jointly. In general, we must allow for more complex situations, where compatible sets of measurements may overlap in complicated ways.
We shall now introduce the notion of measurement cover, which formalizes the idea that only certain measurements can be carried out jointly.
A measurement cover M on the set X of measurements is a family of subsets of X such that • M is an anti-chain, i.e. C, C ∈ M and C ⊆ C implies C = C .
We think of X as a set of labels for the basic measurements in an experiment. A set C ∈ M is a measurement context, a set of measurements that can be carried out jointly. We shall focus on the maximal compatible sets of measurements, hence the anti-chain condition. Any compatible family of measurements in X will be included in some element of M.
It should be noted that measurement covers provide a very general way of representing compatibility relationships. Of course, a physical interpretation in particular circumstances will give rise to specific structures of this kind. We shall discuss quantum representations of the formalism in detail in section 9. We also discuss the conceptual consequences of our (and related) results concerning compatibility in the postlude in section 10.

Bell-type scenarios.
We shall now describe a particular class of measurement covers that arises in the formulation of Bell-type theorems on non-locality and in the study of PR boxes and other non-local devices.
Consider a disjoint family {X i } i∈I . We think of I as labeling the parts of a system, which may be space-like separated; X i is the set of basic measurements which can be carried out at part i. We form the disjoint union X of this family. We define M to be those subsets of X containing exactly one measurement from each part. Thus we regard measurements carried out in different parts of the system as compatible, but do not allow for compatible measurements in the same part.

2.4.2.
Kochen-Specker-type scenarios. Measurement covers are general enough to cover the situations arising in Kochen-Specker style proofs of contextuality, as well as the Bell-type scenarios for non-locality.
Consider the set X = {m 1 , . . . , m 18 }, and the measurement cover M whose elements are the columns of the following table: The importance of this example is that it can be realized by unit vectors in R 4 , such that each measurement context C in M is an orthogonal set of vectors. This structure is used in the 18-vector proof of the Kochen-Specker theorem in [22].
We shall discuss proofs of the Kochen-Specker theorem in detail later in this paper: from the point of view of the abstract, 'logical' structure in section 7 and as regards the interpretation in quantum mechanics in section 9.2.

Empirical models
We shall now show how the intuitive scenario described at the beginning of this section can be captured formally, using the mathematical structure we have developed.
Suppose we are given a measurement cover M. Recall that M covers X , i.e. M = X . We shall define a no-signaling empirical model for M to be a compatible family for the cover M with respect to the presheaf D R E. This means that for each measurement context C ∈ M, there is a distribution e C ∈ D R E(C). Moreover, this family of distributions is compatible in the sense of the sheaf condition: for all C, C ∈ M, e C |C ∩ C = e C |C ∩ C .
In the case of Bell-type scenarios, this is readily seen to coincide with the usual notion of nosignaling. This says that the probability for Alice to get the outcome specified by s 0 for her measurement m a is the same, whether we marginalize over the possible outcomes for Bob when he makes the measurement m b , or the measurement m b . In other words, Bob's choice of measurement cannot influence Alice's outcome. This is exactly the standard definition of no-signaling. We should also note, as a boundary case, that E(∅) is a one-element set, and D R E(∅) is again a one-element set. Thus if contexts have empty intersection, the compatibility condition is trivially satisfied.
The general notion of a compatible family for arbitrary covers M applies to a much wider range of situations than Bell-type scenarios; later we will show that the empirical models which can be represented as quantum mechanical systems satisfy this more general form of no-signaling.
As we shall only consider no-signaling models in this paper, henceforth we shall simply speak of empirical models.

Examples
We shall now show how some standard examples appear in our formalism.
Consider a bipartite Bell-type scenario, where Alice has two possible measurements {a, a }, and Bob has {b, b }. There are two possible outcomes, 0 or 1, for each measurement.
Thus there are four maximal measurement contexts: which index the rows of the following table: The rows of this table correspond to the sets of sections E(C), where C ranges over the maximal measurement contexts. Thus, for example, the cell labeled with p 2 corresponds to the The table specifies a weight p i for each of these sections; in the standard case of probabilistic models, these will be non-negative reals, such that the values along each row sum to 1, and hence form a probability distribution. The distributions e C for each maximal context C collectively specify what we are calling an empirical model; and the no-signalling condition corresponds exactly to the compatibility condition on this family of distributions.
As a specific example, consider the following table: We shall use this model later to give a proof of Bell's theorem [1]. As another example, consider: This is a PR box [10]. We can also consider models over other semirings of weights. For example, the following is a specification of the possibilistic version of a non-local Hardy model [11], with weights in the Boolean semiring. It can be viewed as specifying the support of a standard probabilistic Hardy model.

Global sections
We shall now show how the structures we have exposed in our mathematical description of empirical models can be brought to bear on the analysis of non-locality and contextuality.
We have already observed that the presheaf of events E is in fact a sheaf; it is natural to ask if the same holds for the presheaf D R E. Indeed, since empirical models are compatible families for this presheaf, to say that the sheaf condition holds for such a family {e C } C∈M , with respect to a measurement cover M, is to say that there exists a global section d ∈ D R E(X), defined on the entire set of measurements X . Such a global section defines a distribution on the set E(X) = O X , which specifies assignment of outcomes to all measurements. Moreover, this distribution must restrict to yield the probabilities specified by the empirical model on all the measurement contexts in M: i.e. for all C ∈ M, d|C = e C . Thus the existence of a global section for the empirical model corresponds exactly to the existence of a distribution defined on all measurements, which marginalizes to yield the empirically observed probabilities. This places the idea of extendability of probability distributions, as studied in pioneering work by Fine [23], in a canonical and general mathematical form.
We can say more than this. A global assignment s ∈ E(X) = O X , i.e. a global section of the sheaf E, can be seen as a canonical form of deterministic hidden variable, which assigns a definite outcome to each measurement, independent of the measurement context in which it appears. This yields an assignment s|C for each measurement context C. A global section d ∈ D R E(X) specifies a distribution on this canonical set of deterministic hidden variables. Each s ∈ O X induces a distribution δ s ∈ D R E(X), where δ s (s) = 1, and δ s (s ) = 0 if s = s . The distribution induced by s on each measurement context C is δ s |C; note that δ s |C = δ s|C . Now we have Thus the condition that d|C = e C for each measurement context C says exactly that we reproduce the empirically observed probabilities e C (s) by averaging over the hidden variables with respect to the distribution d.
It is also easily verified that for each context C, and s ∈ E(C): That is, the probability distribution determined by s factorizes as a product of the probabilities assigned to the individual measurements, independent of the context in which they appear. We shall define a general version of this factorizability property later, in section 8.
If we specialize to the case of Bell-type scenarios, we see that factorizability corresponds to Bell locality [1]. For example, in a context {a, b}, where a is a measurement for Alice and b a measurement for Bob, then for a joint assignment of outcomes {a → o 1 , b → o 2 }, it says that the probability of this joint outcome determined by the hidden variable s is the product of the probabilities it determines for {a → o 1 } and {b → o 2 }. In other situations, it corresponds to a form of non-contextuality at the level of distributions.
We can summarize this discussion as follows.

12
We note also that, as we shall show later (see theorem 8.1), apparently more general forms of realization of empirical models by factorizable hidden-variable models, in which the hidden variables are not required to be deterministic, are in fact equivalent to canonical realizations by global sections. Thus the entire issue of non-locality and contextuality-i.e. the existence of empirical models that have no such realizations-is equivalently formulated as the non-existence of global sections for the corresponding compatible families.
Thus, we have a characterization of the phenomena of locality and non-contextuality in terms of obstructions to the existence of global sections, a central issue in the pervasive applications of sheaves in geometry, topology, analysis and number theory. This opens the door to the use of the powerful methods of sheaf theory in the study of non-locality and contextuality.

Existence of global sections
The discussion in the previous section motivates the following problem: Given an empirical model, determine if it has a global section.
We shall give a general linear-algebraic method for answering this question, which as we have seen is equivalent to the question of whether there exists a realization of the model by local or non-contextual hidden variables.

The incidence matrix
We are given a measurement cover M. The first (and main) step is to construct a matrix M of 0s and 1s, which we shall call the incidence matrix of M. This matrix is defined using only M and the event sheaf E, and can be applied to any empirical model expressed as a compatible family for M, with respect to any distribution functor D R .
To define the incidence matrix, we firstly form the disjoint union C∈M E(C) of all the sections over the contexts in M and then specify an enumeration s 1 , . . . , s p of this set. We also specify an enumeration t 1 , . . . , t q of all the global assignments t j ∈ O X , i.e. the global sections of the sheaf E. We then form the ( p × q)-matrix M, with entries defined as follows: , 0, otherwise. Conceptually, this matrix represents the tuple of restriction maps To see this, note that for each C we have the embedding E(C) −→ P(E(C)) :: s → {s}.
Thus we obtain a map E(X) −→ C∈M P(E(C)). Now we use the isomorphism i∈I P(X i ) ∼ = P i∈I X i to obtain a map E(X) −→ P( C∈M E(C)). Such a map is the same thing as a relation The incidence matrix is the Boolean matrix representation of this relation. Viewing it as a 0/1-matrix over the semiring R, it acts by matrix multiplication on distributions in D R E(X), represented as row vectors: Thus the image of this map will be the set of families {e C } C∈M which arise from global sections.

Example: Bell-type scenarios
We shall illustrate this construction for Bell-type scenarios. Following standard terminology, we shall refer to a Bell-type scenario with n parts, each of which has k possible measurements, each with l possible outcomes, as of (n, k, l) type. Note that for a system of (n, k, l) type, there are k n measurement contexts, for each of which there are l n possible assignments of outcomes. Thus there are (kl) n sections over the contexts. The set of all measurements is of size kn, and there are l kn global assignments. Thus the incidence matrix in this case will be of size (kl) n × l kn . Each row of the matrix will contain l (k−1)n 1s.
We shall describe the (2,2,2) case explicitly. In this case, the matrix is 16 × 16. We shall use the enumeration of sections over contexts given in the table in figure 1. We shall also use an evident enumeration of global sections obtained by viewing them as binary strings, where the ith bit indicates the assignment of an outcome to the ith measurement, listed as a, b, a , b .
The incidence matrix is then as follows.
This matrix has rank 9. We shall give a general formula for the rank of the incidence matrix in proposition 5.6, and apply it to the (n, 2, 2) cases in section 5.3.
We note that in the case of Bell-type scenarios, incidence matrices have been studied as 'transfer matrices' in [24]; see also [25]. 7 Our account generalizes this to arbitrary measurement covers and also provides a clear conceptual derivation of these matrices in terms of the restriction maps.

Global sections as solutions of linear systems
Now we consider an empirical model {e C }, defined with respect to the distribution functor D R . Such a model assigns a weight in the semiring R to each section s i ∈ E(C). Thus it can be specified by a vector V of length p, where V[i] = e C (s i ). We can also introduce a vector X of length q of 'unknowns', one for each global section t j ∈ E(X). Now a solution for the linear system MX = V will be a vector of values in R, one for each t j . To ensure that this vector is a distribution, we augment M with an extra row, every entry in which is 1, and similarly augment V with an extra element, also set to 1. A solution for this augmented system will enforce the constraint and hence ensure that the assignment of weights defines a distribution on E(X). The remaining equations ensure that this distribution restricts to yield the weight specified by the empirical model for each section s j . We also note that in the case of Bell-type scenarios of (n, k, l) type, it is not necessary to use the augmented system; the solutions of the equation MX = V will automatically be distributions. This follows easily from the regular structure of the incidence matrices for these cases.

Examples
We shall consider a number of examples, based on the models of (2, 2, 2) type discussed in section 2.6.

The Bell model. We look again at the Bell model
We are interested in finding a solution in the non-negative reals, i.e. a probability distribution on the global assignments E(X). This amounts to solving the linear system over the reals, subject to the constraint X 0, i.e. to a linear programming problem. It is easy in this case to give a direct argument that there is no such solution, and hence that the above model has no hidden-variable realization, thus proving Bell's theorem [1].

Proposition 4.2. The Bell model has no global section
Proof. We focus on four of the 16 equations, corresponding to rows 1, 6, 11 and 13 of the incidence matrix. We write X i rather than X[i].
Adding the last three equations yields Since all these terms must be non-negative, the left-hand side of this equation must be greater than or equal to the left-hand side of the first equation, yielding the required contradiction.
This is obtained from a standard probabilistic Hardy model by replacing all positive entries by 1; thus it can be interpreted as the support of the probabilistic model. In this case, we are interested in the existence of a solution over the Boolean semiring. This corresponds to a Boolean satisfiability problem. For example, the equation specified by the first row of the incidence matrix corresponds to the clause while the fifth yields the formula A solution is an assignment of Boolean values to the variables which simultaneously satisfies all these formulae. Again, it is easy to see by a direct argument that no such assignment exists. Proof. We focus on the four formulae corresponding to rows 1, 5, 9 and 16 of the incidence matrix: Since every disjunct in the first formula appears as a negated conjunct in one of the other three formulae, there is no satisfying assignment.
To understand the significance of this result, we note the following general fact. Proof. This follows simply from the fact that the map from the non-negative reals to the Booleans which takes all nonzero elements to 1 is a semiring homomorphism.
It follows that, if the support of a probabilistic model has no global section with respect to the Boolean distribution functor D B , then the probabilistic model itself has no global section with respect to the probability distribution functor D R 0 . Thus the argument given above implies that the probabilistic Hardy model also has no global section, and hence is non-local.
The converse of proposition 4.4 is false. Indeed, the Bell model, which as we have seen has no probabilistic global section, does have a Boolean global section for its support. This is easy to show directly, but also follows from the general results in [26], which show that Hardy models are complete for the (2,2,2)-type cases, and in particular that there must be at least three sections excluded from the support in order for non-locality to hold, while the Bell model has only two zero entries.
In this sense, we can say that the Hardy model satisfies a stronger non-locality property than the Bell model. In general, we say that a probabilistic model is probabilistically non-extendable if it has no global section over D R 0 , and possibilistically non-extendable if its support has no global section over D B . We have seen that possibilistic non-extendability is strictly stronger than probabilistic non-extendability.

Negative probabilities
We shall now consider the question of extendability over real-valued distributions D R , i.e. signed probability measures. Formally, this simply amounts to solving the linear system over the reals, with no additional constraints. Conceptually, this allows the introduction of negative probabilities in the extended model. Of course, these marginalize to yield standard non-negative probabilities in the measurement contexts stipulated by the empirical model. Thus the usual relative-frequency interpretation of the actually observed statistics is maintained.
The appearance of negative probabilities in quantum mechanics has a long history, which we shall sketch in the postlude (section 10). In this section, we shall prove that all empirical models are extendable with respect to signed probability measures. In fact, there is an equivalence between extendability under signed measures and no-signalling. Note that the class of no-signalling models is strictly larger than the empirical models of this type that arise in quantum mechanics. For example, it includes the superquantum Popescu-Rohrlich boxes [10].
The result therefore shows that negative probabilities, in themselves, cannot characterize quantum mechanics. This runs contrary to an impression that might be gained from the literature. For example, Feynman writes: 'The only difference between a probabilistic classical world and the equations of the quantum world is that somehow or other it appears as if the probabilities would have to go negative . . . ' [27, p 480]. In fact, the introduction of negative probabilities yields the entire no-signaling world.

Solving the linear system over the reals
Given an empirical model e over D R , our aim is to find a global section. The existence of such a global section for e, which is represented by the real vector V, reduces to the existence of a solution for the linear system MX = V over the reals, with no additional constraints.
Note that there is no semiring homomorphism from the reals to the Booleans. Indeed, if there were such a homomorphism h, we would have A similar argument shows that there is no homomorphism from the reals to the non-negative reals. Thus there is no result analogous to proposition 4.4, and it is possible for the linear system to be solvable over the reals, while no solution exists over the non-negative reals or the Booleans.
We shall now show that such solutions exist for all no-signaling probabilistic empirical models, over arbitrary measurement covers. This substantially generalizes previous results, e.g. theorem 1 in [25].
We introduce some notation. We fix a standard set of outcomes O := {1, . . . , l}. Given a cover M, we define the set of partial contexts: For each U ∈ U and p 0, we define All the terms on the rhs of this equation are in e ( p) , while every element of e ( p+1) can be written in the form of the lhs.
Unwinding the induction, every number e C (s) is given by a linear combination of values in e (0) , obtained by back-substitution in (1).
We can consider probabilistic models as real vectors, as in the previous section. For a given cover M, the dimension of the ambient vector space will be t := C∈M l |C| . We now come to our main result. Proof. Since the non-contextual models are a subset of the no-signaling models, this follows immediately from the matching lower bound on the dimension of the local subspace from proposition 5.3, and the upper bound on the dimension of the no-signalling space from proposition 5.2.
As an immediate consequence of this result, we have the following.
Theorem 5.5. Let M be any measurement cover, and e a probabilistic model over this cover, with the corresponding vector V ∈ R t . Then the linear system MX = V has a solution over the reals.
We can also apply this result to the incidence matrix. Let M be the incidence matrix defined over a cover M and set of outcomes O.
Proposition 5.6. The rank of M, as a matrix over the reals, is D.
Proof. The incidence matrix defines a linear map from the vector space generated by the global assignments O X into R t . By theorem 5.4, the dimension of the image of this map is D.

Example: the Popescu-Rohrlich box
We consider the PR box: This vector can be taken as giving a local hidden-variable realization of the PR box using negative probabilities. Similar realizations can be given for the other PR boxes.

An explicit formula for the dimension
We now consider some symmetry properties of a cover M, and the associated family of partial contexts U. We define U ( j) to be the set of elements of U of cardinality j, 0 j n. We say that M is homogeneous if the following conditions hold.
(i) All the contexts C ∈ M have the same number n of elements.
(ii) Every set U ∈ U ( j) is a subset of the same number N j of contexts C ∈ M. Note that we must always have N 0 = p, where p = |M|.
We consider some examples.
• Every (n, k, l)-type Bell scenario is homogeneous, with p = k n and N j = k n− j .
• Many of the constructions used in the Kochen-Specker proofs are homogeneous, for example the cover corresponding to the Peres-Mermin magic square [7,28], which consists Proof. From the definitions, Homogeneity implies that |U ( j) | = p n j /N j .
We now apply this result to our examples.
• For (n, k, l)-type scenarios, we have Applying the binomial theorem, we obtain D = (k · (l − 1) + 1) n . This retrieves the dimension established in [25], with the minor difference that the value given there is D − 1. This apparent discrepancy arises because marginalization over the empty set is excluded in [25], using the fact that, by normalization, e ∅ (∅) = 1. However, in this case equations (1) are affine rather than linear.
• For the 18-vector cover, taking l = 2, we obtain D = 118. This can be compared with the dimension of the ambient vector space, which is 9 × 2 4 = 144. • The corresponding value for the Peres-Mermin square is D = 34, with ambient dimension 48.
We can also apply this formula to the rank of the incidence matrix. For example, for (n, 2, 2)-scenarios, where the incidence matrix is of size 4 n × 4 n , the rank is 3 n . This formula for the rank can be made visually apparent in this case, by noting that, with a suitable choice of enumeration for the rows and columns, the incidence matrices M(n) have a self-similar inductive structure:

Global sections and no-signaling
No-signalling has been built into our notion of empirical model through the requirement of compatibility of the family {e C }. Note, however, that any family, whether compatible or not, gives rise to a linear system of equations MX = V. If this system has a solution, so that the family has a global section, it is automatically compatible and hence satisfies no-signaling. Proof. This follows immediately from the functoriality of restriction. For any C, C ∈ M: Hence d|C and d|C agree on their overlap.
Combining this result with theorem 5.5, we obtain the following theorem.

Theorem 5.9. Probability models have local hidden-variable realizations with negative probabilities if and only if they satisfy no-signalling.
Thus we have a striking equivalence between no-signalling models and those admitting local hidden-variable realizations with negative probabilities.

Strong contextuality
Consider a probability model over a cover M. By proposition 4.4, if the model is extendable over D R 0 , its support is extendable over the Booleans. This means that there is a Boolean distribution d on E(X) which restricts to supp(e C ) for every context C ∈ M. Such a distribution is simply a non-empty subset S of E(X). The condition d|C = supp(e C ) means that, for all s ∈ S, s|C ∈ supp(e C ) for every C ∈ M; moreover, every section in supp(e C ) is of the form s|C for some s in S. Given an empirical model e, we define the set S e := {s ∈ E(X) : ∀C ∈ M. s|C ∈ supp(e C )}.
Thus a consequence of the extendability of e is that S e is non-empty.
We say that the model e is strongly contextual if this set S e is empty. Whereas a global section for an empirical model e completely determines its behavior, asking for some assignment s ∈ E(X) which is consistent with the support of e is much weaker. The negative property that not even one such assignment exists is correspondingly much stronger. Indeed, the Hardy model, which as we saw in the previous section is possibilistically non-extendable, is not strongly contextual. The global assignment is in S e for this model. The Bell model similarly fails to be strongly contextual.
The question now arises: are there models coming from quantum mechanics which are strongly contextual in this sense?
We shall now show that the well-known GHZ models [12], of type (n, 2, 2) for all n > 2, are strongly contextual. This will establish a strict hierarchy Bell < Hardy < GHZ of increasing strength of obstructions to non-contextual behavior for these salient models.
The GHZ model of type (n, 2, 2) can be specified as follows. We label the two measurements at each part as X (i) and Y (i) , and the outcomes as 0 and 1. For each context C, every s in the support of the model satisfies the following conditions.
• If the number of Y measurements in C is a multiple of 4, the number of 1s in the outcomes specified by s is even.
• If the number of Y measurements is 4k + 2, the number of 1s in the outcomes is odd.
We will see later how a model with these properties can be realized in quantum mechanics.
Proposition 6.1. The GHZ models are strongly contextual, for all n 3.

Proof.
We consider the case when n = 4k, k 1. Assume for a contradiction that we have a global section s ∈ S e for the GHZ model e.
If we take Y measurements at every part, the number of outcomes that are under the assignment is even. Replacing any two Ys by Xs changes the residue class mod 4 of the number of Y s, and hence must result in the opposite parity for the number of 1 outcomes under the assignment. Thus for any Y (i) , Y ( j) assigned the same value, if we substitute Xs in those positions they must receive different values under s. Similarly, for any Y (i) , Y ( j) assigned different values, the corresponding X (i) , X ( j) must receive the same value.
Suppose first that not all Y (i) are assigned the same value by s. Then, for some i, j, k, Y (i) is assigned the same value as Y ( j) , and Y ( j) is assigned a different value than Y (k) . Thus Y (i) is also assigned a different value than Y (k) . Then, X (i) is assigned the same value as X (k) , and X ( j) is assigned the same value as X (k) . By transitivity, X (i) is assigned the same value as X ( j) , yielding a contradiction.
The remaining cases are where all Ys receive the same value. Then any pair of Xs must receive different values. But taking any three X s, this yields a contradiction, since there are only two values, so some pair must receive the same value.
The case when n = 4k + 2, k 1, is proved in the same fashion, interchanging the parities. When n 5 is odd, we start with a context containing one X , and again proceed similarly.
The most familiar case, for n = 3, does not admit this argument, which relies on having at least four Ys in the initial configuration. However, for this case one can easily adapt the wellknown argument of Mermin using 'instruction sets' [29] to prove strong contextuality. This uses a case analysis to show that there are eight possible global sections satisfying the parity constraint on the three measurement combinations with two Ys and one X ; and all of these violate the constraint for the X X X measurement.
We shall also mention an elegant result due to Lal [13]. Proposition 6.2 (Lal). The only strongly contextual no-signaling models of type (2, 2, 2) are the PR boxes.
Thus strong contextuality actually characterizes the PR boxes.

Strong contextuality and maximal non-locality
The property of strong contextuality is defined in a simple 'qualitative' fashion, in terms of the support of a model. As we shall now see, for probabilistic models it is equivalent to a notion which can be defined in quantitative terms and has been studied in this form in the special case of Bell-type scenarios 8 .
Suppose that {e C } C∈M is a model over the presheaf D R 0 . We consider convex decompositions where L is a local model and q a no-signalling model. This means that, for every C ∈ M, and s ∈ E(C), we have e C (s) = λL C (s) + (1 − λ)q C (s).
We define the non-contextual fraction of e to be the supremum over all λ appearing in such convex decompositions (2). This notion was introduced for Bell-type scenarios in [30]; see also [31,32], where the terminology local fraction is used. A model with local fraction 0 is defined to be maximally non-local. Geometrically, this corresponds to the model being on a face of the no-signaling polytope with no local elements.
In the general setting of models defined on arbitrary measurement covers, we say that a model e is maximally contextual if the non-contextual fraction of e is 0.

Proposition 6.3. A model e is strongly contextual if and only if it it is maximally contextual.
Proof. Suppose firstly that e admits a convex decomposition (2). By the results of section 3 and also theorem 8.1, we can take L to be a convex sum of deterministic models i µ i δ s i , where each s i ∈ E(X) is a global assignment. If λ > 0, then from (2), s i ∈ S e for each i. Thus strong contextuality implies maximal contextuality.
For the converse, suppose that s ∈ S e . Taking L = λ · δ s , we shall define q such that (2) holds. For each C ∈ M and s ∈ E(C): It is easily verified that, for each C, s ∈E(C) q C (s ) = 1. To ensure that q is always non-negative, we must have λ inf C∈M e C (s|C). Since this is the infimum of a finite set of positive numbers, we can find λ > 0 satisfying this condition. It remains to verify that q is no-signalling, i.e. that {q C } forms a compatible family. Given A similar analysis applies to q C |C ∩ C (s 0 ). Using the compatibility of e, we conclude that q C |C ∩ C = q C |C ∩ C .
We can use this equivalence to give a characterization of maximal contextuality, and in particular of maximal non-locality, in terms of a CSP. In the case of dichotomic measurements, this reduces to a Boolean satisfiability problem. 24 We recall that a CSP [33,34] is specified by a triple (V, K , R), where V is a finite set of variables, K is a finite set of values and R is a finite set of constraints. A constraint is a pair (C, S), where C ⊆ V and S ⊆ K C . (It is more common to define a constraint as an ordered list of k variables, and a set of k-tuples of values, but this is obviously equivalent to the version given.) An assignment s : V → K satisfies a constraint (C, S) if s|C ∈ S. A solution of the CSP (V, K , R) is an assignment s : V → K which satisfies every constraint in R.
Let e be a model over a cover M, with outcome set O. For each C ∈ M, we have the set S e (C) := supp(e C ) ⊆ O C . We can associate the CSP (X, O, {S e (C) | C ∈ M}) with e.

Proposition 6.4. A probabilistic model e is maximally contextual if and only if the corresponding CSP has no solution. In particular, for Bell-type scenarios, e is maximally nonlocal if and only if the corresponding CSP has no solution.
Proof. This follows directly from proposition 6.3, since global sections in the support of e are clearly in bijective correspondence to solutions of the associated CSP.
In the case of dichotomic measurements, the CSP reduces to a Boolean satisfiability problem. In this case, we interpret the two possible outcomes as truth values, and X as a set of propositional variables.
Given a model e, we define the formula ¬m.

Generic strong contextuality and Kochen-Specker theorems
Let e and e be models, such that the support of e is included in the support of e . Then S e is included in S e ; hence if e is strongly contextual, so is e. Thus by showing strong contextuality for a single model, we can show it for a whole class of models. We shall fix our set of outcomes as {0, 1}. This means that we can define subsets of E(C) by formulae φ C , with the elements of C used as propositional variables. A section s : C → {0, 1} can be viewed as a Boolean assignment for these variables, and φ C defines the set of its satisfying assignments.
We are interested, in particular, in the formula This is satisfied by those assignments with exactly one outcome set to 1.
A Kochen-Specker-type result [2] can be factored into two parts.
(i) Defining covers M such that there is no global section s ∈ E(X) which satisfies the formula (ii) Providing quantum representations for these covers, which interpret the measurements by quantum observables in such a way that every quantum model for this set of observables has its support included in ONE(C) for each C ∈ M, and hence is strongly contextual.
We shall explain the quantum aspects in a later section. Here we shall investigate the combinatorial structures involved in the first part.
We shall give a simple combinatorial condition on the cover M, which is implied by the existence of a global section s satisfying φ M . Violation of this condition therefore suffices to prove that no such global section exists. It follows that, if there is a common divisor of the numbers |M(m)|, it must divide |M|.
For example, if every m ∈ X appears in an even number of elements of M, while M has an odd number of elements, then φ M has no global section. This corresponds to the 'parity proofs' which are often used in verifying Kochen-Specker-type results [22,35].
The simplest example of this situation is the 'triangle', i.e. the measurement cover with elements {a, b}, {b, c}, {a, c}. This example has also been discussed, in a somewhat different context, in [36].
An example where X has 18 elements, and there are nine maximal compatible sets, each with four elements, such that each element of X is in two of these, appears in the 18-vector proof of the Kochen-Specker theorem in [22].

Kochen-Specker graphs
The measurement covers that can be represented by quantum systems are of a particular form: they are generated by a symmetric binary compatibility relation, since compatibility in quantum mechanics means that the observables pairwise commute. Thus, for example, the 'triangle' cannot arise from quantum observables.

26
This suggests that we should take into account this feature. It turns out that this leads us directly to some standard notions in graph theory.
An undirected graph G is specified by a finite set of vertices V G , and a set of edges E G , which are two-element subsets of V G . A clique of G is a set C ⊆ V G with an edge between every pair of vertices in C. The set of maximal cliques of G forms a measurement cover M G .
Let G be a graph. A set S ⊆ V G is called a stable transversal [37] if for every maximal clique C of G (i.e. for every C ∈ M G ), |S ∩ C| = 1. Note that it is necessarily the case that a stable transversal is independent, i.e. there is no edge between any pair of elements of S, since otherwise we could extend this pair to a maximal clique containing both. Conversely, suppose that T is a stable transversal of G. If we define s as the characteristic function of T on X , then s | ONE(C) for each maximal clique C of G, and so φ M has a global section.
In order to apply graph-theoretic results to the quantum situation, we need to know which graphs can arise from families of quantum observables. For reasons that will be explained when we discuss quantum representations in section 9, we are interested in graphs that can be labelled by vectors in R d , such that two vertices are adjacent if and only if the corresponding vectors are orthogonal. It turns out that in graph theory, the complementary notion is used [38], so we shall say that such graphs have a faithful orthogonal co-representation in R d . We must also require that the maximal cliques all have size d.
Thus we define Kochen-Specker graphs to be finite graphs G such that • G has a faithful orthogonal co-representation in R d ; • the maximal cliques of G all have the same size d; • G has no stable transversal.
Any such graph generates a measurement cover M G such that the formula φ M G has no global section; and every such graph can be realized by quantum observables, as will be shown in section 9. Thus, these graphs provide explicit finite witnesses for generic strong contextuality. An example is provided by the orthogonality graph for R 4 defined by the set of 18 vectors given in [22], as well as the various sets of 31 or more vectors that have been found in R 3 [2,[39][40][41].
A final desideratum is to provide a purely graph-theoretic condition for the existence of a faithful orthogonal co-representation. In [38,42] the following result is proved. Theorem 7.3. Every graph on n nodes whose complementary graph is (n − d)-connected has a faithful orthogonal co-representation in R d .
We note that a general graph-theoretic approach to contextuality, on somewhat different lines than ours, has been developed in [8]. Interesting connections are shown between contextuality and Lovasz's ϑ-function [43].
In [8], 'compatibility structures' are studied as sets of events rather than measurements. This leads to the formalism of convex operational theories as 'generalized probability theories'.
By contrast, we distinguish between measurements, outcomes and events. This allows the functorial presheaf structure of probabilistic models to be articulated. Moreover, we use standard probability theory, as encapsulated in the distribution functor D R 0 . The non-classical, contextual features of models arise from their functorial variation over contexts. At the same time, this mathematical structure directly reflects the basic operational scenario described at the beginning of section 2.

Global sections and hidden variables
We shall now consider a general notion of hidden-variable model, and show that an empirical model is realized by a factorizable hidden-variable model if and only if it has a global section.
We are given a measurement cover M. We fix a set of values for a hidden variable. A hidden-variable model h over assigns, for each λ ∈ and C ∈ M, a distribution h λ C ∈ D R E(C). It also assigns a distribution h ∈ D R ( ) on the hidden variables. Note that this distribution is independent of the context; this is the standard structural assumption of λ-independence [44]. We require that for each λ ∈ , the family {h λ C } C∈M is compatible, i.e. for all C, C ∈ M: Just as compatibility for empirical models corresponds to no-signaling, compatibility for hidden-variable models corresponds to the parameter independence condition [45,46].
We say that a hidden-variable model h realizes an empirical model e if the probabilities specified by e are recovered by averaging over the values of the hidden variable. Formally, this says that for all C ∈ M and s ∈ E(C): The intended purpose of hidden-variable models is to explain the non-intuitive behavior of empirical models, in particular those arising from quantum mechanics, by showing that it can be reproduced by a model whose behavior is more intuitive, at the cost of introducing hidden variables. In particular, one would like to explain the non-local and contextual behavior predicted by quantum mechanics in this way. The general property which a hidden-variable model should satisfy in order to provide such an explanation is factorizability, which subsumes both Bell locality [1] and a form of non-contextuality at the level of distributions. It is defined as follows.
We say that a hidden-variable model h is factorizable if, for every C ∈ M, and s ∈ E(C): This says that the probability assigned to a joint outcome factors as the product of the probabilities assigned to the individual measurements. Note, in particular, that if m ∈ C ∩ C , then the compatibility condition on h implies that h λ C |{m} = h λ C |{m}. Thus the probability distributions on outcomes of individual measurements are independent of the contexts in which they occur.
For Bell-type scenarios, factorizability corresponds exactly to Bell locality [1]. More generally, it asserts non-contextuality at the level of distributions.
Our main result can now be stated as follows. Proof. Proposition 3.1 shows that (ii) implies (i). It remains to prove the converse.
Suppose that e is realized by a factorizable hidden-variable model h. For each m ∈ X , we define h λ m := h λ C |{m} ∈ D R E({m}) for any C ∈ M such that m ∈ C. By the compatibility of the family {h λ C }, this definition is independent of the choice of C. Also, we shall write s|m rather than s|{m}. We define a distribution h λ We must show that this is a distribution. We enumerate the set of measurements X as X = {m 1 , . . . , m p }. A global assignment s ∈ E(X) can be specified by a tuple (o 1 , . . . , o p ), where o i = s(m i ). Now we can calculate: We now show that for each context C in M, h λ X |C = h λ C . We choose an enumeration of X such that C = {m 1 , . . . , m q }, q p.
Now we define a distribution d ∈ D R E(X) by averaging over the hidden variables: We verify that this is a distribution: It remains to show that d restricts at each context C to yield e C .

d|C(s)
= e C (s). Thus d is a global section for e.
This result provides a definitive justification for equating the phenomena of non-locality and contextuality with obstructions to the existence of global sections.

Quantum representations
Since our aim is to investigate the general properties of systems and physical theories, it has been important that our entire discussion has been conducted without presupposing quantum mechanics, Hilbert spaces, etc. The mathematical structures which we have used have arisen in a rather transparent fashion from the basic experimental scenario with which we began.
However, it is important to make explicit how the structures we have described can be represented in quantum mechanics.
We begin with measurement covers. A quantum representation of a measurement cover on a set X can be described as follows. We fix a Hilbert space H. As usual, an observable is a bounded self-adjoint operator A on H. Two observables A, B are compatible if they commute: AB = B A. In this case, the composite AB is again self-adjoint and hence forms an observable.
Given a set X = {A x } x∈X of observables on H indexed by X , we form a measurement cover by taking M to be the set of all maximal commuting subsets of X. Note that pairwise commutation implies that the observables in each such subset, composed in any order, form a well-defined observable. We say that an abstract measurement cover M has a quantum representation if it arises in this way.
For Bell-type scenarios, a quantum representation will have a particular form, reflecting the usual idea that the measurements are carried out at a number of different sites, which may be space-like separated. We will have a family {H i } of Hilbert spaces, one for each part. The elements of X i will index a family X i of incompatible (i.e. non-commuting) observables on H i . We change these into local observables on the compound system H = H 1 ⊗ · · · ⊗ H k by defining A i := I ⊗ · · · ⊗ A ⊗ · · · ⊗ I for each A ∈ X i . Then, A i commutes with B j whenever i = j, and we can form a measurement cover of Bell type on the compound system.
It is interesting in this connection to discuss a result due to Tsirelson [47]. This result can be stated, following [48], as follows. The import of this result is that, under the stated assumptions, tensor product structure can be retrieved automatically as a special case of the general situation of commuting operators on a single space. Thus, the special form of representation for Bell-type scenarios is not really necessary, although it is the one which is commonly used. Now we turn to events. For simplicity, we shall confine ourselves to the finite-dimensional case. Recall that a self-adjoint operator A has a spectral decomposition where α i is the ith eigenvalue, and P i is the projector onto the corresponding eigenspace. Measuring a quantum state ρ with this observable will result in one of the observable outcomes α i , with probability Tr(ρP i ), while the state will be projected into the corresponding eigenspace.
For simplicity of notation, we shall focus on dichotomic quantum observables, i.e. selfadjoint operators on a Hilbert space H with a spectral resolution into two orthogonal subspaces. In this case, we can use a standard two-element set O = {0, 1} to label these outcomes, and the sheaf E to record the collective outcomes of a compatible set of observables.
Thus for each basic measurement label m in X , we have an observable A m with spectral decomposition A m = α 0 m P 0 m + α 1 m P 1 m , where P 0 m + P 1 m = I . Given a maximal set of commuting observables C = {A m 1 , . . . , A m k }, for each s ∈ O C we have a projector P s = P s(m 1 ) m 1 · · · P s(m k ) m k . The composed observable A C = A m 1 · · · A m k has a decomposition of the form To ensure that these eigenvalues can be associated with distinct outcomes, it is necessary that α s = α t implies that s = t. This can be achieved by appropriate choices of the eigenvalues α i m . It may well be the case that this decomposition contains redundant terms, in the sense that P s = 0 for some values of s. The important point is that these projectors do yield a resolution of the identity: Now we consider empirical models. Suppose we are given an empirical model e on a measurement cover M, which has a quantum representation in the form described above, based on a Hilbert space H. A quantum representation of e is given by a state ρ on H. For each compatible set of observables C ∈ M, the state defines a probability distribution ρ C on E(C), by the standard 'statistical algorithm' of quantum mechanics: ρ C (s) = Tr(ρP s ). Thus An interesting point now arises: do the distributions {ρ C } necessarily form a compatible family? In the case of a Bell-type scenario, the fact that they do is the content of the standard no-signalling theorem [17]. However, Bell-type scenarios are very special cases of measurement covers. We shall therefore verify explicitly that the distributions determined by a quantum state, with respect to any family of sets of commuting observables, do form a compatible family in the sense of sheaf theory. We can regard this as a generalized form of no-signaling theorem.
Proof. Firstly, we define C 0 := C ∩ C , C 1 := C\C 0 , and C 2 := C \C 0 . Thus C is the disjoint union of C 1 and C 0 , and C is the disjoint union of C 2 and C 0 . Note that E(C) ∼ = E(C 0 ) × E(C 1 ), and E(C ) ∼ = E(C 0 ) × E(C 2 ). Thus we can write s ∈ E(C) as s = (s 0 , s 1 ), and similarly for sections in E(C ). In this notation, P (s 0 ,s 1 ) = P s 0 P s 1 . Now we can calculate A similar computation shows that ρ C |C 0 (s 0 ) = ρ C 0 (s 0 ). Hence ρ C |C ∩ C = ρ C |C ∩ C .
Thus, we see that quantum mechanics obeys a general form of no-signalling, which applies to compatible families of observables in general, not just those represented as operating on different factors of a tensor product. This form of no-signaling says that, at the level of distributions, the statistics obtained for a measurement on a given state are independent of the context of other compatible measurements which may also have been carried out.
We can in fact use Tsirelson's theorem 9.1 to reduce this result to the standard form of nosignalling theorem. 9 Given sets of commuting observables C and C , every operator in C ∩ C commutes with every operator in the symmetric difference C∇C , so theorem 9.1 applies, and we can represent these two sets of observables as acting on different factors of a tensor product. The standard version of no-signalling can now be used to show that the marginals on the first factor are independent of the choice of measurement on the second.

Greenberger, Horne and Zeilinger models
We shall briefly review how GHZ models, which were used in section 6, can be represented in quantum mechanics. For n > 2, we take the Hilbert space to be the tensor product of n qubit spaces. The local observables in each factor are the X and Y spin measurements, represented in the Z basis by eigenvectors for spin Right or Left along the x-axis, with basis vectors and similarly for spin Forward or Back along the y-axis, with basis vectors We shall label the outcomes as 0 for spin Right for X and spin Forward for Y and 1 for spin Left and spin Back, respectively. The model is then generated by the GHZ state [12,49], written in the Z basis as |↑ · · · ↑ + |↓ · · · ↓ √ 2 .
If we measure each particle with a choice of X or Y observable, the probability for each outcome is given by the square modulus of the inner product where b i is the basis vector corresponding to the given outcome in the ith component. This computation is controlled by the product of the |↓ -coefficients of the basis vectors, and hence by the cyclic group of order 4 generated by i.
The following table gives the coefficients of the |↓ components labelled by the measurement and outcome: 9 We thank one of the journal referees for this observation. 33 The probability table for this model can be specified as follows.
• Each row with an odd number of Y measurements has full support.
• Each row in which the number of Y measurements is a multiple of 4 has as support those entries with an even number of outcomes labeled 1.
• Each row in which the number of Y measurements is 4k + 2 has as support those entries with an odd number of outcomes labeled 1.
• In each case, the distribution is uniform on the support.
Note that here by 'row' we mean a row of the probability table, i.e. the distribution on the set of sections over a given measurement context. Thus the interesting structure of this model arises purely from the support.

Kochen-Specker representations
We shall now discuss how the abstract discussion of Kochen-Specker situations in section 7 can be represented in terms of quantum mechanics. We shall consider a particular form of dichotomic observables. Given unit vectors e 1 , . . . , e k representing distinct rays in a Hilbert space H, we write A e j := j · P e j + 0 · P ⊥ e j . Then we can take X = {A e 1 , . . . , A e k } as a set of measurements. Note that A e i commutes with A e j if and only if e i is orthogonal to e j . Also, the composition of a set of commuting observables {A e i } i∈I will have a spectral decomposition of the form i∈I i · P e i + 0 · P {e i |i∈I } ⊥ .
If we measure any state with this observable, the outcome must be that we get exactly one of the branches P e i , with eigenvalue i, or that we get 'none of the above', corresponding to the branch P {e i |i∈I } ⊥ , with eigenvalue 0. Moreover, if the cardinality of I equals the dimension of the Hilbert space, then the latter case cannot apply.
If we now consider how outcomes are represented in the sheaf E, we see that we indeed have an a priori condition on those sections s which can be in the support of a distribution coming from a quantum state, as desired. Namely, using x i as a label for A e i and taking s(x i ) = 1 for the outcome corresponding to P e i for this observable, we see that the only sections which are possible are those which assign 1 to at most one measurement. Moreover, for those sets of compatible observables whose cardinality equals the dimension of the space-which must necessarily be maximal, and hence will appear in the measurement cover-exactly one measurement must be assigned 1.
Thus if we take a set of unit vectors indexed by X , such that each vector is contained in at least one orthonormal basis indexed by a subset of X , the measurement cover M represented by the observables A x will have the following key property: for any quantum state ρ, the support of the corresponding empirical model will satisfy the formula ONE(C) for each context C in M. So the problem of exhibiting a state-independent form of strong contextuality has been reduced to the problem of finding a Kochen-Specker graph, as described in section 7.

Bell-type scenarios and Kochen-Specker theorems
The measurement covers arising from Bell-type scenarios are a rather special class, which can be characterized as follows.
Proof. Equivalence relations are in bijective correspondence to partitions X = i X i . The maximal cliques of G are exactly the transversals of this partition, i.e. the sets T ⊆ X such that T intersects with each X i in exactly one element.
Note, in particular, that in Bell-type scenarios, incompatibility is transitive. This is by no means the general case. In terms of operators, A and B may commute, while C may fail to commute with either.
The more complex configurations typical of Kochen-Specker constructions can never arise from Bell-type scenarios. Proof. Given s, we define the local state ρ i := |ψ i ψ i | for each i, where ψ i is the eigenvector corresponding to the outcome specified by s for the measurement at i. Then the model defined by the state ρ := ρ 1 ⊗ · · · ⊗ ρ n has s in its support.
Hence there is no Kochen-Specker-type theorem for Bell-type scenarios. While, as we have seen, there are model-specific strong contextuality results, there are no generic results. The measurement covers arising from these scenarios are simply not rich enough in their combinatorial structure of overlapping intersections to support a result of this form.

Postlude
Our treatment of non-locality and contextuality makes a number of points.
• Firstly, it is carried out at a high level of generality, and without any presupposition of quantum mechanics. None of the characteristic mathematical structures of quantum mechanics, such as complex numbers, Hilbert spaces, operator algebras or projection lattices, are needed to expose the key structural issues. This characteristic is shared to some extent by other foundational approaches, such as generalized probabilistic theories [17], but these formalisms are still rather closer to that of quantum mechanics, and indeed have been directly suggested by it. Structures such as sheaves and presheaves varying over contexts can be seen as basic elements of a general 'logic of contextuality', and related structures have been used for a wide range of purposes, e.g. in the semantics of computation [51][52][53]. This opens up the possibility of making some interesting connections between the study of non-locality and contextuality in physics, and ideas arising in other fields.
• The sheaf-theoretic language, which directly captures the idea of structures varying over contexts, is a canonical setting for studying contextuality. Moreover, as we have seen, the gluing conditions and the existence of global sections capture the essential content of nonlocality and contextuality in a canonical mathematical form. This opens the door to the use of the powerful methods of sheaf theory, which plays a major role in modern mathematics, in analyzing the structure of non-locality and contextuality. These notions are still poorly understood in multipartite and higher-dimensional settings.
In [54], the first author, with Shane Mansfield and Rui Soares Barbosa, define an Abelian presheaf based on the support of an empirical model. TheCech cohomology of this presheaf with respect to the measurement cover is used to define a cohomological obstruction to locality or non-contextuality, as a certain cohomology class. It is shown for a number of salient examples, including PR boxes, GHZ states, the Peres-Mermin square and the 18-vector configuration from [22] giving a proof of the Kochen-Specker theorem in four dimensions, that this obstruction does not vanish, thus yielding cohomological witnesses for contextuality. While these results are preliminary, they suggest that the use of cohomological methods in the study of non-locality and contextuality has some promise.
• The canonical form of description of the key concepts in terms of the existence of global sections largely replaces any explicit mention of hidden variables. These appear only in section 8, in the context of a foundational result showing the equivalence of local hiddenvariable realizations to the existence of global sections. On the other hand, empirical models, which can be seen as directly related to observation and experiment, play a prominent role throughout the paper.
There is also an interesting conceptual point to be made in relation to incompatibility of measurements. Usually, this is taken to be a postulate of quantum mechanics, and specific to the quantum-mechanical formalism of non-commuting observables. However, in the light of general results such as those obtained in this paper, in a line of work going back to that of Fine [23], a different view emerges. The incompatibility of certain measurements can be interpreted as the impossibility-in the sense of mathematically provable non-existence-of joint distributions on all measurements which marginalize to yield the observed empirical distributions. Thus, if we refer to the experimental scenario with which we began section 2, this shows that there cannot be, even in principle, any such scenario in which all measurements can be carried out jointly, which is consistent with the actually observed outcomes.
Thus the incompatibility of certain measurements is revealed as a theory-independent structural impossibility result for certain families of empirical distributions. These families include those predicted by quantum mechanics, and confirmed by experiment, but the result itself is completely independent of quantum mechanics. Thus in this sense, we can say that incompatibility is derived rather than assumed.

Related work
The present paper builds on our previous work, in particular [19] by the first author, and [55,56] by the second author (with H Jerome Keisler and Noson Yanofsky, respectively). A natural direction for generalization of the results in the present paper would be from the finite setting considered here to the measure-theoretic one studied in [55]; note that the distribution functor can be defined over general measure spaces [57].
Since we use sheaf theory as our mathematical setting, there is an obvious point of comparison with the topos approach, as developed by Isham and Butterfield, Döring and Isham and Heunen et al [58][59][60].
The general point that presheaves varying over a partially ordered set of contexts provide a natural mathematical setting for studying contextuality phenomena is certainly a common feature. It should also be mentioned that presheaves have been used for similar purposes in the context of the semantics of computation, e.g. in the Reynolds-Oles functor-category semantics for programs with state [51,52] and in the presheaf models for concurrency of Cattani and Winskel [53].
A more specific source of inspiration is the important insight given in [58], which initiated the whole topos approach, that the Kochen-Specker theorem could be reformulated very elegantly in presheaf terms as stating the non-existence of global sections of a certain presheaf.
On the other hand, there are several differences between this paper and the topos approach. For example, the topos approach focuses on a specific structure, the spectral presheaf, based on an operator algebra. In this sense, it uses concepts specific to quantum mechanics from the very start. Moreover, many of the key structures introduced in our paper, such as the distribution functor and measurement covers, do not appear in the topos approach. One of our central objectives is to give a unified account of contextuality and non-locality, but locality issues have not been considered in the topos approach; nor has extendability, another key topic for us. It will, of course, be interesting to see if additional commonalities develop in future work.
The appearance of negative probabilities in quantum mechanics has a long history. The Wigner quasi-probability distribution [14], further developed by Moyal [16], is a phasespace representation of quantum mechanics using negative probabilities. Feynman views such negative probabilities as a calculational convenience [17]. He explains that the appearance of a negative probability for a certain outcome does not invalidate the theory being used. Rather, this tells us that the relevant conditions cannot be realized or that the outcome cannot be verified or both. More specifically related to what we do, Sudarshan and Rothman [61] show that a local hidden-variable analysis of the Bell model is possible if certain values of the hidden variable arise with negative probability. Finally, in Dirac [15], negative probabilities enter in the relativistic extension of quantum mechanics.