\section{Introduction}

Of all the descriptions of nature throughout human history, quantum behavior is the strangest. Not that it is necessary to satisfy our vision, but because it is after more than a century a formalism without a clear explanation that allows a reasonably intuitive panorama. It is due to our classic intuition that fails to confront quantum behavior, with fundamentally non-classical results. To make explicit such non-classicality, which appears in the early years of the development of quantum theory \cite{PhysRev.47.777}, the concept of nonlocality has emerged. With theoretical work first by Bell \cite{PhysicsPhysiqueFizika.1.195}, and with experiments that culminated in important results \cite{cite-key, PhysRevLett.115.250401, PhysRevLett.115.250402}, nonlocality finally explained the impossibility of understanding quantum theory by classical means. 

It is possible to describe the quantum theory classically, as in Bohm's interpretation \cite{PhysRev.85.166}, but they all violate some property accepted as classical, as the speed limit for localized influence, and independence of the context in which the interaction occurs. This last property, called contextuality, was initially proposed in Ref. \cite{Kochen1975}, and it deals with the inability to describe even with extra variables the results of a given physical system. As shown in Ref. \cite{Abramsky_2011} nonlocality is a special case of contextuality, and starting from the topos formalism for quantum theory, we have that contextuality is at the origin of all the main properties that make it what it is \cite{doring2020contextuality}. Therefore, contextuality is at the origin of what is known today as non-classicality and can be informally explained as the inability to a global agreement even if local agreement occurs \cite{abramsky2020contextuality}. As already demonstrated \cite{Abramsky2015ContextualityCA}, contextuality can be understood as the inability to remove a paradox from a data set, even with the inclusion of variables, thus being described as the emergence of fundamental paradoxes, with application in data science \cite{Abramsky_2019}.

Similar to nonlocality, which implies the violating of certain inequalities obtained by assuming classic properties in the outcomes of a model, one can construct inequalities for contextuality. Thus the set of so-called classical correlations is determined as satisfying these inequalities, and violations invalidate one of the so-called classical properties previously assumed. The study of such contextual inequalities is a field of research in development. However, even for simple models the amount of such inequalities necessary to specify the classic set makes the generic study of correlations complicated.

To understand contextual behavior, and to build tools in the study of specific models, several formalisms were constructed, which have more or less refinement, and with their limitations. For example, Contextuality-by-Default \cite{Dzhafarov1, Dzhafarov2, Dzhafarov3} seeks to suppose dependence in contexts from the beginning, on the level of random variables. The generalized contextuality \cite{Spekkens_2005} defines contextuality for the entire operational framework, and not just to measurements. The formalism of exclusivity graphs \cite{Cabello_2014} identifies the maximum limits of violations with graph properties generated by the relationship between measurement outputs, enabling the identification of the set of quantum correlations. The sheaf approach to contextuality \cite{Abramsky_2011} seeks to encode contextuality through a structure in category theory, enabling equivalence between the absence of a global section and contextual behavior. The latter also has a study corresponding to the topological property of the models, and the relationship between contextuality and cohomology \cite{Car__2017,caru2018complete,montanhano2021contextuality}. The relation with topology can also be used under the appropriate formalism \cite{Okay_2020}.

As a more recent example of formalism for the usual contextuality, we have the bundle approach, where the compatibility of measurements is codified in the hypergraph formalism, and for each vertex, understood as a measurement, we have the possible outcomes. The contextual behavior follows from the impossibility of globally codify the bundle constructed with these fibers, based on the hypergraph. Thus, contextuality appears as a property of the bundle, as a total space. Its use already appeared as a graphic resource in the sheaf approach \cite{Beer_2018}, but its due formalism occurred later in Ref. \cite{Terra_2019_FibreBundle}.

In the first part of the present paper (\ref{Fibration approach}), we make a detailed formalization for the bundle approach, explaining the reasons for the simplicial complex structure that is usually imposed in the compatibility hypergraphs, in addition to the local independence conditions. The equality of the fibers is not supposed, and therefore a fibration is constructed having the same informational content as the sheaf approach. Another generalization is the use of non-finite fibers, as occurs in Ref. \cite{barbosa2019continuousvariable}. The version in the fibration approach of the Fine–Abramsky–Brandenburger theorem is presented, identifying different definitions of non-contextuality, and enabling the identification of nonlocality as a special case of contextuality.

The second part (\ref{Topology of $R$-fibrations}) explores the relation between contextuality and the geometry of the scenario. The Voroby'ev theorem is revised, and an example shows that the contextuality in this formalism is not topological invariant, but comes from a geometric property of the fibration. A treatment analogous to discrete differential geometry is presented, allowing a geometric visualization of empirical models when connecting the fibers and resulting in the equivalence between non-contextuality and triviality of the fibration. We define a hierarchy of probabilistic contextuality, indexed by the dimension of the maximal contexts taken into account when probing the contextual behavior. With this hierarchy, we show two things. First, we find an example of all levels of it in quantum theory with GHZ models. And second, we find evidence of the dependence between the contextuality of a model and the topology of the underlying measurement scenario.

Finally, we restrict to equivalent and finite fibers in the third part (\ref{Exploring $1$-contextual models}).  We codify the information from the previously static probabilistic outcome table in Markov kernels, such that it can be understood as the connections between fibers, flirting with the idea of dynamics in join measurements. We use the singular value decomposition to extract a group element from each Markov kernel, allowing the study of parallel transport in the bundle and the formalization of the holonomy group. Examples are presented, with the explicit calculation method for the Markov kernels and the holonomy group, and where methods for quantifying contextuality \cite{Abramsky_2017} are simply applicable. We define the discrete curvature in the measurement bundle with $1$-contextuality by the discrete outer derivative using the generalized Stokes theorem, for cases with non-singular Markov kernels. Also, the condition of non-disturbance is removed, allowing the inclusion of the disturbance influence in the holonomy group, and relating it to the extended contextuality formalism \cite{Amaral_2019}.

\newpage
\section{Fibration approach}
\label{Fibration approach}

\subsection{Measurement scenario}
\label{Measurement scenario}

Contextuality can be understood as a local concordance that can't be extended to a global concordance. It deals with compatibility between measurements, here understood as fundamental objects. Thus this phenomenon appears as relations between parts of a set. To formalize this idea, let's first define how to write these relations.

\begin{definition}[Hypergraph]
A hypergraph is a triple $\left(X,\mathcal{C},\epsilon\right)$, where $X$ is a set of objects called vertices, $\mathcal{C}$ is a set of objects called hyperedges, and $\epsilon$ is the incidence weight $\epsilon:X\times\mathcal{C}\to\left\{0,1\right\}$ that codify if a vertex $m\in X$ is in a hyperedge $U\in\mathcal{C}$ ($\epsilon\left(m,U\right)=1$) or not ($\epsilon\left(m,U\right)=0$).
\end{definition}

This definition enables different hyperedges with the same vertices, thus encoding more information than just a relation between vertices. We might interpret it as different kinds of relations with the same objects, which can be important if we are working with relations in data analysis. For our purposes, we can restrict our construction to just one hyperedge by a set of vertices, such that the information is between them as some kind of compatibility between these objects. As said in Ref. \cite{abramsky2020contextuality}, it loses little by way of examples.

\begin{definition}[Hypergraph realization in the power set of $X$]
A hypergraph realization in the power set is the usual triple  $\left(X,\mathcal{C},\epsilon\right)$, that satisfies $\mathcal{C}\subset\mathbb{P}\left(X\right)$. Therefore $\epsilon$ can be defined implicitly in $\mathcal{C}$, and we can omit it.
\end{definition}

As we will be studying how the relationship between the objects interferes in the formed geometry, unrelated objects are not important and can be disregarded. For simplicity, we will restrict ourselves to the case that there is always at least one relation for any object.

\begin{definition}[Hypergraph realization as a covering]
A hypergraph is realized in the power set $\mathbb{P}\left(X\right)$ as a covering if
\begin{itemize}
    \item $\cup_{U_{i}\in \mathcal{C}}U_{i}=X$;
    \item $\emptyset\in \mathcal{C}$.
\end{itemize}
\end{definition}

For empirical realizations of these objects, and their interpretation as a classical description, the hyperedges must have a $\sigma$-algebra structure for their sub-hyperedges.

\begin{definition}[Simplicial complex]
A simplicial complex is a hypergraph $\left(X,\mathcal{C}\right)$ with covering representation in the power set, here called respectively as vertices and simplices, that satisfies
\begin{itemize}
    \item if $U,V\in \mathcal{C}$, then $U\cap V\in \mathcal{C}$;
    \item if $U,V\in \mathcal{C}$, and $U\subset V$ then $V-U\in \mathcal{C}$.
\end{itemize}
\end{definition}

The first condition implies intersection closure and the second complementation closure. Thus we get union closure, and as we are working with contexts with a finite number of atomic measurements, we have the $\sigma$-algebra conditions for each hyperedge. We can now define the concept of measurement scenario.

\begin{definition}[Measurement scenario]
Let $X$ be a collection of fundamental objects called simple measurements, in the sense of being atomic. On $X$ we define a covering $\mathcal{C}\subset \mathbb{P}\left(X\right)$ such that it satisfies the structure of a simplicial complex. We call the elements of $\mathcal{C}$ contexts of the measurement set $X$, which are compatibles if they are in the same context. A pair $\left(X,\mathcal{C}\right)$ is called a measurement scenario.
\end{definition}

This definition implies that there are maximal contexts ($U\in \mathcal{C}$ is maximal if for all $V\in \mathcal{C}$ and $U\subset V$, then $U=V$), and minimal contexts ($U\in \mathcal{C}$ is minimal if for all $V\in \mathcal{C}$ and $V\subset m=U$, then $U=V$). We will denote the set of maximal contexts as $\mathcal{C}^{+}$, and the set of minimal contexts as $\mathcal{C}^{-}$. By the $\sigma$-algebra structure, we can limit our study to minimal contexts, and not the measurements, permitting us to do a disjoint union of a maximal context by its minimal parts. Therefore we will call a context atomic if it is minimal, and usually call it measurement.

This course-graining given by the "effective" atomic measurement arises a direct question about the relation between measurement scenarios. Is there any way to prove a measurement in a scenario is fundamental? Formally define the coarse-graining could give some hints about the loss of information, and some work is already being done for the case of an adequate course-graining in quantum theory \cite{duarte2020investigating}.
We could translate to an equivalent question changing coarse-graining to a refinement of a simplicial complex, therefore in some sense, we are talking about the irreducibility of a measurement scenario. A physical example of refinement is spin degeneration, where refinement occurs by applying a suitable magnetic field. Such a question must be studied in the formalism of category theory, more specifically the categories of empirical models \cite{Karvonen_2019}\footnote{The problem of the fundamental nature of measurements only appears here because of the treatment of measurements as the fundamental objects. A more natural description is by the notion of coverage, and consequently of site, for the category of contexts. A site can informally be described as a space without points, implying the question of a measurement be fundamental is empty: there are no fundamental objects, only the covering, and its construction depends on how refined is the observer's tools. For this, a categorical treatment of the scenario is necessary.}.

\subsection{Fibrations and fiber bundles}
\label{Fibrations and fiber bundles}

A fibration can be understood as a generalization of the Cartesian product.

\begin{definition}
A fibration is a topological space called total space $\mathcal{R}$ equipped with a continuous projection function in a base topological space $X$
\begin{equation}
    \begin{split}
        \pi:\mathcal{R} &\to X\\
        r &\mapsto \pi(r)=m
    \end{split}
\end{equation}
such that $\pi^{-1}(m)=O^{m}$ takes each point $m$ to its respective fiber. The total space can then be seen as gluing the fibers from the base, or in notation analogous to the exact short sequence
\begin{equation}
    O^{m}\to\mathcal{R}\to X.
\end{equation}
\end{definition}

The concept of a section of a fibration will be necessary.

\begin{definition}[Section]
A section of a fibration with projection $\pi:\mathcal{R}\to X$ is a continuous application $s_{U}:U\to\mathcal{R}$, where $U\in\mathbb{P}(X)$, such that if $m\in U$ then
\begin{equation}
\pi(s_{U})(m)=m
\end{equation}
holds. If $U=X$ the section is said global, if not it is said local.
\end{definition}

Yet nothing restricts the type of fibration. The trivialities between fibers and between the base and the fibers, both locally, define that there is no storage of information in these structures. Thus it is necessary first to cover the base $X$,  codifying the notion of locality, in such a way that we can define a $\sigma$-algebra in each element of the covering.

\begin{definition}[Local independent gluing]
Let $\mathcal{R}$ be a fibration, and $\mathcal{C}$ a covering of the base $X$. If $m_{i}\in U\in\mathcal{C}$ for all $i$, then the gluing set of fibers of $U$ is a local independent gluing if $O^{U}=\prod_{i} O^{m^{i}}$.
\end{definition}

The direct consequence of this definition of independence between fibers is that within an element of the covering, we can write the bundle as the Cartesian product of the fibers, justifying the notion of local independence. 

We can define the action of a section on a subset $V\subset U\in\mathcal{C}$ by $s_{U}(V)=O^{U}|_{V}$ when the gluing between fibers is defined. Local independent gluing defines the action in an obvious way. The next definition imposes the independence between the base and the fibers, in the local sense of a covering, using this notion of fiber of a covering's element\footnote{Basically this definition of triviality codify the independence between the outcomes and the base, separating these objects, and justifying their different treatments.}.

\begin{definition}[Local fiber independence]
Let $\mathcal{R}$ be a fibration, and $\mathcal{C}$ a covering of the base $X$. For any $U\in \mathcal{C}$, we have the local independence between the base and its set of fibers if all local sections on the $U$  are of the form
\begin{equation}
    s_{U}: U \to U\times O^{U}.
\end{equation}
\end{definition}

If we assume that the fibers are the same, in addition to the independence conditions above, we have a fiber bundle.

\subsection{Measurable and event fibrations}
\label{Measurable and event fibrations}

We can now use the concept of fibration to code the outcomes $O^{m}$ of each measurement $m$. The base space is nothing more than the simplicial complex that represents the measurement scenario, with the covering having the contexts as elements. The local independent gluing can be rewritten with just the elements of the covering, here understood as the covering of contexts. The idea is to use the simplicial complex structure of $\mathcal{C}$. We will also use the term fiber to denote the set of outcomes of a context.

\begin{definition}[Local independent gluing for contexts]
Let $\mathcal{R}$ be a fibration, and $\mathcal{C}$ a covering of the base $X$. If $U\subset V\in\mathcal{C}$, then the set of fibers of $U$ is an independent gluing if it is the restriction, in the sense of Cartesian product, of the set of fibers of $V$. In notation, $O^{U}=O^{V}|_{U}$, what means, by closing complementarity, that the set of fibers can be written as
\begin{equation}
O^{V}=O^{U}\times O^{V-U}.    
\end{equation}
\end{definition}

We will work with general fibers, not only finite ones, and therefore the $\sigma$-algebra of each set of outcomes must be made explicit, making them measurable spaces. We then denote each fiber of a measurement $m\in X$ as $\textbf{O}^{m}=(O^{m},\Sigma^{m})$. The fibration will be
\begin{equation}
    \textbf{O}^{m}\to\mathcal{R}\to X.
\end{equation}
The local gluing independence of the fibration is justified globally by the independence between outcomes of different measurements. As one can access the outcomes just locally, we will work with the outcomes of a context $U\in\mathcal{C}$, thus denoting $\textbf{X}=(X,\mathcal{C})$, we have the fibration 
\begin{equation}
    \textbf{O}^{m}\to\mathcal{R}\to \textbf{X}.
\end{equation}
One can ignore the measurements and work with just the contexts from this point, once we can only access the contexts. The same argument holds for the outcomes and the elementes of the $\sigma$-algebra.  We will keep the use of $\textbf{X}$ and $\textbf{O}^{m}$ to maintain explicitly the use of a simplicial complex and measurable spaces, respectively. The new total space $\mathcal{R}$ can be understood locally as a element $(U,\sigma_{U})$, with $U\in\mathcal{C}$ and $\sigma_{U}\in\Sigma^{U}$. Thus we can denote the projection function locally as
\begin{align}
\begin{split}
  \pi \colon \mathcal{R} &\to \textbf{X}\\
  \left(U,\sigma_{U}\right) &\mapsto U.
\end{split}
\end{align}

\begin{definition}
A fibration $\left(\textbf{X},\left\{\textbf{O}^{U}\right\}_{U\in\mathcal{C}},\pi\right)$ that satisfies the conditions of local independent gluing and local fiber independence is called measurable fibration.
\end{definition}

The sections $\left\{s_{U}\right\}$ of a context $U$ are in bijection with the elements of $\Sigma^{U}$, once their definition gives an element $\sigma_{U}$ for each context $U$, which follows from local fiber independence. We will call a section in a measurable fibration, and consequently the respective element of the $\sigma$-algebra, an event $\sigma_{U}$\footnote{Usually the events are the elements of $O^{U}$. But this only holds because one is using a discrete $\sigma$-algebra.}. 

Events are defined in a context and can depend on it. For an event to be globally defined without access to the global structure, it's necessary two conditions. Fist we impose local agreement, $\sigma_{U}|_{U\cap V}=\sigma_{V}|_{U\cap V}$ holds for any pair of contexts $U,V\in\mathcal{C}$ such that $U\cap V\neq\emptyset$. Second we impose uniqueness, if two global sections $\sigma_{X}$ and $\sigma_{X}'$ satisfy $\sigma_{X}|_{U}=\sigma_{X}'|_{U}$ for all $U\in\mathcal{C}$, then $\sigma_{X}=\sigma_{X}'$. With these two properties satisfied, any local section is then the restriction of a global section. These properties can be justified by an assumed reality of global outcomes.

\begin{definition}
A measurable fibration $\left(\textbf{X},\left\{\textbf{O}^{U}\right\}_{U\in\mathcal{C}},\pi\right)$ that satisfies local agreement and uniqueness is called event fibration.
\end{definition}

\subsection{$R$-states, empirical $R$-models and $R$-fibrations}
\label{$R$-states, empirical $R$-models and $R$-fibrations}

The idea of an empirical model is nothing more than a generalization of the notion of gluing fibers of a fibration. Instead of a deterministic gluing of elements of $O^{m}$, we can only use the measurable structure. First, we need to define the notion of semi-ring, such as the Boolean semi-ring $\mathbb{B}$, the reals $\mathbb{R}$, or the probability semi-ring $\mathbb{R}^{+}$. 

\begin{definition}
A generic semi-ring is a set $R$ equipped with two binary operations $+$ and $\cdot$ such that $(R,+)$ is a commutative monoid with $0_{R}$:
\begin{itemize}
    \item $(a+b)+c=a+(b+c)$
    \item $0_{R}+a=a+0_{R}=a$
    \item $a+b=b+a$
\end{itemize}
$(R,\cdot)$ is a monoid with $1_{R}$:
\begin{itemize}
    \item $(a\cdot b)\cdot c=a\cdot (b\cdot c)$
    \item $a\cdot 1_{R}=1_{R}\cdot a=a$
\end{itemize}
the multiplication distributes:
\begin{itemize}
    \item $a\cdot (b+c)=a\cdot b +a\cdot c$
    \item $(a+b)\cdot c=a\cdot c+b\cdot c$
\end{itemize}
and $0_{R}$ annihilates:
\begin{itemize}
    \item $a\cdot 0_{R}=0_{R}\cdot a=0_{R}$
\end{itemize}
\end{definition}

The choice of a $R$ defines a way to probe the fibration.

\begin{definition}
A $R$-state is a map $P::U\in\mathcal{C}\to \mu_{P}^{U}$ from a context to a $R$-measure on its events, $\mu_{P}^{U}:\Sigma^{U}\to R$, such that $\int_{O^{U}}\mu_{P}=1_{R}$, where the integral is defined on the $\sigma$-algebra of the fiber, and $1_{R}$ is the identity element of the semi-ring.
\end{definition}

\begin{definition}[Empirical $R$-model]
An empirical $R$-model is defined as an event fibration and a fixed $R$-state $P$ acting on it.
\end{definition}

By the definition, $P\left(U\right)$ is a $R$-measure for the set of events on the context, and the $R$-measure on sub-contexts can be obtained by marginalization. We can codify a empirical $R$-model as a fibration by the projection
\begin{align}
\begin{split}
  \pi \colon \mathcal{R} &\to \mathcal{C}\\
  \left(U,\textbf{O}^{U},\mu_{P}^{U}\right) &\mapsto U.
\end{split}
\end{align}
See that the state is fixed, and the use of all $\textbf{O}^{U}$ is necessary to make sense of the measure.

\begin{definition}
With the previously projection, an empirical $R$-model $\left(\textbf{X},\left\{\textbf{O}^{U}\right\}_{U\in\mathcal{C}},P,\pi\right)$ is called $R$-measure fibration, or $R$-fibration for short.
\end{definition}

A section $s_{U}^{P}$ on a $R$-fibration takes a subset $U$ of $X$ and gives a $R$-measure $\mu_{P}^{U}$ on all the events $\Sigma^{U}$ of $U$. In this sense, there is only one section for each context of this fibration.

A natural question is what happens with the $R$-measures at the intersections between contexts. To fix it, we impose the local agreement between the distributions.

\begin{definition}[Non-disturbance]
An empirical $R$-model with $R$-state $P$ is called non-disturbing if for any two contexts $U_{1}$ and $U_{2}$ with $U=U_{1}\cap U_{2}\neq\emptyset$, then $\mu_{P}^{U_{1}}|_{U}=\mu_{P}^{U_{2}}|_{U}=\mu_{P}^{U}$ holds. Otherwise it is called disturbing.
\end{definition}

\subsection{First examples of $R$-fibrations}
\label{First examples of $R$-fibrations}

\begin{example}[Trivial model] 
The usual trivial example of a non-contextual non-disturbing bundle is given by the table of section probabilities of Fig. \ref{Trivial bundle}. 
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 11cm 0cm 0]{Trivial.png}
    \hspace*{2cm}
\Large
\begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$bc$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$cd$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$de$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$ea$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\end{tabular}
    \caption{(Left) The visualization of the trivial model through its bundle diagram. The global sections are explicit, and determined by the fiber elements. (Right) Table of outcome probabilities of each context for the trivial model.}
    \label{Trivial bundle}
\end{figure}
Here, and for all the explicit examples of this paper, we have finite simplicial complex and finite fibers. The contexts are $\mathcal{C}=\left\{ab,bc,cd,de,ea,a,b,c,d,e\right\}$, with minimal contexts $\mathcal{C}^{-}=\left\{a,b,c,d,e\right\}$ and maximal contexts $\mathcal{C}^{+}=\left\{ab,bc,cd,de,ea\right\}$. All the fibers for minimal contexts are the same, $O^{i}=\left\{0,1\right\}$, and the local independence fix the events for maximal contexts. It is a probabilistic model, $R=\mathbb{R}^+$, and its table gives the probabilities for each event of each maximal context\footnote{Examples with finite fibers can be described by the values in $R$ of each element of $O^{U}$, using the discrete $\sigma$-algebra, and the other events are kept implicitly.}. Only the non-null events are represented in the bundle diagram, as possibilistic coarse-graining. As one can see, this $\mathbb{R}^+$-model is non-disturbing, once all the events of all the intersections have probability $\frac{1}{2}$, and it can be described as two global events with probability $\frac{1}{2}$.
\end{example}

\begin{example}[Liar cycle, PR box model]
An example of non-disturbing $\mathbb{R}^+$-model with no global section is the PR box scenario, also called by logicians the liar cycle, Fig. \ref{Liar cycle}.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 11cm 0cm 0]{PR.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$bc$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$cd$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$de$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$ea$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\end{tabular}
    \caption{(Left) The visualization of the PR box model through its bundle diagram. There isn't any global event, caused by the swap of elements in the path $ea$. (Right) Table of outcome probabilities of each context for the PR box model.}
    \label{Liar cycle}
\end{figure}
It could be understood as a set of individuals saying that the next one will say the truth, cyclically, but the last one saying that the first one lied, such that a paradox occurs. The structure of the event fibration is the same as the previous example. The difference appears in the $\mathbb{R}^+$-fibration, in the measure defined on $\textbf{O}^{ea}$. The model still is non-disturbing, but global sections that define the model as a measure of global events don't exist.
\end{example}

\begin{example}[KCBS model]
The next example looks like a extreme version of the PR box, but in fact just repeat the change of elements of the outcome fiber in every context, or in the logical representation, everyone are saying the next one is a liar, Fig. \ref{KCBS}.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 11cm 0cm 0]{KCBS.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\hline
\large{$bc$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\hline
\large{$cd$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\hline
\large{$de$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\hline
\large{$ea$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\end{tabular}
    \caption{(Left) The visualization of the KCBS model through its bundle diagram. Every local section is a swap, implying that for a odd number of sides there isn't any well defined global event. (Right) Table of outcome probabilities of each context for the KCBS model.}
    \label{KCBS}
\end{figure}
Again the event fibration is the same, the difference appearing in the measures. There isn't a global section, which can be view by the bundle diagram. As one can see, topologically this and the previous example are equivalent, one just needs to relabel the events. 
\end{example}

\subsection{Non-contextual behaviour}
\label{Non-contextual behaviour}

There are different ways to formalize contextuality, all as the violation of some non-contextual notion. The best-known follows from seeking to include hidden variables to explain the empirical model, and it's similar to the inclusion of auxiliary variables to seek to correct data inconsistencies and to resolve non-fundamental paradoxes \cite{abramsky2020contextuality}.

\begin{definition}[Non-contextuality by model]
An empirical model is said $R$-non-contextual by model if the $R$-measure $\mu_{P}^{U}$ depends on each of the minimum measurements that make up $U$ independently, with the exception of hidden variables that must be statistically taken into account, that is, it is defined as the average of hidden variables in space $\Lambda$ with $R$-weight $p:\Lambda\to R$, with $\sum_{\lambda\in\Lambda}p(\lambda)=1_{R}$,
\begin{equation}
\mu_{P}^{U}=\int_{\Lambda}\left(p\left(\lambda\right)\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}\mu_{P}^{\left(V_{i},\lambda\right)}\right)d\lambda=\int_{\Lambda}\left(p\left(\lambda\right)\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}P\left(V_{i},\lambda\right)\right)d\lambda
\end{equation}
where the $R$-measure on $\textbf{O}^{U}$ couples the $R$-measures $\mu_{P}^{V_{i}}$ of the fibers $\textbf{O}^{V_{i}}$, with $\bigcup_{i}V_{i}=U$ the decomposition of $U$ in its minimal contexts, in the canonical way.
\end{definition}

This non-contextual $R$-model definition assumes two properties of the allowed hidden-variable model, as punctuated in Ref. \cite{barbosa2019continuousvariable}. The first is $\lambda$-independence, which assumes the independence of the $R$-measure concerning contexts, and the second is parameter-independence, which assumes non-disturbance of the hidden variable model. Both and more properties of hidden variable models are studied in Ref. \cite{Brandenburger_2008}\footnote{What this definition is saying is that a non-contextual $R$-model can be understood as a coarse-graining of a $R$-fibration with contexts $(U,\lambda)$ such that the coupling of all the measures is globally trivial.}.

Another way to define $R$-non-contextuality is by defining a unique function that explains all the empirical $R$-model, in a sense, it would be like the notion of asking a question to a physical system through a measurement without interfering with the outcome result, as an objective reality that only needs to be discovered.

\begin{definition}[Non-contextuality by section]
An empirical $R$-model is said $R$-non-contextual by section if every local section can be extended to a global section.
\end{definition}

The notion of contextuality by section originates from the sheaf approach to contextuality \cite{Abramsky_2011}, but it was first written for bundles in the approach presented in Ref. \cite{Terra_2019_FibreBundle}.

Finally, we can start with a global $R$-measure that can be marginalized to obtain the $R$-measure of a specific outcome of a measurement, as in a classical model. Inspired by this fact, we define $R$-non-contextuality as the existence of such a global $R$-measure. 

\begin{definition}[Contextuality by marginals]
An empirical $R$-model is said $R$-non-contextual by marginals if there is a $R$-measure $\mu_{P}^{X}$, defined on all the measurements set, such that we can write any $R$-measure as $\mu_{P}^{U}=\mu_{P}^{X}|_{U}$ for all $U\in\mathcal{C}$.
\end{definition}

The next theorem, well known in the sheaf approach to contextuality \cite{Abramsky_2011}, is a generalization of the same result presented in Ref. \cite{Terra_2019_FibreBundle} in the fiber bundle approach. Here we generalized the fibers to any measurable space, not just finite ones. The demonstration is inspired by the same theorem for generalized measurable spaces for continuous fibers presented in Ref. \cite{barbosa2019continuousvariable}.

\begin{theorem}
[Fine-Abramsky-Brandenburger] Given an empirical $R$-model on a measurement scenario $\textbf{X}$, the following statements are equivalent:
\begin{enumerate}
    \item the model is $R$-non-contextual by model;
    \item the model is $R$-non-contextual by marginals;
    \item the model is $R$-non-contextual by section.
\end{enumerate}
\label{FAB}
\end{theorem}

\begin{proof}
($1\to 2$) If we have an empirical $R$-model that is $R$-non-contextual by model, then for any context $U\in\mathcal{C}$ holds
\begin{equation}
\mu_{P}^{U}=\int_{\Lambda}\left(p\left(\lambda\right)\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}\mu_{P}^{\left(V_{i},\lambda\right)}\right)d\lambda=\int_{\Lambda}dp\left(\lambda\right)\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}\mu_{P}^{\left(V_{i},\lambda\right)}.
\end{equation}

By the same reason, we can write
\begin{equation}
\mu_{P}^{X}=\int_{\Lambda}dp\left(\lambda\right)\prod_{V_{i}\in \mathcal{C}^{-}}\mu_{P}^{\left(V_{i},\lambda\right)}
\end{equation}
defining a $R$-measure on $X$. The marginals follows from
\begin{equation}
\mu_{P}^{X}|_{U}=\int_{\Lambda}dp\left(\lambda\right)\prod_{V_{i}\in\mathcal{C}^{-}}\mu_{P}^{\left(V_{i},\lambda\right)}|_{U}=\int_{\Lambda}dp\left(\lambda\right)\prod_{V_{i}\in\mathcal{C}^{-}|_{U}}\mu_{P}^{\left(V_{i},\lambda\right)}=\mu_{P}^{U},
\end{equation}
therefore it's an model $R$-non-contextual by marginals.

($2\to 3$) Given a $R$-measure $\mu_{P}^{X}$ of $X$, and let $s_{U}^{P}$ be a local section, $\pi\left(s_{U}^{P}\right)\left(V\right)=V$ for all $V\subset U$, $V\in\mathcal{C}$. As 
\begin{equation}
s_{U}^{P}\left(V\right)=\left(V,\textbf{O}^{V},\mu_{P}^{U}|_{V}\right)
\end{equation}
we can extend the section by
\begin{equation}
s_{X}^{P}\left(V\right)=\left(V,\textbf{O}^{V},\mu_{P}^{X}|_{V}\right)
\end{equation}
where obviously holds for all $U'\in\mathbb{P}\left(\mathcal{C}^{-}\right)$
\begin{equation}
s_{X}^{P}\left(U'\right)=\left(U',\textbf{O}^{U'},\mu_{P}^{X}|_{U'}\right).
\end{equation}
This is especially true for $U'=X$, and therefore the model is $R$-non-contextual by section.

($3\to 1$) If we have an empirical model that is $R$-non-contextual by section, then for any $U\in\mathbb{P}(\mathcal{C}^{-})$ holds
\begin{equation}
s_{X}^{P}\left(U\right)=\left(U,\textbf{O}^{U},\mu_{P}^{X}|_{U}\right).
\end{equation}
We always can write a $R$-measure on $U$ as
\begin{equation}
\mu_{P}^{U}(\sigma_{U})=\int_{\Lambda}dp(\lambda)K_{U}(\lambda,\sigma_{U})
\end{equation}
with any $\sigma_{U}\in\Sigma^{U}$, and $K$ the kernel for $U$. Choosing $\Lambda=\textbf{O}^{X}$, $p=\mu_{P}^{X}$, and defining $K_{U}(\lambda,\sigma_{U})=\delta_{\mu_{P}^{X}|_{U}}(\sigma_{U})$ and the restriction function $f\left(\mu_{P}^{X}\right)=\mu_{P}^{X}|_{U}=\mu_{P}^{U}$, we have
\begin{align}
\begin{split}
    \int_{\Lambda}dp(\lambda)K_{U}(\lambda,\sigma_{U}) 
    &=\int_{\textbf{O}^{X}}d\mu_{P}^{X}(\sigma_{X})K_{U}(\sigma_{X},\sigma_{U})\\
    &=\int_{\textbf{O}^{X}}d\mu_{P}^{X}(\sigma_{X})\delta_{f\left(\mu_{P}^{X}\right)}(\sigma_{U})\\
    &=\int_{\textbf{O}^{X}}d\mu_{P}^{X}(\sigma_{X})\left(\chi_{\sigma_{U}}\circ f\right)\\
    &=\int_{\textbf{O}^{U}}d\left(f^{*}\mu_{P}^{X}\right)(\sigma_{X})\chi_{\sigma_{U}}\\
    &=\int_{\textbf{O}^{U}}\chi_{\sigma_{U}}d\mu_{P}^{X}(\sigma_{X})|_{U}\\
    &=\mu_{P}^{X}|_{U}(\sigma_{U}).
\end{split}
\end{align}
where $\chi_{\sigma_{U}}$ is the characteristic function. This tells us that the model obtained is deterministic. It follows that it is factorisable, since the Dirac $R$-measure $\delta_{\mu_{P}^{U}}$ factorize as a product of Dirac $R$-measures,
\begin{equation}
\delta_{\mu_{P}^{U}}=\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}\delta_{\mu_{P}^{U}|_{V_{i}}}=\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}\delta_{\mu_{P}^{V_{i}}}.
\end{equation}
Being $\sigma_{U}=\prod_{{V_{i}\in \mathcal{C}^{-}|_{U}}}\sigma_{V_{i}}$, we can write
\begin{equation}
K_{U}\left(\sigma_{X},\sigma_{U}\right)=\delta_{\mu_{P}^{X}|_{U}}(\sigma_{U})=\prod_{V_{i}\in \mathcal{C}^{-}|_{U}}\delta_{\mu_{P}^{V_{i}}}\left(\sigma_{V_{i}}\right)=\prod_{V_{i}\in\mathcal{C}^{-}|_{U}}K_{V_{i}}\left(\sigma_{X},\sigma_{V_{i}}\right)
\end{equation}
therefore we can finally define $K_{V_{i}}\left(\sigma_{X},\sigma_{V_{i}}\right)=\mu_{P}^{\left(V_{i},\lambda\right)}\left(\sigma_{V_{i}}\right)$, $\lambda=\sigma_{X}$, and as holds for $X$, we conclude that the model is $R$-non-contextual by model.
\end{proof}

During the previous demonstration, it was shown that a model is $R$-non-contextual if and only if it can be factorizable. This property when $R=\mathbb{R}^{+}$ is equivalent to Bell's locality \cite{Bell:111654}, as explained in Ref. \cite{Abramsky_2011}. The theorem above thus relates Bell's nonlocality as a special case of the contextuality of the respective empirical model. For our case with non-finite fibers, this identification is generalized for cases of a continuous spectrum.

\subsection{Examples of contextuality in $R$-fibrations}
\label{Examples of contextuality in $R$-fibrations}

The examples that will be presented here have finite outcome fiber and are non-disturbing. To check the contextual behavior, we will use the contextual fraction (see Appendices).

\begin{example}[Trivial model] 
The model of Fig. \ref{Trivial bundle} can be describe as the combination of two global events,
\begin{equation}
    s_{X}^{trivial}=\frac{1}{2}(abcde\to 00000)+\frac{1}{2}(abcde\to 11111)
\end{equation}
defining a global section of the $\mathbb{R}^{+}$-fibration. By theorem \ref{FAB}, the model is $\mathbb{R}^{+}$-non-contextual, in agreement with non-contextual fraction $NCF=1$.
\end{example}

\begin{example}[Liar cycle, PR box model]
The PR box model of Fig. \ref{Liar cycle} can't be described as a combination in $R=\mathbb{R}^{+}$ of global events, thus there isn't a global section that describes it. The cause is the swap in the context $ea$, giving a $\mathbb{R}^{+}$-contextual behaviour for this $\mathbb{R}^{+}$-fibration, with non-contextual fraction $NCF=0$. The PR box model is an example of strong contextuality, once there isn't any well-defined global event, and can't be reproduced by quantum theory.
\end{example}

\begin{example}[KCBS model]
The KCBS model of Fig. \ref{KCBS} follows the same reasoning as the PR box model. It can't be described by a combination of global events, because of an odd number of swaps. The non-contextual fraction is $NCF=0$, showing the $\mathbb{R}^{+}$-contextual behavior of this model.
\end{example}

\begin{example}[Hardy model]
The example of Fig. \ref{Hardy} has two important differences from the previous ones. First it is more complicated, but one still can directly see if it is contextual or not just using the events. Second, it can be realized in quantum theory.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 11cm 0cm 0]{Hardy.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$\frac{2}{9}$} & \large{$\frac{2}{3}$} & \large{$\frac{1}{9}$} & \large{$0$} \\
\hline
\large{$bc$} & \large{$0$} & \large{$\frac{1}{3}$} & \large{$\frac{2}{3}$} & \large{$0$} \\
\hline
\large{$cd$} & \large{$\frac{1}{3}$} & \large{$\frac{1}{3}$} & \large{$\frac{1}{3}$} & \large{$0$} \\
\hline
\large{$de$} & \large{$0$} & \large{$\frac{2}{3}$} & \large{$\frac{1}{3}$} & \large{$0$} \\
\hline
\large{$ea$} & \large{$\frac{2}{9}$} & \large{$\frac{1}{9}$} & \large{$\frac{2}{3}$} & \large{$0$} \\
\end{tabular}
    \caption{(Left) The visualization of the Hardy model through its bundle diagram. This model has global events, but some local events can't be extended to a global one. (Right) Table of outcome probabilities of each context for the Hardy model.}
    \label{Hardy}
\end{figure}
The model is non-disturbing, with non-contextual fraction $NCF=\frac{7}{9}$, thus being $\mathbb{R}^{+}$-contextual. It shows global events, starting in $(ab\to 00)$, $(cd\to 00)$ and $(ea\to 00)$, but there are events that can't be extended to global ones, $(ab\to 01)$, $(ab\to 10)$, $(cd\to 01)$, $(cd\to 10)$, $(ea\to 01)$ and $(ea\to 10)$. A model that presents global events but also presents non-extendable local events is called possibilistic contextual, in the sense of being described as $\mathbb{B}$-contextual.
\end{example}

\begin{example}[Bell model]
The Bell model, Fig. \ref{Bell} is the usual example of a non-disturbing contextual model in quantum mechanics.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 8cm 0cm 0]{CCC5.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$bc$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} \\
\hline
\large{$cd$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} \\
\hline
\large{$da$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} \\
\end{tabular}
    \caption{(Left) The visualization of the Bell model through its bundle diagram. This model has only global events, and the contextual behaviour only appears because of the impossibility to explain it with positive real numbers. (Right) Table of outcome probabilities of each context for the Bell model.}
    \label{Bell}
\end{figure}
The $ab$ local section is trivial, but the others have probabilities that remember the liar cycle. In this sense, this model can be understood as a combination of a trivial model and three PR boxes. Such decomposition is in agreement with the non-contextual fraction $NCF=\frac{3}{4}$, therefore the Bell model is a $\mathbb{R}^{+}$-contextual model. As one can see by its bundle diagram, all events are defined as a restriction of a global event. For this reason, the Bell model is an example of probabilistic contextuality, contextual behaviour only appears when dealing with the measures.
\end{example}

\section{Topology of $R$-fibrations}
\label{Topology of $R$-fibrations}

\subsection{Necessary condition to contextual behavior}
\label{Necessary condition to contextual behavior}

A result discovered before the notion of contextuality being defined, due to Voroby'ev \cite{Vorobyev_1962}, is the characterization of a necessary but not sufficient condition in the measurement scenario to be part of a contextual empirical model. The theorem is linked with the notion of cyclicity, in the sense of Graham's decomposition.

\begin{definition}
A hypergraph $\left(X,\mathcal{C}\right)$ is said acyclic if it can be reduced to the empty set through the Graham's decomposition, algorithm given by the repeated application of the following operations:
\begin{itemize}
\item if $m\in X$ such that it belongs to a single hyperedge, then delete $m$ from this hyperedge;
\item if $V \subsetneq U$, with $V,U \in \mathcal{C}$, then delete $V$ from $\mathcal{C}$.
\end{itemize}
\end{definition}

The interpretation of Graham's decomposition algorithm is to "forget" contexts that can be described by others, as a coarse-graining of contexts. Contextuality depends on maximal contexts and their intersections, as one can see by the contextual fraction algorithm. Graham's decomposition deletes minimal measurements that aren't intersections, and contexts that aren't maximal or minimal. In this sense, acyclic scenarios allow themselves to be simplified arbitrarily, while cyclic scenarios do not, requiring a more detailed analysis of this "defect" that we call contextuality. For this reason, Graham's decomposition does not preserve the simple complex structure of the measurement scenario. As obtained in Ref. \cite{Karvonen_2019}, being acyclic induces morphisms - there linked with simplification of the object - from the terminal object of the category of empirical models.

\begin{figure}
    \centering
    \includegraphics[height=0.1\textwidth]{Vorobev1.png}
    \caption{Graham decomposition of a filled triangle. The steps are: to exclude the edges; to exclude the isolated vertices; finally to exclude the interior (there is no vertices). The result is the empty set, therefore the hypergraph is acyclic.}
    \label{Vorobev1.png}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[height=0.1\textwidth]{Vorobev0.png}
    \caption{Graham decomposition of a triangle with barycentric subdivision. The first and unique allowed step is to exclude the edges. There isn't any other possible step, therefore the hypergraph is cyclic.}
    \label{Vorobev0.png}
\end{figure}

The property of being cyclic, although it appears to be a topological property in the sense of capturing "holes" in the hypergraph, is not a topological invariant, as can be seen by the example in Fig. \ref{Vorobev1.png} and Fig. \ref{Vorobev0.png}. The triangle of Fig. \ref{Vorobev1.png} is simply connected, and therefore collapsible, besides it is acyclic. In the case of the triangle with barycentric subdivision of Fig. \ref{Vorobev0.png}, despite being simply connected and therefore collapsible, in addition to being homeomorphic to the previous case, it is not an acyclic hypergraph and can be a measurable scenario for an empirical model.

\begin{theorem}[Voroby'ev theorem]
If an empirical model has an associate hypergraph acyclic, then it is non-contextual.
\end{theorem}

In short, contextuality does not follow directly from the topology of the simplicial complex of the measurement scenario\footnote{For different approaches it is possible to relate to the topological aspects \cite{Okay_2020}, but of all the empirical model.}. The example in the Fig. \ref{Vorobev1.png} and Fig. \ref{Vorobev0.png} not only show independence in terms of topology, by detaching the topology of the simplicial complex from its ability to be a base for a contextual measure fibration, it also indicates that the inclusion of freedom (the vertex in the center of the barycentric triangle) is sufficient to allow such behavior.

\subsection{Discrete differential geometry}
\label{Discrete differential geometry}

As a simplicial complex, any measurement scenario allows a study in the formalism of discrete differential geometry \cite{Crane:2013:DGP, grady2010discrete}. A $n$-simplex is treated as a "quanta of space", and the topology follows from the topology of the simplicial complex.

Another feature is the formalism of discrete differential forms, which can be informally thought of as a way to measure the "size" of the simplices. The set of $n$-simplices of a simplicial complex $\textbf{X}$ is denoted by $\mathcal{C}_{n}$.

\begin{definition}
Discrete differential forms are defined as linear duals of the simplices, where we will denote by $\mathcal{C}^{n}$ the set of $n$-forms. If $\bra{\omega}\in\mathcal{C}^{n}$, then we have 
\begin{align}
\begin{split}
  \bra{\omega} \colon \mathcal{C}_{n} &\to R\\
  \ket{S} &\mapsto \left<\omega |U\right>.
 \end{split}
\end{align}
\end{definition}

As our usual notion of contextuality is defined by a fixed $R$-state $P$, and the non-disturbance condition implies that the $R$-measures are well defined, the simplicial complex accept as duals of the simplices the elements of the $\sigma$-algebra of the outcome space $\textbf{O}^{U}$ of the context $U$, therefore 
\begin{equation}
    \bra{\omega}\ket{U}_{P}=P[U](\omega)=\mu_{P}^{U}(\omega)\in R,
\end{equation}
for all $\omega\in\Sigma^{U}$\footnote{In this sense that we are working with measurement contextuality. The state is kept fixed, and the contextual behaviour follows from the relation between events and measurements, here described as contexts. Event and measurement define the notion of effect in operational theories, thus measurement contextuality is the contextuality of effects when the state is fixed.}.

The curvature in the discrete differential geometry will depend on the relationship with parallel transport since there is no differentiability to work directly. Its use is generally for modeling digital structures,  and it is calculated using the angle generated by the transport of the vector normal to the surface. Note however that it is a curvature that describes the geometry of the surface, which can then be understood as immersed in a Euclidean space. Such geometric curvature determines using Stokes' theorem the associated shape, but it has no relation to contextuality. Any description through discrete differential forms comes from the relations between the fibers and does not reflect (at least not directly) the geometric representation of the measurement scenario.

\subsection{$G$-fibrations and triviality}
\label{$G$-fibrations and triviality}

Let's define a way to change the fibers of a fibration.

\begin{definition}
A transformation on the fibers is a measurable application $g:\mathcal{R}\to\mathcal{R}$ of the total space to itself, such that for any local coordinate $(b,e)\in E$, with $b$ and $e$ elements of the base and the fiber, respectively, $g(b,e)=(b,e')$ (it acts on the fibers). The set of all such transformations will be denoted by $G$.
\end{definition}

We suppose the base and the fibers have topology, $G$ is a continuous monoid action (a monoid satisfies almost all group properties and may violate invertibility, i.e., it is a semigroup with identity) with the topology of the total space $E$, and the projection on the base $\pi$ is continuous. With these assumptions, $G$ becomes a topological monoid if its elements are continuous.

Weak-homotopy equivalence between two topological spaces can be seen as the equivalence of their shapes. Formally, two topological spaces are weak-homotopy equivalents if their homotopy groups are isomorphic. Let's separate the fibers by weak-homotopy equivalence, getting disjoint components, and work with path-connected components. For each connected component, we have the following definition \cite{Felix_1995}.

\begin{definition}
Given a topological monoid $G$, a $G$-fibration is a fibration such that the fibers are weak-homotopy equivalents and the continuous action of $G$ preserves the fibers.
\end{definition}

A fibration is called trivial if the independence condition between fibers holds globally. A well-known result of the theory of $G$-fibrations is the following. 

\begin{theorem}
A $G$-fibration is trivial if and only if any local section admits an extension to a global section.
\end{theorem}

We can use this result to characterize the context of a model by the triviality of its fibration if we identify $G$. 

\begin{corollary}
A $R$-measure $G$-fibration is $R$-non-contextual if and only if it's trivial.
\end{corollary}

It follows from the non-contextuality by section: the triviality of a $G$-fibration is equivalent to extendability of a local section to a global one, and as it is one of the equivalent notions of contextuality given by the Fine–Abramsky–Brandenburger theorem, we have the equivalence between $R$-non-contextuality of the model and triviality of its respective $R$-measure $G$-fibration.

\subsection{Topological dependence and $n$-contextuality}
\label{Topological dependence and $n$-contextuality}

The intuitive idea of this section is to follow the recipe for building a simple complex, increasing the dimension of the simplices to be included in each step, and study the dependence on contextuality. Starting with vertices, we know that the scenario is acyclic, and therefore not contextual.

For the inclusion of edges, we know that contextuality appears, as was already shown in examples. Its verification can be done many times by reasoning that takes one measurement in another until it returns to the original and finds a contradiction. We will call contextuality with this dependence on points in the measurement scenario $1$-contextuality. The question is whether there is contextuality for $n>1$ without $1$-contextuality. The next example shows that it does.

\begin{example}
An example of a measurement scenario that has non-trivial cyclicality is given by the border of a tetrahedron, with only the four vertices, six edges, and four faces. The table below has the probabilities of obtaining certain outputs within maximal contexts, as is common in the literature. In it, we have the encoding of a measure fibration with identical fibers, each with two outputs $\left\{0,1\right\}$, and base with contexts represented by the boundary of a tetrahedron, with measurements $\left\{a,b,c,d\right\}$.
\begin{equation}
\begin{tabular}{ c|c|c|c|c|c|c|c|c } 
& \large{$000$} & \large{$001$} & \large{$010$} & \large{$011$} & \large{$100$} & \large{$101$} & \large{$110$} & \large{$111$}\\
\hline
\large{$abc$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$abd$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$acd$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\hline
\large{$bcd$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\end{tabular}
\end{equation}
As one can see, the probabilities in any subcontext represented by the edges are maximally random, implying non-contextuality for each face. There is concordance between them, making it be a non-disturbing empirical model. But as can be seen using a measure of contextuality, such as the contextual fraction \cite{Abramsky_2017}, it is a contextual empirical model. In conclusion, the contextual behavior of this model does not originate in the structure of $1$-simplices, but from the $2$-simplices structure.
\label{Tetra}
\end{example}

The $n$-contextuality appears as the contextuality generated by including $n$-simplices, or equivalently when the model is explored with $n$-dimensional structures. One way of doing this exploration is through the contextual fraction (see the Appendices) when changing the maximal contexts of the model. For non-disturbing models, $1$-contextuality behavior will appear if we measure contextual fraction with $1$-simplices as the maximal contexts. The $2$-contextual behavior appears if the measure of contextuality changes due to the change of the maximal contexts to $2$-simplices. We can do this procedure inductively until the maximal contexts of the model. Thus, $n$-contextuality occurs when we cannot reduce the dimension of the simplicial complex without losing certain information about the model's contextuality, a kind of irreducible behavior.

A question that can be asked is whether quantum theory presents any examples of $n$-contextuality. Quantum theory has a well-known example for all $n$.

\begin{example}
The $n$ dimensional GHZ model is a scenario with $n+1$ parts, each with two measurements and fibers with two elements. For $n=1$ we have the Bell scenario, while for $n=2$ has an octahedron shape. The model is fixed when choosing the state
\begin{equation}
    \ket{GHZ}=\frac{\ket{0}^{\otimes (n+1)}+\ket{1}^{\otimes (n+1)}}{\sqrt{2}}
\end{equation}
which is maximally entangled. By the theorem \ref{FAB} and the structure of the possible measurements in quantum theory, it is always possible to find a set of measurements that presents contextuality for this model. The marginalized measures are maximally uniform (a reflection of the state's non-biseparability), and therefore the contextuality doesn't appear in simplices of a smaller dimension than $n$.
\end{example}

The case of the GHZ model in octahedron is well known, and its usual version has the table of joint probabilities
\begin{equation}
\begin{tabular}{ c|c|c|c|c|c|c|c|c } 
& \large{$000$} & \large{$001$} & \large{$010$} & \large{$011$} & \large{$100$} & \large{$101$} & \large{$110$} & \large{$111$}\\
\hline
\large{$ABC$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\hline
\large{$ABc$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$}\\
\hline
\large{$AbC$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$}\\
\hline
\large{$Abc$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$aBC$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$}\\
\hline
\large{$aBc$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$abC$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$abc$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$}\\
\end{tabular}
\end{equation}
which can be verified by contextual fraction that it is a strong contextual model ($NCF=0$). Another example also with strong contextuality, but super-quantum, that inspired the tetrahedron model in example \ref{Tetra} is the Svetlichny's box
\begin{equation}
\begin{tabular}{ c|c|c|c|c|c|c|c|c } 
& \large{$000$} & \large{$001$} & \large{$010$} & \large{$011$} & \large{$100$} & \large{$101$} & \large{$110$} & \large{$111$}\\
\hline
\large{$ABC$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$ABc$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$AbC$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$Abc$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\hline
\large{$aBC$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$aBc$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\hline
\large{$abC$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\hline
\large{$abc$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\end{tabular}
\end{equation}
which also has maximally uniform marginals, and therefore only presents contextuality in dimension $n=2$.

An open question is whether the contextual fraction always increases with the inclusion of larger simplices.

\begin{conjecture}
The contextual fraction cannot decrease with the increase of the hierarchy of $n$-contextuality.
\end{conjecture}

Another interesting result is the apparent dependence on the topology of the measurement scenario, but in a different way than the one suggested in Ref. \cite{Terra_2019_FibreBundle}. In Ref. \cite{Dzhafarov_2020} we have the example of an empirical model in a barycentric triangle, which ends up being a sub-model of the tetrahedron presented in example \ref{Tetra}. In it the face $abc$ is forgotten, and the non-contextual fraction is $NCF=\frac{1}{2}$, whereas the complete tetrahedron presents $NCF=\frac{1}{4}$. We have two options: either the face adds $\frac{1}{4}$ of contextuality in the model, or it happens due to the change in topology.

To test the possibilities, it is possible to study the local sections on the face, since the marginals are maximally uniform. Realizing that possible local sections in the triangle satisfy the system of linear equations
\begin{equation}
    \sum_{x}p(x,y,z|a,b,c)=p(y,z|b,c)
\end{equation}
\begin{equation}
    \sum_{y}p(x,y,z|a,b,c)=p(x,z|a,c)
\end{equation}
\begin{equation}
    \sum_{z}p(x,y,z|a,b,c)=p(x,y|a,b)
\end{equation}
\begin{equation}
    \sum_{x,y,z}p(x,y,z|a,b,c)=1
\end{equation}
that are valid for non-perturbation (which basically says that the probabilities at the vertices are independent of the contexts, and therefore depend only on the vertex), in addition to the probability condition, we obtain that the triangle $abc$ has generic section on the face given by the vector
\begin{equation}
\left(\frac{1}{4}-\eta,\eta,\eta,\frac{1}{4}-\eta,\eta,\frac{1}{4}-\eta,\frac{1}{4}-\eta,\eta\right) 
\end{equation}
with $\eta\in[0,\frac{1}{4}]$, with the maximally uniform occurring in $\eta=\frac{1}{8}$. However, as it can be calculated, add a face to the model, obtaining the generic case
\begin{equation}
\begin{tabular}{ c|c|c|c|c|c|c|c|c } 
& \large{$000$} & \large{$001$} & \large{$010$} & \large{$011$} & \large{$100$} & \large{$101$} & \large{$110$} & \large{$111$}\\
\hline
\large{$abc$} & \large{$\frac{1}{4}-\eta$} & \large{$\eta$} & \large{$\eta$} & \large{$\frac{1}{4}-\eta$} & \large{$\eta$} & \large{$\frac{1}{4}-\eta$} & \large{$\frac{1}{4}-\eta$} & \large{$\eta$}\\
\hline
\large{$abd$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$}\\
\hline
\large{$acd$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\hline
\large{$bcd$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$\frac{1}{4}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{4}$}\\
\end{tabular}
\end{equation}
where contextuality remains the same, with $NCF=\frac{1}{4}$, corroborating the option of topological dependency. A formalization of this dependency must be constructed so that something more can be said about this result, and it's beyond the scope of this paper.

Finally, the definition of $n$-contextuality raises the possibility of also study the disturbance with its dependence on the dimension of the simplicial complexes. We will call this hierarchy $n$-disturbance, and just like $n$-contextuality, it encodes the irreducibility that a model presents concerning the dimension of the measurement scenario. A deeper study of these hierarchies would be interesting, it being a path for future work.

\section{Exploring $1$-contextual models}
\label{Exploring $1$-contextual models}

\subsection{Contextual connection}
\label{Contextual connection}

For the rest of the paper, we will investigate contextuality restricting ourselves to contexts with two atomic measurements, and probabilistic states. The following construction is about connections, therefore $1$-forms on the simplicial complex.

An application to codify the transport from one vertex to another must be linear by a convexity argument, and its information lies in the measure on the context's events. From now on, we will talk about probabilistic empirical models, therefore $R=[0,1]$, implying that such an application is a Markov kernel.

\begin{definition}
A path operator is an application $T:\mathcal{C}_{1}\otimes_{\mathcal{C}_{0}}\mathcal{C}_{0}\to\mathcal{K}$, that leads an $1$-simplex and a vertices of it to a Markov kernel $T_{nm}:\mathcal{D}\left(\textbf{O}^{m}\right)\to\mathcal{D}\left(\textbf{O}^{n}\right)$.
\end{definition}

One property that can be noticed is that the joint measure does not choose a direction in the $1$-simplex, which must be chosen when introducing one of the vertices as an initial. It is the discrete version of choosing a point and a direction in a variety and obtaining the rule of changing some property in that direction. Note, however, that $T_{nm}T_{mn} $ is not necessarily the identity.

\begin{definition}[Connection]
A connection is defined as
\begin{equation}
\mathbb{T}:\Gamma\left(\mathcal{C}_{0}\right)\to\Gamma\left(\mathcal{C}_{1}\otimes_{\mathcal{C}_{0}} \mathcal{C}_{0}\right)
\end{equation}
where $\Gamma\left(\mathcal{C}_{0}\right)$ is the collection of sections on elements of $\mathcal{C}_{0}$, and $\Gamma\left(\mathcal{C}_{1}\otimes \mathcal{C}_{0}\right)$ is the set of linear applications with the form
\begin{align}
\begin{split}
  T \colon \mathcal{C}_{1}\times_{\mathcal{C}_{0}}\Gamma\left(\mathcal{C}_{0}\right) &\to \Gamma\left(\mathcal{C}_{0}\right)\\
  \left(\left\{m,n\right\},s^{P}_{m}(m)\right)=\left(\left\{m,n\right\},\left(m,\textbf{O}^{m},\mu_{P}^{m}\right)\right) &\mapsto \left(n,\textbf{O}^{n},T_{nm}\mu_{P}^{m}\right)=s_{n}^{P'},
\end{split}
\end{align}
 with $T_{nm}:\mathcal{D}\left(\textbf{O}^{m}\right)\to\mathcal{D}\left(\textbf{O}^{n}\right)$ the Markov kernel. $T$ is called a path transformation.
\end{definition}

The path transformation is the version of the path operator that works with the sections, and not with just the base space, and includes it as a simplification. The connection defined here is the discrete equivalent of the usual connection of differential geometry. 

The contextual connection will be the case where the connection is constructed with the information of the joint measure of the $1$-simplex. Given a context $\left\{m,n\right\}$ with two minimal contexts $m$ and $n$, the allowed path transformations has the form \begin{align}
\begin{split}
  T \colon \mathcal{C}_{1}\times_{\mathcal{C}_{0}}\Gamma\left(\mathcal{C}_{0}\right) &\to \Gamma\left(\mathcal{C}_{0}\right)\\
  \left(\left\{m,n\right\},s^{P}_{m}(m)\right)=\left(\left\{m,n\right\},\left(m,\textbf{O}^{m},\mu_{P}^{m}\right)\right) &\mapsto \left(n,\textbf{O}^{n},T_{nm}\mu_{P}^{m}\right)=\left(n,\textbf{O}^{n},\mu_{P}^{mn}|_{n}\right)=s_{mn}^{P}|_{n}.
\end{split}
\end{align}

The connection defines a transformation in both the fibers and the base. Due to the local independence of the fiber, we can separate the horizontal and vertical parts. The change in the fibers need to be extracted from the Markov kernels, but different fibers imply that the composition is not a globally well-defined product in the set of Markov kernels\footnote{They will form a category, knows as the Markov category \cite{PANANGADEN1999171}.}. With the proper choice of fibers and topology, the vertical part is described by the set of Markov kernels: the equivalence between the Markov kernel and the path transformation follows if the fibers are homeomorphic (generically denoted by $\textbf{O}$). Only with this condition, we get a topological monoid, that we identify with $G$. 


We will call a measure fibration that satisfies the properties presented in this section a measure $G$-bundle, once it satisfies then the condition of $G$-bundle \cite{Souza_2020} (it's a language abuse, $G$ isn't a group). With this, we get the next corollary.

\begin{corollary}
A measure $G$-bundle, with $G$ the monoid described by the contextual connection $T$, is non-contextual if and only if it's trivial.
\end{corollary}

As we will see explicitly in the examples, the joint measure on a $1$-simplex has just enough information to construct its Markov kernels (one for each direction), and vice versa.

\subsection{Parallel transport in $1$-contextual models}
\label{Parallel transport in $1$-contextual models}

We will first study the case of finite fiber $R$ with $n$ elements. In this case, as described in Ref. \cite{amaral2017geometrical}, we can describe a probabilistic measure as a vector living in $\mathbb{R}^{d}$ in some fixed basis, such that the conditions of probabilistic distributions holds (non-negative entries that sum to one). Since the fibers are the same, the Markov kernels are stochastic matrices that represent the change in these vectors (a linear operator such that the probabilistic properties are preserved). But as one can see, the basis of the vector space can change, and the connection doesn't need to be trivial.

With this description, we can identify the measure bundle as a vector bundle \cite{Lang1995}, with $\mathcal{D}\left(\textbf{O}\right)=\mathbb{R}^{d}$ as fibers, but the vectors accessible by a section are restricted to probabilistic ones. The basis for each fiber is fixed, to keep the probabilistic properties, as an intrinsic property of the fiber, not previously related with the vector.

Let's study what kind of kernels the non-disturbance condition allows in the vertices. The passage from a context to another can be described by a transition function, which will be view in more detail in the study of disturbing empirical models. For now, the transition between two contexts can be seen as a Markov kernel $T_{mm}$ such that 
\begin{equation}
T_{mm}\left(\mu_{P}^{n_{i}m}|_{m}\right)=\left(\mu_{P}^{n_{f}m}|_{m}\right),
\end{equation}
but that preserve the structure of $\textbf{O}^{m}$. Since $T_{mm}$ is a linear application that takes a vector that represents a measure to another, and the basis of the vector space, the transformation allowed by the non-disturbance condition needs not just to preserve the distribution, but also the basis of the vector space because the fiber of outcomes is the same. Thus the Markov kernels that are allowed have the general form $T_{mm}=ODO^{T}$, with $O$ an orthogonal matrix and $D$ a diagonal matrix with entries $0$'s or $1$'s, the definition of an idempotent matrix.

For the general case of a path transformation, the stochastic matrix can be singular value decomposed in an orthogonal part, the group $G=O(d)$ of the principal $G$-bundle describing the transformations between frames, and a diagonalizable matrix, that codifies the forgetting information through the path. Therefore by matrix diagonalization through singular value decomposition, we can extract a $O(d)$ element for each stochastic matrix, 
\begin{equation}
T_{mn}=U\Sigma V^{T}=\left(U\Sigma U^{T}\right)\left(UV^{T}\right),
\end{equation}
where the matrix $U$ is the eigenvector matrix with the orthonormal basis of $T_{mn}T^{T}_{mn}$, the matrix $V$ is the eigenvector matrix with the orthonormal basis of $T^{T}_{mn}T_{mn}$, and $\Sigma$ is the diagonal matrix with the singular values as the diagonal entries. We identify $UV^{T}$, that effectively charge the basis of the vector space, as an element of $G$ that changes the outcome fiber due to a path transformation, and define a monoid homomorphism 
\begin{align}
\begin{split}
    \Phi:\mathbb{M}(d) &\to O(d)\\
    M &\mapsto UV^{T}
\end{split}
\end{align}
of the stochastic matrices to the orthogonal group, both defined in $\mathbb{R}^{d}$. As one can see, there will be problems when dealing with singular stochastic matrices, as they erase part of the original information.

Parallel transport on the measure bundle is the composition of the stochastic matrices from an initial vertex through a path of $1$-simplices to a final one, by two different paths. In the end, a comparison of the information transported is made. The information here is the basis of the vector space, or equivalently the frame in the frame bundle.

\begin{theorem}[Parallel transport and contextuality: finite case]
If a $G$-bundle satisfying the non-disturbance condition and with non-singular stochastic matrices is non-contextual, then for any two paths $I^{b}_{a}$ and $I'^{b}_{a}$ with the same initial and final vertices, holds 
\begin{equation}
\prod_{I_{a}^{b}}\Phi\left(T_{a_{i}a_{i+1}}\right)=\prod_{I'^{b}_{a}}\Phi\left(T_{a_{i}a_{i+1}}\right).
\end{equation}
\end{theorem}

\begin{proof}
Let a non-contextual empirical model satisfying the non-disturbance condition and being non-contextual. The non-disturbance condition implies the extension to a global section of the measures. Its measure fibration admits a monoid such that a homomorphism $\Phi$ can be reduced to a group $G=O(d)$, turning the measurable fibration in a $G$-bundle. By theorem \ref{FAB}, we have a global section 
\begin{equation}
s^{P}_{X}=\left(U,\textbf{O}^{X}|_{U},\mu^{X}_{P}|_{U}\right).
\end{equation}
As all the outcome fibers are the same, we can write a local section on a measurement $a$ as being transported through a path $I_{a}^{b}$ as
\begin{equation}
\left(b,\textbf{O},\prod_{I_{a}^{b}}T_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\mu^{a}_{P}\right),
\end{equation}
and through a path $I'^{b}_{a}$ as
\begin{equation}
\left(b,\textbf{O},\prod_{I'^{b}_{a}}T_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\mu^{a}_{P}\right).
\end{equation}
By the non-disturbance condition, the phase of the parallel transport will be given by a change in the outcome space, but by global section the bundle must be trivial, implying in the equality
\begin{equation}
\prod_{I_{a}^{b}}\Phi\left(T_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\right)=\prod_{I'^{b}_{a}}\Phi\left(T_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\right).
\end{equation}
\end{proof}

For a non-finite outcome space, the interpretation of a vector space it's more subtle, but we can do a similar construction. Suppose that the Markov kernels $T_{mn}=\omega(x,y)$ are square integrable on all the outcome fiber $O$. We can define
\begin{equation}
\omega_{1}(x,y)=\int_{R}\omega(x,z)\omega(y,z)dz
\end{equation}
and
\begin{equation}
\omega_{2}(x,y)=\int_{R}\omega(z,x)\omega(z,y)dz,
\end{equation}
that are symmetric and positive defined. Using the Mercer's theorem \cite{devito2011extension}, they can be rewritten as 
\begin{equation}
\omega_{1}(x,y)=\sum_{j}\alpha_{j}u_{j}(x)u_{j}(y)
\end{equation}
and
\begin{equation}
\omega_{2}(x,y)=\sum_{j}\alpha_{j}v_{j}(x)v_{j}(y).
\end{equation}
One can show that
\begin{equation}
\omega(x,y)=\sum_{j}\sqrt{\alpha_{j}}u_{j}(x)v_{j}(y).
\end{equation}
Therefore the map $\Phi:\mathbb{M}\to\mathbb{M}$ can be defined as $\Phi\left(\omega(x,y)\right)=\sum_{j}u_{j}(x)v_{j}(y)$. With this, we can prove the next theorem similarly to the finite case.

\begin{theorem}[Parallel transport and contextuality: non-finite case]
If a $G$-bundle satisfying the non-disturbance condition, with square integrable Markov kernels and non-singular stochastic matrices is non-contextual, then for any two paths $I_{a}^{b}$ e $I'^{b}_{a}$ with the same initial and final vertices, holds
\begin{equation}
\prod_{I_{a}^{b}}\Phi\left(T_{a_{i}a_{i+1}}\right)=\prod_{I'^{b}_{a}}\Phi\left(T_{a_{i}a_{i+1}}\right).
\end{equation}
\label{Parallel}
\end{theorem}

\subsection{Contextual holonomy}
\label{Contextual holonomy}

Another way to codify non-trivial parallel transport, and so $1$-contextuality is by the holonomy group, that is non-trivial if and only if there is at least one non-trivial phase of the parallel transport through a loop. Given a loop $\gamma$ with fixed point $x$ in the simplicial complex, we define the function $P_{\gamma}:\mathcal{D}\left(\textbf{O}\right)\to\mathcal{D}\left(\textbf{O}\right)$ as $P_{\gamma}=\prod_{\gamma}\Phi\left(T_{a_{i}a_{i+1}}\right)$. We know that $P_{\gamma}\in GL\left(\mathcal{D}\left(\textbf{O}\right)\right)$.

\begin{definition}
The group $Hol_{x}(T)=\left\{P_{\gamma}\in GL\left(\mathcal{D}\left(\textbf{O}\right)\right)|\gamma\text{ is a loop based at }x\right\}$ is called the holonomy group at the vertex $x\in\mathcal{C}^{-}$ of the connection $T$.
\end{definition}

The holonomy group will codify the phase of the non-trivial parallel transport as a subgroup generated in a fixed loop, by repeating it. Also notice that $Hol_{x}(T)\in O(d)$, and the independence of a point in the loop, since a transformation of similarity is enough to change the point, without changing the group. As a consequence, we can then get the following.

\begin{theorem}
If an empirical model is $1$-non-contextual and doesn't present a singular path, then it has a trivial holonomy group for the contextual connection.
\label{Holonomy}
\end{theorem}

Again, models with singular paths must be omitted, as they can erase contextual behavior by losing information. The reciprocal of this theorem is false: it is possible to obtain contextual models with a trivial holonomy group. Both cases will appear in examples in the next section.

We can express the theorem \ref{Holonomy} through the logical statement $NC\wedge NS\implies TH$, where NC is non-contextual, NS is non-singularity, and TH is trivial holonomy. The negative, $H\implies C\lor S$ says that holonomy as defined or indicates contextuality or singularity in the model, which erases contextuality. It may be that the holonomy used is too coarse, as it fixes the elements of the outgoing fiber as the base of the vector space. For this reason, it doesn't fully capture contextuality in non-singular models, in addition to the singularity having a strange behavior regarding contextuality\footnote{This is a problem when using group structures to study semi-ring measures. Something is forgotten, and a different framework is necessary, see Ref. \cite{montanhano2021contextuality}.}. One can speculate if higher holonomy groups can do an equivalent condition for higher contextual behaviors. 

The examples of the next section will have measurement scenarios encoded in graphs, and cannot have $n$-contextuality for $n>1$. In these cases, we can use the previous results to verify the necessary conditions for contextual behavior. Suppose a $1$-simplex with vertices $a$ and $b$, and to make it even simpler let's follow the examples, assuming only two elements ${0,1}$ in the fibers. As a context, there are the probabilities that each mutual result will occur, denoted by $p(i,j|a,b)$, with $i,j\in{0,1}$. We can construct the matrix of such probabilities $M^{(a,b)}_{ij}$, which has no notion of transport from one vertex to another. As we assume the action to the left of the Markov kernel of the path transformation, the origin vertex indexes the lines of the stochastic matrix. Besides, columns are normalized. In this way, the kernel will have forms dependent on the direction chosen in the $1$-simplex, following the previous rules for the treatment of $M^{(a,b)}_{ij}$. We get by taking $a$ as the origin of the transport
\begin{equation}
    T^{a\to b}_{ij}=\frac{M^{(a,b)}_{ij}}{\sum_{i}M^{(a,b)}_{ij}}=\frac{p(i,j|a,b)}{\sum_{i}p(i,j|a,b)}=\frac{p(i,j|a,b)}{p(j|b)}=p(i|j;a,b)
\end{equation}
and taking $b$ as the origin of the transport
\begin{equation}
    T^{b\to a}_{ji}=\frac{\left(M^{(a,b)}_{ij}\right)^{T}}{\sum_{i}M^{(a,b)}_{ij}}=\frac{p(i,j|a,b)}{\sum_{j}p(i,j|a,b)}=\frac{p(i,j|a,b)}{p(i|a)}=p(j|i;b,a).
\end{equation}
When there isn't doubt, the direction will be omitted.

\subsection{Examples}
\label{Examples}

\begin{example}[Trivial model] 
The example of Fig. \ref{Trivial bundle} has kernels
\begin{equation}T_{ij}=\begin{bmatrix}
1 & 0\\
0 & 1
\end{bmatrix},\end{equation}
implying $\Phi\left(T_{ij}\right)=id$, therefore
\begin{equation}\prod_{I_{x}}\Phi\left(T_{ij}\right)=id.\end{equation}
By non-disturbance, $\Phi\left(t_{xx}\right)=id$. The holonomy group of this example is trivial, in agreement with the non-contextual behaviour of this model.
\end{example}

\begin{example}[Liar cycle, PR box model]
For the example of Fig. \ref{Liar cycle}, following the construction of the stochastic matrices, we get
\begin{equation}
T_{ab}=T_{bc}=T_{cd}=T_{de}=\begin{bmatrix}
1 & 0\\
0 & 1
\end{bmatrix},\end{equation}
therefore $\Phi\left(T_{ij}\right)=id$ for these contexts, but for the last one
\begin{equation}T_{ea}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}\end{equation}
and $\Phi\left(T_{ea}\right)=T_{ea}$. As $\Phi\left(t_{xx}\right)=id$ for non-disturbing models, we get
\begin{equation}
\Phi\left(\prod_{I_{x}}T_{ij}\right)=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}\neq id.\end{equation}
The holonomy group is non-trivial, $Hol_{x}\left(T\right)=\mathbb{Z}_{2}$, because $\Phi\left(\prod_{2nI_{x}}T_{ij}\right)=id$ and $\Phi\left(\prod_{(2n+1)I_{x}}T_{ij}\right)=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}$, with $n\in\mathbb{Z}$, in agreement with the contextual behaviour of the model.
\end{example}

\begin{example}[KCBS model]
The example of Fig. \ref{KCBS} has stochastic matrices
\begin{equation}
T_{ij}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}
\end{equation}
for all contexts, resulting in $\Phi\left(\prod_{I_{x}}T_{ij}\right)=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}\neq id$, in agreement with its contextual behaviour. For the same reason of the PR box, the holonomy group is $Hol_{p}\left(T\right)=\mathbb{Z}_{2}$.
\end{example}

\begin{example}[Hardy model]
Previously examples were simple, in the sense that $\Phi$ changed nothing in the stochastic matrices. The example of Fig. \ref{Hardy} is different. The stochastic matrices are
\begin{equation}
T_{ab}=\begin{bmatrix}
\frac{2}{8} & 1\\
\frac{6}{8} & 0
\end{bmatrix}, T_{bc}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}, T_{cd}=\begin{bmatrix}
\frac{1}{2} & 1\\
\frac{1}{2} & 0
\end{bmatrix}, T_{de}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}, T_{ea}=\begin{bmatrix}
\frac{2}{3} & 1\\
\frac{1}{3} & 0
\end{bmatrix},
\end{equation}
and doing the singular value decomposition and applying $\Phi$, we get 
\begin{equation}
\Phi\left(T_{ea}T_{de}T_{cd}T_{bc}T_{ab}\right)= \begin{bmatrix}
\frac{4}{5} & \frac{3}{5}\\
\frac{3}{5} & -\frac{4}{5}
\end{bmatrix},
\end{equation}
different of the identity implied by non-disturbance. By the same reason of the PR box, the holonomy group is $Hol_{p}\left(T\right)=\mathbb{Z}_{2}$, a result of its contextual behaviour.
\end{example}

\begin{example}[Bell model]
The stochastic matrices of Fig. \ref{Bell} are given by
\begin{equation}
T_{ab}=\begin{bmatrix}
1 & 0\\
0 & 1
\end{bmatrix}, T_{bc}=T_{cd}=\begin{bmatrix}
\frac{3}{4} & \frac{1}{4}\\
\frac{1}{4} & \frac{3}{4}
\end{bmatrix}, T_{de}=\begin{bmatrix}
\frac{1}{4} & \frac{3}{4}\\
\frac{3}{4} & \frac{1}{4}
\end{bmatrix}, T_{ea}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix},\end{equation}
and $\Phi\left(T_{ea}T_{de}T_{cd}T_{bc}T_{ab}\right)=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix}$. Therefore  $Hol_{p}\left(T\right)=\mathbb{Z}_{2}$.
\end{example}

\begin{example}[Maximally random model]
All the previously examples have non-singular stochastic matrices. This one, Fig. \ref{Homogeneous}, is the extreme case of singular paths.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 8cm 0cm 0]{CCC6.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\hline
\large{$bc$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\hline
\large{$cd$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\hline
\large{$da$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\end{tabular}
    \caption{(Left) The visualization of the maximally random model through its bundle diagram. This model has all possible global sections of its scenario. (Right) Table of outcome probabilities of each context for the maximally random model model.}
    \label{Homogeneous}
\end{figure}
Taking all the stochastic matrices as the same, 
\begin{equation}
T_{ij}=\begin{bmatrix}
\frac{1}{2} & \frac{1}{2}\\
\frac{1}{2} & \frac{1}{2}
\end{bmatrix},
\end{equation}
a idempotent matrix, we get $\Phi\left(T_{ij}\right)=id$, a non-contextual behaviour (which is confirmed by the contextual fraction), and a trivial holonomy group. 
\end{example}

\begin{example}[Modified Bell model]
Bell model has a trivial path transformation, and in the modified model of Fig. \ref{Modified Bell} we change it to a "liar" path transformation. The point here is to show that a local change can force contextuality to vanish, and we can still have a non-contextual non-disturbing model.
\begin{figure}[h]
    \centering
\includegraphics[height=0.15\textwidth, trim= 0cm 8cm 0cm 0]{CCC3.png}
\hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\hline
\large{$bc$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} \\
\hline
\large{$cd$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} \\
\hline
\large{$da$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} \\
\end{tabular}
    \caption{(Left) The visualization of the modified Bell model through its bundle diagram. It's explicit the change of the local section of the context $ab$. (Right) Table of outcome probabilities of each context for the modified Bell model.}
    \label{Modified Bell}
\end{figure}
We just change $T_{ab}$ of the Bell model to
\begin{equation}
T_{ab}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix},
\end{equation}
clearly modifying the product to $T_{ea}T_{de}T_{cd}T_{bc}T_{ab}=id$, what is preserved by $\Phi$. The holonomy group is trivial, and the model is non-contextual, agreeing with the contextual fraction.
\end{example}

\begin{example}["Liar in maximally random" models]
Another modification of a previously example. The model of Fig. \ref{Contextual Homogeneous} modify a context of the homogeneous example, with the objective to show that even if the holonomy group is non-trivial, it is still possible for the model to be non-contextual.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 8cm 0cm 0]{CCC3.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$0$} & \large{$\frac{1}{2}$} & \large{$\frac{1}{2}$} & \large{$0$} \\
\hline
\large{$bc$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\hline
\large{$cd$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\hline
\large{$da$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} & \large{$\frac{1}{4}$} \\
\end{tabular}
    \caption{(Left) The visualization of the "liar in maximally random" model with three maximally random paths. Its bundle diagram is the same of the modified Bell model, the difference is in the probabilistic weights. (Right) Table of outcome probabilities of each context for the "liar in maximally random" model with three maximally random paths.}
    \label{Contextual Homogeneous}
\end{figure}
In the maximally random model with three maximally random paths, we change $T_{ab}$ to
\begin{equation}
T_{ab}=\begin{bmatrix}
0 & 1\\
1 & 0
\end{bmatrix},
\end{equation}
which implies $\prod_{I_{x}}\Phi\left(T_{ij}\right)=T_{ab}$, a non-trivial parallel transport. Again and for the same previously reason, $Hol_{p}\left(T\right)=\mathbb{Z}_{2}$. But $NCF=1$, and it's a non-contextual model. We could exchange maximally random paths for identity ones, not modifying the holonomy group. For example, let's change the path $bc$ to the trivial one, $T_{bc}=id$, keeping two maximally random paths. Though contextual fraction one can find that the model is still non-contextual. But if we change another maximally random path, say $cd$, to the trivial one, one gets $NCF=\frac{1}{2}$, implying contextual behavior.
\end{example}

\begin{example}[Counterexample for holonomy]
An example that has no singularity, but has contextuality even though it does not have holonomy, Fig. \ref{Contextual trivial}.
\begin{figure}[h]
    \centering
    \includegraphics[height=0.15\textwidth, trim= 0cm 8cm 0cm 0]{CCC1.png}
    \hspace*{2cm}
    \Large
    \begin{tabular}{ c|c|c|c|c } 
& \large{$00$} & \large{$01$} & \large{$10$} & \large{$11$} \\
\hline
\large{$ab$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$bc$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$cd$} & \large{$\frac{1}{2}$} & \large{$0$} & \large{$0$} & \large{$\frac{1}{2}$} \\
\hline
\large{$da$} & \large{$\frac{3}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{1}{8}$} & \large{$\frac{3}{8}$} \\
\end{tabular}
    \caption{(Left) The visualization of the model that is a counterexample of a reciprocal of the theorems in the previous section. The idea is to keep all edges trivial, except one that has the same probabilities as the Bell model. (Right) Table of outcome probabilities of each context for the model.}
    \label{Contextual trivial}
\end{figure}
For three of the four edges holds $T_{ab}=T_{bc}=T_{cd}=Id$. The remain has the form
\begin{equation}
T_{ab}=\begin{bmatrix}
\frac{3}{4} & \frac{1}{4}\\
\frac{1}{4} & \frac{3}{4}
\end{bmatrix},
\end{equation}
which implies $\prod_{I_{x}}\Phi\left(T_{ij}\right)=Id$, a trivial parallel transport. The holonomy group is trivial, but $NCF=\frac{3}{4}$, and therefore it's a contextual model.
\end{example}

\subsection{Discrete exterior derivative in $1$-contextuality}
\label{Discrete exterior derivative in $1$-contextuality}

Usually, the curvature is given by a differential description, by the algebra of the group $G$. Due to the relation with the holonomy group given by the Ambrose–Singer theorem in the differential case, the curvature in the discrete differential geometry is described as the phase of the parallel transport. But let's formalize the concept of curvature by representing our group in a Lie group, and work with its algebra.

The $\Phi$ image of a Markov kernel will be written as $\Phi\left(T_{nm}\right)=e^{\nabla_{nm}}$, with $\nabla_{nm}$ the average covariant derivative on the $1$-simplex $nm$. We then define the connection of the frame bundle as the $1$-form with values in the Lie algebra $\mathfrak{g}$
\begin{align}
\begin{split}
    \nabla:\mathcal{C}_{1} &\to\mathfrak{g}\\
    nm &\mapsto \nabla_{nm}.
\end{split}
\end{align}
A $1$-form does not act only on the $1$-simplex, but depends on its orientation, here implicit in the ordering $nm$.

Locally, in the sense of belonging to a context, we have a section, therefore a trivial bundle. The connection $1$-form can be write as its vertical and horizontal parts,
\begin{equation}
\nabla_{nm}=\triangle_{nm}+A_{nm}.
\end{equation}
with the horizontal part
\begin{align}
\begin{split}
    \triangle:\mathcal{C}_{1}&\to\mathfrak{g}\\
    nm &\mapsto \triangle_{nm}
\end{split}
\end{align}
and the vertical part
\begin{align}
\begin{split}
    A:\mathcal{C}_{1}&\to\mathfrak{g}\\
    nm &\mapsto A_{nm}
\end{split}
\end{align}
being $1$-forms as well. Due to the local independence, these two parts commute in the group representation, implying that their sum in the algebra representation is well defined.

The product of an $1$-form $\omega$ with a $1$-simplex $nm$ to a Lie algebra will be denoted by
\begin{equation}
    \bra{nm}\ket{\omega}=log\left(e^{\omega\left(nm\right)}\right).
\end{equation}
For example, the vertical part of the connection is
\begin{equation}
\bra{nm}\ket{A}=A_{nm}=log\left(e^{A_{nm}}\right).
\end{equation}
To describe the non-local generalization of this equation, we need to use the formalism of simplicial complexes, where we define the linear operator $\partial$ on a $n$-simplex in the usual way. This allows us to talk about the edge of a region simply connected $S$, given by the sum of $1$-siplices of the edge
\begin{equation}
    \partial S=\sum_{i}a_{i}a_{i+1}
\end{equation}
where $a_{i}a_{i+1}$ are the $1$-simplices that make up the edge. This allows us to write the product over a loop, making sense of the notation $log(exp)$ to symbolize the Baker–Campbell–Hausdorff formula in the case of non-abelianity,
\begin{equation}
    \bra{\partial S}\ket{\omega}=log\left(\prod_{i}e^{\omega\left(a_{i}a_{i+1}\right)}\right). 
\end{equation}
As a example, with $S=abc$ a $2$-simplex, $\partial\left(abc\right)=(ab)+(bc)+(ca)$, and $\bra{\partial (abc)}\ket{A}=log\left(e^{A_{ab}}e^{A_{bc}}e^{A_{ca}}\right)$. For an Abelian algebra $\mathfrak{g}_{f}$, holds the linearity
$\bra{\partial (abc)}\ket{A}=A_{ab}+A_{bc}+A_{ca}$.

We define the operator $d$ as usual for the Abeliancase, following the discrete differential geometry, through Stokes' theorem $\bra{S}\ket{d\omega}=\bra{\partial S}\ket{\omega}$, and for the non-Abelian case, we define $D$ through generalized Stokes' theorem, where we lost the linearity $\bra{S}\ket{D\omega}=\bra{\partial S}\ket{\omega}$. Again in the example,
\begin{equation}
\bra{abc}\ket{dA}=\bra{\partial (abc)}\ket{A}=log\left(e^{A_{ab}}e^{A_{bc}}e^{A_{ca}}\right)=A_{ab}+A_{bc}+A_{ca}
\end{equation}
and for the non-Abelian case,
\begin{equation}
\bra{abc}\ket{DA}=\bra{\partial (abc)}\ket{A}=log\left(e^{A_{ab}}e^{A_{bc}}e^{A_{ca}}\right).
\end{equation}

The $2$-forms $DA$ and $dA$ are the discrete versions of curvature that codify the contextual behaviour. With them we can write to a simply connected surface $S$
\begin{equation}
\bra{\partial S}\ket{\nabla}=\bra{\partial S}\ket{\triangle}+\bra{\partial S}\ket{A}=\bra{\partial S}\ket{A}=\bra{S}\ket{DA},
\end{equation}
where the second equality follows from $\bra{\partial S}\ket{\triangle}$ depends only the base of the bundle. From theorem \ref{Holonomy}, contextuality in a simply connected space only appears if the discrete contextual curvature are non-trivial. But again, it doesn't imply contextuality.

An analogous of the Aharonov–Bohm effect \cite{PhysRev.115.485} appears here as the fact that curvature only capt the holonomy in simply-connected regions, which is characterized by the subgroup $Hol^{0}_{x}\left(\mathbb{T}\right)$ of contractile loops. The effect appears in regions with holes, where the curvature is not defined, but the contextuality behavior happens.

The examples presented in this paper, with exception of the barycentric triangle, have a non-trivial topology. But we can immerse them in a more complex scenario, as the cases studied in Ref. \cite{Abramsky_2017}. As a closed surface, all the loops have an interior, and they are the bounder of a simply-connected surface, and the homology group being non-trivial is equivalent to a non-trivial curvature.

\subsection{Disturbing empirical models}
\label{Disturbing empirical models}

For disturbing empirical models, the marginal measures could be different, and the trivialization of the measure part of the measure $G$-bundle can not be guaranteed. But some construction can be done, with a beautiful generalization.

\begin{definition}
For a disturbing empirical model, the transition function between contexts is defined by the application
\begin{align}
\begin{split}
t_{UV}:\Gamma\left(U\cap V\right)&\to\Gamma\left(U\cap V\right)\\
\left(U\cap V,\textbf{O}^{U\cap V},\mu_{P}^{V}|_{U\cap V}\right)&\mapsto\left(U\cap V,\textbf{O}^{U\cap V},\mu_{P}^{U}|_{U\cap V}\right).
\end{split}
\end{align}
\end{definition}

The transition function $t_{UV}$ is a Markov kernel when describing disturbance in models that can be codified in $1$-simplices, where the intersection is a vertex that links two paths. The disturbance can be understood as a non-trivial contribution of the vertex in the path transformation. Using the same argumentation as before, we get the following generalization. 

\begin{theorem}[Parallel transport and contextuality: disturbing case]
If a $G$-bundle with square integrable Markov kernels and with non-singular stochastic matrices is non-contextual, then for any two paths $I_{a}^{b}$ e $I'^{b}_{a}$ with the same initial and final vertices, holds 
\begin{equation}
\prod_{I_{a}^{b}}\Phi\left(t_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\right)=
\prod_{I'^{b}_{a}}\Phi\left(t_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\right).
\label{Disturbing}
\end{equation}
\end{theorem}

With this result, the extended version of the empirical model in Ref. \cite{Amaral_2019} for disturbing models that can be codified in $1$-simplices is explicit. We can just write an extended empirical model where $t_{a_{i}a_{i}}$ are just another (virtual) context and work in a non-disturbing model.

The holonomy group for $1$-contextual models remains the same. The transition functions need to be taken into account when defining the group, and the description by holonomy remains valid. For a loop, $\gamma$ based in $x\in\mathcal{C}_{0}$ of a measurement scenario, the element of the holonomy group $Hol_x\left(T\right)$ for this loop has the form
\begin{equation}
    Hol\left(\gamma\right)=\prod_{\gamma}\Phi\left(t_{a_{i}a_{i}}T_{a_{i}a_{i+1}}\right).
\end{equation}
For a non-Abelian group, the product order matters, but for Abelian ones, we can write the beautiful equation
\begin{equation}
    Hol\left(\gamma\right)=\prod_{\gamma}\Phi\left(t_{a_{i}a_{i}}\right)\prod_{\gamma}\Phi\left(T_{a_{i}a_{i+1}}\right).
\end{equation}
In this way, we can calculate directly from the table of probabilities for the local sections of contexts with two measurements, and from the transformation data by the disturbance of the model, the elements of the holonomy group.

\newpage
\section{Conclusion}
\label{Conclusion}

The first part of the present paper was a presentation of the fibration approach to contextuality, showing why measurement scenarios are usually encoded in simplicial complexes for non-finite outcome sets. In this approach, the different notions of non-contextuality were unified by Fine–Abramsky–Brandenburger theorem. In the second part, an exploration of the relation of topology and contextual behaviour was done, with the definition of a hierarchy of contextuality. The example of GHZ model shows that all levels of the hierarchy are presented in quantum theory, and the tetraedron scenario gives hints of a relation between non-trivial topology and quantity of contextuality. Finally, the last part explores the first level of the hierarchy, with the identification of a relationship between contextual behavior and holonomy. Such relation permits defining a curvature that appears in contextual models, and a natural extension to disturbing models is also possible, as shown.

One of the questions in Ref. \cite{Terra_2019_FibreBundle} is whether contextuality can be fully described through the first homotopy group or not. As presented here, specifically with the tetraedron scenario and the GHZ models, there is contextuality that depends on higher homotopy groups, culminating in the notion of $n$-contextuality. More work must be done to construct identification tools to turn this concept into a clearer framework.

Tools that use outcome probabilities to identify contextuality already exist, but the contextual connection has a straightforward interpretation of the Markov kernels. There is more space for exploring the relationship of this dynamic with $1$-contextuality. The role of singular paths has to erase contextual behaviors should be better explored, to perhaps enable a concept that identifies contextuality under necessary and sufficient conditions. A known problem with the presented formalism is that the use of group structure isn't natural to relate measures, implying violations in the characterization of contextuality \cite{montanhano2021contextuality}.

Finally, it also allows us to imagine the role of higher holonomy groups in $n$-contextuality. For disturbing models, the codification of extended contextuality in transition functions and its role in the holonomy group culminated in a beautiful result that deserves future attention, as the natural $0$-contextuality. But one must be aware that, besides the group structure violates the natural description of the probabilistic measure, the $\mathcal{C}$ can be more complicated than a simplicial complex construction.

