Challenges
Datasets
Workspaces
Papers
Discussions
Leaderboard
Log inSign up
Challenges
Datasets
Workspaces
Papers
Discussions
Leaderboard
Blog
Job Board
Q3AS

© 2026 Aqora Quantum S.A.S.

TermsPrivacyLegal Notice

arXiv:2609.17294

ConteXtuAlity: an open source Python package for contextuality

Kim Vallée

quant-phSubmitted Sep 15, 2026• Announced Sep 16, 2026
arXivHTMLPDF

Abstract

We present an open source Python package, ConteXtuAlity, for computing various quantities related to contextuality. This package features an interface to the sheaf-theoretic framework for contextuality, providing an implementation of measurement scenarios and empirical models as well as linear programs to compute the contextual fraction and the signalling fraction. In this work, we demonstrate the package's features and give examples of its use. We also provide benchmarks, demonstrating how performances scale with the size of measurement scenarios. The package is designed for both experienced theorists and newcomers to the field of contextuality alike, with an emphasis on flexibility and extensibility.

AI Summary

Queued: an LLM will read the paper as soon as there is capacity.

Comments
22 pages, 2 figures

Related papers

Contextual Fraction as a Measure of Contextuality

Samson Abramsky, Rui Soares Barbosa, Shane Mansfield

We consider the contextual fraction as a quantitative measure of contextuality of empirical models, i.e., tables of probabilities of measurement outcomes in an experimental scenario. It provides a general way to compare the degree of contextuality across measurement scenarios; it bears a precise relationship to violations of Bell inequalities; its value, and a witnessing inequality, can be computed using linear programing; it is monotonic with respect to the "free" operations of a resource theory for contextuality; and it measures quantifiable advantages in informatic tasks, such as games and a form of measurement-based quantum computing.

arXiv:1705.07918•Physical Review Letters•Aug 4, 2017•170 citations

Categories of Empirical Models

Martti Karvonen

A notion of morphism that is suitable for the sheaf-theoretic approach to contextuality is developed, resulting in a resource theory for contextuality. The key features involve using an underlying relation rather than a function between measurement scenarios, and allowing for stochastic mappings of outcomes to outcomes. This formalizes an intuitive idea of using one empirical model to simulate another one with the help of pre-shared classical randomness. This allows one to reinterpret concepts and earlier results in terms of morphisms. Most notably: non-contextual models are precisely those allowing a morphism from the terminal object; contextual fraction is functorial; Graham-reductions induce morphisms, reinterpreting Vorob'evs theorem; contextual models cannot be cloned.

arXiv:1804.01514•Electronic Proceedings in Theoretical Computer Science•Jan 31, 2019•18 citations

Quantum-like contextuality in large language models

Kin Ian Lo, Mehrnoosh Sadrzadeh, Shane Mansfield

Contextuality is a distinguishing feature of quantum mechanics, and there is evidence that it is a necessary condition for quantum advantage in the context of magic state distillation. To harness it, researchers have been asking whether similar phenomena arise in other domains. The answer has been affirmative, e.g. in behavioural sciences. However, one has to adopt frameworks that take some degree of signalling into account. Two such frameworks exist: (i) a signalling-corrected sheaf-theoretic model and (ii) the Contextuality-by-Default (CbD) framework. This paper provides the first large-scale experimental evidence for contextuality in the large language model BERT. We constructed a linguistic schema modelled over a contextual quantum scenario, instantiated it in the Simple English Wikipedia, and extracted probability distributions for the instances. This led to the discovery of 77 118 sheaf-contextual and 36 938 948 CbD contextual instances. We prove that these contextual instances arise from semantically similar words by deriving an equation that relates degrees of contextuality to the Euclidean distance of BERT’s embedding vectors. Our linguistic schema is a variant of the coreference resolution challenge. These results suggest that quantum methods may be advantageous in the field of natural language processing.

arXiv:2412.16806•Proceedings of the Royal Society A Mathematical Physical and Engineering Sciences•Aug 1, 2025•4 citations

Contextual robustness: An operational measure of contextuality

Lu Li, Kaifeng Bu, Junde Wu

The operational characterization of contextuality is the cornerstone in the development of resource theory of contextuality. Here, we introduce contextual robustness as an operational measure of contextuality on empirical models. We first show that it satisfies all the properties a proper contextual measure should satisfy. Besides, we derive the linear programing of contextual robustness and prove that contextual robustness exactly characterizes the maximal violation of certain types of Bell inequalities. Moreover, we show that contextual robustness quantifies the accessible advantage of empiric models in measurement-based quantum computation, and provide a tighter upper bound on accessible advantage in certain cases.

Physical Review A•Jan 23, 2020•7 citations

Possibilistic (and other) notions of contextuality

Andrew W. Simmons

Since Bell, Kochen and Specker formulated the first notions of contextuality, a number of frameworks have been created to help make philosophical and mathematical sense of the concept. Two of the most common are the Equivalence-based approach due to Spekkens, and the Sheaf-theoretic framework of Abramsky and Brandenburger. Each of these can support a hierarchy of strengths of contextuality, which can include possibilistic concepts. This thesis will explore the differences between the two approaches, and explore what can be demonstrated by using weaker notions of noncontextuality. Notions of noncontextuality are important for proving no-go theorems which highlight that many properties that are true of classical mechanics fail to be compatible with quantum predictions. Often, the notions of noncontextuality used are very strong assumptions, and even weaker flavours of noncontextuality can be used to draw the same, or similar conclusions. An important class of such notions are, possibilistic assumptions that only care about whether or not events are possible or impossible, rather than the exact Born rule probabilities that are applied to events. Even these weaker notions are often impossible to resolve with the logical structure and predictions of quantum theory. Contextuality has been demonstrated to be a resource for many quantum computational operations, and the contextual fraction has been shown to be an important resource. We introduce a metric that can differentiate between different quantum mechanical scenarios with contextual fraction 1, and demonstrate analogues of CHSH and Tsirelson bounds for this quantity. We also investigate the computational complexity of calculating the values of some metrics for nonlocality and contextuality, completing the classification of possibilistic nonlocality scenarios, as well as other metrics of nonlocality analogous to our metric of maximal contextuality.

•Sep 1, 2018•2 citations

On possible explanations for quantum contextuality

Alisson Tezzin

Recent research on quantum contextuality has been strongly centered on device-independent frameworks, such as the many graph approaches to contextuality and the celebrated sheaf-theoretical approach. Contextuality is described in these frameworks as a property of data only, making it possible to characterize and quantify the phenomena regardless of the reasons why it occurs. In this paper we look beyond the data and focus on possible explanations for this experimental fact. We show that a classical system generating contextual data can easily be found if the following conditions are satisfied (1) We only have access to a specific collection of epistemic measurements (which, all things considered, is basically Bohr's view on quantum measurements) and (2) There is a limitation on which of these measurements can be jointly performed. The way we see it, this example indicates that contextuality may be a consequence of the type of measurement taken into account, instead of an intrinsic feature of the system upon which these measurements are performed; if this is correct, the widespread idea that quantum contextuality is a non-classical feature can be avoided.

•Sep 16, 2021•0 citations
We present an open source Python package, ConteXtuAlity, for computing various quantities related to contextuality. This package features an interface to the sheaf-theoretic framework for contextuality, providing an implementation of measurement scenarios and empirical models as well as linear programs to compute the contextual fraction and the signalling fraction. In this work, we demonstrate the package's features and give examples of its use. We also provide benchmarks, demonstrating how performances scale with the size of measurement scenarios. The package is designed for both experienced theorists and newcomers to the field of contextuality alike, with an emphasis on flexibility and extensibility.
We consider the contextual fraction as a quantitative measure of contextuality of empirical models, i.e., tables of probabilities of measurement outcomes in an experimental scenario. It provides a general way to compare the degree of contextuality across measurement scenarios; it bears a precise relationship to violations of Bell inequalities; its value, and a witnessing inequality, can be computed using linear programing; it is monotonic with respect to the "free" operations of a resource theory for contextuality; and it measures quantifiable advantages in informatic tasks, such as games and a form of measurement-based quantum computing.
A notion of morphism that is suitable for the sheaf-theoretic approach to contextuality is developed, resulting in a resource theory for contextuality. The key features involve using an underlying relation rather than a function between measurement scenarios, and allowing for stochastic mappings of outcomes to outcomes. This formalizes an intuitive idea of using one empirical model to simulate another one with the help of pre-shared classical randomness. This allows one to reinterpret concepts and earlier results in terms of morphisms. Most notably: non-contextual models are precisely those allowing a morphism from the terminal object; contextual fraction is functorial; Graham-reductions induce morphisms, reinterpreting Vorob'evs theorem; contextual models cannot be cloned.
Contextuality is a distinguishing feature of quantum mechanics, and there is evidence that it is a necessary condition for quantum advantage in the context of magic state distillation. To harness it, researchers have been asking whether similar phenomena arise in other domains. The answer has been affirmative, e.g. in behavioural sciences. However, one has to adopt frameworks that take some degree of signalling into account. Two such frameworks exist: (i) a signalling-corrected sheaf-theoretic model and (ii) the Contextuality-by-Default (CbD) framework. This paper provides the first large-scale experimental evidence for contextuality in the large language model BERT. We constructed a linguistic schema modelled over a contextual quantum scenario, instantiated it in the Simple English Wikipedia, and extracted probability distributions for the instances. This led to the discovery of 77 118 sheaf-contextual and 36 938 948 CbD contextual instances. We prove that these contextual instances arise from semantically similar words by deriving an equation that relates degrees of contextuality to the Euclidean distance of BERT’s embedding vectors. Our linguistic schema is a variant of the coreference resolution challenge. These results suggest that quantum methods may be advantageous in the field of natural language processing.
The operational characterization of contextuality is the cornerstone in the development of resource theory of contextuality. Here, we introduce contextual robustness as an operational measure of contextuality on empirical models. We first show that it satisfies all the properties a proper contextual measure should satisfy. Besides, we derive the linear programing of contextual robustness and prove that contextual robustness exactly characterizes the maximal violation of certain types of Bell inequalities. Moreover, we show that contextual robustness quantifies the accessible advantage of empiric models in measurement-based quantum computation, and provide a tighter upper bound on accessible advantage in certain cases.
Since Bell, Kochen and Specker formulated the first notions of contextuality, a number of frameworks have been created to help make philosophical and mathematical sense of the concept. Two of the most common are the Equivalence-based approach due to Spekkens, and the Sheaf-theoretic framework of Abramsky and Brandenburger. Each of these can support a hierarchy of strengths of contextuality, which can include possibilistic concepts. This thesis will explore the differences between the two approaches, and explore what can be demonstrated by using weaker notions of noncontextuality. Notions of noncontextuality are important for proving no-go theorems which highlight that many properties that are true of classical mechanics fail to be compatible with quantum predictions. Often, the notions of noncontextuality used are very strong assumptions, and even weaker flavours of noncontextuality can be used to draw the same, or similar conclusions. An important class of such notions are, possibilistic assumptions that only care about whether or not events are possible or impossible, rather than the exact Born rule probabilities that are applied to events. Even these weaker notions are often impossible to resolve with the logical structure and predictions of quantum theory. Contextuality has been demonstrated to be a resource for many quantum computational operations, and the contextual fraction has been shown to be an important resource. We introduce a metric that can differentiate between different quantum mechanical scenarios with contextual fraction 1, and demonstrate analogues of CHSH and Tsirelson bounds for this quantity. We also investigate the computational complexity of calculating the values of some metrics for nonlocality and contextuality, completing the classification of possibilistic nonlocality scenarios, as well as other metrics of nonlocality analogous to our metric of maximal contextuality.
Recent research on quantum contextuality has been strongly centered on device-independent frameworks, such as the many graph approaches to contextuality and the celebrated sheaf-theoretical approach. Contextuality is described in these frameworks as a property of data only, making it possible to characterize and quantify the phenomena regardless of the reasons why it occurs. In this paper we look beyond the data and focus on possible explanations for this experimental fact. We show that a classical system generating contextual data can easily be found if the following conditions are satisfied (1) We only have access to a specific collection of epistemic measurements (which, all things considered, is basically Bohr's view on quantum measurements) and (2) There is a limitation on which of these measurements can be jointly performed. The way we see it, this example indicates that contextuality may be a consequence of the type of measurement taken into account, instead of an intrinsic feature of the system upon which these measurements are performed; if this is correct, the widespread idea that quantum contextuality is a non-classical feature can be avoided.