Simplicial quantum contextuality

We introduce a new framework for contextuality based on simplicial sets, combinatorial models of topological spaces that play a prominent role in modern homotopy theory. Our approach extends measurement scenarios to consist of spaces (rather than sets) of measurements and outcomes, and thereby generalizes nonsignaling distributions to simplicial distributions, which are distributions on spaces modeled by simplicial sets. Using this formalism we present a topologically inspired new proof of Fine's theorem for characterizing noncontextuality in Bell scenarios. Strong contextuality is generalized suitably for simplicial distributions, allowing us to define cohomological witnesses that extend the earlier topological constructions restricted to algebraic relations among quantum observables to the level of probability distributions. Foundational theorems of quantum theory such as the Gleason's theorem and Kochen-Specker theorem can be expressed naturally within this new language.


Introduction
It has long been recognized that quantum mechanics stands in stark contrast to the classical physics that preceded it. Early pioneers, such as Schrodinger [1], as well as Einstein, Podolsky, and Rosen (EPR) [2], were quick to recognize nonlocality as a novel feature of quantum mechanics, a notion which was later refined by the seminal work of Bell [3]. In tandem to this Kochen and Specker (KS) [4], and independently Bell [5], demonstrated no-go results concerning the possibility of hidden variable models with pre-existing outcome assignments. In recent years these ostensibly different phenomena have been given a unified account, being recognized as facets of a single fundamental feature of quantum theory known simply as contextuality.
Along side its important role in the foundations of quantum mechanics, contextuality has found many applications in quantum information theory and has been shown to be responsible for many information-processing advantages. See [6][7][8][9] and references therein for both of these aspects. There are several different approaches to capture the essence of this important quantum phenomenon: operation-theoretic [10], sheaf-theoretic [11] and (hyper)graph-theoretic [12,13]. Among these the sheaf-theoretic approach has yielded a successful framework for a systematic study of contextuality for nonsignaling distributions arising from commuting quantum observables, not necessarily acting on distinct tensor factors; allowing for a comprehensive treatment of both quantum nonlocality as well as contextuality more broadly. More recently, a topological approach was introduced in [14] that is well-suited for studying contextuality as a computational resource in measurement-based quantum computation (MBQC) [15]. Building off of these efforts, here we introduce a new framework that extends both the topological and sheaf-theoretic approaches and is based on the theory of simplicial sets, which are combinatorial models of topological spaces generalizing simplicial complexes. For previous work where topology and sheaf-theory come in contact, see e.g., [16][17][18][19][20].
Studies of contextuality often adopt an operational stance wherein physical systems are treated as "boxes" that take inputs and produce outputs. A measurement scenario then specifies a finite set of inputs and outputs corresponding to choices of measurement and their potential outcomes. Drawing on the quantum analogy, not all measurements can be simultaneously performed, rather only certain subsets of measurements called contexts. The statistics of a long run of measurements can then be summarized by a collection of probability distributions that satisfy a compatibility condition known as the nonsignaling condition. Examples of contextual nonsignaling distributions were first observed in studies of quantum nonlocality through so-called Bell scenarios, most famously by Bell [3] and by many authors since then; see e.g., [21][22][23]; also see [8]. For more general types of scenarios where contexts are given by commuting observables, not necessarily local, the sheaf-theoretic formalism [11] provides a rigorous approach to study contextuality. On the other hand, certain types of contextuality proofs, mainly the state-independent ones such as the Mermin square scenario [6], can be described using topological methods [14] based on chain complexes and group cohomology. In the latter framework measurement contexts are organized into a topological space and a cohomological obstruction defined on this space detects state-independent contextuality. Although this approach cannot be directly applied to the study of nonsignaling distributions, certain types of state-dependent contextuality proofs that are useful as a computational resource in MBQC can be successfully analyzed.
Motivated by the topological approach we introduce a new framework, the simplicial approach to contextuality, in which we define contextuality for scenarios consisting of spaces of measurements and spaces of outcomes. Upgrading the set of measurements and outcomes to a space allows for more general types of distributions. We refer to those new types of distributions as simplicial distributions. Ordinary nonsignaling distributions defined on sets of measurements and outcomes are referred to as discrete scenarios and can be studied as a special case, but with extra freedom provided by topology.
A key conceptual innovation on this front is to model a measurement and its corresponding outcome as a topological simplex which comes with an intrinsic spatial dimension. Such simplicies can then be organized into a combinatorial space which forms a simplicial set. For example, the Clauser, Horne, Shimony, Holt (CHSH) scenario [24], a well-known bipartite Bell scenario, can be treated in a couple of different ways. The canonical realization of the CHSH scenario as a discrete scenario gives a one-dimensional space (boundary of a square where measurements label the vertices), whereas a certain two-dimensional realization (a square whose edges are labeled by the measurements) proves to be useful for a new topological proof of Fine's theorem [25,26] for characterizing noncontextuality. Alternatively, another realization of the same scenario (as a punctured torus where measurements label the edges) gives a characterization of contextuality in terms of an extension condition to the whole torus. In this paper we focus on realizations where measurements and outcomes label one-dimensional simplices (edges) increasing the geometric dimension by one as compared to the canonical realization in the discrete case.
The main benefit of mixing spaces with probabilities is the topological intuition that allows us to decompose such distributions to distributions on simpler pieces of the underlying space. Contextual properties of those simpler pieces can be analyzed separately and then "glued back" to determine the contextuality of the original distribution. In this paper our goal is to analyze the well-known scenarios and provide new insights using our simplicial formalism. However, our framework goes beyond the theory of nonsignaling distributions; see Example 2.2. A systematic study of such new scenarios will appear elsewhere. Our main contributions in this paper can be summarized as follows: • We introduce a new class of objects called simplicial distributions (Definition 3.4) that generalize simplicial sets to probabilistic ones and extends the theory of nonsignaling distributions.
• Contextuality for simplicial distributions (Definition 3.10) is introduced and analyzed for well-known scenarios. This notion of contextuality generalizes the sheaf-theoretic formulation (Theorem B.2).
• A new proof of Fine's theorem [25] [26] for the CHSH scenario based on topological arguments is presented (Theorem 4.13).
• We characterize contextuality in terms of the failure of extending distributions (Proposition 4.1) and apply this to the CHSH scenario (Corollary 4.14).
• The cohomological framework of [14] is extended to simplicial distributions, and in particular to nonsignaling distributions, by constructing cohomology classes that detect strong contextuality (Corollary 5.7).
• Quantum measurements are generalized to simplicial quantum measurements, where outcomes are represented by a space instead of a set. We then pass to simplicial distributions via the Born rule and define contextuality for quantum states with respect to a simplicial quantum measurement (Definition 6.2).
• Finally two foundational results from quantum theory, Gleason's theorem [27] and Kochen-Specker theorem [4], are presented in our simplicial framework (Theorem 7.1 and Corollary 7.2) demonstrating the expressive power of the simplicial language.
The rest of the paper is organized as follows: In Section 2 we provide an informal introduction to our framework, building basic intuition about simplicial distributions from a topological viewpoint. In Section 3 we provide a formal foundation for our framework, defining abstract simplicial sets before modeling measurements and outcomes as spaces within this setting. A generalization (Lemma 4.5) of Fine's ansatz [26,28] is provided in Section 4 which is later utilized in our topological proof of Fine's theorem. In Section 5 we formulate strong contextuality for simplicial distributions and describe its relation to cohomology. Section 6 introduces simplicial quantum measurements and applies the cohomological framework of the previous section to state-independent contextuality proofs that were previously analyzed in [14]. Some foundational results in quantum theory are described in Section 7 before we conclude the main text. In the appendix, Section A provides background information on simplicial identities and Section B describes how to embed the sheaftheoretic formalism of [11] into the simplicial framework.

Motivation and the idea
In this section we describe our simplicial framework in an informal way. Starting from the topological approach to the state-independent Mermin square we build step-by-step towards probabilistic scenarios, such as the CHSH scenario.

Topological proofs of contextuality
In the topological framework developed in [14] a state-independent proof of quantum contextuality is detected by a cohomology class. For instance, the Mermin square scenario can be illustrated by a torus together with a certain triangulation as depicted in Fig. (1a). The observables labeling the edges of the triangles, say denoted by A, B, C, satisfy ABC = (−1) β(A,B) 1.
(1) The function β which determines the sign gives rise to a cohomology class [β] that lives on the underlying space constructed by gluing the triangles. The fact that there is no way to assign eigenvalues ±1 to each observable consistent with the algebraic relations given by Eq. (1) translates into the statement that the cohomology class [β] is nonzero. This observation can be generalized to provide a topological basis for state-independent contextuality proofs using the language of chain complexes from algebraic topology. In this topological formalism it is also possible to discuss certain types of state-dependent proofs of contextuality. For example, removing the context on which β is nonzero results in a scenario that is contextual with respect to the Bell state |Ψ = (|00 + |11 )/ √ 2, the simultaneous eigenstate of the observables X ⊗ X, Y ⊗ Y and Z ⊗ Z with the associated eigenvalues 1, −1 and 1; respectively. In this case one can modify the cocycle with respect to these eigenvalues to introduce a new cocycle β Ψ . Topologically the underlying space X is a punctured torus, that is a torus minus a point. Now the associated cohomology class [β Ψ ], which lives on the space X, is a relative cohomology class defined with respect to the boundary ∂X. Another well-known example is the Mermin star scenario (without the nonlocal context), which is contextual with respect to the Greenberger-Horne-Zeilinger (GHZ) state |Ψ = (|000 + |111 )/ √ 2. These types of state-dependent contextuality proofs can be formalized using the language of relative chain complexes [14,29].

Including probability distributions
Although the formalism described in [14] can deal with certain types of state-dependent contextuality proofs, neither the quantum state nor the measurement statistics enter the picture directly. Our approach fills this gap.
Before going into the details of the formalism we will illustrate the basic idea in the special case of a bipartite scenario. Consider two parties, Alice and Bob, each performing a quantum measurement described by the observables A and B acting on a Hilbert space H with eigenvalues (−1) a where a ∈ Z 2 = {0, 1}. At this point we are not assuming that the observables are local. We only assume that the measurements can be performed simultaneously, i.e. the observables commute. Following the topological approach described in Section 2.1 these observables can be organized into a triangle σ, or 2-simplex as in Fig. (2). The faces of the triangle are therefore denoted by d 0 σ labeled by B, d 1 σ labeled by C = AB and d 2 σ labeled by A. These are the edges, i.e. the 1-simplices, constituting the boundary of the triangle as in Fig. (2). To clarify our topological conventions two remarks are in order: (1) Notice that this approach models an individual measurement as a one-dimensional object (i.e., 1-simplex) while a context consisting of more than one measurement spans at least a two-dimensional space (i.e., 2-simplex). This increases the working dimension of our spaces, as compared to the sheaf [11] and (hyper)graph theoretic [12] [13] approaches, thus facilitating a richer connection to topology. (2) In general, for a pair of commuting observables A and B, and a complex valued function F of two variables, quantum mechanics asserts that one can always find a third commuting observable C = F (A, B). Following [14], which itself drew from the state-independent contextuality proofs of Mermin [6], we focus our attention on those compatible observables that are formed by product relations AB. In the context of MBQC such observables are more aptly called inferables; see e.g., [15].
A pair of observables defines a projective measurement. Let Π ab AB denote the projector onto the simultaneous eigenspace of A and B with eigenvalues (−1) a and (−1) b ; respectively. Marginalizing over each outcome gives the projectors for the observables A, B and C: where Π a A projects onto the (−1) a eigenspace, and similarly for the other observables. We can organize this information in a topological way by interpreting outcomes as geometric objects. A pair of outcomes (a, b) represents a triangle and to each such triangle we associate the projector Π ab AB . Assembling the projectors Π ab AB into a projective measurement Π AB : Z 2 2 → Proj(H) and Π a A (similarly Π b B and Π c C ) into a projective measurement Π A : Z 2 → Proj(H) Eq. (2) can be written as face relation in Fig. (3a): To pass to probabilities we pick a quantum state ρ and apply the Born rule. The probability p ab AB = Tr(ρΠ ab AB ) is assigned to the triangle labeled by the pair (a, b) of outcomes. More precisely, we regard p ab AB as a probability distribution on the collection of triangles labeled by the outcomes (a, b). We have the following marginals where p a A = Tr(ρΠ a A ), and similarly for the other observables. these marginals where p AB : Z 2 2 → R ≥0 is the probability distribution associated to p ab AB and p A : Z 2 → R ≥0 (similarly p B and p C ) is the probability distribution associated to p a A .

The CHSH scenario
A bipartite Bell scenario consists of two parties, Alice and Bob, where Alice performs a measurement x with outcome a and Bob performs a measurement y with outcome b. The joint statistics observed by Alice and Bob can be summarized by a conditional probability distribution p ab xy . When there are multiple measurement choices for Alice and Bob this results in a collection of such probabilities that are subject to compatibility requirements called nonsignaling conditions; see e.g., [30]. For instance, in a CHSH scenario where Alice can perform the measurements x 0 and x 1 and Bob can perform y 0 and y 1 , obtaining probabilities p ab x i y j for each pairing {x i , y j }, the corresponding nonsignaling conditions are given by These expressions ensure that Alice's choice of measurement does not affect the outcome of Bob's measurement, and vice versa. If Alice and Bob are far apart (i.e., they are causally disconnected), then the nonsignaling conditions prohibit superluminal communication between them, in accordance with the theory of special relativity. In our approach the nonsignaling conditions are depicted quite naturally. Using the topological representation of Section 2.2 each p ab x i y j can be placed on a triangle and the nonsignaling conditions can be encoded as the matching of the face relations at the intersections of the triangles. To see this we start with the simpler case of a single measurement per party. We would like to represent the probabilities p ab xy in a topological fashion as in the previous section. First we associate a triple of compatible measurements with the faces of the triangle. More specifically, to the faces d 2 σ and d 0 σ we assign the measurements x and y, respectively. To complete the picture, however, we must also associate a measurement with the d 1 σ face compatible with x and y. A measurement is said Figure 4: (a) Face relations of a distribution on a triangle. (b) A convenient way to represent the probabilities p ab on the triangle. Marginals on each edge can be obtained by summing p 00 with the probability close to that edge: p 0 x = p 00 + p 01 , p 0 y = p 00 + p 10 and p 0 x⊕y = p 00 + p 11 .
to be compatible with both x and y if its outcome can be obtained by a classical post-processing of the outcomes of x and y individually. This definition of compatibility draws on the operational definition of joint measurability introduced in [31,32]. Similar notions of compatibility have also been expressed in [15]. For our purposes we take x ⊕ y to be the XOR of x and y so that x ⊕ y produces the outcome c = a + b mod 2 when the outcome of x happens to be a and the outcome of y happens to be b. Such a choice is well-motivated on physical grounds as the XOR produces precisely that statistic which is relevant for many studies of contextuality; e.g., appearing through correlation functions [8,33], linear side-processing in MBQC [15], as well as in so-called all-versusnothing arguments [34]. Later we will see that the XOR outcomes can be modeled by the nerve space (Definition 3.5). Probability distributions associated with the measurement (x, y) are represented as in Fig. (4a). In this representation p xy is the probability distribution on the collection of triangles labeled by pairs (a, b) ∈ Z 2 2 . The distributions on the edges p x , p y and p x⊕y are obtained by marginalization in the usual way: or equivalently using the face relations For the CHSH scenario we will take a triangle for each pair (x i , y j ) of measurements and glue them in a way that the topology encodes the nonsignaling conditions given in Eq. (4). There are different ways of doing this which produces different spaces at the end. We will consider the one given in Fig. (5a). The edges labeled by x 0 are identified, and similarly the ones labeled by x 1 . The resulting space is a punctured torus T • . Note that we are simply removing the two triangles (diamond shape) in the middle of the torus representing the Mermin square scenario in Fig. (1a).
(Topologically this space is equivalent to the picture in Fig. (1b)). The collection of contexts labeling the triangles are given by The nonsignaling (compatibility) conditions for p can be rewritten in a topological way The orientation on the boundary of each triangle determines the label for the contexts (compare with Fig. (4a)), e.g. p ab y 0 x 0 is the probability for the outcome assignment (y 0 , x 0 ) → (b, a), and so on.

Contextuality in the new framework
The full definition of contextuality will require the precise notion of a space (given in Section 3.1) on which our formalism is based. For now we will give an idea how contextuality is formulated using the topological pictures introduced above. Let us start with deterministic distributions. Those are given by delta distributions associated with an outcome assignment on each measurement. For example, in the CHSH scenario considered in Fig. (5a) deterministic distributions are of the form δ s where s is a function from {x 0 , x 1 , y 0 , y 1 } to Z 2 . By definition [7,35] a nonsignaling distribution p is noncontextual if it is a probabilistic mixture of deterministic distributions: where λ(s) ≥ 0 and s λ(s) = 1. Example 2.2 (New contextual scenarios). The triangle scenario can be modified to obtain a contextual scenario by gluing the d 0 and d 1 faces. This forces the probabilities p = (p 00 , p 01 , p 10 , p 11 ) to satisfy the additional relation p 10 = p 11 which is enforced by the topological identification. For this scenario p is contextual if and only if p 00 + p 01 < 1. For example, (0, 0, 1/2, 1/2) is contextual: A noncontextual distribution is one with p 00 = λ, p 01 = 1−λ, and p 11 = p 10 = 0 for some 0 ≤ λ ≤ 1.
In general topological identifications can be used to construct new scenarios that impose additional constraints satisfied by the probabilities. These kinds of scenarios that arise in our framework cannot be realized directly as nonsignaling distributions. In this paper we will not attempt for a systematic study of these new kinds of scenarios, such a study will appear elsewhere. In this case there exists probabilities λ(abc) ∈ [0, 1] satisfying the equation: One solution can be given as follows: p aa q cc /(p 00 + p 11 ) e = 0 p aā q cc /(p 01 + p 10 ) e = 1 (9) whereā stands for a + 1, and similarly forc.
Example 2.4 (Mermin square scenario). Next let us consider a contextual example, such as the state-dependent version of the Mermin square scenario given in Fig. (1b). To see that the nonsignaling distribution obtained from the quantum mechanical system consisting of the given observables and the Bell state is contextual it suffices to look at the restriction p| ∂X to the boundary. This is a deterministic distribution specified by (δ e , δ f , δ g ) with e + f + g = 1 as dictated by the eigenvalues on the Bell state. However, a noncontextual distribution satisfies the property that e + f + g = 0 mod 2 as a consequence of the following equation: On the right-hand side the outcomes assigned to the torus satisfy the relations e = a + c, g = b + d and f = (b + c) + (a + d). Fig. (5a) is more complicated but also well-known. There is a characterization of noncontextual nonsignaling distributions for this scenario due to Fine [25,26]. The distribution p| ∂X , which is the restriction to the boundary of the punctured torus in Fig. (5a), consists of the distributions p x i ⊕y j for the measurements x i ⊕ y j where i, j ∈ Z 2 . According to Fine's theorem [25,26] a nonsignaling distribution on the CHSH scenario is noncontextual if and only if the following CHSH inequalities [24] hold

Example 2.5 (CHSH scenario). Contextuality analysis of the CHSH scenario in
(These inequalities are equivalent to the ones in terms of the correlations under the standard relationship [8, Section 4a] between XOR probabilities and correlation functions.) We will carry on a careful analysis of this scenario in Section 4.5 as an application of our framework. Therein we use another space (left figure in Fig. (10)) that realizes this scenario to give a topological proof of Fine's theorem. Then using the current realization, given by the punctured torus, we characterize noncontextuality in terms of an extension condition. To illustrate this latter point consider a Popescu-Rohrlich (PR) box [21] regarded as a distribution on the punctured torus. This distribution cannot be extended to a distribution on the torus as demonstrated in Fig. (5b) (where we use the convenient representation given in Fig. (4b)): Let p + be the distribution on the context (x 0 ⊕ y 0 , x 1 ⊕ y 1 ) and p − be the one on (x 1 ⊕ y 0 , x 0 ⊕ y 1 ). The marginals on the d 0 and d 2 faces implies that p + is the deterministic distribution δ 10 assigning (x 0 ⊕y 0 , x 1 ⊕y 1 ) → (1, 0) and p − = δ 00 assigning (x 1 ⊕ y 0 , x 0 ⊕ y 1 ) → (0, 0). But then the marginals on the d 1 faces do not match since d 1 p + = 0 = 1 = d 1 p − . This is a general feature of contextual distributions on the CHSH scenario. In Corollary 4.14 we show that a distribution on the punctured torus extends to a distribution on the torus if and only if it is noncontextual.

Distributions on spaces and contextuality
In Section 2 we explained in an informal way how to interpret nonsignaling distributions as distributions on spaces. Here we introduce our simplicial framework in a more rigorous fashion. We define the notion of a simplicial scenario which consists of a pair of spaces representing both measurements and outcomes. Then we introduce simplicial distributions on these scenarios generalizing the nonsignaling distributions defined for discrete scenarios (see Appendix B). Contextuality defined at this level of generality subsumes the usual notion for the discrete case. Central to our framework is the theory of simplicial sets. They provide combinatorial descriptions of topological spaces and are the main objects of study in modern homotopy theory [36].

Space of measurements
In the simplicial framework we will work with spaces of measurements represented by simplicial sets. In this section we introduce simplicial sets as combinatorial models of spaces and describe some of the measurement spaces that appear in Section 2. The topological n-simplex consists of the points (t 0 , t 1 , · · · , t n ) in R n+1 such that each t i ≥ 0 and i t i = 1. Such a simplex has (n + 1)-faces. Intuitively a simplicial set is a collection of "abstract" n-simplices representing a topological n-simplex together with face maps, telling us how to glue these simplices; and the degeneracies allowing us the extra freedom to collapse some of the irrelevant simplices. More formally, a simplicial set X consists of the following data: • A sequence of sets X 0 , X 1 , · · · , X n , · · · for n ≥ 0 where each X n represents the set of nsimplices.
• Face maps representing the faces of a given simplex.
• Degeneracy maps s j : X n → X n+1 for 0 ≤ j ≤ n representing the degenerate simplices.
The face and the degeneracy maps are subject to the simplicial identities given in the appendix, Eq. (49). See Appendix A for more on these identities and [37] for a reader-friendly introduction to simplicial sets. An n-simplex is called degenerate if it lies in the image of a degeneracy map, otherwise it is called nondegenerate. Geometrically only the nondegenerate simplices are relevant. Among the nondegenerate simplices there are ones that are not a face of another nondegenerate simplex. Those simplices we will refer to as generating simplices. The set of generating simplices of a simplicial set is nonempty unless the set of n-simplices is empty for all n ≥ 0: If a generating simplex of dimension n > 1 does not exist then all the 0-simplices are generating. To illustrate the idea let us consider the simplicial set ∆ d representing the topological simplex of dimension d: • The set of n-simplices is given by {σ a 0 a 1 ···an : 0 ≤ a 0 ≤ · · · ≤ a n ≤ d}.
• The face map d i acts by deleting the i-th element • The degeneracy map s j acts by copying the j-th element s j σ a 0 a 1 ···an = σ a 0 a 1 ···a j a j ···an .
Nondegenerate simplices are given by σ a 0 a 1 ···an with no repetition in a 0 a 1 · · · a n , and the only generating simplex is given by σ 01···d . Note that any other simplex can be obtained from σ 01···d by applying a sequence of face and degeneracy maps, hence the name generating. In our framework X will represent a space of measurements. The n-simplices of X will represent n-dimensional contexts, or briefly n-contexts.
Example 3.1. The triangle scenario in Example 2.1 consists of two measurements {x, y} assembled into a triangle by adding the third measurement x ⊕ y. The measurement space in this case is ∆ 2 whose generating simplex will be denoted by σ 012 xy , and the three faces are denoted by σ 12 y , σ 02 x⊕y and σ 01 x to indicate the corresponding measurements.
To construct more complicated spaces of measurements one can start from more than one generating simplex, which can live in different dimensions, and specify which faces and degeneracies produced from these distinct generating simplices are identified.
Example 3.2. The diamond scenario in Example 2.3 with contexts {x 0 , y 0 } and {x 1 , y 1 } assembled into two triangles glued along a common d 1 -face can be represented by a measurement space Z defined as follows: • Generating 2-simplices: σ x 0 y 0 and σ x 1 y 1 .
• Identifying relation: The CHSH scenario of Example 2.5 consists of four triangles organized into a punctured torus T • defined as follows:

Space of outcomes and distributions
In our framework a space of outcomes will be represented by a simplicial set Y . An n-simplex represents an n-dimensional outcome, or briefly an n-outcome. We will see that distributions on the set of n-outcomes can also be assembled into a simplicial set. This formalizes the intuitive picture given in Section 2. We then specialize to a particular outcome space known as the nerve space, which makes precise the notion of an XOR outcome described in Section 2.3. Let R denote a commutative semiring, e.g. the nonnegative reals R ≥0 or the Boolean algebra B = {0, 1}. An R-distribution, or simply a distribution, on a set U is a function p : U → R of finite support, i.e. p(u) = 0 for finitely many u ∈ U , such that u∈U p(u) = 1 [38]. Given a function f : Definition 3.4. Let Y be a simplicial set representing an outcome space. The space D R Y of distributions on Y is the simplicial set defined as follows: • The set of n-simplices is given by the set D R (Y n ) of distributions on Y n for n ≥ 0.
• The simplicial structure maps are given by D R d i and D R s j .
For simplicity of notation we will write d i and s j for these simplicial structure maps.
Motivated by the topological approach of [14], an essential feature of our framework is that quantum observables, or abstract measurements more broadly, are assigned to edges of a topological space as in Fig. (2) and Fig.(4a), respectively. Following the discussion of Section 2, the triangle in Fig. (2) is represented by a pair (A, B) of observables; similar notions apply to abstract measurements (x, y) in Bell scenarios. We can also represent the pair (A, B) as a projective measurement given in Fig. (3a) on the collection of triangles whose edges are labeled by the outcomes: σ 01 → a, σ 12 → b and σ 02 → a + b. We will generalize this idea to a set of compatible measurements x 1 , x 2 , · · · , x n labeling the edges of an n-simplex: where the remaining edges are XOR measurements whose outcomes are inferable from those of x i . In this case the outcomes associated with an XOR measurement are inferred by summing the outcomes of the performed measurements. (The sum is modulo d if the outcomes take values in Z d . This will be made more precise in Eq. (19).) Suppose the measurements come from quantum observables that pairwise commute. Then the associated projective measurement will be on the collection of n-simplices labeled by tuples (a 1 , a 2 , · · · , a n ) of outcomes generalizing the two-dimensional case. There is a nice way to assemble these simplices into a space, known as the nerve space 1 .
Note that (N Z d ) 0 consists of the empty tuple ( ), the unique 0-simplex.
Next we describe the space D R N Z d of distributions on the nerve: An n-simplex of D R N Z d is a distribution of the form p : Z n d → R and the simplicial structure maps are given by Notation 3.6. To describe D R N Z 2 in dimensions ≤ 2 we will use the following notation: For n = 2 we identify p ∈ D R (Z 2 2 ) with the tuple (p 00 , p 01 , p 10 , p 11 ). There are three face maps d i : For n = 1 the distribution p is identified with (p 0 , p 1 ), and since p 0 sending every distribution to 1 and there are two degeneracy maps s j :

Contextuality for simplicial distributions
We begin with the notion of a map between spaces in the simplicial set formalism. A map f : X → Z of simplicial sets, or a map of spaces, consists of a sequence of functions • f n : X n → Z n for n ≥ 0, • compatible with the face and the degeneracy maps in the sense that for all 0 ≤ i, j ≤ n and σ ∈ X n .
We will write f σ for the image f n (σ). With this notation Eq. (14) can be written as Remark 3.7. A map f : X → Y of spaces is determined by its values on the generating simplices.
(Here we assume that X n = ∅ for some n ≥ 0. Otherwise, the map is unique.) Let {σ i : σ i ∈ X m i } denote the set of generating simplices of X. Then f consists of assignments σ i → f σ i for each generating simplex, where f σ i is a m i -simplex of Y , compatible with the simplicial structures. The latter condition simply amounts to the requirement that if θ is a m-simplex of X which can be obtained from two distinct generating simplices, say σ i and σ j , then the assignment θ → f θ determined by the assignments for σ i and σ j should match. More precisely, if θ = α i (σ i ) = α j (σ j ) for some maps α i and α j given by a composition of faces and degeneracies then our assignment has to satisfy In the special case X = ∆ n space maps f : ∆ n → Y are in bijective correspondence with the elements of Y n .
Next we introduce distributions in the simplicial framework generalizing the notion of nonsignaling distributions.

Definition 3.8.
A simplicial scenario is a pair (X, Y ) consisting of a space X of measurements and a space Y of outcomes. A simplicial distribution on this scenario is a map p : X → D R Y of spaces. We write S(X, Y ) for the set of simplicial distributions on (X, Y ).
A map r : X → Y of spaces will be called an outcome map, or sometimes an outcome assignment. There is an associated simplicial distribution δ r : X → D R Y defined by sending an n-context σ to the delta distribution δ r σ = δ rσ on the set of n-outcomes. For θ ∈ Y n we have We denote the set of classical distributions by C(X, Y ).
In the simplicial setting the definition of contextuality relies on the following map: where σ ∈ X n , θ ∈ Y n and r : X → Y runs over outcome assignments such that r σ = θ. This makes precise the intuitive pictures that appear in the examples of Section 2.4.
To avoid confusion we will indicate which convex combination we mean. We emphasize that in general C(X, Y ) is not a subset of S(X, Y ). This definition generalizes the usual notion of contextuality for nonsignaling distributions; see Definition B.1 and Theorem B.2. In this sense our framework extends the sheaf-theoretic approach [11] that formalizes the theory of contextuality for nonsignaling distributions. Example 3.11. Using Remark 3.7 we can describe distributions on the simplicial scenario (∆ n , Y ) for an arbitrary outcome space Y . We have D(∆ n , Y ) = Y n for the deterministic distributions. This implies that the set of classical distributions is given by Similarly, simplicial distributions p : ∆ n → D R Y are given by Consequently the Θ-map in (16) is the identity map, and hence every distribution on the simplicial scenario (∆ n , Y ) is noncontextual. The triangle scenario of Example 2.1 is the special case where n = 2 and Y = N Z 2 .
The notion of contextuality depends on the underlying semiring R. We will say R-(non)contextual when we want to emphasize this dependence. Similarly this dependence will be emphasized for the simplicial and classical distributions by including R in the notation. We write S R (X, Y ) and C R (X, Y ) for the set of simplicial R-distributions and classical R-distributions; respectively. A semiring homomorphism φ : R → S gives us a commutative diagram The vertical maps are obtained simply by applying φ to the distributions on the simplices of Y for a simplicial distribution p : X → D R Y , or to the coefficients of a classical distribution d = r λ(r) δ r .
Probability distributions will be our main application. A simplicial R ≥0 -distribution will also be called a simplicial probability distribution. An important example of a semiring homomorphism is φ : R ≥0 → B that sends positive numbers to 1 and zero to 0. A simplicial R ≥0 -distribution is said to be logically (or possibilistically) contextual if φ * (p) is B-contextual. This extends the usual definition for nonsignaling distributions [40]. A famous example is Hardy's bipartite scenario [41]. In Section 5 we introduce strong contextuality for simplicial distributions and explore its connection with cohomology. Now we turn to the examples of Section 2.4 and revisit them formally.

Simplicial scenarios with nerve as the outcome space
Our canonical choice for the outcome space will be N Z d . We begin by a description of outcome assignments for a simplicial scenario (X, N Z d ) where X is an arbitrary measurement space.
for all σ ∈ X 2 . Moreover, for a generating n-simplex σ = σ 01···n of X n and r σ = (a 1 , a 2 , · · · , a n ) Proof. We will use the description of a space map given in Remark 3.7. First we prove the statement for X = ∆ n , in which case it suffices to prove Eq. (19). In this case r is determined by an n-tuple r σ = (a 1 , a 2 , · · · , a n ) of outcomes in Z d . We will do induction on k. Let us define Using compatibility of r with the face maps and Eq. (12) we obtain r σ where in the last step we used our induction hypothesis and the k = 1 case; see Fig. (6). For the general case an outcome map r : Denoting by r x i and r y j the 1-outcomes associated to the 1-contexts σ x i and σ y j , Proposition 3.13 implies that r x i = a i and r y j = b j . Classical distributions on this scenario are given by The formula in Eq. (9) for λ in terms of the initial pair (p, q) of distributions implies that Θ is surjective. Therefore every distribution on this simplicial scenario is noncontextual. A generalization of this formula (given in Eq. (29)) appears in the proof of Lemma 4.5, a result on gluing classical distributions.
Example 3.16. Next we describe the set of deterministic and classical distributions on the CHSH scenario. The measurement space is the punctured torus T • described in Example 3.3. An outcome assignment r : T • → N Z 2 is determined by the images of the four generating simplices: r y 0 x 0 , r y 0 x 1 , r x 0 y 1 and r x 1 y 1 . Each of these 2-outcomes are specified by a pair in Z 2 . They further satisfy a set of relations imposed by the ones among the generating simplices given in Eq. (11): Using these equations together with Proposition 3.13 we obtain r y 0 4 2 where under this identification a quadruple (a 0 , b 0 , a 1 , b 1 ) uniquely specifies the outcome map r, and the set of classical distributions is given by A simplicial distribution p : T • → D R N Z 2 is determined by the images of the generating simplices, given by the distributions together with a set of relations imposed by Eq. (11). This set of relations is precisely the one given in Eq. (7), i.e. the usual nonsignaling conditions for the CHSH scenario. For a deterministic distribution r represented by a quadruple δ a 0 b 1 , δ a 1 b 1 . In general, a classical distribution d = r λ(r) δ r , where r runs over the quadruples (a 0 , b 0 , a 1 , b 1 ), will be mapped to a simplicial distribution p = Θ(d) such that similarly for the remaining distributions: p y 0 x 1 , p x 0 y 1 , p x 1 y 1 . This means that p is precisely a classical distribution in the usual sense. Therefore for the CHSH scenario contextuality in the sense of Definition 3.10 coincides with the usual notion of contextuality (see Definition B.1).

Distributions on the circle
So far we have been considering the nerve space N Z d as the space of outcomes. Now we will consider a subspace 3 , the circle S 1 , as the outcome space and describe the corresponding distributions on a simplicial scenario (X, S 1 ). Distributions on the circle will be important in the formulation of the Gleason's theorem (Theorem 7.1). Also in Section 6.3 the circle will play a role in the formulation of state-independent contextuality as a distinguished measurement space. As a simplicial set the circle S 1 is defined as follows: • Generating 1-simplex: σ 01 .
For example, the 2-simplices are given by σ 000 = σ 111 , σ 011 and σ 001 ; see Fig. (7). Faces and degeneracies can be obtained by applying the deleting and copying operations to the string 01 · · · n. The simplicial structure maps in dimensions ≤ 2 are illustrated in Fig. (7). Alternatively, the circle can be seen as a subspace of N Z d if we map the simplices in Eq. (22), respectively, to the following n-tuples: (0, 0, · · · , 0), (1, 0, · · · , 0), (0, 1, · · · , 0), · · · , (0, 0, · · · , 0, 1) In particular, the 2-simplices are mapped as follows in Fig. (7). We will denote this map by Next we describe the space of distributions on the circle. An n-simplex of D R S 1 is a distribution p : (S 1 ) n → R on the set of n-simplices listed in Eq. (22). If we set p k = p(σ 0 k−1 1 n−k ) then such distributions are in bijective correspondence with n-tuples (p 1 , p 2 , · · · , p n ) satisfying p i ≥ 0 for all 1 ≤ i ≤ n and n i=1 p i ≤ 1. In this representation the faces and the degeneracies are given by We can see D R S 1 as a subspace of D R N Z d via the map where h is as given in (24). Under this map a tuple (p 1 , p 2 , · · · , p n ) representing an n-simplex of D R S 1 maps to the distributionp : Z n d → R given bỹ p k a k = 1 and a j = 0 for all j = k 1 − k p k a 1 = a 2 = · · · = a n = 0 0 otherwise.

Example 3.17.
For the diamond scenario an outcome map r : Z → S 1 is determined by the 2-outcomes r x i y i = (a i , b i ), where i = 0, 1, as in the case where the outcome space is N Z 2 , however this time the pair can not be (1, 1). For a simplicial probability distribution p : Z → D R ≥0 S 1 determined by the pair (p, q) of distributions there is an additional constraint: p 11 = q 11 = 0. Compatibility at the d 1 -face then implies p 00 = q 00 . Therefore we have S(Z, S 1 ) = {(p 01 , p 10 , q 01 , q 10 ) ∈ [0, 1] 4 : p 01 + p 10 = q 01 + q 10 ≤ 1}.
Any distribution on the scenario (Z, S 1 ) is still noncontextual. Given p ∈ S(Z, S 1 ) we can use Eq. (9) to construct a classical distribution d = abc λ(abc) δ abc such that λ(abc) = 0 whenever (a, b) or (c, a + b + c) is equal to (1,1). This implies that d ∈ C(Z, S 1 ), which can be used to show that p is noncontextual.

Gluing and extending distributions
In the previous section a simplicial scenario was defined as a pair (X, Y ) of spaces. Using the flexibility afforded by the language of simplicial sets we can readily define maps between measurement spaces or outcome spaces. These maps allow us to compare simplicial distributions on two different scenarios and study their contextual behavior by comparison. Here we formalize this approach and deduce new results on contextual properties of distributions using topological reasoning. Our main tool is the "gluing lemma" formulated in Lemma 4.5 that significantly generalizes Fine's approach to gluing classical distributions. As an application of our formalism we provide a new topological proof of Fine's theorem [25,26] for the CHSH scenario (Theorem 4.13). Our approach is to study distributions on simpler measurement spaces then using the gluing lemma to draw conclusions about more complicated measurement spaces. We also give a new characterization of contextuality in terms of extensions to larger measurement spaces as formulated in Corollary 4.14.

Changing measurement and outcome spaces
Let X and Z be spaces of measurements and Y be a space of outcomes. A map f : Z → X of spaces induces the following functions distributions: When f : Z → X is the inclusion map of a subspace we simply write δ r | Z (or r| Z ), d| Z and p| Z for the corresponding distributions on Z obtained by restricting an outcome map, a classical distribution and a simplicial distribution; respectively. The Θ-map is compatible with changing the measurement space in the sense that there is a commutative diagram In the notation of the Θ-map we emphasize dependence on the measurement and the outcome spaces. Usually we omit the outcome space when only the measurement space is changed. When Z is a subspace of X the commutativity of the diagram is expressed as Θ X (d)| Z = Θ Z (d| Z ). Changing the outcome space also induces maps between the sets of distributions and a commutative diagram expressing the compatibility with the Θ-map. A map g : Y → W of spaces induces: • g * : D(X, Y ) → D(X, W ) defined by sending δ r to the deterministic distribution δ g•r .
The corresponding commutative diagram in this case is given by A result analogous to Proposition 4.1 can be formulated: If a distribution p on (X, Y ) is noncontextual then g * (p) on (X, W ) is noncontextual as well. Proof. As observed above, the commutativity of Diag. (27) implies that if p is noncontextual then g * (p) is noncontextual. Conversely, assume that g * (p) is noncontextual. That is, there exists d ∈ C(X, W ) such that Θ X,W (d) = g * (p). Note that both of the vertical maps in Diag. (27), g * and D R g * , are injective since g is injective. Let S denote the set of outcome assignments s : X → W such that d(s) = 0. An outcome assignment s : X → W consists of a family of simplices {s σ } σ , where σ runs over the generating simplices of X, compatible under the simplicial structure maps (Remark 3.7). Since Θ X,W (d) = g * (p) every s ∈ S belongs to the support of g * (p). Injectivity of g * implies that supp(g * p) is contained in supp(p). Therefore s σ for every generating simplex σ of X belongs to Y . The simplices {s σ } σ define a simplicial set maps : X → Y such that s = g •s.
where p x i = p σx i and p y j = p σy j . In this case the distribution q = h * (p) on (T • , N Z 2 ) is given by where we use Notation 3.6 and write q σ = (q 00 σ , q 01 σ , q 10 σ , q 11 σ ) for a 2-context σ. By Proposition 4.2, p is noncontextual if and only if q is noncontextual. Now, using CHSH inequalities for q we obtain the following set of inequalities p 1 x i + p 1 y j ≤ 1 i, j ∈ Z 2 , which are always satisfied by p as a consequence of the description given in Eq. (28). Therefore every p ∈ S(T • , S 1 ) is noncontextual and can be written as a probabilistic mixture of the following 7 deterministic distributions: δ 0000 , δ 1000 , δ 0100 , δ 0010 , δ 0001 , δ 1010 , δ 0101 .

Gluing classical distributions
When the space of measurements can be written as a union of smaller spaces deterministic distributions and simplicial distributions can be described as compatible distributions on the subspaces.

Distributions in S(X, Y ) can be identified with pairs (p
Proof. This is a consequence of the fact that a map r : X → Y (or p : X → D R Y ) of spaces is uniquely determined by the restrictions r| A and r| B . Conversely, a pair (r A , r B ) of maps compatible on the intersection A ∩ B can be glued to give a map r : X → Y .
Note that an analogous observation does not apply to classical distributions. In general C(X, Y ) is different from compatible pairs (d A , d B ) of classical distributions. However, we can associate a classical distribution to any such pair (d A , d B ) generalizing the constructions used in the diamond scenario (Example 3.15), or Fine's theorem [26] including its versions [28] (Example 4.7) and joint probability distributions constructed in [42].

Lemma 4.5. Let R be a semifield. Suppose that the space of measurements is a union X = A ∪ B.
For p ∈ S(X, Y ) the following are equivalent:

There exists distributions d
Proof. Assuming (1) holds we can take . Conversely, assume that (2) holds. Using the pair (d A , d B ) we can construct a distribution d ∈ C(X, Y ). For an outcome map r : X → Y the distribution is defined as follows Note that the denominator is also equal to d B | A∩B (r| A∩B ) by the compatibility of the classical distributions d A and d B . First we verify that d is a probability distribution on D(X, Y ): Clearly d(r) ≥ 0 and we have In In the fourth line we used   imply that any simplicial distribution on (Z d,n , Y ) is noncontextual. This observation was proved in the special case of the diamond scenario in Example 3.15. Fig. (8) illustrates Z 3,2 , in which case Eq. (29) specializes to the ansatz used by Fine [26]. The case of Z d,2 is also studied in [28].

Extensions of distributions
In certain situations noncontextuality can be characterized as the possibility of extending the distribution to a larger measurement space. This technique will be very useful to extract the essence of Fine's argument for the sufficiency of the CHSH inequalities as a criteria for noncontextuality.  4.9 (Extending from the boundary). Consider the inclusion of the boundary f : ∂∆ n → ∆ n and take Y = N Z d as the space of outcomes. By Proposition 3.13 we know that r ∈ D(∆ n , N Z d ) is determined by the edges r σ (i−1)i . The 1-outcomes for the remaining 1-contexts can be obtained (inferred) from a i 's as a consequence of the formula in Eq. (19). A similar analysis works for ∂∆ n when n ≥ 3. Though for n = 2, note that ∂∆ 2 consists of three edges and an outcome map t : ∂∆ 2 → N Z d is specified by a triple (t σ 01 , t σ 12 , t σ 02 ) ∈ Z 3 d . Unlike ∆ 2 there is no compatibility relation imposed among the 1-outcomes, i.e. we do not require t σ 02 = t σ 01 + t σ 12 . But for n ≥ 3 the subspace ∂∆ n has the same set of 2-contexts as ∆ n and an outcome map on the boundary is still determined by the 1-outcomes assigned to σ (i−1)i . Therefore in this case f * : D(∆ n , N Z d ) → D(∂∆ n , N Z d ) is a bijection, and Proposition 4.8 implies that a distribution on (∂∆ n , N Z d ) is noncontextual if and only if it extends to (∆ n , N Z d ). In Proposition 4.12 we show that for n = 3 and d = 2 extension always exists, hence any distribution on (∂∆ 3 , N Z 2 ) is noncontextual.

Diamond scenarios and CHSH inequalities
For the rest of this section we restrict to simplicial probability distributions, that is we take R = R ≥0 . Let Z denote the diamond scenario obtained by gluing two copies of ∆ 2 along a common edge. Here we don't make any restrictions on the choice of the face on each triangle. Our goal is to study distribution on the boundary ∂Z and determine when an extension to the whole space exists. For this we will decompose the boundary into simpler spaces. Let Λ n k for 0 ≤ k ≤ n denote the subspace of ∆ n generated by all the faces of the form d i σ 01···n where i = k. This space is called the n-dimensional k-th horn. For a distribution p on (∆ n , Y ) we will write p a 0 a 1 ···a k = p σ a 0 a 1 ···a k for the distribution assigned to the simplex σ a 0 a 1 ···a k . In dimension n = 2 a horn is obtained by omitting one of the edges in the boundary of a 2-simplex. We will first describe when a simplicial distribution on (Λ 2 1 , N Z 2 ) extends to (∆ 2 , N Z 2 ) along the inclusion map Λ 2 1 → ∆ 2 . This is equivalent to understanding when such a distribution is noncontextual as a consequence of Proposition 4.8. Let p be a distribution on (Λ 2 1 , N Z 2 ) specified by the tuple (p 0 01 , p 0 12 ) ∈ [0, 1] 2 . If p extends to a distributionp on ∆ 2 then we requirẽ for some distribution p 02 on the d 1 -face. Note that p 1 ij = 1 − p 0 ij for 0 ≤ i < j ≤ 2, so that we can express the inequalities only in terms of p 0 ij . A suitablep ab can be found if and only if p 0 02 satisfies Applying Fourier-Motzkin elimination to p 0 02 we see that p extends to ∆ 2 if and only if Notice that such a p 0 02 can always be found for any p 0 01 and p 0 12 since expanding the absolute value in Eq. (31) and canceling like terms yields the "trivial" inequalities 0 ≤ p 0 01 , p 0 12 ≤ 1. Similar inequalities exist for the other horn inclusions Λ 2 k → ∆ 2 for k = 0, 2. We will use this analysis to study extensions from the boundary of the diamond scenario.

Proposition 4.10. A distribution p on the boundary of the diamond scenario extends to the diamond if and only if p satisfies the CHSH inequalities in Eq. (10).
Proof. For Z we will assume that it is obtained by gluing along the d 1 faces. The argument for the other choices is similar. The distribution p on the boundary of the diamond is specified by (p 0 01 , p 0 12 , q 0 01 , q 0 12 ) ∈ [0, 1] 4 . The distribution p extends to a distribution on the diamond if and only if two copies of the inequalities, one for p ij 's and one for q i j , have a common solution for p 0 02 = q 0 02 . Generalizing (31), this occurs precisely when By Fourier-Motzkin elimination this single inequality is equivalent to the following four in addition to the trivial inequalities corresponding to 0 ≤ p 0 ij , q 0 ij ≤ 1. Expanding the absolute values gives the inequalities 0 ≤ p 0 01 + p 0 12 + q 0 01 − q 0 12 ≤ 2 0 ≤ p 0 01 + p 0 12 − q 0 01 + q 0 12 ≤ 2 0 ≤ p 0 01 − p 0 12 + q 0 01 + q 0 12 ≤ 2 0 ≤ −p 0 01 + p 0 12 + q 0 01 + q 0 12 ≤ 2. (32) These equations are formally identical to the CHSH inequalities appearing in Eq.(10).
Next we analyze the situation for two copies of diamonds glued along a triangle. This produces a space as in Fig. (9). Again orientation of the edges can be different, our choice is the one that will be used later in the topological proof of Fine's theorem.

Topological proof of Fine's theorem
Let H denote the space of measurements obtained by gluing two copies of ∂∆ 3 along a common face given by a triangle. For concreteness we will assume they are glued along their d 0 -faces as in Fig (10). The subspace generated by the faces σ 013 and σ 012 of the first ∂∆ 3 is a copy of the diamond scenario Z. Similarly the subspace generated by σ 0 13 and σ 0 12 is another copy of the diamond scenario Z. The intersection of these two copies is a horn Λ 2 0 generated by the edges d 0 σ 013 and d 0 σ 012 . Let Q denote the subspace given by the union of the two diamonds; see Fig (10). We will refer to (Q, N Z 2 ) as the square scenario. We begin by showing that any distribution on ∂∆ 3 is noncontextual. Proof. By Example 4.9 it suffices to show that any distribution p on (∂∆ 3 , N Z 2 ) extends to a distribution on (∆ 3 , N Z 2 ). The distribution p is determined by the marginals p ijk = p σ ijk on the generating simplices σ ijk where 0 ≤ i < j < k ≤ 3. Extending p to ∆ 3 amounts to specifying a distribution p 0123 = p σ 0123 on the generating simplex σ 0123 . This distribution is defined as follows: Set p 000 0123 to be the minimum of {p 00 ijk : 0 ≤ i < j < k ≤ 3} and determine the remaining values p abc 0123 from the marginals. To see how this works assume that the minimum is p 00 123 . The cases where the minimum is p 00 023 , p 00 013 and p 00 012 are dealt with similarly. The marginals for the d i -faces give us It remains to show that marginalizing to the d i -th face produces the original distribution. This is clear for i = 0 by construction, and can be shown for the remaining faces by direct verification.
The distribution is also normalized as can be shown by summing up the elements in p 0123 given above.  is a bijection since both sets are given by Z 4 2 and an outcome assignment is determined by the outcomes assigned to the measurements x i 's and y j 's (Proposition 3.13). By Proposition 4.8 p is noncontextual if and only if it extents to H. Observe that H is the union of Q and A (the space in Fig. (9)) along the boundary ∂A. Now by Proposition 4.11 p| ∂A extends to A if and only if the three CHSH inequalities are satisfied. Two of those corresponding to Z(σσ ) and Z(σσ ) are satisfied because these diamonds also lie on the boundary of the diamonds with vertices (0, 1, 2, 3) and (0 , 1, 2, 3) in Q, and Proposition 4.10 implies that at their boundary the CHSH inequalities are satisfied. The third one corresponds precisely to the CHSH inequalities for p| ∂Q .
We turn back to the CHSH scenario where the measurement space is represented as a punctured torus T • as in Example 2.5; see Fig. (5a). For example, Corollary 4.14 implies that the PR box in Fig. (5b) is contextual since it fails to extend to the torus. An alternative proof of Fine's theorem that uses the punctured torus realization (Fig. 5a) is given in [43].

Strong contextuality and cohomology
In this section we show that strong contextuality can be detected by cohomology. This is the first step towards verifying our claim that the simplicial formalism generalizes the earlier topological approach. In fact, significant control is achieved by constructing our cohomological classes for general simplicial distributions, as opposed to cohomology classes constructed in [14] that come essentially from algebraic relations among quantum observables. In the next section we apply our constructions to state-independent contextuality making the link to the topological approach.

Strong contextuality
There is a stronger version of contextuality whose definition relies on the notion of support. The support of a simplicial distribution p : X → D R Y is defined by

Proposition 5.1. If the support of p : X → D R Y is empty then p is contextual
Proof. Assume that p is noncontextual, that is, it can be written as a probabilistic mixture p = r λ(r) δ r . Then for s such that λ(s) = 0 we have Therefore s belongs to the support of p.

Definition 5.2. A simplicial distribution p on (X, Y ) is called strongly contextual if its support supp(p) is empty.
This notion generalizes strong contextuality for nonsignaling distributions; see Corollary B.4. For example, the PR box described in Fig. (5b) is strongly contextual.

Deterministic distributions and cohomology
In this section we relate the set D(X, N Z d ) of deterministic distributions to the first cohomology group of X. Let us introduce the cohomology group of a simplicial set. We omit the discussion of homology groups as they are not used in this paper. We will restrict to Z d as the coefficients of our cohomology groups. Given a space X we can construct a cochain complex The n-th cohomology group of X is defined to be the quotient group given by the kernel of δ n modulo the image of δ n−1 : H n (X) = ker(δ n ) im(δ n−1 ) .
A map g : Z → X of spaces induces a homomorphism g * : H n (X) → H n (Z) between the cohomology groups. Under this map a cohomology class By Proposition 3.13 (and Remark 3.14) sending an outcome assignment r : X → N Z d to the 1-cochain r 1 : Corollary 5.3. Let X be a space of measurements with a single 0-context. Then the function α X given in (35) is a bijection.
Proof. When X 0 = { } the first cohomology group is given by the kernel of δ 1 : C 1 (X) → C 2 (X) since δ 0 is the zero map. In this case H 1 (X) consists of those functions f satisfying the condition in Proposition 3.13. Therefore deterministic distributions are given by the elements of H 1 (X).
Example 5.4. An example to a measurement space with a single 0-context is the circle S 1 . The first cohomology group of S 1 is computed using the cochain complex C 0 → C 1 → C 2 , which is given by We use the simplices given in Eq. (23) and write ab instead of (a, b) for simplicity. Given f : Thus δ 1 f (ab) = f (0) for ab = 00, 01, 10 and f is in the kernel if and only if f (0) = 0. This implies that

Cohomological witness for contextuality
Let X be a space of measurements and Z be a subspace. One can construct the quotient spacē X = X/Z where the subspace Z is identified to a point. More formally, the n-simplices ofX are given by the difference set X n − Z n union with { n } representing the collapsed simplices coming from Z n . The simplicial structure is given as follows: • For σ ∈ X n − Z n the face and the degeneracy maps act as those of X n , except that • d i n = n−1 and s j n = n+1 .
We will construct a cohomological witness on the quotient spaceX that detects contextuality. Let us write i : Z → X for the inclusion and q : X →X for the quotient map. The main tool is the following exact sequence 5 in cohomology Given [f ] ∈ H 1 (Z) the cohomology class ζ[f ] is defined as follows: • Lift f to a cochainf ∈ C 1 (X) by setting • Using δ 1f construct a cochainf in C 2 (X) by settinḡ The connecting homomorphism ζ sends [f ] to the cohomology class [f ]. Example 5.8 below explains how this is done in practice. Exactness of (36) is a standard fact in algebraic topology; see [44, §1.3]. Next result will be useful in Section 6.3.

Lemma 5.5.
If the inclusion map i : Z → X splits, i.e. there exists a map j : X → Z of spaces such that j • i : Z → Z is the identity map, then the connecting homomorphism ζ is the zero map.
Proof. The map j can be used to show that i * : H 1 (X) → H 1 (Z) is surjective so that by exactness of (36) the connecting homomorphism is zero. To see the surjectivity observe that the composite Using the map in (35) we will compare the sequence in (36) to the sequence of deterministic distributions to obtain the following commutative diagram Proof. If an extension exists then by the commutativity of Diag. (38) and the exactness of the bottom part of that diagram we have Conversely, assume that ζ • α Z (r) = 0. Recall from (35) that α Z sends a deterministic distribution represented by r : Z → N Z d to the function r 1 : Z → Z d , the restriction onto the set of 1contexts (similarly α X and αX ). Now we apply the construction of the connecting homomorphism described above to f = r 1 to obtain the cochainsr 1 ∈ C 1 (X) andr 1 ∈ C 2 (X); see Eq. (37), so that [r 1 ] = ζ[r 1 ] = 0. Therefore there exists t ∈ C 1 (X) such that δ 1 (t) =r 1 . We claim that the function s 1 =r 1 − q * (t), which corresponds to a deterministic distribution s by Proposition 3.13, gives the desired extension of r. For this we need to verify that s 1 satisfies Eq. (18) and i * (s 1 ) = r 1 . First one follows from δ 1 ( Given p ∈ S(X, N Z d ) and the subspace Z we define a set of cohomology classes: Corollary 5.7. Let p ∈ S(X, N Z d ) and Z ⊂ X be a subspace. If cl Z (p) does not contain the zero class, i.e. 0 / ∈ cl Z (p), then p is strongly contextual.
Proof. Proposition 5.6 implies that none of the elements in supp(p| Z ) extends to X since 0 / ∈ cl Z (p). Therefore the support supp(p) is empty.
A typical application of this result is the case when p| Z is a deterministic distribution so that cl Z (p) consists of a single cohomology class [β p ] ∈ H 2 (X). Then [β p ] serves as a witness for strong contextuality, in the sense that [β p ] = 0 implies strong contextuality for p.
Our construction of the cohomology witnesses can be compared to the Čech cohomological construction of [45]. Therein the construction is with respect to one of the contexts in the measurement cover, whereas in our construction Z can be any subspace; see Example 5.8. Another difference is that our construction relies on the abelian group structure of the set of outcomes. Figure 11: The 1-cochain specified by (e, f, g) on the boundary is first extended to a 1-cochain on the whole space by assigning zeros to the remaining edges. The coboundary δ 1 turns this 1-cochain to a 2-cochain that assigns to each triangle the sum of the numbers on the edges of its boundary. This produces a 2-cochain on the torus where the values assigned to each 2-simplex are as indicated in the figure.
Example 5.8. Consider the state-dependent version of Mermin square discussed in Example 2.4. The torus minus a single triangle is our space X of measurements. The subspace Z will be taken as the boundary of X consisting of the three edges. Let p be a simplicial distribution on (X, N Z 2 ) such that p| Z is a deterministic distribution specified by (δ e , δ f , δ g ) where e, f, g ∈ Z 2 . The cocycle β p that lives on the quotient spaceX is calculated as in Fig. (11). The quotientX is a torus, in particular, it is a closed surface. Therefore [β p ] = 0 if and only if the cochain β p = 0, i.e. when e + f + g = 1 mod 2.

Quantum measurements on spaces
In this section we generalize quantum measurements with a discrete, usually finite, set of outcomes to quantum measurements associated to a space of outcomes. This construction gives us the notion of simplicial quantum measurements. In addition, if we are given a quantum state, then the Born rule, or a simplicial version thereof, can be used to obtain a simplicial probability distribution. This affords us the ability to examine whether a quantum state is contextual by examining the resulting simplicial distribution. Similar constructions also work for projective measurements. Applying the cohomological witness introduced in Section 5.3 to state-independent contextuality results in a precise connection to the earlier topological approach. We then use these tools to rigorously analyze the state-independent Mermin square scenario introduced in Section 2.

Simplicial quantum measurements
Let H denote a finite-dimensional complex Hilbert space and L(H) denote the complex vector space of linear maps on H. We will write Pos(H) ⊂ L(H) for the set of positive semidefinite operators. A quantum measurement [46] on a set U is a function P : U → Pos(H) of finite support, i.e. P (u) = 0 for only finitely many u ∈ U , such that u∈U P (u) = 1. When H = C a quantum measurement is the same as a probability distribution on U . We will write Q H (U ) for the set of quantum measurements on U . Given a function s : V → U and a quantum measurement P ∈ Q H (V ) we define the quantum measurement Q H s(P ) on U by the assignment u → v∈s −1 (u) P (v). Definition 6.1. Let Y be a simplicial set representing a space of outcomes. The simplicial set Q H (Y ), called the space of quantum measurements on Y , consists of the n-simplices Q H (Y n ) for n ≥ 0. The simplicial structure maps are given by Q H d i and Q H s j , which for simplicity of notation will be denoted by d i and s j . A simplicial quantum measurement on a simplicial scenario (X, Y ) is a map X → Q H Y of spaces. We will write Q(X, Y ) for the set of simplicial quantum measurements on (X, Y ).
Our construction is natural with respect to the underlying Hilbert space in the sense that a linear map Φ : L(H) → L(K) that is positive and unital [46] induces a map Φ * : Q H Y → Q K Y of spaces. In particular, given a quantum state ρ the Born rule can be used to define a function ρ * : Q H U → D R ≥0 U by sending a quantum measurement P to the probability distribution ρ * (P )(u) = Tr(ρP (u)). We will extend this to the level of spaces: A quantum state ρ can be used to define a map of spaces by sending a quantum measurement P ∈ Q H Y n to the distribution on Y n defined by θ → Tr(ρP (θ)).
Compatibility of ρ * with the simplicial identities follows from the linearity of the trace.

Definition 6.2.
A quantum state ρ is called (non)contextual with respect to a simplicial quantum measurement P : A quantum state ρ is called strongly contextual with respect to P if the distribution ρ * P is strongly contextual.

Projective measurements on the nerve
Let Proj(H) ⊂ Pos(H) denote the subset of projection operators. A projective measurement on a set V is a quantum measurement of the form Π : V → Proj(H) [46]. For such measurements it holds that for distinct elements of V the projectors are orthogonal: Proposition 2.40]. We will write P H (V ) for the set of projective measurements on V . The simplicial constructions for quantum measurements also work for projective measurements: The simplicial set P H Y , called the space of simplicial projective measurements on Y , consists of the nsimplices P H (Y n ) for n ≥ 0 with the simplicial structure maps P H d i and P H s j , which for simplicity denoted by d i and s j . We will write P(X, Y ) for the set of projective measurements on (X, Y ). Note that P H Y is a subspace of Q H Y . The simplicial version of the Born rule given in (40) induces a commutative diagram of spaces where • δ Y sends θ ∈ Y n to the delta distribution δ θ ∈ D R Y n defined in Eq. (15), • δ H,Y sends θ ∈ Y n to the projective measurement defined by δ θ H (θ ) = 1 for θ = θ and 0 otherwise. Commutativity of the diagram is a consequence of the trace 1 condition satisfied by quantum states. There is also a similar diagram for Q H Y .
Projective measurements on the nerve space N Z d have an alternative description. Let U (H) denote the group of unitary operators acting on H. Let N (Z d , U (H)) denote the simplicial set 6 whose n-simplices are given by and the degeneracy maps Proof. Let ω denote the d-th root of unity e 2πi/d . In dimension n the simplicial set map sd sends a tuple (A 1 , · · · , A n ) of unitaries to the projective measurement Π : Z n d → Proj(H) where Π(a 1 , · · · , a n ) projects onto the simultaneous eigenspace with eigenvalues (ω a 1 , · · · , ω an ). This assignment respects the simplicial structure. The inverse map sd −1 sends a projective measurement Π to the tuple of unitaries (A 1 , · · · , A n ) where ω a i Π(a 1 , · · · , a n ).
Example 6.4. The state-dependent Mermin square scenario together with the Pauli observables in Fig. (1b) can be regarded as a morphism A : X → N (Z 2 , U (H)) where X is the underlying space and H = (C 2 ) ⊗2 . This morphism assigns a pair of observables for each 2-context of X.
For example, f y 0 x 0 is sent to the pair (1 ⊗ X, X ⊗ 1). If we compose with the isomorphism in Proposition 6.3 we obtain a simplicial projective measurement P : Under this morphism a 2-context is sent to the projective measurement given by the simultaneous diagonalization of the pair of observables. For example, f y 0 x 0 will be sent to the measurement determined by the projectors

State-independent contextuality
State-independent contextuality arises from the impossibility of being able to assign eigenvalues to a set of observables in such a way that all product relations 7 among mutually commuting observables are also satisfied by the assigned eigenvalues [6]. As mentioned in the introduction (Section 2.1) this type of contextuality is detected by a cohomology class constructed in [14]. This cohomology class can also be described in the simplicial framework by using the cohomological witness introduced in Section 5.3. We begin by introducing a version of contextuality that does not depend on a quantum state. Definition 6.5. A simplicial quantum measurement P : X → Q H Y is called contextual if ρ * (P ) (defined by (40)) is strongly contextual for every quantum state ρ.
To capture state-independent contextuality proofs studied in [14] we consider projective measurements on the outcome space Y = N Z d and specialize the setting of Section 5.3 to the case where the subspace is a circle. More precisely, the setting is as follows: • X is a space of measurements with a subspace Z = S 1 , • Π : X → P H N Z d is a simplicial projective measurement such that the generating simplex σ = σ 01 of the circle is mapped to the projective measurement on Z d defined by δ 1 H (a) = 1 for a = 1 and 0 otherwise (i.e. the measurement defined in (42) for the 1-simplex θ = 1)).
Let ρ be a quantum state. Consider the simplicial distribution p ρ : X → D R ≥0 N Z d obtained using the Born rule p ρ = ρ * (Π). The distribution p ρ | S 1 obtained by restriction to the circle is a deterministic distribution: the generating simplex σ to the delta distribution δ 1 ∈ D R ≥0 Z d concentrated at 1 ∈ Z d . Moreover, by Example 5.4 we have under which the deterministic distribution p| S 1 is mapped to 1 ∈ Z d . The cohomology witness that constitutes the set cl S 1 (p ρ ) (defined in Eq. (39)) is given by Note that the cohomology class [β] is independent of the quantum state since it only depends on the restriction of p ρ to the circle. In practice a simplicial projective measurement Π satisfying Eq. (44) comes from a map A : Using the isomorphism in Proposition 6.3 we can obtain a simplicial projective measurement Π = sd • A that satisfies Eq. (44). The typical example is the Mermin square scenario interpreted in the simplicial framework. Example 6.7. Let us consider the state-independent Mermin square. The space of measurements is the torus T depicted in Fig. (1a) and the space of outcomes is N Z 2 . As in the case of statedependent Mermin square discussed in Example 6.4 we will interpret the assignment of observables to the edges as a map of spaces where X is a space of measurements obtained by modifying the torus T . In the torus the 2-context for which the cochain β = 1 does not define a simplex of N (Z 2 , U 4 ) since (X ⊗X)(Z ⊗Z) = −Y ⊗Y . This context can be decomposed into two simplices as in Fig. (12). Replacing this single simplex in the torus with the two simplices produces a punctured torus with a triangulation as in the middle figure in Fig. (13). Note that this procedure produces an extra loop σ, which generates a subspace Z = S 1 , such that A σ = −1. Let us write i : S 1 → X for the inclusion of the loop. We can go back to the torus by contacting this loop to a point, that is by considering the quotient map q : X →X = X/S 1 . This time though the triangulation of the torus will be different than the original one at the modified 2-simplex. By a computation similar to Example 6.4 we see that the cochain β = 1 on the torus, and hence the associated cohomology class [β] is nonzero. This is our cohomological witness for the contextuality of the simplicial projective measurement Π = sd • A. Other examples studied in [14] can also be put into this framework by a similar modification. There is an important consequence of this example which relates to state-independent contextuality in terms of the failure of eigenvalue assignments. Proof. Let Π : X → P C 4 N Z 2 denote the simplicial projective measurement considered in Example 6.7. We can elevate this to a projective measurement defined over an Hilbert space H ∼ = C d of dimension d ≥ 4 by using the linear isometry C 4 → C d onto the subspace spanned by the first 4 canonical basis vectors. Using this observation we can construct the right-hand square of the following commutative diagram In Example 6.7 we showed that [β] = 0. By Lemma 5.5 this implies that i : S 1 → X does not split. Therefore N Z 2 → P H N Z 2 does not split since such a splitting would provide a splitting for i.
We will see in Section 7.2 that this result can be improved to include Hilbert spaces of dimension 3 and the cases of all d ≥ 2 as a consequence of the Kochen-Specker theorem (Theorem 7.2). To make connection to eigenvalue assignments consider the composition Under this map an n-simplex (a 1 , · · · , a n ) of the nerve space is sent to the tuple (ω a 1 1, · · · , ω an 1). Splitting of this map would, in particular, yield an assignment of values ν(A) ∈ Z d in such a way that 1. ν(ω a 1) = a for all a ∈ Z d , 2. ν(A 1 ) + ν(A 2 ) = ν(A 1 A 2 ) for all pairwise commuting unitaries A 1 and A 2 (with the d-torsion condition: A d i = 1). This is precisely an eigenvalue assignment that respects product relations among commuting dtorsion unitaries. Corollary 6.8 has the interpretation that for d = 2 and dim(H) ≥ 4 such an eigenvalue assignment is impossible.

Foundational theorems in the simplicial setting
In this section we describe two foundational results in quantum theory, Gleason's theorem and Kochen-Specker theorem, in our simplicial framework.

Gleason's theorem
In this section we will formulate Gleason's theorem in our simplicial framework; see [48,Prop 1.7.1] for a related result in the sheaf-theoretic framework. For this we will consider the simplicial scenario (X, Y ) where the space of measurements is X = P H S 1 and the space of outcomes is Y = S 1 . We begin our discussion with a description of P H S 1 . The situation is quite similar to simplicial distributions on the circle (see §3.5) except that instead of probabilities we will use projectors. We can represent an n-simplex Π ∈ (P H S 1 ) n by an n-tuple (Π 1 , Π 2 , · · · , Π n ) where Π k = Π(σ 0 k−1 1 n−k ). In this representation the face maps are given by and the degeneracy maps for 0 ≤ j ≤ n are given by s j (Π 1 , Π 2 , · · · , Π n ) = (Π 1 , Π 2 , · · · , Π j , 0, Π j+1 , · · · , Π n ).
In our formalism Gleason's theorem will be used to obtain a precise description of simplicial distributions f : P H S 1 → D R ≥0 S 1 . We are interested in the maps f which make the following diagram commute As we have seen in Diag. (41) quantum states (density operators) produce such maps via the Born rule. We will write S S 1 (P H S 1 , S 1 ) for the set of simplicial distributions making Diag. (46) commute. Proof. If we represent the n-simplices of P H S 1 by tuples of projectors then the Born rule is simply the assignment (Π 1 , · · · , Π n ) → (Tr(ρΠ 1 ), · · · , Tr(ρΠ n )).
• The compatibility of f with the face maps d 0 , d 1 and d 2 implies that f 1 assigns p 1 + p 2 to the projector Π 1 + Π 2 .
The up shot is that f 1 : Proj(H) → R ≥0 is a finitely-additive measure. The commutativity of Diag. (46) implies: • For n = 1 the generating simplex σ 01 of the circle is mapped to the projector 1 under δ H,S 1 , and then mapped to f 1 (1) under f , which (by the commutativity of the diagram) is the same as the image of the diagonal map δ S 1 , which is 1 ∈ Z d .
This condition implies that f 1 is also normalized. Hence by the Gleason's theorem f 1 is induced by a quantum state ρ, that is f 1 (Π) = Tr(ρΠ). To finish the proof we observe that f is uniquely determined by f 1 : Suppose f (Π 1 , · · · , Π n ) = (p 1 , · · · , p n ). Using ϕ i defined in Eq. (20) we compute

Kochen-Specker theorem
As is well-known [49, Page 189] Gleason's theorem can be used to deduce the Kochen-Specker theorem. The main idea is to consider the embedding defined as follows: • We set ϕ(0) = 0 and ϕ(1) = 1.
• For a nonzero v ∈ R 3 let Π v denote the projector onto the line spanned by v.
We set ϕ( • For a 2-dimensional subspace V ⊂ R 3 let Π V denote the associated projector. Let v denote a nonzero vector orthogonal to V . We set ϕ( Proof. It suffices to prove the theorem for C 3 since we can embed it as a subspace in H when dim(H) ≥ 3 and deduce the result for the larger Hilbert space. For the rest we take H = C 3 . A similar argument as in Theorem 7.1 shows that maps g : P H S 1 → S 1 that make the following diagram commute coincide with finitely-additive normalized measures µ : Proj(H) → N. Such a measure satisfies the property that for any set {Π 1 , · · · , Π n } of orthogonal projectors summing to 1 the function µ assigns 1 exactly to one of the projectors and assigns 0 to the rest in the set. Consider the embedding ϕ : Proj(R 3 ) → Proj(H) given in (47) and define π : S 2 → Proj(R 3 ) by sending a point v to the projector Π v . Now observe that the following function has image given by the set {0, 1} since for any triple of pairwise orthogonal lines the map µ assigns 1 to exactly of one them and 0 to the rest. Let τ : N → R ≥0 denote the inclusion of the semirings. Gleason's theorem says that the composite Proj(H) µ − → N τ − → R ≥0 , which is a finitely additive R ≥0measure, is given by Π → Tr(ρΠ) for some ρ ∈ Den(H). But this implies thatμ : S 2 → N is given by v → Tr(ρJ v ). Thereforeμ is a continuous map and since S 2 is connected its image cannot be {0, 1}, a disconnected set. Hence there does not exist any finitely-additive N-measures, which translates into the statement that there does not exist any map g of spaces making Diag. (48) commute.
Kochen-Specker theorem can be used to improve Corollary 6.8.
Proof. This follows from the commutative diagram of spaces A splitting for δ N Z d would give a splitting for δ S 1 , which is impossible by Theorem 7.2.

Conclusion
Here we have presented a new framework based on the theory of simplicial sets which extends both the topological approach of [14] and the sheaf-theoretic approach of [11]. Our formalism generalizes the standard notion of nonsignaling distributions to that of simplicial distributions which are based on scenarios consisting of spaces of measurements and outcomes. Contextuality is introduced at this level of generality and fundamental theorems such as Fine's theorem, Gleason's theorem, and the Kochen-Specker theorem are presented in this new formalism. The flexibility afforded by the simplicial framework allows us, moreover, to introduce novel characterizations of contextuality both topological and cohomological. A chief contribution of our approach is to promote the set of measurements and outcomes to a space of measurements, given by a simplicial set X, and a space of outcomes, given by a simplicial set Y . In this picture contexts correspond to the n-simplices of X and outcomes correspond to the n-simplices of Y , both of which have an intrinsic dimensionality. The basic objects of our formalism, called simplicial distributions, are then represented by maps of spaces p : X → D R Y . Our constructions are natural with respect to the change of measurement space or the change of outcome space, as well as the underlying semiring R in which distributions take values. In fact, those familiar with category theory may notice that with our definitions everything takes place in the Kleisli category [50] of the category of simplicial sets with respect to D R (regarded as a monad on this category). Simplicial distributions appear as morphisms in this category. See [51] for the role of convexity in this category-theoretic perspective. It would be interesting to compare this category and its natural variants to other categories associated to nonsignaling distributions, e.g. [52,53]. Many more aspects of these objects, in particular the role of simplicial homotopy, remain to be explored, which we leave for future work to be addressed elsewhere.
Another appealing aspect of the current formalism is how topology can aid in the study of contextuality. This was demonstrated explicitly in our topological proof of Fine's theorem for characterizing noncontextuality in the CHSH scenario. A similar analysis can be carried over to other scenarios; e.g., Bell scenarios [8], KS-scenarios [7], n-cycle scenarios [54], etc. In fact, the framework of simplicial sets allows for a much richer landscape of measurement scenarios than those typically encountered, which may be of interest for physics and mathematics alike. We also highlight that noncontextuality can be characterized here in an economical fashion through the constructions of gluing and extension. Such notions provide a potentially powerful analytic tool for applications in quantum computation, such as extending [15] to temporally ordered MBQC. identities: Intuitively a simplicial set is a combinatorial description of a space obtained by gluing n-simplices. The simplicial relations encode the faces and the degeneracies of an n-simplex and they can be derived by specializing to X = ∆ n . We can do this by applying d i and s j to the generating simplex σ 01···n of ∆ n . Recall that d i deletes the i-th entry and s j copies the j-th entry in the string 01 · · · n. For example, when i < j first copying the j-th index and then deleting the i-th index is the same as first deleting the i-th index and then copying the (j − 1)-th: Similarly other identities in Eq. (49) can be verified.
Simplicial identities in low dimensions are the most relevant to us. Although, face maps are already described in the main text we include them for completeness: • For an edge e ∈ X 1 , the target vertex is d 0 e and the source vertex is d 1 e.
Degeneracy maps in dimensions ≤ 2 are depicted in Fig. (14) and they are given as follows: • For a vertex v ∈ X 0 , the edge e = s 0 v has the target and the source vertices given by v itself.
• For an edge e ∈ X 1 , the triangles s 0 e and s 1 e are described as in Fig. (14).  • C is a collection 8 of contexts covering M , 8 The collection C is assumed to be an antichain in the sense that any two contexts with C ⊂ C implies that C = C.
• Z d represents the set of outcomes.
Such scenarios are called measurement scenarios in the sheaf-theoretic formulation of contextuality [11]. A nonsignaling distribution on the scenario (M, C, Z d ) is a collection of distributions p C ∈ D R (Z C d ) satisfying the nonsignaling conditions Restriction to the intersection means marginalization where r runs over functions C → Z d such that the restriction r| C∩C to the intersection coincides with s. We will write N(C, Z d ) for the set of nonsignaling distributions. This space is a (convex) polytope, and is usually referred to as the nonsignaling polytope. Sending a distribution d ∈ D R (Z M d ) to the nonsignaling distribution (d| C ) C∈C gives a function Any discrete scenario can be realized as a simplicial scenario so that nonsignaling distributions are in one-to-one correspondence with distributions on the simplicial scenario. For this, given a discrete scenario (M, C, Z d ) we need to specify the space of measurements and the space of outcomes.
The space X C of measurements, after we fix an ordering on M , is the following simplicial set: • The set (X C ) n of n-simplices is given by tuples (m 0 , m 1 , · · · , m n ) of measurements in M , where m 0 ≤ m 1 ≤ · · · ≤ m n , such that each m i ∈ C for some context C ∈ C.
As noted in [55] (M, C) can be regarded as a simplicial complex. The simplicial set X C is the usual way of realizing an ordered simplicial complex as a simplicial set. The space of outcomes, denoted by ∆ Z d , is the following simplicial set: • The set (∆ Z d ) n of n-simplices consists of (n + 1)-tuples (a 0 , a 1 , · · · , a n ) of outcomes a i ∈ Z d .
It is straight-forward to verify that the simplicial identities in Eq. (49) are satisfied. Next we consider the space D R ∆ Z d of distributions. An n-simplex p is a distribution on (∆ Z d ) n = Z n+1 d . The i-th face map acts by d i p(a 0 , · · · , a n−1 ) = a∈Z d p(a 0 , · · · , a i−1 , a, a i , · · · a n−1 ) and the j-th degeneracy map acts by s j p(a 0 , · · · , a n+1 ) = p(a 0 , · · · , a j−1 , a j , a j+2 , · · · a n+1 ) a j = a j+1 0 otherwise.

Theorem B.2.
There is a commutative diagram where the vertical maps are isomorphisms. In particular, a nonsignaling distribution p is contextual in the sense of Definition B.1 if and only if it is contextual in the sense of Definition 3.10 when regarded as a distribution on (X C , ∆ Z d ).
Proof. Let U = {u 0 , u 1 , · · · , u k }, where u 0 ≤ u 1 ≤ · · · ≤ u k , be a subset of a context C ∈ C. Let ∆ U ∼ = ∆ k denote the subspace generated by the simplex σ U = (u 0 , u 1 , · · · , u k ). The inclusion map i : ∆ U → ∆ C induces a commutative diagram The top horizontal map sends an outcome map r to the function r σ C ∈ Z C d . The bottom horizontal map is also similarly defined. The right vertical map is the restriction of a function C → Z d to the subset U . Commutativity of the diagram can be expressed as Observe that X C is the union of the subspaces ∆ C as C runs over the contexts in C. This follows from the observation that an n-context (m 0 , m 1 , · · · , m n ), where m i ∈ C, is also an n-context of ∆ C . By Proposition 4.4 deterministic distributions can be identified with tuples (d ∆ C ) C∈C of distributions compatible under restrictions to the intersections. By Diag. (50) these are precisely the tuples (r σ C ∈ Z C d ) C∈C compatible under restriction to intersections. These are in bijective correspondence with functions M → Z d . Therefore C(X C , ∆ Z d ) ∼ = D R (Z M d ). Again by Proposition 4.4 simplicial distributions are given by tuples (p ∆ C ) C∈C compatible under restriction to intersections. Applying D R to Diag. (50) allows us to identify such tuples with (p C ∈ D R (Z C d )) C∈C compatible under restriction to intersections. They are precisely the elements of the nonsignaling polytope, that is we have S(X C , ∆ Z d ) ∼ = N(C, Z d ). Under the identifications Θ-map becomes the Θ -map.
Example B.3. Consider the CHSH scenario with measurement set M = {x 0 ≤ x 1 ≤ y 0 ≤ y 1 } and outcome set Z 2 . The set C of contexts of the scenario is given in Eq. (6). The corresponding measurement space X C is 1-dimensional, in fact the boundary of the square scenario Q of Section 2.1, as depicted in Fig. (15). Under the identifications (vertical bijections) of Theorem B.2 the support of a distribution p ∈ S(X C , ∆ Z d ) as defined in Eq. (34) coincides with the notion of support for discrete scenarios [11].
Corollary B.4. A nonsignaling distribution is strongly contextual in the sense of [11] if and only if it is strongly contextual in the sense of Definition 5.2 when regarded as a simplicial distribution on (X C , ∆ Z d ).