A square, a pentagon and quantum contextuality

Disclaimer. I am an employee of IonQ. The views expressed here are my own and I am not speaking for IonQ.

I enjoyed this recent post about a beautiful experiment on quantum contextuality by the Google Quantum AI team. Congratulations to everyone who worked on it! I’m glad to see contextuality getting this kind of attention.

Entanglement, the uncertainty principle, and quantum magic tend to get more attention. To me, contextuality gets at an even deeper question. Could a quantum system carry a ready-made answer to each measurement, with that answer staying the same whichever other compatible measurements we choose to make alongside it? Quantum theory gives us examples where no such assignment of answers can work.

Contextuality was my first love in physics and the subject of my first paper. I’ve been working on it for over a decade, and I can’t remember a year when I didn’t write a paper on it. It’s also why my website and blog are called Contextual Stories. What keeps me coming back is how a question that sounds so philosophical can help us certify quantum devices, study quantum error correction, and design protocols for proofs of quantumness and quantum advantage.

Let’s start with a square. The Google team used a version of it in its experiment. The measurements we can make together lie along a row or down a column.

The Peres–Mermin square

In 1990, Asher Peres and David Mermin gave a proof of contextuality using nine observables on a single two-qubit system. We can see the problem by trying to fill a three-by-three square with signs. Each row must have product +1. The first two columns must have product +1 and the last must have product −1. In the grid below, only the last column has the wrong product. Try flipping the bottom-right sign. [12]

Can all six products be right?

Flip any sign. A checked box means −1 and an unchecked box means +1. A row or column has product −1 when it contains an odd number of checked boxes.

RowC1C2C3Row
product
R1
R2
R3
Col.
prod.
Required+1+1−1
Why can’t all six products have the required signs?

Let’s multiply the nine entries across the rows. We get (+1) × (+1) × (+1) = +1. Down the columns the same nine numbers would give (+1) × (+1) × (−1) = −1. Changing any one entry flips two products, one row and one column. We can move the error, but we can’t make all six products right.

Measurement contexts and contextuality

A measurement context is a set of measurements we can make together. In the ideal square, we can also make them one at a time in any order and get the same joint probabilities. Think of the seven of hearts. Its suit is hearts and its rank is seven. Whether we record its colour alongside its suit or alongside its rank, we write “red”. In fact, we could have written down all three answers before anyone chose which pair to ask about.

The square uses two qubits, each a quantum system with two levels. Some cells ask about one qubit and others about the pair. The top-left cell asks about the second qubit and gives +1 or −1. We can measure it with the rest of its row or with the rest of its column. Why choose? The row and the column also ask two incompatible questions about the first qubit.

What would happen if, as with the card, each measurement already had an answer we could write down? We’d have nine signs, one per cell. Every such grid gets at least one product wrong. Even choosing a fresh grid at random on every run would leave some chance of a wrong product when we independently choose which row or column to check.

Quantum mechanics predicts that, with ideal measurements, every row has product +1. The first two columns have product +1 and the last has product −1. No assignment of one sign to each cell, used in both its row and its column, can account for all six rules. They hold for any initial state of the two qubits. This is state-independent contextuality. [4, 12]

What are the nine observables?

An observable is a quantity we can measure. The Pauli observables X, Y and Z correspond to three perpendicular axes for a qubit. Each has outcomes +1 and −1. I is the identity. For example, XZ means X on the first qubit and Z on the second. Their product gives the outcome of XZ. Here is one realization of the Peres–Mermin square. [12]

IZZIZZ
XIIXXX
XZZXYY

In the top row, IZ and ZI give the individual Z outcomes. The third entry, ZZ, gives their product. Multiplying all three signs therefore gives +1. Some other lines require a joint measurement on both qubits. We can now see why we had to choose a line. The top row contains ZI and the left column contains XI. These measure Z and X on the first qubit, and we cannot measure both sharply together.

From one square to two players

So far, we have used the square to reason about measurements on one system. To see how it became a game between two people, it helps to go back to 1989. Daniel Greenberger, Michael Horne and Anton Zeilinger imagined four observers, each measuring one of four entangled particles. Quantum theory predicted relations among their answers that would hold with certainty. Any list of answers prepared in advance for each observer’s possible measurements would get at least one relation wrong. In 1990, David Mermin gave a version with three observers. Could two observers get the same kind of contradiction? [16]

Eleven years later, in 2001, Adán Cabello found a way while working in Seville. He is also a coauthor of the Google paper. His two observers, Alice and Bob, each hold a four-level quantum system, called a ququart. The two ququarts are maximally entangled. One way to prepare them is to share two maximally entangled pairs of qubits (Bell pairs), with Alice and Bob each holding one qubit from each pair. The Peres–Mermin square now tells them what to measure. Alice uses her assigned row and Bob his assigned column. With ideal measurements they satisfy the product rules and agree at the intersection on every round, without exchanging a message. P. K. Aravind later called the arrangement a magic square. [13]

In the magic square game, Alice and Bob agree on a strategy before the referee draws the questions. A classical plan can list all nine of Alice’s signs, row by row, and all nine of Bob’s, column by column. The lists can differ. They can even use shared randomness to choose their plan. With entanglement they agree on what to measure and get their signs when they play. Once the round begins they can’t communicate.

  1. The referee gives each player a blank 3 × 3 grid.
  2. The referee picks a row and a column independently and uniformly at random. Alice learns only the row and Bob only the column.
  3. Alice fills the three cells of her row with +1 or −1 so that their product is +1.
  4. Bob fills the three cells of his column with +1 or −1 so that their product is +1, except in the third column, where it must be −1.

They win if they write the same number in the cell where Alice’s row and Bob’s column meet.

How do they get their answers to agree? Suppose they play 1,000 rounds. Before they begin, they prepare one entangled pair of atoms for each round. In the table, A labels Alice’s reading and A′ (read “A prime”) labels Bob’s. The other letters follow the same convention.

Alice measures A and B for row 1, C and D for row 2, or E and F for row 3. Each reading is +1 or −1. For row 1, she writes A, B and their product AB.

Bob measures A′ and C′ for column 1, B′ and D′ for column 2, or E′ and F′ for column 3. For column 3, he writes E′, F′ and the negative of their product, −E′F′.

Bob · column 1Bob · column 2Bob · column 3
Alice · row 1A = A′B = B′AB = E′
Alice · row 2C = C′D = D′CD = F′
Alice · row 3E = A′C′F = B′D′EF = −E′F′
Alice’s row answers are on the left (blue) and Bob’s column answers on the right (red, with primes). Letters denote signs measured in this round. Only the intersection of the chosen row and column is compared. Adapted from a table by Adán Cabello.

If Alice gets row 1 and Bob gets column 3, Alice reports A, B and AB. Bob reports E′, F′ and −E′F′. They win this round when AB equals E′. The letters label local readouts. Alice’s E is the outcome of measuring XZ, while Bob’s E′ is the outcome of measuring ZZ. [13]

What did Google measure?

In 2009, Gerhard Kirchmair and colleagues tested state-independent contextuality with trapped ions, and Elias Amselem and colleagues tested it with photons. [12] I especially appreciate the Google Quantum AI team’s decision to test the square in two ways on a superconducting chip. Figure 1 of the paper shows how often the two players agree in the game. Figure 2 tests the product rules by measuring a row or column one entry at a time. [1]

Google used an equivalent sign convention (Table 1 of the Science paper). In the bottom row of the Pauli square, XZ and ZX become −XZ and −ZX. If both players reverse their reported signs in those two cells, the first two column products change from +1 to −1. The row product stays +1, and the players still agree at exactly the same intersections. This is why all three columns in Google’s paper have product −1. [1]

For the game, we give Alice a randomly chosen row and Bob an independently chosen column. With Google’s signs, Alice returns three answers with product +1 and Bob returns three with product −1. We check whether they agree at the intersection. They can plan together beforehand. Once they receive their questions, they have to answer without exchanging messages. [1]

Play one round as the referee

Here is a fixed classical strategy in Google’s sign convention. Alice uses the grid on the left. Bob reverses the bottom-right sign, so all three of his columns have product −1. Can you find the pair of questions on which they disagree?

Alice’s grid
+1+1+1
+1+1+1
−1−1+1
Bob’s grid
+1+1+1
+1+1+1
−1−1−1
Alice’s row Bob’s column Alice’s row 1: (+1, +1, +1). Alice’s row 2: (+1, +1, +1). Alice’s row 3: (−1, −1, +1). Bob’s column 1: (+1, +1, −1). Bob’s column 2: (+1, +1, −1). Bob’s column 3: (+1, +1, −1). Cell (1, 1): both report +1. They win this round. Cell (1, 2): both report +1. They win this round. Cell (1, 3): both report +1. They win this round. Cell (2, 1): both report +1. They win this round. Cell (2, 2): both report +1. They win this round. Cell (2, 3): both report +1. They win this round. Cell (3, 1): both report −1. They win this round. Cell (3, 2): both report −1. They win this round. Cell (3, 3): Alice reports +1 and Bob reports −1. They lose this round.
Reveal the losing pair

Row 3 and column 3 intersect at the one cell where their grids differ. Alice reports +1 and Bob reports −1. In the other eight cases, Alice and Bob give the same answer at the intersection.

If a classical strategy won on all nine pairs, we could stack Alice’s three rows into a grid and read off Bob’s three columns. That grid would satisfy all six product rules. So at least one pair must lose. The strategy we just tried loses on exactly one, row 3 with column 3. With equally likely questions the best classical win rate is therefore 8/9. Randomly mixing strategies can’t raise it. On four qubits, Google tried each pair of questions 100,000 times. [1]

Magic square game98.30%Win rate. Without communication, the classical bound is 88.89%.
Sequential measurement test5.590 ± 0.008Measured value. The noncontextual bound is 4 and the ideal quantum value is 6.

To see what 98.30% means, imagine playing 900 rounds. With the questions chosen uniformly at random, even the best classical players would expect to lose at least 100 rounds if they had to answer separately. At the chip’s measured win rate, we’d expect about 15 losses. What I like about this experiment is that we can work out the first number with pencil and paper, then test a processor against it. Google implemented the two players’ measurements as separate operations on the chip. That detail matters when we compare the result with 8/9. Even one bit exchanged after the questions arrive would let classical players win every round. [1, 8]

For the second experiment, Google used an auxiliary qubit, or ancilla, to measure the three observables in a chosen row or column in sequence. Cabello proposed the corresponding state-independent inequality in 2008. [13] We can calculate the score ourselves. Give a line +1 if its product is right and −1 if it is wrong. For a fixed grid, the best we can do is five right and one wrong, giving 5 − 1 = 4. With repeated measurements we add the average scores for the six lines. The ideal quantum value is 6, and the team measured 5.590 ± 0.008. The interpretation depends on how well the measurements preserve compatibility and how faithfully the same cell is measured in its two contexts. Section 4 of the supplement reports that two readings of the same observable agreed 96.36% of the time when only compatible measurements came between them. It also shows how correcting a phase shift in the auxiliary qubit improved the score. [1]

Google also played a related parity game with up to 71 qubits, one for each player. Even at that scale, the measured win rate stayed above the classical bound for players who answer without communicating. They also verified genuine entanglement across 45 qubits by checking how closely the prepared state matched the ideal one (Fig. S6 of the supplement). [1] To me, reaching 71 players was an experimental breakthrough.

In a separate experiment, the team tackled the two-dimensional hidden linear function problem, in which a matrix specifies which output strings count as solutions. The team reports solving it “with success probability higher than 0.5 up to 105 qubits” (Science, p. 873). [1]

Why the hidden linear function problem matters

For comparison, consider Peter Shor’s 1994 result on factoring. He showed how a quantum computer could factor a large integer in polynomial time. The number of steps grows at most as a fixed power of the number of digits. An expanded account appeared in 1995. The consequence for RSA was immediate. Factoring the large number in an RSA public key would let someone calculate the private key and decrypt messages sent to its owner. Could a classical computer also factor efficiently, perhaps using randomness? We still don’t know. [14]

The hidden linear function problem gives us a different way to compare the two kinds of computers. The input is a pattern of bits on the sites and edges of a square grid. We can read every bit directly, without querying a black box (an oracle). These bits specify a quadratic function. On a certain set of bit strings, its value is 0 or 2 according to a simple rule. Count the ones in a particular selection of positions. An even count gives 0, and an odd count gives 2. Our task is to find any selection that works for every string in that set. [1, 15]

In 2018, Sergey Bravyi, David Gosset and Robert König proved how many layers of gates this task requires. An ideal quantum circuit using gates on individual qubits and neighbouring pairs can find a valid answer with certainty in a fixed number of layers, however large the grid grows. A classical circuit can solve the problem too. But if each gate reads only a bounded number of bits, the number of layers must grow at least logarithmically with the grid size to succeed with probability greater than 7/8 on every input, even with randomness. The proof uses quantum nonlocality to establish this difference in depth. [1]

What does that theorem tell us at the size of Google’s experiment? As the Google team writes, “Bravyi et al.’s proof is only valid for tens of thousands of qubits” (Science, p. 872). At the sizes the team tested, its comparison used a conjecture about the depth needed for an exact classical solution. [1]

I appreciate how clearly the authors distinguish what they measured on 105 qubits from what remains to be proved about classical circuits at that size. These contextuality tests also give us a way to benchmark a quantum processor. On Google’s chip they revealed small, systematic errors that tests with random gates missed. [1]

Testing a single device

Adán Cabello and I studied a related question using a different game. Could we design a test for one processor and prove in advance how often a shallow classical circuit could win at that size? Our 99-qubit test uses a three-player Greenberger–Horne–Zeilinger (GHZ) parity game. Each player’s question arrives at a site chosen independently at random from 17 possibilities. A classical device can share randomness across the chip, do unlimited work before the questions arrive, and connect any sites it likes. It must fix those connections before we draw the sites. [10]

Once we reveal the questions, we count how many layers of two-input gates the classical device uses to answer. We prove that its winning probability is at most 57/68 (about 83.82%) with one layer and 63/68 (about 92.65%) with two. An ideal quantum device wins every trial. For our hardware estimates, we used gate and readout error rates from the Google team’s earlier preprint. An experimental violation remains to be demonstrated. If the lower confidence bound on the measured win rate exceeds either threshold, we can rule out classical circuits of the corresponding depth under these conditions. [10]

Another way to test a single device is to limit what it can learn from an earlier question. Atul Singh Arora, Alexandru Cojocaru, Andrea Coladangelo and I studied how to use cryptography for this when the device has bounded computational power. [9]

We can also ask whether a collection of measurements already used for another purpose gives a proof of contextuality. In quantum error correction we make measurements to learn about errors while preserving the information we have encoded. For some protocols that switch between codes to perform protected gates, we can find such a proof using just the code measurements and products of compatible measurements. [11]

The pentagon and the KCBS inequality

We can see contextuality with as few as five measurements arranged around a pentagon. During my PhD, I drew one on just about every whiteboard I worked at. If anyone came across one, they figured I’d been there :)

Each corner of that pentagon stood for a yes-or-no measurement. Each edge joined two measurements we could make together, with at most one “yes” between them.

How many corners can we mark?

Mark two corners that do not share an edge. Now try adding a third. The edges are A–B, B–C, C–D, D–E and E–A.

See one solution

Mark A and C. B touches both marks, D touches C, and E touches A. The same argument works for any two nonadjacent corners, so two is the most you can mark.

Let’s write A, B, C, D and E around the pentagon. Each letter stands for a measurement with two possible answers, yes and no. If two letters share an edge, we can measure them together, but they cannot both give yes. For A and B we can get yes–no, no–yes or no–no. We can also measure A together with E. The pair we choose is the context in which we measure A.

Suppose the system already has an answer for A, and we get that answer whichever neighbour we measure alongside it. This is the assumption of a noncontextual value assignment. If that holds for all five letters, we could write the answers on a slip of paper before choosing a pair. Mark the yeses on the pentagon. Each slip can have at most two marks. We can use a different slip on every run and we’ll still average at most two. If p(A) is the fraction of slips with a yes beside A, we can write the same argument as an inequality. This is the KCBS inequality, named for Klyachko, Can, BinicioÄźlu and Shumovsky. [3]

p(A) + p(B) + p(C) + p(D) + p(E) ≤ 2

We can do the experiment with three internal states of a single ion. Together they encode a qutrit, a three-level quantum system. Each vertex represents a yes-or-no measurement. In the ideal experiment, its “yes” outcome corresponds to a projector onto one particular qutrit state. The states at adjacent vertices are orthogonal, so their two measurements cannot both give “yes”. For a suitable choice of the initial state and the five projectors, quantum mechanics predicts a probability of 1/√5, about 44.7%, for each “yes”. The sum is √5, about 2.236. [3, 5]

How can we get 2.236 when we could only mark two corners? We prepare the ion the same way on each run and choose one pair to measure. In the ideal experiment at most one measurement in that pair gives “yes”. The probability of “yes” for A is the same whether we measure it with B or with E. The difficulty comes when we try to explain all five probabilities by assuming that each ion carried a slip with five answers. Every such explanation gives a sum of at most two. That is the sense in which these measurements exhibit contextuality. [3, 4]

Self-testing a trapped-ion qutrit with the KCBS inequality

We’ve used a state and five measurements to predict a sum of probabilities. Can we go the other way? Suppose the measurements are projective and the “yes” projectors at adjacent vertices are orthogonal. If the sum reaches √5, the statistics identify the ideal KCBS state and the action of the five measurements on that state, up to an isometry, a map that preserves inner products. This is what we mean by self-testing here. My collaborators and I proved this result using the graph-theoretic approach to contextuality developed by Cabello, Severini and Winter. [5, 6]

With Xiao-Min Hu and colleagues, we tested this prediction using three internal states of a single trapped calcium-40 ion (40Ca+). We used laser pulses to choose the measurement and detected the ion’s fluorescence to read out the result. Even when the measured sum falls short of √5, it gives a lower bound on the total fidelity, a measure of how closely the prepared state and the five states following a “yes” outcome agree with their ideal counterparts. The bound assumes the measurements have the properties described above. To check those assumptions in the lab, we measured how often two adjacent measurements both gave “yes” and compared the outcome probabilities when we reversed the measurement order. [7]

If we were doing the ion experiment, I’d keep the counts for A with B and for A with E in separate columns of the notebook. I’d want to see how closely those two estimates agree before combining them into the single number we write beside A on the whiteboard.

That’s what brings me back to the pentagon. I can draw it on a whiteboard to explain why five ready-made answers won’t work, then use the same drawing in the lab to ask how well we prepared a single ion.

Acknowledgements and AI usage

I thank Adán Cabello, Shashwat Kumar, and Rodrigo G. Cortiñas for their helpful comments on an earlier draft. I used AI to generate the HTML for the interactive figures and puzzles.

References and further reading

  1. Post announcing the Willow experiments (2026). Google Quantum AI and Collaborators, “Quantum-classical separation in bounded-resource tasks arising from measurement contextuality,” Science 394, 870–874 (2026) (quotations on pp. 872–873, Fig. 4 and supplementary materials §6.A, Eq. S45). Google Research’s illustrated account. Google Quantum AI, arXiv:2512.02284v1, p. 5 (earlier estimate). S. Bravyi, D. Gosset and R. König, “Quantum advantage with shallow circuits,” Science (2018), Theorem 2.
  2. A. S. Arora, K. Bharti and Arvind, “Revisiting the admissibility of non-contextual hidden variable models in quantum mechanics” (2016 preprint, published 2019).
  3. A. A. Klyachko, M. A. Can, S. BinicioÄźlu and A. S. Shumovsky, “Simple Test for Hidden Variables in Spin-1 Systems,” Physical Review Letters (2008).
  4. S. Kochen and E. P. Specker, “The Problem of Hidden Variables in Quantum Mechanics” (1967). C. Budroni et al., “Kochen-Specker contextuality,” Reviews of Modern Physics (2022), a guide to the definitions and experimental assumptions.
  5. A. Cabello, S. Severini and A. Winter, “Graph-Theoretic Approach to Quantum Correlations,” Physical Review Letters (2014), on what can be read from an exclusivity graph.
  6. K. Bharti, M. Ray, A. Varvitsiotis, N. A. Warsi, A. Cabello and L.-C. Kwek, “Robust Self-Testing of Quantum Systems via Noncontextuality Inequalities,” Physical Review Letters (2019).
  7. X.-M. Hu et al., “Self-testing of a single quantum system from theory to experiment,” npj Quantum Information (2023), the trapped-ion realization.
  8. A. Broadbent and A. A. MĂ©thot, “On the power of non-local boxes” (2005), Theorems 1 and 2 on one-bit classical strategies.
  9. A. S. Arora, K. Bharti, A. Cojocaru and A. Coladangelo, “A computational test of quantum contextuality, and even simpler proofs of quantumness” (2024 preprint).
  10. K. Bharti and A. Cabello, “Experimentally Testable Quantum Advantage in Shallow Circuits” (2026 preprint), Eq. (2) and Table I.
  11. D. Khu, A. Tanggara, C. Jin and K. Bharti, “Contextuality of Quantum Error-Correcting Codes,” PRX Quantum (2026).
  12. A. Peres, “Incompatible results of quantum measurements,” Physics Letters A (1990). N. D. Mermin, “Simple Unified Form for the Major No-Hidden-Variables Theorems,” Physical Review Letters (1990). G. Kirchmair et al., “State-independent experimental test of quantum contextuality,” Nature (2009). E. Amselem et al., “State-Independent Quantum Contextuality with Single Photons,” Physical Review Letters 103, 160405 (2009).
  13. A. Cabello, “‘All versus Nothing’ Inseparability for Two Observers,” Physical Review Letters 87, 010403 (2001). P. K. Aravind, “Quantum mysteries revisited again,” American Journal of Physics 72, 1303 (2004). A. Cabello, “Experimentally Testable State-Independent Quantum Contextuality,” Physical Review Letters 101, 210401 (2008).
  14. P. W. Shor, “Algorithms for quantum computation: discrete logarithms and factoring,” FOCS (1994). Expanded 1995 preprint.
  15. “Hidden linear function problem,” Wikipedia, for the mathematical definition and circuit.
  16. D. M. Greenberger, M. A. Horne and A. Zeilinger, “Going Beyond Bell’s Theorem” (1989). N. D. Mermin, “Quantum mysteries revisited,” American Journal of Physics 58, 731–734 (1990).

Comments

  1. i hadn't appreciated that contextuality experiments could reveal hardware errors that other benchmarks miss. fascinating to see how something so fundamental to quantum mechanics can also help us understand how well a quantum computer is working. thanks for writing this.

    ReplyDelete

Post a Comment

Popular posts from this blog

What Should the Human Part of Science Become?

The human is not a means to an output. The human is the point.