{'fraction_non_alphanumeric': 0.06182828405726568, 'fraction_numerical': 0.017540657825363994, 'mean_word_length': 3.6037154592979834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 37, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Simplicial distributions, convex categories and contextuality

The data of a physical experiment can be represented as a presheaf of probability distributions. A striking feature of quantum theory is that those probability distributions obtained in quantum mechanical experiments do not always admit a joint probability distribution, a celebrated observation due to Bell. Such distributions are called contextual. Simplicial distributions are combinatorial models that extend presheaves of probability distributions by elevating sets of measurements and outcomes to spaces. Contextuality can be defined in this generalized setting. This paper introduces the notion of convex categories to study simplicial distributions from a categorical perspective. Simplicial distributions can be given the structure of a convex monoid, a convex category with a single object, when the outcome space has the structure of a group. We describe contextuality as a monoid-theoretic notion by introducing a weak version of invertibility for monoids. Our main result is that a simplicial distribution is noncontextual if and only if it is weakly invertible. Similarly, strong contextuality and contextual fraction can be characterized in terms of invertibility in monoids. Finally, we show that simplicial homotopy can be used to detect extremal simplicial distributions refining the earlier methods based on Cech cohomology and the cohomology of groups.


Introduction
Physical experiments are probabilistic: When a measurement is performed, the corresponding outcome occurs with a certain probability. Quantum theory comes with an additional constraint prohibiting certain measurements from being performed jointly. Therefore in a quantum mechanical experiment, the data that describes the outcome probabilities consists of a family of probability distributions indexed over subsets of measurements that are allowed to be performed jointly. More precisely, this family is a presheaf of probability distributions since the restriction of probabilities to a smaller subset of measurements, also called marginalization, is compatible. A striking phenomenon in physics, known as Bell's nonlocality and its generalization called contextuality, can be expressed as the nonexistence of a joint probability distribution over the set of all measurements that marginalizes to the distributions of the restricted set of measurements obtained from the experiment. Such a joint distribution always exists in classical theories. In particular, a joint distribution provides a model where all measurement outcomes are assigned before the measurement takes place, and the measurement probabilities are obtained by considering all such global assignments with a certain probability. It is a celebrated result of Bell [Bel64] that in quantum theory, the joint distribution does not always exist, i.e., there are contextual families of distributions. Another celebrated result due to Kochen-Specker [KS67] proves a similar result by showing the impossibility of the global assignments of outcomes in quantum theory. The latter demonstrates a stronger version of contextuality.
There are various approaches to formalizing contextuality. The presheaf approach is introduced in [AB11]. The ingredients in this approach are (1) a simplicial complex Σ whose vertices represent the set of all measurements, and its simplices are those that can be jointly performed, and (2) a finite set of outcomes for the measurements. For the outcome set, we don't lose any generality by considering the ring Z d of integers modulo d. A distribution on (Σ, Z d ) is a presheaf of distributions, i.e., a family (p σ ) σ∈Σ together with a compatibility condition. Each p σ is a distribution on the set of all functions σ → Z d . More formally, let D R denote the distribution monad on the category of sets [Jac10], where R is a commutative semiring. Then p σ belongs to D R (Z σ d ) where R = R ≥0 , the semiring of nonnegative reals. The presheaf approach uses tools fromČech cohomology to study contextuality. Furthermore, this systematic study introduces degrees of contextuality, such as strong contextuality and the more refined measure of contextuality known as the contextual fraction. Another approach to contextuality is the topological approach of [ORBR17] based on techniques from the cohomology of groups. This approach introduces cohomology classes that can detect strong contextuality but fail to capture weaker versions, e.g., the famous Clauser-Horne-Shimony-Holt (CHSH) scenario [CHSH69]. In [OKI22] both approaches are unified under the theory of simplicial distributions. This theory goes beyond the usual assumption that measurements and outcomes are represented by finite sets. In this framework, one can study distributions on spaces of measurements and outcomes, where a space is represented by a simplicial set. Simplicial sets are combinatorial objects more expressive than simplicial complexes. They are fundamental objects in modern homotopy theory [GJ09]. A simplicial distribution is defined on a pair (X, Y ) of simplicial sets, where X represents the measurements and Y the outcomes. The distribution monad can be elevated to a monad on the category of simplicial sets. Given Y , one can define another simplicial set D R (Y ) whose simplices are distributions on the set of simplices of Y . A simplicial distribution is a morphism of simplicial sets p : X → D R (Y ).
In this paper, we study simplicial distributions from a categorical perspective. For a semiring R the algebras of the distribution monad D R : Set → Set are called R-convex sets. This notion generalizes the usual notion of convexity for R = R ≥0 . Let Conv R denote the category of R-convex sets. Every monad has an associated Kleisli category. In the case of D R , the morphisms of the Kleisli category sSet D R are the simplicial distributions, i.e., for simplicial sets X, Y the set Set D R (X, Y ) of morphisms is given by simplicial set morphisms X → D R (Y ). Let sConv R denote the category of simplicial R-convex sets. The main examples of such simplicial objects are D R (Y ) for some simplicial set Y .
Proposition 1.1. The functor sending a pair (X, Y ) of simplicial sets to the set sSet(X, Y ) of simplicial set morphisms restricts to a functor The main application of this result is to the set of simplicial distributions. By this result the set sSet(X, D R (Y )) is an R-convex set. Contextuality for simplicial distributions is defined using a comparison map Θ X,Y : D R (sSet(X, Y )) → sSet(X, D R (Y ) ).
Under this map, the delta distribution at a simplicial set morphism ϕ : X → Y is sent to the simplicial distribution given by the composition , called a deterministic distribution. Since the target is R-convex, Θ X,Y is the unique extension to the free D R -algebra, the domain of the map. A simplicial distribution is called contextual if it lies in the image of Θ X,Y ; otherwise called noncontextual. We show in Section 2.4 how to realize a presheaf of distributions as a simplicial distribution. In Theorem 2.18 we show that the notion of contextuality for simplicial distributions specializes to the notion for presheaves of distributions originally introduced in [AB11].
A category-theoretic point of view suggests lifting our analysis from the level of morphism sets to the level of categories. For this, we introduce the notion of convex categories. The first step is to lift D R to a monad on the category Cat of (locally small) categories (Corollary 3.7). Then we define an R-convex category as a D R -algebra in Cat. Every category enriched over the category of R-convex sets is an R-convex category. However, the converse does not always hold. The prominent example of a convex category is the Kleisli category Set D R , and its simplicial version sSet D R , which are not enriched over Conv R . We can think of Θ X,Y assembled into a morphism in ConvCat R from the free R-convex category to the Kleisli category, both of which obtained from the category of simplicial sets: For outcome spaces which also have a group structure the convex set of simplicial distributions can be given a monoid structure. Our categorical framework combined with this monoid structure has interesting applications connecting contextuality to a weak notion of invertibility in convex monoids. As we show in Section 2.4 any presheaf of distribution can be realized as a simplicial distribution p : where N Z d is the nerve of the additive group Z d . The simplicial set N Z d is, in fact, a simplicial group. The group structure on the nerve induces a monoid structure on the convex set sSet(X, D R (N Z d )) of simplicial distributions. We remark that this monoid structure is new and has not been investigated in the study of contextuality. More precisely, sSet(X, D R (N Z d )) is a convex monoid, i.e., a convex category with a single object. For a convex monoid M , with the map π M : D R (M ) → M giving the D R -algebra structure, an element m ∈ M is called weakly invertible if it lies in the image of the composite D R (M * ) is the inclusion of the units. Our main result connects weak invertibility to noncontextuality.
Theorem 1.2. Let R be a zero-sum-free, integral semiring. Given a simplicial set X and a simplicial group Y , a distribution p ∈ sSet(X, D R (Y )) is noncontextual if and only if p is weakly invertible.
Moreover, we introduce the notion of strong invertibility, a monoid-theoretic description of strong contextuality. We also introduce a degree of invertibility called invertible fraction which generalizes the notion of noncontextual fraction introduced in [AB11, ABM17]. Simplicial distributions are formulated using the theory of simplicial sets. It is a natural question to understand the role of homotopy in the context of simplicial distributions. Embedding presheaves of distributions to our simplicial framework makes homotopical tools available for the study of contextuality. In Corollary 5.23 we show that simplicial homotopy can be used to detect extremal distributions, a question of fundamental importance in the study of polytopes of distributions; see [Pit89, BLM + 05, JM05, ABK + 16].
Our paper is organized as follows: In Section 2.1 we recall basics from convex sets and in Section 2.2 we introduce simplicial distributions. Proposition 1.1 (Proposition 2.15) is proved in Section 2.3. In Section 2.4, we show how to describe a presheaf of distributions as a simplicial distribution. In this section, we also provide examples of simplicial distributions, such as the CHSH scenario (Example 2.22). Convex categories are introduced in Section 3.1. In Section 3.2 we show that the Kleisli category sSet D R is a convex category. Weak invertibility, strong invertibility and invertible fraction are introduced in Sections 4.1, 4.2 and 4.3; respectively. Our main result Theorem 1.2 (Theorem 5.8) is proved in Section 5.1. The relationship between strong invertibility and strong contextuality is studied in Section 5.2. Extremal simplicial distributions and the role of simplicial homotopy are discussed in Section 5.3.

Simplicial distributions
Throughout the paper R will denote a commutative semiring. In this section, we introduce simplicial distributions [OKI22] defined over the semiring R. These objects describe distributions on a simplicial set parametrized by another simplicial set. Our main result is that the set of simplicial distributions constitute an R-convex set, in the sense that it is an algebra over the distribution monad. In practice, simplicial distributions come from presheaves of distributions, introduced in [AB11]. We describe how to embed the theory of presheaves of distributions into the theory of simplicial distributions.

Algebras over a monad
We recall some basic facts about algebras over a monad from [Lan78, section VI]. A monad on a category C is a functor T : C → C together with natural transformations δ : Id C → T and µ : T 2 → T satisfying µ • T µ = µ • µT and µ • δT = µ • T δ = Id T . A T -algebra consists of an object X of C together with a morphism π : T (X) → X of C such that the following diagrams commute The category of T -algebras will be denoted by C T . The object T (X) together with the structure morphism µ X is called a free T -algebra. There is an adjunction T : C C T : U where T sends an object to the associated free T -algebra and U is the forgetful functor. The Kleisli category of T , denoted by C T , is the category whose objects are the same as the objects of C and morphisms X → Y are given by C(X, T (Y )). In fact, C T is equivalent to the full subcategory of free Conversely, under this isomorphism, a morphism g : X → Y is sent to π Y • T (g).

Convex sets
Main examples of interest are the semiring of nonnegative reals R ≥0 and the Boolean algebra B = {0, 1}. The distribution monad D R : Set → Set is defined as follows: • For a set X the set D R (X) of R-distributions on X consists of functions p : X → R of finite support, i.e., |{x ∈ X : p(x) = 0}| < ∞, such that x∈X p(x) = 1.
• Given a function f : The structure maps of the monad are given as follows: Definition 2.2 ( [Jac09]). A D R -algebra in the category of sets is called an R-convex set. A morphism of R-convex sets is given by a morphism of D R -algebras. We will denote the category of R-convex sets by Conv R .
In the case of R = R ≥0 the notion of R ≥0 -convexity coincides with the usual notion of convexity, as we recall from [Jac10] in Proposition 2.3 below.
Given a real convex set X it is sometimes more convenient to use the notation αx + (1 − α)y instead of α, x, y . A morphism of convex sets is an function f : X → Y satisfying for all α ∈ [0, 1] and x, x ∈ X. This yields the category of real convex sets denoted by Conv.
The category Conv is isomorphic to the category Conv R ≥0 . Under this isomorphism a real convex set X is sent to the R ≥0 -convex set (X, π X ) where π X : D R≥0 (X) → X, π X (P ) = x∈X P (x)x.

Simplicial convex sets
We begin by introducing simplicial sets. Our main reference is is [GJ09]. The simplex category ∆ consists of A simplicial set is a functor X : ∆ op → Set. The set of n-simplices is usually denoted by X n = X ([n]). An object [m] in the simplex category gives a simplicial set ∆[m] whose set of n-simplices is given by ∆([n], [m]). It is a well-known fact that every simplicial set can be obtained by "gluing", or more formally as a colimit of, simplicial sets of this form. A morphism of simplicial sets is a natural transformation f : X → Y between the functors. We will write sSet for the category of simplicial sets. This definition can be extended to an arbitrary category C and the resulting category is denoted by sC.
Proposition 2.4. A monad (T, δ, µ) on C extends to a monad T : sC → sC by applying T degree-wise: • T (X) is the simplicial object with (T X) n = T (X n ) and the simplicial structure maps are given by d • T (f ) : T (X) → T (Y ) in degree n is given by T (f ) n = T (f n ).
Our main interest is the extension of the distribution monad to the category of simplicial sets, i.e., the functor D R : sSet → sSet. The associated category of D R -algebras will be denoted by sConv R .

Simplicial distributions
Simplicial distributions are first introduced in [OKI22]. In this section we recall the basic definitions. Let sSet D R denote the Kleisli category of the distributions monad (acting on the category of simplicial sets). Its objects are simplicial sets and morphisms between two simplicial sets X and Y are given by simplicial set morphisms of the form p : X → D R (Y ).
Definition 2.5. Morphisms sSet D R (X, Y ) of the Kleisli category are called simplicial distributions on (X, Y ). When the underlying semiring is R ≥0 we will call these morphisms simplicial probability distributions. For notational convenience we write p σ , where σ ∈ X n , for the distribution There is a comparison map Θ X,Y : D R (sSet(X, Y )) → sSet(X, D R (Y ) ) (2) defined as follows: Let x : ∆[n] → X be an n-simplex of X. We can construct a commutative diagram where the vertical maps are induced by x and the bottom horizontal map is given by the identity The top horizontal map exists since X is a colimit of its simplices. The Θ-map gives rise to an important definition.
Definition 2.6. A simplicial distribution p : X → D R Y is called contextual if p does not lie in the image of Θ X,Y . Otherwise, it is called noncontextual. When we want to refer to the semiring R we say R-contextual, or R-noncontextual.
The map Θ X,Y can be given a more explicit description.
Proposition 2.7. For d ∈ D R (sSet(X, Y )) and x ∈ X n we have That is, for y ∈ Y n we have Θ(d) n (x) : y → ϕn(x)=y d(ϕ).
In Corollary 2.16 we will show that Θ is the unique map in Conv R that makes the following diagram commute Alternatively, noncontextual distributions can be described as convex mixtures of distributions in the image of (δ Y ) * . ). In this case the resulting distribution is denoted by Similarly, sSet(∆[n], Y ) can be identified with Y n . Then the Θ-map is the identity map and every simplicial distribution is noncontextual.
Next, we introduce a stronger version of contextuality.
Definition 2.10. The support of a simplicial distribution p : We say p is strongly contextual if supp(p) is empty. Proposition 2.12. Let R be a zero-sum-free semiring. If a simplicial distribution p is strongly contextual then it is contextual.
Proof. Suppose that p is noncontextual, that is there exists d ∈ D R (sSet(X, Y )) such that Then ψ : X → Y with d(ψ) = 0 will belong to the support of p since For simplicial probability distributions one can introduce a degree of contextuality generalizing the notion introduced in [AB11, Subsection 6.1].
Definition 2.13. The noncontextual fraction of a simplicial probability distribution p ∈ sSet(X, D(Y )), which is denoted by NCF(p), is defined to be the supremum of α ∈ [0, 1] such that where q and s run over simplicial probability distributions with q noncontextual. The contextual fraction of p is defined to be CF(p) = 1 − NCF(p).

Simplicial distributions as a convex set
In this section we will show that sSet(X, Y ), where Y is an object of sConv R , is an R-convex set (Proposition 2.15) and prove a uniqueness result about the comparison map Θ X,Y (Proposition 2.16). For simplicity of notation we will write U = sSet(X, Y ), especially when this set appears in the structure maps for convexity.
Lemma 2.14. Let Y be an object of sConv R . For x ∈ X n , consider the map Then P ∈ D R (D R (Y n )) satisfies the following equations: Proof. To prove Equation (4) we first verify that For q ∈ D R (U ) we have Using this we obtain Now using Equation (6) and applying Equation (7) which proves Equation (4).
Next we prove Equation (5): For y ∈ Y n we have Proof. Let X be a simplicial set and Y be an object of sConv R . Let π U be the map that defined in Lemma 2.14, we want to prove that with this structure map U = sSet(X, Y ) is an object of Conv R . First we verify that π U • δ U = Id U : ). Therefore we need to prove that Substituting Equations (4) and (5) from Lemma 2.14 into Equation (8) and using π Yn • D R (π Yn ) = π Yn • µ Yn gives the desired result. It remains to show that for f : Y 1 → Y 2 and g : X 1 → X 2 the induced maps are morphisms in Conv R . This follows from the naturality of Θ X,Y in both X and Y .
For a simplicial set Y observe that D R (Y ) is an object of sConv R , hence Proposition 2.15 applies. We employ sSet(X, D R (Y )) with an R-convex set structure by defining More explicitly, for Q ∈ D R (sSet(X, D R (Y ) )) and x ∈ X n this gives Conv R , with respect to the adjunction Set Conv R , and it is given by the composite In particular, it is the unique map in Conv R that makes Diagram (3) commutes.
Proof. By the naturality of Θ X,− we have the following commutative diagram: that is the following equation holds We compose with (µ Y ) * on both sides of Equation (13) to obtain Now the last composite on the left-hand side can be rewritten as and similarly for the right-hand side we have which proves Equation (11). By Remark 2.1 we see that Θ X,Y is the transpose of (δ Y ) * in Conv R .

Simplicial distributions from presheaves of distributions
Simplicial presheaf of distributions can be constructed from the following data: We will write Σ 0 to denote the set of vertices of the simplicial complex. We will think of Σ as a category C Σ whose objects are the simplices σ ∈ Σ and morphisms are inclusions σ → σ . An element p of the inverse limit of the composite functor For more details see [AB11].
For a set U let ∆ U denote the simplicial set whose n-simplices are given by the set U n+1 and the simplicial structure maps are given by For the next definition we will use the following notation: For p : X → D R Y and σ ∈ X n we write p σ for the distribution on D R Y n .
Construction 2.17 (Realization). Given (Σ, Z d ) we consider a pair of simplicial sets (X Σ , Y ) where X Σ is the subsimplicial set of ∆ Σ 0 whose n-simplices are given by We define a function Real : is injective. Choosing a well-ordering for Σ 0 the maps η σ can be assembled into the η map in the following commutative diagram This gives the desired result.
Remark 2.19. The condition of being strongly contextual also simplifies in the case of Real(p). The support of the distribution (Definition 2.10) becomes supp(Real(p)) = {s ∈ Z Σ 0 d : p σ (s| σ ) = 0, ∀σ ∈ Σ}. This is precisely the definition of the support of a distribution in D R (Σ, Z d ) [AB11].
Observe that the map η given in the proof of Theorem 2.18 is a morphism of R-convex sets. In particular for R = R ≥0 this implies that the notion of contextual fraction for simplicial distributions (Definition 2.13) coincides with the corresponding notion for distributions in D(Σ, Z d ) given in [AB11].
Remark 2.20. The realization Real defined in Construction 2.17 has an ordered version. That is, given an ordered simplicial complex Σ, one can define X ord Σ as the subsimplicial set of X Σ consisting of ordered tuples of vertices that constitute a simplex. Then the η map in the proof of Theorem 2.18 is an isomorphism In the examples below we will consider this ordered version since the corresponding pictures contain smaller number of simplices.
Example 2.21. Let Σ denote the simplicial complex with vertices x, y and a single maximal simplex {x, y}. An element of D(Σ, Z 2 ) is simply a distribution p ∈ D(Z 2 2 ). Let us write p ab = p(a, b) where a, b ∈ Z 2 . With this notation p can be conveniently represented as a box (table): Let us write p x = p| {x} and p y = p| {y} . Then the compatibility relations become which can be read off from the rows and the columns of the box. Let us describe the corresponding simplicial distribution. The ordered version X ord Σ is isomorphic to ∆[1]. Therefore p gives a simplicial distribution of the form ∆[1] → D(∆ Z 2 ), again denoted by p for simplicity. Let ι 1 denote the unique nondegenerate 1-simplex of ∆[1], i.e., the identity map [1] → [1]. Then the value of the distribution p ι 1 (see Definition 2.5 for notation) at the 1-simplex (a, b) of ∆ Z 2 is given by p ab . The two 0-simplices d 1 (ι 1 ) and d 0 (ι 1 ) correspond to x and y; respectively. The conditions in Equation (17) are expressed as the simplicial relation Example 2.22. A famous example, known as the CHSH scenario [CHSH69], consists of the simplicial complex on the vertex set Σ 0 = {x 0 , x 1 , y 0 , y 1 } determined by the maximal simplices The resulting (ordered) simplicial complex is the boundary of a square: ) together with the compatibility conditions imposed by the inverse limit. Writing p ab x i y j for the probability Again a convenient way to represent this data is to use a table of the form x 0 y 0 p 00 x 0 y 1 p 01 x 0 y 1 p 10 x 0 y 1 p 11 x 0 y 1 x 1 p 00 x 1 y 0 p 01 x 1 y 0 p 10 x 1 y 0 p 11 x 1 y 0 p 00 x 1 y 1 p 01 x 1 y 1 p 10 x 1 y 1 p 11 The compatibility conditions in Equation (18)  Next, we describe another way of realizing presheaves of distributions where the target space is distributions on the nerve space N Z d . For a monoid (M, ·) the nerve N (M ) is the simplicial set whose set of n-simplices is given by M n with the following simplicial structure: where e M is the identity element. We will need the following adjunction where (− * −) denotes the join of the simplicial sets and Dec 0 is the décalage functor [Ste12]. The simplicial set Dec 0 X is obtained from shifting the simplices of X down by one degree, i.e., (Dec 0 X) n = X n+1 , and forgetting the first face and degeneracy maps.
Proposition 2.23. The adjunction given in Equation (19) induces a commutative diagram of R-convex sets under the adjunction that given in Equation (19) is equal to the composition of the transpose of f under the same adjunction with Dec 0 (δ Y ). Observe also that the map Dec 0 (δ Y ) equal to the map δ Dec 0 Y , so we have the following diagram in sSet Using Proposition 2.16 we get the result.
There is an isomorphism of simplicial sets defined in degree n by sending (a 0 , a 1 , · · · , a n ) to the tuple (a 0 , a 1 − a 0 , · · · , a n − a n−1 ). Note that the isomorphism is preserved even after applying the D R functor since essentially décalage only shifts the dimension. Therefore there is a bijection and given by d 2 ι 2 , d 0 ι 2 and d 1 ι 2 ; respectively. Then p can be represented as follows: The distribution p z = d 1 p ι 2 is given by p 0 z = p 00 + p 11 , and p 0 x , p 0 y are as before; see Equation (17). We will write x ⊕ y for the z edge, the XOR of x and y. For more details on this interpretation see [OKI22].
Example 2.25. In Example 2.22 the simplicial complex Σ is the boundary of a square. The join ∆[0] * X Σ (or rather the ordered version ∆[0] * X ord Σ ) is the cone of this one-dimensional space, which is the square consisting of four triangles: This simplicial set is used in the topological proof of Fine's theorem [OKI22,Section 4.5]. See also [OCI22] for an alternative proof of Fine's theorem that uses a different simplicial realization.

Convex categories
In this paper by a category we mean a locally small category in the sense that the collection of morphisms between any two objects forms a set. Let Cat denote the category of (locally small) categories. In this section we introduce the notion of convex categories by upgrading the distributions functor D R to a monad on Cat.

Convex categories
Let X and Y be sets. We define a multiplication map m X,Y : by  sending (p, q) to the distribution p · q given by This is a well-defined distribution since and the support of p · q is a subset of the finite set {(x, y) : p(x) = 0, q(y) = 0}.
Let C be a category. For objects X, Y, Z of C we define a map * : to be the composite of m C(X,Y ),C(Y,Z) with D R (•), where • is the composition in C. So we have where the sum runs over morphisms g 1 : X → Y and g 2 : Y → Z such that g 2 • g 1 = f in C.
Lemma 3.2. Given X, Y, Z, objects in a category C, and given morphisms In particular, δ g * δ f = δ g•f .
Proof. Given h ∈ C(X, Z) we have Lemma 3.3. Let C be a category. Consider the data consisting of • the collection of objects of C, • for objects X, Y of C the set D R (C(X, Y )) of morphisms.
This data together with Equation (22) as the composition map specifies a category D R (C).
Proof. The identity morphism in D R (C)(X, X) is given by the delta distribution δ Id X . Given Similarly, we have p * δ Id X = p. For associativity we check that for s ∈ D R (C)(X, Y ), q ∈ D R (C)(Y, Z) and p ∈ D R (C)(Z, W ) we have A similar calculation shows that (p * (q * s))(f ) gives the same result.
Lemma 3.4. Given a functor F : C 1 → C 2 in Cat let us define the following maps: • D R (F ) : Obj(D R (C 1 )) → Obj(D R (C 2 )) defined as the map F between the objects of the categories.
• D R (F ) X,Y : D R (C 1 )(X, Y ) → D R (C 2 )(F X, F Y ) defined by applying D R functor to the map F X,Y between the morphism sets.
Then these maps specify a functor D R (F ) : Proof. Given X ∈ Obj(D R (C 1 )), we have Combining Lemma 3.3 and Lemma 3.4 we can upgrade D R to a functor on Cat.
Corollary 3.5. Sending C → D R (C) and F → D R (F ) gives a functor D R : Cat → Cat.
Proof. Follows from the the functoriality of D R : Set → Set.
Next we will show that D R is a monad. For this we introduce the structure morphisms.
Lemma 3.6. Given a category C and objects X, Y of C we define the following maps: • δ C : C → D R (C) to be the identity map on the objects and δ C : to be the identity on the objects and µ C : These maps specify the following natural transformations: Proof. First, we prove that δ C and µ C are functors. Given X ∈ Obj(C), we have δ C (Id X ) = δ Id X , which is the identity morphism in D R (C)(X, X). Similarly, µ C (δ δ Id X ) = δ Id X . Given f ∈ C(X, Y ), where the second equality follows from Lemma 3.2. For Q 1 ∈ D R (D R (C(X, Y ))), Q 2 ∈ D R (D R (C(Y, Z)) and f ∈ C(X, Z) we calculate The naturality of δ and µ follows from the naturality of the set-theoretic versions of δ and µ.
Combining Corollary 3.5 and Lemma 3.6 we obtain the main result of this subsection.
Corollary 3.7. The triple (D R , δ, µ) is a monad on Cat Definition 3.8. A D R -algebra in Cat will be called an R-convex category. We will write ConvCat R for the category of R-convex categories.
This notion of convex category is different than the one introduced in [Jac11, Definition 5.1]. For example, (R, ·) is an R ≥0 -convex category with one object, but not a convex category in the latter sense since coproducts do not exist in this category. Next, we provide an explicit criterion to check whether a category is R-convex.
Proposition 3.9. Let C be a category such that the set C(X, Y ) of morphisms is an R-convex set for all objects X, Y of C. We define the following maps: • Obj(D R (C)) → Obj(C) to be the identity map.
• D R (C)(X, Y ) → C(X, Y ) to be the structure map π C(X,Y ) .
These maps give a well defined functor π C : D R (C) → C if and only if (C, π C ) is an R-convex category.

Categories enriched over R-convex sets are examples of convex categories.
Proposition 3.10. Any category C enriched over Conv R is an R-convex category.
Proof. The set C(X, Y ) is R-convex for every object X, Y . We will prove that the maps in Proposition 3.9 give a well-defined functor π C : D R (C) → C. We have π C(X,X) (δ Id X ) = π C(X,X) (δ C(X,X) (Id X )) = Id X . Given X, Y, Z ∈ Obj(C), let r 1 : C(X, Y )×C(Y, Z) → C(X, Y ) and r 2 : C(X, Y )×C(Y, Z) → C(Y, Z) be the projection maps. Using the proof of [Rie17, Theorem 5.6.5], we obtain that By composing Equation (23) with m C(X,Y ),C(Y, Z) , defined in Equation (20), from the right and using Lemma 3.1 we obtain that (π C(X, Z) . This gives the following commutative diagram: By Proposition 3.9 we conclude that C is an R-convex category.
Remark 3.11. The notion of R-convex category is weaker than the notion of category enriched over Conv R . For example, the monoid (R, ·) as a category with one object is an R ≥0 -convex category, but the product is not a morphism in Conv. Therefore it is not enriched over convex sets. Similarly, the Kleisli category Set D R is not enriched over R-convex sets, but it is an R-convex category. In Proposition 3.13 we will show that its simplicial version sSet D R is also an R-convex category, which is again not enriched over R-convex sets.

Real convex categories
The isomorphism between the categories of R ≥0 -convex sets and real convex sets (Proposition 2.3) extends to the case of R ≥0 -convex categories. We have the following equivalent characterizations of R ≥0 -convex categories.
Proposition 3.12. Let C be a category such that the set C(X, Y ) of morphisms is a real convex set for all objects X, Y of C. Let π C : D(C) → C be defined as in Proposition 3.9 where π C(X,Y ) is the corresponding structure map of C(X, Y ) when regarded as an R ≥0 -convex set (see Proposition 2.3). Then the following statements are equivalent.

For objects
3. For objects X, Y, Z of C, morphisms f 1 , f 2 ∈ C(X, Y ), g 1 , g 2 ∈ C(Y, Z), and numbers α, β ∈ [0, 1] we have the following equality: Proof. We begin by showing that (1) implies (2). Let X, Y, Z ∈ Obj(C), Using Lemma 3.2 and the functoriality of π C we obtain i,j Conversely, assume that (2) holds. By Proposition 3.9 it is enough to prove that π C is a functor.
Finally, note that (3) is a special case of (2) and one can get (2) from (3) by induction.
We will write ConvCat for the category ConvCat R ≥0 and refer to the objects of this category as real convex categories. Note that Proposition 3.12 implies that the category of R-vector spaces with the canonical convex structure on the R-vector space of linear maps is a real convex category.

Kleisli category as a convex category
Recall that the Kleisli category C T of a monad T : C → C has the same objects as C and for objects X, Y its morphisms are given by C(X, T Y ). For an object X the identity morphism in C T (X, X) is given by δ X : X → T X. The composition of two morphisms f : X → T Y and g : Y → T Z is defined by We are interested in the Kleisli category of the distribution monad D R : sSet → sSet. In this case the composition can be explicitly written as where p ∈ sSet(X, D R (Y )), q ∈ sSet(Y, D R (Z)) and x ∈ X n .
Proposition 3.13. The Kleisli category sSet D R is an R-convex category.
Proof. The map π : D R (sSet D R ) → sSet D R which employs sSet D R with the structure of an Rconvex category is defined to be identity on the collection of objects. For simplicial sets X, Y the map π X,Y : is defined to be π sSet(X,D R (Y )) (see Equation (9) and Proposition 2.15). We need to show, as a consequence Proposition 3.9, that π is a functor. That is, for all P ∈ D R (sSet(X, D R Y )) and Q ∈ D R (sSet(Y, D R Z)) we have π(Q * P ) = π(Q) π(P ). This follows from the following computation: For x ∈ X n we have Q(q )q n (y) = y∈Yn π(P ) n (x)(y)π(Q) n (y) = (π(Q) π(P )) n (x).
Let F T : C → C T denote the functor defined as follows: • Obj(C) → Obj(C T ) is the identity functor.
The functor F T has a right adjoint U T : C T → C (see [Rie17, Lemma 5.2.11]). In fact, the monad T arises from this adjunction. In the following we will consider the free convex category D R (sSet), and the Kleisli category sSet D R , which is also a convex category (Proposition 3.13).
The Θ-map defined in Equation (2) can be given a categorical interpretation using the theory of convex categories.
Proposition 3.14. The transpose of the functor F D R : sSet → sSet D R with respect to the adjunction D R : Cat ConvCat R : U is the functor Θ : D R (sSet) → sSet D R which is defined as identity on the objects and as the map Θ X,Y on morphisms.
Proof. Using Proposition 2.16 we see that Θ = π sSet D R • D R (F D R ). Then Remark 2.1 implies that Θ is the corresponding transpose of F D R .

Convex monoids
In Section 3 we introduced the notion of a convex category. Now, in this section we will specialize to convex monoids, that is convex categories with a single object. We will introduce a weak notion of invertibility for convex monoids. This definition is inspired by the definition of noncontextuality for simplicial distributions. Later in Section 5 we will see that the two notions coincide for cases of interest. For real convex monoids we introduce the notion of invertible fraction to quantify the closeness of an element to being invertible. The monad D R acting on Cat restricts to a monad on the category Mon of monoids. A D Ralgebra (M, π M ) over this monad is called an R-convex monoid. By Proposition 3.9 this is equivalent to saying that (M, π M ) is an R-convex set and the map π M : D R (M ) → M is a homomorphism of monoids. We will write ConvMon R for the category of R-convex monoids. Proposition 3.12 specializes to give the following result.
Corollary 4.1. Let (M, ·) be a monoid which is also a real convex set. Let π M denote the structure map of M when regarded as an R ≥0 -convex set. Then the following statements are equivalent.
3. For m 1 , m 2 , n 1 , n 2 ∈ M and α, β ∈ [0, 1] we have the following equality Remark 4.2. By part (3) of Corollary 4.1 one can see that the notion of a convex monoid given in [RR17, Definition 9] is a special case of R ≥0 -convex monoid.
As in the case of categories, from now on we will write ConvMon for ConvMon R ≥0 and refer to the objects of this category as real convex monoids.
Example 4.3. A semiring R can be given the structure of an R-convex set by defining π R : D R (R) → R as follows: Since R is commutative π R is a homomorphism of monoids, hence R becomes an R-convex monoid.
Example 4.4. The set R of real numbers is a convex set, and with the following product is a monoid with 1 as the identity. In addition, part (3) of Corollary 4.1 holds, hence (R, π R ) is a real convex monoid. Note that ([0, 1], π R , ) is a real subconvex monoid of (R, π R , ).
Example 4.5. The set of continuous functions from R to R is a real convex set. With the composition operation it is a monoid, but not a real convex monoid.

Weak invertibility
In this section, we will introduce the notion of weak invertibility for monoids. We begin by relating monoids to groups.
In Equation (25) we used the fact thatπ M (δ n ) = π M (D R (i M )(δ n )) = π M (δ n ) = n. This shows that if m is weakly invertible then n · m is weakly invertible. Conversely, if n · m is weakly invertible then applying this observation to the product n · m (instead of m) we obtain that n −1 · (n · m) = m is weakly invertible.
Next, we provide a criterion for weak invertibility in pull-backs of convex monoids. This is a version for convex monoids of a "gluing result" for simplicial distributions [OKI22,Lemma 4.4]; see also [FF16,Section 3.4].
Lemma 4.10. Let R be a division semiring which is also zero-sum-free (see [Hut81]). Consider the following diagram in Set: ) because of the compatibility of p 1 , p 2 and x 1 , x 2 . First, we verify that p ∈ D R (X 1 × Y X 2 ): In the last line we use the following fact: Since R is a zero-sum-free semiring, D R (f 1 )(p 1 )(f 1 (x 1 )) = 0 implies p 1 (x 1 ) = 0. Let r j : X 1 × Y X 2 → X j , where j = 0, 1, be the projection maps. We will show that D R (r 1 )(p) = p 1 . Let x ∈ X 1 . If D R (f 1 )(p 1 )(f 1 (x)) = 0, then If D R (f 1 )(p 1 )(f 1 (x)) = 0, then as before p 1 (x) = 0. We also have Similarly, one can show that D R (r 2 )(p) = p 2 .
Proposition 4.11. Let R be a division which is also a zero-sum-free semiring. Consider the following diagram in ConvMon R : For (m 1 , m 2 ) ∈ M 1 × N M 2 the following are equivalent: , π M 1 (P 1 ) = m 1 and π M 2 (P 2 ) = m 2 Proof. We have the following map between the pull-back squares: Applying D R to this diagram induces The vertical maps in Diagram (28) Since Mon is a complete category, using the proof of [Rie17, Theorem 5.6.5], we obtain that Therefore (m 1 , m 2 ) ∈ M 1 × N M 2 is weakly invertible if and if (m 1 , m 2 ) is in the image of the map This happens if and only if there exists P 1 ∈ D R (M * 1 ) and P 2 ∈ D R (M * 2 ) such that D R (f 1 )(P 1 ) = D R (f 2 )(P 2 ) and π M 1 (P 1 ) = m 1 , π M 2 (P 2 ) = m 2 .
Remark 4.12. Let X 1 and X 2 be simplicial sets. Consider two simplicial set maps f i : Z → X i for i = 1, 2. Let Y be a simplicial group Applying Proposition 4.11 (together with Theorem 5.8 below) to the diagram of convex monoids gives us a criterion on deciding whether a simplicial distribution p ∈ sSet(X 1 Z X 2 , D R (Y )) is noncontextual. This is a generalization of [OKI22, Lemma 4.4], in the case when Y is a simplicial group, to the category of convex monoids.

Strong invertibility
We introduce a stronger version of invertibility akin to strong contextuality (Definition 2.10) defined in terms of supports. To study the properties of strong invertibility we will restrict to a special class of semirings.
Definition 4.14. A semiring R is called integral if a · b = 0 implies a = 0 or b = 0 if for all a, b ∈ R (see [Jac09, Definition 7]).
In this section the semiring R will be zero-sum-free (Definition 2.11) and integral.
As an immediate consequence of this observation we have the following.
Corollary 4.16. Let R be a zero-sum-free, integral semiring, and M be an R-convex monoid. Let n ∈ M * and m ∈ M . Then the following are equivalent: 1. m is strongly non-invertible.
Next result follows immediately from Lemma 4.17.
Corollary 4.18. Let R be a zero-sum-free semiring. For a morphism f : M 1 → M 2 in ConvMon R and m ∈ M 1 we have the following: 1. If Isupp(f (m)) ∩ f (M * 1 ) = ∅, then m is strongly non-invertible.
2. If f (m) is strongly non-invertible, then m is also strongly non-invertible.

Invertible fraction
We now give the definition of the invertible fraction for real convex monoids.  Proof. Let P 1 , P 2 ∈ D R (M ) such that π(P i ) = m i for i = 1, 2. Then π(P 1 * P 2 ) = m 1 · m 2 and m ∈M *  Proof. For P ∈ D(M 1 ) such that π M 1 (P ) = m we have π M 2 (D(f )(P )) = f (π M 1 (P )) = f (m) and Proof. Let us write m 1 , m 2 , · · · , m k for the distinct elements in {x ∈ M | P (x) = 0}. Given > 0, for every 1 ≤ i ≤ k we choose P i ∈ D(M ) such that π(P i ) = m i and IF(m i ) − < m ∈M * P i (m ).
In fact, Q = µ M (P ), whereP ∈ D(D(M )) is defined as the follows: On the other hand, D(π)(P ) ∈ D(M ) and for x ∈ M we have We obtain that D(π)(P ) = P . Thus by the right-hand Diagram in (1), we see that π(Q) = π(P ). Therefore π(Q) = m. Using this and by our choice of P 1 , · · · , P k , we obtain Hence we proved that for every > 0 there exists Q ∈ D R (M ) such that π(Q) = m and This gives the desired result.
Remark 4.25. Theorem 2.18 implies that the notion of contextuality for simplicial distributions and the corresponding notion for presheaves of distributions provided in [AB11] coincide. Later in Corollary 5.9 we will show that noncontextual fraction of a simplicial distribution p : X → D(Y ) is equal to its invertible fraction (here we assume Y is a simplicial group). With these observations Proposition 4.24 generalizes the first inequality of [ABM17, Theorem 2] satisfies by the contextual fraction of a presheaf of distributions.
Next we provide an alternative characterization of invertible fraction, which will be useful when comparing this notion to noncontextual fraction.
By Proposition 2.3 the structure map π M is a morphism in Conv. Therefore we obtain Since P ∈ D(M * ) we have m ∈M * P 1 (m ) = 1, and therefore Note that π M (I(P )) is weakly invertible, thus sup A ≥ IF(m).

Contextuality and invertibility
Recall that a simplicial distribution p : X → D R (Y ) is called noncontextual if it lies in the image of Θ X,Y : D R (sSet(X, Y )) → sSet(X, D R (Y )) (Definition 2.6). When Y is a simplicial group the set of simplicial distributions sSet(X, D R (Y )) is a convex monoid (Corollary 5.2). In this monoid we can consider those elements that are weakly invertible (Definition 4.6). In this section we prove our main result, which is the equivalence of the two notions for simplicial distributions. We also prove a similar equivalence between their strong versions.

Contextuality and weak invertibility
In this section we establish the equivalence of the notions of noncontextuality and weak invertibility.
Lemma 5.1. Let X be a simplicial set and Y be a simplicial monoid. Then the map Θ X,Y : ) is a homomorphism of monoids.
Proof. Given p, q ∈ D R (sSet(X, Y )), and x ∈ X n , y ∈ Y n , we have In particular, for a simplicial set X and a simplicial monoid Y the set sSet(X, D R (Y )) of morphisms is an R-convex monoid.
Proof. The structure map π sSet(X,Y ) : D R (sSet(X, Y )) → sSet(X, Y ) is a homomorphism of monoids since it is the composite of Θ X,Y : D R (sSet(X, Y )) → sSet(X, D R Y ), which is a homomorphism by Lemma 5.1, with the homomorphism (π Y ) * : sSet(X, D R Y ) → sSet(X, Y ). In addition, by Proposition 2.15 sSet(X, Y ) is an R-convex set. It remains to show that the restriction is compatible with morphisms. This follows from Propsition 2.15 and the fact that the functor sSet(−, −) : sSet op × sSet → Set restricts to a functor sSet(−, −) : sSet op × sMon → Mon.
Next we describe the monoid structure of sSet(X, D(N Z 2 )) when X is one of the spaces in Example 2.24 and 2.25. the product p · q is represented by the box y x p 1 · q 1 + p 2 · q 2 + p 3 · q 3 + p 4 · q 4 p 1 · q 2 + p 2 · q 1 + p 3 · q 4 + p 4 · q 3 p 1 · q 3 + p 3 · q 1 + p 2 · q 4 + p 4 · q 2 p 1 · q 4 + p 2 · q 3 + p 3 · q 2 + p 4 · q 1 Similarly, we can describe the product for the square X = ∆[0] * X Σ .The identity element in sSet(∆[0] * X Σ , DN Z 2 ) is given by The product can be computed considering one box at a time, labeled by (x i , y j ), and using the formula in Equation (32).
Our main result in this section connects noncontextuality and weak invertibility.
Theorem 5.4. Given a simplicial set X and a simplicial group Y . If the distribution p ∈ sSet(X, D R (Y )) is noncontextual then p is weakly invertible (Definition 4.6).
Proof. We have the following commutative diagram: By Proposition 2.16 Θ X,Y is the transpose of (δ Y ) * with respect to the adjunction D R : Mon ConvMon R : U . Similarly, the mapπ sSet(X,D R (Y )) is the transpose of the inclusion homomorphism (sSet(X, D R (Y ))) * → sSet(X, D R (Y )) with respect to the same adjunction. Therefore we obtain the following commutative diagram: Lemma 5.6. Let R be a zero-sum-free, integral semiring and G be a group. Then (D R (G)) * is equal to the image of δ G : G → D R (G).
Proof. The image of δ G is contained in (D R (G)) * , since this map is a homomorphism of monoids. For the converse consider p = g∈G α g δ g with inverse q = g∈G β g δ g , that is The case h = e G implies that there exists g ∈ G for which q(g) = 0. On the other hand, the second case gives us that p(hg −1 ) = 0 for all h = e G , since R is zero-sum-free and integral. Therefore p is the delta distribution δ g −1 .
Lemma 5.7. Let R be a zero-sum-free and integral semiring. Given a simplicial set X and a simplicial group Y the set (sSet(X, D R (Y ))) * of units is the image of the following map: For the other direction, consider p, q ∈ sSet(X, D R (Y )) such that p · q = e sSet(X,D R (Y ) ) . This means that we have p(x) * q(x) = e D R (Yn) for x ∈ X n . By Lemma 5.6 there exists y(x) ∈ Y n such that p(x) = δ y(x) . Then we define ϕ n : X n → Y n by ϕ n (x) = y(x). Then compatibility of p with the simplicial structure maps and implies that ϕ : X → Y defined in degree n by ϕ n is a simplicial set map such that (δ Y ) * (ϕ) = p.
Theorem 5.8. Let R be a zero-sum-free and integral semiring. Given a simplicial set X and a simplicial group Y , a distribution p ∈ sSet(X, D R (Y )) is noncontextual if and only if p is weakly invertible.
Corollary 5.9. Let X be a simplicial set and Y be a simplicial group. For p ∈ sSet(X, D(Y )) we have NCF(p) = IF(p).

Strong contextuality and strong invertibility
In this section we make the connection between strong contextuality and strong non-invertibility when R = R ≥0 . Let X be a simplicial set. A simplex x ∈ X n is called degenerate if x belongs to ∪ n−1 j=0 s j (X n−1 ); otherwise it is called nondegenerate.
Observe that α > 0 since X has finitely many simplices and for x ∈ X n we have both p n+1 (s i (x))(ψ n+1 (s i (x))) and p n−1 (d j (x))(ψ n−1 (d j (x))) are greater than or equal to p n (x). If α = 1, which implies that p = δ Y • ψ, then δ Y • ψ ∈ Isupp(p). Then let us suppose that α < 1. For n ≥ 0, we define q n : X n → D R (Y n ) by We need to verify that indeed q n (x) ∈ D R (Y n ): Observe that for y ∈ Y n , we have pn(x)(y) 1−α otherwise.
Corollary 5.11. Let X be a simplicial set with finitely many nondegenerate simplices, Y be a simplicial group and p ∈ sSet(X, D(Y )).
Example 5.18. Let X denote the square space in Example 2.25 and ∂X denote its boundary consisting of the nondegenerate 1-simplices given by x i ⊕ y j where i, j ∈ Z 2 . The inclusion f : ∂X → X induces f * : sSet(X, D(N Z 2 )) → sSet(∂X, D(N Z 2 )) ∼ = [0, 1] 4 defined by f * (p ab x i y j ) = (p 00 x i y j + p 11 x i y j ) i,j∈Z 2 .

Homotopic simplicial distributions
Simplicial homotopy can be used to capture strongly contextual simplicial distributions and vertices. We begin with a preliminary observation.
Lemma 5.19. Let f : Z → X be a simplicial set map, and p ∈ sSet(X, D R (Y )).
Example 5.24. Let X denote the simplicial set obtained by gluing two copies of ∆[1] along their boundaries: Consider two simplicial set maps ϕ, ψ ∈ sSet(X, N Z 2 ). These maps are determined by the images of the 1-simplices x, y. Let ϕ be given by (x, y) → (0, 0), and ψ by (x, y) → (1, 0). Note that ϕ ∼ ψ. But the deterministic distributions δ N Z 2 • ϕ and δ N Z 2 • ψ are homotopic via the following unique homotopy: Note that (X × ∆[1], N Z 2 ) is another way to describe the CHSH scenario of Example 2.22. The distribution above is a PR box. Each of the 8 distinct PR boxes can be captured in this way as a homotopy.
In general, given the four triangles corresponding to the four boxes in the CHSH scenario, any way of assembling them into a simplicial set provides a description as a simplicial distribution. In addition to the realizations given in this example and Example 2.25 there is another realization where X is a punctured torus; see [OKI22] and [OCI22].