Memory cost of quantum contextuality

The simulation of quantum effects requires certain classical resources, and quantifying them is an important step in order to characterize the difference between quantum and classical physics. For a simulation of the phenomenon of state-independent quantum contextuality, we show that the minimal amount of memory used by the simulation is the critical resource. We derive optimal simulation strategies for important cases and prove that reproducing the results of sequential measurements on a two-qubit system requires more memory than the information carrying capacity of the system.


Introduction
According to quantum mechanics (QM), the result of a measurement may depend on which other compatible observables are measured simultaneously [1][2][3]. This property is called contextuality and is in contrast to classical physics, where the answer to a single question does not depend on which other compatible questions are asked at the same time.
Contextuality can be seen as complementary to the well-known nonlocality of distributed quantum systems [4]. Both phenomena can be used for information-processing tasks, albeit the applications of contextuality are far less explored [5][6][7][8][9][10][11][12]. Although contextuality and nonlocality can be considered as signatures of nonclassicality, they can be simulated by classical models [3,[13][14][15]. However, while nonlocal classical models violate a fundamental physical principle (the bounded speed of information), it is not clear whether contextual classical models violate any fundamental principle. Moreover, while the resources needed to imitate quantum nonlocality have been extensively investigated [16][17][18], there is no such knowledge about the resources needed to simulate quantum contextuality.
In any model that exhibits contextuality in sequential measurements, the system will eventually attain different internal states during certain measurement sequences. These states can be considered as memory-a model attaining the minimum number of states is then memory-optimal and defines the memory cost. In this paper, we investigate the memory cost as the critical resource in a classical simulation of quantum contextuality and we construct memory-optimal models for relevant cases. The amount of memory required increases as we consider more and more contextuality constraints. This can be used to quantify contextuality in a given quantum setting. We show that certain scenarios breach the amount of two-bits needed for 3 the simulation of two qubits. This demonstrates that the memory needed to simulate only a small set of measurements on a quantum system may exceed the information that can be transmitted using this system (given by the Holevo bound [19])-a similar effect has been observed so far only for the classical simulation of a unitary evolution [20].

Scenario
We focus on the following set of two-qubit observables, also known as the Peres-Mermin (PM) square [4,21], where σ x , σ y and σ z denote the Pauli operators. The square is constructed such that the observables within each row and column commute and are hence compatible, and the product of the operators in a row or column yields 1, except for the last column where it yields −1. Thus, the product of the measurement results for each row and column will be +1 except in the third column, where it will be −1. In contrast, for a noncontextual model the measurement result for each observable must not depend on whether the observable is measured in the column or row context. Hence, the number of rows and columns yielding a product of −1 is always even, as any observable appears twice. Similar to the Bell inequalities for local models, any noncontextual model satisfies the inequality χ ≡ ABC + abc + αβγ + Aaα + Bbβ − Ccγ 4, (2) while for perfect observables QM predicts χ = 6 [22]. Here, the term ABC denotes the average value of the product of the outcomes of A, B and C if these observables are measured simultaneously or in sequence on the same quantum system. The violation is independent of the quantum state, which emphasizes that the phenomenon is a property of the set of observables rather than of a particular quantum state.
Recently, this inequality was experimentally tested using trapped ions [23], photons [24] and nuclear magnetic resonance systems [25]. The results show good agreement with the quantum predictions. In these experiments, the observables are measured in a sequential manner. Since the observed results cannot be explained by a model using only preassigned values, the system necessarily attains different states during some particular sequences, i.e. the system memorizes previous events. (Note that in QM the system also attains different states during the measurement sequences.) This leads to our central question: how much memory is required to simulate quantum contextuality?

A first model
Before we formulate the previous question more precisely, let us provide an example of a model that simulates the contextuality in the PM square. We assume that the system can only attain three different physical states S 1 , S 2 and S 3 (e.g. discrete points in phase space). Let us associate a table with each state via 4 Those tables define the model's behavior in the following way: if, e.g., the system is in state S 1 and we measure the observable γ , consider the first table at the position of γ (i.e. the last entry in the third row). The + sign at this position indicates that the measurement result will be +1, while the system stays in state S 1 . If we continue and measure C, we encounter the entry (+, 2), which indicates the measurement result +1 and a subsequent change to the state S 2 . Being in state S 2 , the second table defines the behavior for the next measurement: for instance, a measurement of c yields now the result −1 and the system stays in state S 2 . Thus, starting from state S 1 , the measurement results for the sequence γ Cc are +1, +1, −1, so that the product is −1 in accordance with the quantum prediction. It is straightforward to verify that this model yields χ = 6. In addition, the observables within each context are compatible in the sense that in sequences of the form A A, AB A or Aαa A, the first and last measurement of A yields the same output. In fact this particular model is memory-optimal (cf theorem 1) and we assign the symbol A 3 to it.

Memory cost of classical models
Any model that reproduces contextuality eventually predicts that the system attains different states during some measurement sequences. As an omniscient observer one would know the state prior to each measurement and could include it in the measurement record. Thus, knowing the state of the system, one can predict the measurement outcome as well as the state of the system that will occur prior to the next measurement. Thus, we can write any model that explains the outcomes of sequential measurements in the same fashion as we did for A 3 .
Taking a different point of view, any such model can be considered to be an automaton with finitely many internal states, taking inputs (measurement settings) and yielding outputs (measurement results). In our notation, the output depends not only on the internal state, but also on the input. Such automatons are known as Mealy machines [26,27].
The quantum predictions add restrictions to such an automaton and thus increase the number of internal states needed. As a simple example we could require that an automaton reproduces the quantum predictions from the rows and columns in the PM square. That is, for all sequences in the set Q rc = {ABC, abc, αβγ , Aaα, Bbγ , Ccγ and permutations}, (4) we require that the automaton must yield an output that matches the quantum prediction. For example, QM predicts for the sequence ABC that the output is either +1, +1, +1 or one of the permutations of +1, −1, −1.
More generally, if Q denotes a set of measurement sequences, we say that an automaton A obeys the set Q if the output for any sequence in Q matches the quantum prediction-i.e., if for any sequence in Q, the output of A could have occurred with a nonvanishing probability according to the quantum scenario. We say that a sequence yields a contradiction if the output of this sequence cannot occur according to QM. Hereby we consider all quantum predictions from any initial state (it would also suffice to only consider the completely mixed state = 1/tr [1]). Furthermore, we assume that prior to the measurement of a sequence, the automaton is always re-initialized. This ensures that the output of the automaton is independent of any action prior to the selected measurement sequence. Note that we only consider the certain quantum predictions that occur with a probability of 1, whereas, e.g., in the PM square we do not require that for the sequence Aγ the probability of obtaining +1, +1 is equal to the probability of obtaining +1, −1.

5
Finally, if an automaton with k states S 1 , . . . , S k obeys Q and there exists no automaton with fewer states obeying Q, we define the memory cost of Q to be M(Q) = log 2 (k).

Contextuality conditions
Our definition of memory cost so far applies to arbitrary situations, even those in which contextuality does not directly play a role. In contrast, contextuality of sequential measurements corresponds to the particular feature that certain sequences of mutually compatible observables cannot be explained by a model with preassigned values (cf [28] for a detailed discussion). The contextuality conditions for observables X 1 , X 2 , . . . thus arise from the set of all sequences of mutually compatible observables, If the choice of observables X 1 , X 2 , . . . exhibits contextuality, then M(Q context ) > 0. In the case of the PM square, Q context surely contains all the row and column sequences that we included in Q rc . In addition, however, Q context contains, e.g., the sequences A A, AB A and Aαa A, for which QM predicts with certainty a repetition of the value of A in the first and last instance. Note that the set Q context also contains more complicated sequences like AC ABC A for which QM predicts with certainty that the values of A (C) in the first, third and sixth (second and fifth) measurements coincide and that the product of the outcome for ABC yields +1. A particular feature of contextuality is that one can find observables that exhibit contextuality independently of the actual preparation (the initial state) of the quantum system. Consequently, one may consider an extended preparation procedure of the automaton, where the experimenter carries out additional measurements between the initialization of the automaton and the actual sequence. The experimenter would, e.g., measure the sequence b ABC but consider the measurement of the observable b to be actually part of the preparation procedure. We write b for a sequence where we are not interested in the result of b. If Q all denotes the set of all sequences with observables X 1 , X 2 , . . ., we write for the set of all sequences in Q context , including arbitrary preparation procedures. For the contextuality in the PM square, the automaton A 3 obeys Q context , while no automaton with fewer than three states can obey Q context ; cf appendix A for details. We did not specify an initial state for A 3 and indeed the contextuality conditions are obeyed for any initial state. We summarize: Theorem 1. The memory cost for the contextuality correlations Q context in the PM square is log 2 (3) ≈ 1.58 bits; M(Q context ) = M(Q context ) = log 2 (3). Consequently, the automaton A 3 is memory-optimal.

Compatibility conditions
The set Q context contains all sequences of mutually compatible observables, but does not contain sequences like ABa A, for which QM also predicts that both occurring values of A are the same. Sequences of this form enforce that all observables compatible with an observable Y 6 must not change the measurement result of Y . This can be covered by the set of all compatibility conditions and a convincing test of contextuality must also test the correlations due to this set of sequences. Again we define Q compat to include arbitrary preparation procedures. The automaton A 3 does not obey Q compat , since e.g. starting with state S 1 , the sequence B Cβ B yields the record +1, +1, −1, − 1 and hence violates the assumption of compatibility; similar sequences can be found for any initial state. We show in appendix D that no automaton with three states can obey simultaneously Q compat and Q context and hence M(Q compat and Q context ) 2. However, automata with four internal states exist that obey Q compat and Q context . As an example of such an automaton, we define A 4 via S 1 : Similar to the situation for A 3 , the initial state for the automaton A 4 can be chosen freely; for details see appendix B. So we have: The memory cost for the contextuality and compatibility correlations in the PM square is two bits; M(Q compat and Q context ) = 2. Consequently, the automaton A 4 is memoryoptimal.

The extended Peres-Mermin (PM) square
There are, however, further contextuality effects for two qubits, which then require more than two bits for a simulation. Namely, in [29] an extension of the PM square has been introduced, involving 15 different observables in 15 different contexts. The argument goes as follows: consider the 15 observables of the type σ µ ⊗ σ ν where µ, ν ∈ {0, x, y, z} and σ 0 = 1 and the case µ = ν = 0 is excluded. In this set, there are 12 trios of mutually compatible observables such that the product of their results is always +1, such as , and three trios of mutually compatible observables such that the product of their results is always . This leads to 15 contexts in total. Similarly to the usual PM square, one can derive a state-independent inequality. For this inequality, QM predicts a value of 15 for the total sum, whereas noncontextual models have a maximal value of 9; cf [29] and appendix E for details. One may argue that this new contextuality argument is stronger than the usual PM square [29]. Does a simulation of it require more memory than the original PM square? Indeed, this is the case: Theorem 3. The memory cost for the contextuality and compatibility correlations in the extended version of the PM square is strictly larger than two bits.

7
More precisely, according to equations (5) and (7) we define the contextuality sequences Q compat,15 and compatibility sequences Q context,15 for the 15 observables in the extension of the PM square. Then, the theorem states that M(Q compat, 15 and Q context,15 ) > 2. The proof is based on the following idea: if one considers the 15 contexts in the extended square, then they can be arranged in a collection of ten distinct squares, each similar to the usual PM square. The contextuality in this arrangement is strong enough that for each fixed assignment of the output, one must have three contradictions for one of the ten usual PM squares. One can show, however, that any four-state solution obeying Q context and Q compat is similar to A 4 , in which for no fixed state one has three contradictions. The full proof is given in appendix E.
Although this paper is mainly concerned with the memory cost of contextuality, we mention that simulation of all certain quantum predictions of the PM square already requires more than two bits of memory. In fact, any four-state automaton that obeys Q compat and Q context is of the form A 4 , up to some symmetries (cf appendix E, proposition 5), but for A 4 the sequence β ab C c yields a contradiction. This proves that M(Q all ) > 2.
On the other hand, QM itself suggests an automaton for simulating contextuality. If, e.g., we choose the pure state |φ φ| defined by A|φ = B|φ = |φ as the initial state, then this state and all the states occurring during measurement sequences define a (nondeterministic) automaton. By a straightforward calculation one finds that this automaton attains 24 different states if we consider the set of all sequences Q all . By a suitable elimination of the nondeterminism, we can readily reduce the number of states to ten (cf appendix F), yielding an upper bound on the required memory and hence 2 < M(Q all ) log 2 (10) ≈ 3.32.

Conclusions
We have investigated the amount of memory needed in order to simulate quantum contextuality in sequential measurements. We determined the memory-optimal automata for important cases and have proven that the simulation of contextuality phenomena for two qubits requires more than two classical bits of memory. However, the maximum amount of classical information that can be stored and retrieved in two qubits is well known to be limited to two bits [19]. This implies that any classical model of such a system would either allow storage and retrieval of more than two bits, or would have inaccessible degrees of freedom. (An example of the latter is A 3 , since one cannot perfectly infer the initial state from the results of any measurement sequence.) It should be emphasized that our analysis is about the memory that is needed to classically simulate the certain predictions from measurement sequences on a quantum system. In contrast, one may ask: how many different states are needed to merely explain the observed expectation values [30][31][32][33][34][35]? However, the number of states needed in this scenario measures the number of different initial configurations of the system, while we have shown that even for a fixed initial configuration, the system must eventually attain a certain number of states during measurement sequences. Similarly, it has been demonstrated that a hybrid system of one qubit and one classical bit of memory is on average superior to a classical system having access only to a single bit of memory [36], while we show in theorem 1 that for a two-qubit system even the certain predictions cannot be simulated with one classical bit of memory.
Our work provides a link between information theoretical concepts, on the one hand, and quantum contextuality and the Kochen-Specker theorem, on the other. Whereas for Bell's theorem such connections are well explored and have given as deep insights into 8 QM [18,37,38], for contextuality many questions remain open: if an experiment violates some noncontextuality inequality up to a certain degree, but not maximally, what memory is required to simulate this behavior? Can nondeterministic machines help us to simulate contextuality? What amount of memory and randomness is required to simulate all quantum effects in the PM square, especially in the distributed setting [12]? Finally, for quantum nonlocality it has been extensively investigated why QM does not exhibit the maximal nonlocality [37,38]. A similar situation occurs for quantum contextuality-can concepts from information theory also help us to understand the nonmaximal violation in this situation?
We have already defined the set of row and column sequences Q rc in equation (4). Another natural constraint is given by the set of repeated measurements where we expect for any of these pairs that the results in the first and the second measurement coincide. Both sets Q rc and Q repeat are obviously subsets of the set of contextuality sequences Q context of the PM square. Nevertheless, an automaton that simultaneously obeys Q rc and Q repeat already possesses more than two internal states, i.e. M(Q rc and Q repeat ) > 1. In order to see this, assume that the automaton has only two internal states and without loss of generality that it starts in state S 1 . We consider the case when in the last column there must be a prescribed state change in order to avoid a contradiction, i.e. in S 1 the product of the assignments of Ccγ is +1, contrary to the quantum prediction. Note that there always exists at least one row or column with such a contradiction and that the proof for any row or column follows the same lines. If there is only one state change (say, after a measurement of γ ), then while measuring the sequence Ccγ , the automaton would remain in S 1 until after the last output and therefore yield a contradiction. If there are two (or more) state changes in the last column (say, c and γ ), both must go to S 2 . Then, the constraints from Q repeat require that γ has the same values in S 1 and S 2 (this is also true for c). But then the sequence Ccγ in Q rc will yield a contradiction. Thus a two-state automaton cannot obey both Q rc and Q repeat . On the other hand, A 3 is an example of a three-state automaton, which obeys Q rc and Q repeat . In fact, A 3 obeys Q context . In order to see this, it is enough to show that for any choice of the initial state, the automaton will obey Q context . So, we assume that S 1 is the initial state; the reasoning for S 2 and S 3 is similar. If we now measure a sequence with observables from the first row only, we may jump between the states S 1 and S 2 , but the output for all observables in the first row are the same for either state. A similar argument holds for all rows and the first and second columns. For a sequence with measurements from the third column, assume that the first observable in the sequence that is not γ , is the observable c. Then the state changes to S 3 , in 9 which the last column does not yield a contradiction. Since only the output C was changed, but C was not measured so far, we cannot get any contradiction. A similar argument can be used for the case when the first observable in the sequence that is not γ , is the observable C.
In summary, since any automaton that obeys Q context has at least three states and A 3 is a three-state automaton obeying the larger set Q context , we have shown that A 3 is memory-optimal for either set.

Appendix B. A 4 obeys Q context and Q compat
In this appendix, we demonstrate that the automaton A 4 indeed obeys Q context and Q compat . The proof for Q context is completely analogous to the one in appendix A.
For Q compat , we consider a fixed observable, e.g. B. Then S 1 and S 2 yield +1, whereas S 3 and S 4 give −1. However, using arbitrary measurements compatible with B (i.e. A, B, C, b and β), we can never reach S 3 or S 4 if we start from S 1 or S 2 and vice versa. Hence no contradiction occurs for any sequence of the type T B X 1 X 2 . . . B. A similar argument holds for all observables if we note, in addition, that e.g. after a measurement of C the automaton can only be in S 2 or S 3 .

Appendix C. Definitions and basic rules used in the optimality proofs
As we have already done in the main text, we denote the observables from the PM square by  Furthermore, we denote the rows of the square by R i and the columns by C i . The value table of each memory state i is denoted by T i and the update table by U i . We write an entry of zero in U i if the state does not change for that observable. Furthermore, we write measurement sequences as A + 1 B − 2 C − 2 a + 3 meaning that when the sequence ABCa was measured, the results were +, −, −, +, and the memory was initially in state S 1 and changed like S 1 → S 2 → S 2 → S 3 .
It will be useful for our later discussion to note some rules about the structure of the value and update tables.
1. Sign flips. Let us assume that we have an automaton obeying Q context and Q compat (or some subset of those sets) and pick a 2 × 2 square of observables (e.g. the set {A, B, a, b} or {A, B, α, β} or {A, C, α, γ }). Then, if we flip in each T i the signs corresponding to these observables, we will obtain another valid automaton. This holds true, because the mentioned sign flips do not change any of the certain quantum predictions from Q context or Q compat . This rule will allow us to later fix one or two entries in a given value If there were two zeros, it could happen that one measures two entries of C j without changing the memory state. But then measuring the third one will reveal the contradiction in T i . (Note that the automaton first provides the result and then updates its state.) 5. Contradictions and other tables. Let us assume that we have an automaton obeying Q context and let there be in T i a contradiction in the column C j (or the row R j ). Then, there must be two different tables T k and T l where in both the column C j has no contradictions anymore, but the assignments of T k and T l differ in two observables of C j . Furthermore, in the column C j of the update table U i there must be two entries leading to two different states. First, note that there must be at least one other table T k where the contradiction does not exist anymore. This follows from the fact that we may measure C j starting from the memory state i. After having made these measurements, we arrive at some state k, and from the contextuality correlations Q context it follows that C j in T k has no contradiction. The table T k differs from T i in at least one observable X in C j . On the other hand, starting from T i one might measure X as a first observable. Then, making further measurements on C j one must arrive at a table T l without a contradiction. Since T k and T l have both no contradiction, they must differ in at least two places, one of them being X . Finally, if the column C j in U i would only have entries of zero and k, then C j in T k could not differ from T i . This eventually leads to a contradiction and hence proves the last assertion.

Appendix D. A 4 is memory-optimal
Here, we prove the optimality of the four-state automaton A 4 , in the sense of obeying Q context and Q compat with a minimum number of states. We use the definitions and rules as introduced in appendix C. Let us assume that we would have a three-state automaton obeying Q context . T 1 has a contradiction, and we can assume, without loss of generality, that it is C 3 . Then, according to rule 1 we can, without loss of generality, assume that all entries in C 3 are '+ '. Together with rule 5 this leads to the conclusion that the three states T i are, without loss of generality, of the form Here, empty places in the tables mean that the corresponding entries are not yet fixed. The table U 1 follows from rule 5, and U 2 and U 3 follow from rule 3.
Which can be the entries corresponding to the observables a and b in U 2 ? Since T 3 assigns a different value to c than T 2 , there cannot be a '3' at these entries; otherwise, a sequence like c + 2 a ? 2 c − 3 would lead to a contradiction to the conditions of Q context . But there can also not be a '1' at these entries, because then the sequence c + 2 a ? 2 γ + 1 c − 3 yields a contradiction to Q compat , since a and γ are compatible with c. So the entries of R 2 in U 2 must be zero, as there are only three states in the memory. A similar argument can be applied to U 3 , showing that here R 3 must be zero.
So the tables have to be of the form Now, according to rule 4, the contradictions in T 2 as well as in T 3 can only be in R 1 . But, according to rule 5, if there is a contradiction in R 1 of T 2 , there must be two different T i and T j where there is no contradiction in R 1 . But there is only one table left, namely T 1 , and we arrive at a contradiction.

Appendix E. Proof that the classical simulation of the extended PM square requires more than two bits of memory
Let us now discuss the extended PM square from [29]. Again, we refer to appendix C for basic definitions and rules. As already mentioned, one considers for that the array of observables     χ 01 χ 02 χ 03 χ 10 χ 11 χ 12 χ 13 χ 20 χ 21 χ 22 χ 23 χ 30 χ 31 χ 32 χ 33 for noncontextual models, while QM predicts a value of 15, independently of the state. First note that in this new inequality 15 terms (or contexts) occur but any noncontextual model can fulfill the quantum prediction for only 12 of them at most, so three contradictions cannot be avoided. One can directly check that in the whole construction of the inequality, ten different PM squares occur. Nine of them are a simple rewriting of the usual PM square, while the 10th comes from the observables χ kl with k, l = 0. Any of the 15 terms in the inequality contributes to four of these PM squares.
Any value table for the 15 observables leads to assignments to the 15 contexts, but it has at least three contradictions. As any context contributes to four PM squares, this would lead to 12 contradictions in the 60 contexts of the ten PM squares, if we consider them separately. Since in a PM square the number of contradictions cannot be two (rule 2), this means that one of the PM squares has to have three contradictions.
Let us now assume that we have a valid automaton for this extended PM square with four memory states. Of course, this would immediately give a valid four-state automaton of any of the ten PM squares. For one of these PM squares, at least one table has to have three contradictions. So it suffices to prove the following lemma:

Lemma 4.
There is no four-state automaton obeying Q compat and Q context , where one table T i has three contradictions.
In the course of proving this lemma we will also prove the following:

Proposition 5. The four-state automaton A 4 is unique, up to some permutation or sign changes.
To prove the lemma, we proceed in the following way. Without loss of generality, we can assume that the first three tables T i look like the T i in equation (D.1a). Then, we can add a fourth table T 4 . For the last column of this table, there are 2 3 = 8 possible values. We will investigate all eight possibilities and show either that we arrive directly at a contradiction or that only an automaton similar to A 4 is possible, in which any table has only one contradiction. This proves the lemma.
We will first deal with the four cases where T 4 has also a contradiction in C 3 . This will lead to observation 6, which will be useful in the following four cases. In this case, a simple application of the previous rules implies that several entries are fixed: Here and in the following, we write the T i and U i just as a row for notational simplicity, starting from T 1 to T 4 . The entries in U 1 and U 4 are fixed from the following reasoning: let us assume that one measures c in T 1 , then, since the values C(T i ) are the same in all T i , one has to change immediately to a table with no contradiction in C 3 , and where the value of c is still the same. The only possibility is T 2 . Furthermore, R 2 in U 2 and R 3 in U 3 must be zero due to the same argument that led to equation (D.2b). It follows (rule 4) that T 2 and T 3 have both exactly one contradiction, which must be in R 1 . So, in R 1 (U 2 ) there must be the entries '1' and '4' (an entry '3' would not solve the problem, because in R 1 (T 3 ) has also a contradiction). As we can still permute the first and the second column, we can without loss of generality assume that the first row in U 2 is [1 4 0]. Due to 13 rule 1, we can also assume, without loss of generality, that A(T 2 ) = +. Similarly, in R 1 (U 3 ) there must be the entries '1' and '4', resulting in two different cases: If R 1 (U 3 ) = [1 4 0], we must have the following tables, T : where the added values in R 1 of the T i follow from R 1 (U 2 ) and R 1 (U 3 ). Now, if we start from T 2 and measure the sequence a 2 A 2 a 1 , we see that we must have a(T 1 ) = a(T 2 ). Similarly, from T 3 we can measure a 3 A 3 a 1 , implying that a( . But this gives a contradiction: in R 2 (T 2 ) and R 2 (T 3 ) there is no contradiction and c(T 2 ) = c(T 3 ). Therefore, it cannot be that a(T 2 ) = a(T 3 ) and at the same time b(T 2 ) = b(T 3 ).
As the second case, we have to consider the possibility that R 1 (U 3 ) = [4 1 0]. Then, also the values of R 1 (T 3 ) must be interchanged, R 1 (T 3 ) = [− + +]. Then, starting from T 2 , the sequence α 2 A 2 γ 1 α 3 shows directly that α(T 2 ) = α(T 3 ). Similarly, starting from T 3 , the sequence a 3 A 3 c 4 a 2 shows that a(T 2 ) = a(T 3 ). But since A(T 2 ) = A(T 3 ), this is a contradiction. The zeros in U 2 and U 3 come from the following argumentation: starting from T 1 , the measurement sequence c + 1 X 2 c ? with X compatible with c shows that in R 2 (U 2 ) and C 3 (U 2 ) there can be no '3' or '4'. But there can also be no '1', because then the sequence c + 1 X 2 γ 1 c − 3 would lead to a contradiction. Therefore, R 2 (U 2 ) and C 3 (U 2 ) have to be zero. Starting from T 4 and measuring γ one can similarly prove that the entries for R 3 (U 2 ) have to be zero and analogous arguments also prove the zeros in U 3 .
It is now clear (rule 4) that the contradictions in T 2 and T 3 have to be in R 1 and the missing entries in U 2 and U 3 can only be '4' and '1'. As we still can permute the first and the second column, there are only two possibilities.
As in case 1, we can directly see that a(T 2 ) = a(T 1 ) = a(T 3 ) and b( Hence, R 2 (T 2 ) and R 2 (T 3 ) differ exactly in the value of c, but in both cases there is no contradiction in R 2 . This is not possible.
Case 2B: Secondly, we consider the case when the first rows of U 2 and U 3 differ, and we take R 1 (U 2 ) = [1 4 0] and R 1 (U 3 ) = [4 1 0]. Then, we apply rule 1 to fix for A(T 3 ) = a(T 3 ) = +. Then, the tables have to be T : Here, C 2 (T 1 ) and C 1 (T 4 ) come from measurement sequences like a + 3 A + 3 a + 4 , starting from T 3 . Again, we have two possibilities for the value of b in T 2 . If we set b(T 2 ) = −, then all values in all T i are fixed and each table has exactly one contradiction. This is, up to some relabeling, the four-state automaton A 4 from the main text (indeed, this is the way how this solution was found). If we set b(T 2 ) = +, then also all T i can be filled, and we must have T : Here, the tables T 1 and T 4 have three contradictions (two new ones in R 2 and R 3 ) and the new entries in U 1 and U 4 must be introduced according to rule 5 (note that a(T i ) and β(T i ) are for all tables the same). Then, however, starting from T 1 , the sequence α − 1 A − 2 γ + 1 α + 3 shows that this is not a valid solution. In this case, a simple reasoning according to the usual rules fixes the entries: T : (E.14) Here we have an obvious contradiction in T 4 /U 4 : C 3 (T 4 ) contains a contradiction, but (due to rule 3) one is not allowed to change the memory state when measuring it. Therefore, the memory can never be in state 4. But then, one would have effectively a three-state solution, which is not possible, as we already know.

Case 4: For T 4 one has
This is the same as case 3, where R 2 and R 3 have been interchanged. Now we have dealt with all the cases where T 4 contains a contradiction in C 3 , just as T 1 . We have seen that in these cases there can only be a solution if each table contains exactly one contradiction, and this solution is unique, up to some permutations or sign flips. Moreover, we could have made the same discussion with rows instead of columns. Therefore from the first four cases, we can state an observation that will be useful in the remaining four cases: Observation 6. If in any four-state solution two tables T i and T j have both a contradiction in the same column C k (or row R k ), then there has to be exactly one contradiction in each value table of the automaton.
So, if there is a four-state solution where one table has three contradictions, then it cannot be that two tables have both a contradiction in the same column or row.
Then we can proceed with the remaining cases. This is the critical case, as it is difficult to distinguish the tables T 2 and T 4 here. First, the following entries are directly fixed: (E. 16) Here, c(U 1 ) = 2 has been chosen without loss of generality. It is clear that c(U 1 ) = 2 or c(U 1 ) = 4; as T 2 and T 4 are equivalent at the beginning, we can choose T 2 here. The entries of the type i| j in U 2 and U 4 mean that the numbers can be i or j, but nothing else. The values of c(U 2 ) (and c(U 4 )) cannot be 1, because then the sequence c + 2 γ + 1 c − 3 directly reveals a contradiction. Furthermore, the zeros in R 3 (U 3 ) and R 2 (U 3 ) follow similarly as equation (D.2b) or from rule 3. In addition, C(U 2 ) = 1, because otherwise the sequence c + 1 C + 2 + 1 reveals a contradiction to the PM conditions. Also, C(U 2 ) = 3, because of c + 1 C + 2 c − 3 . Similarly, 1 and 3 are excluded as values for a(U 2 ) and b(U 2 ), due to the sequences c + 1 a 2 + 1 c − 3 and c + 1 a + 2 c − 3 . Furthermore, we can use our observation 6: if in a four-state solution one column has a contradiction in two of the T i , then there can be only one contradiction in any T i . Here we can use it as follows: it is clear that T 3 has its contradiction in R 1 . Since we aim to rule out a four-state solution where one table has three contradictions, we can assume that there is no contradiction in R 1 in all the other T i (especially in T 2 and T 3 ). Otherwise, we would already know that no solution exists with three contradictions in a table. We can distinguish two cases.
Due to rule 5, the table T 2 must have a contradiction in C 1 , C 2 or R 1 . From observation 6, we can assume that it is not in R 1 . Due to possible permutations of C 1 and C 2 we further assume without loss of generality that the contradiction is in C 1 . Then we have U : We cannot have A(U 2 ) = 3, since there is a contradiction in R 1 (T 3 ) and C(T i ) = + for all tables. In addition, due to rule 5, it is not possible that A(U 2 ) = 4. Finally, we choose a(U 2 ) = 4; the other option would be α(U 2 ) = 4; this will be discussed below. From observation 6 we can conclude that C 1 (T 1 ) and C 1 (T 4 ) do not contain contradictions, since C 1 (T 2 ) contains already a contradiction. So C 1 (T 1 ) and C 1 (T 4 ) must differ in two places (rule 5). One of these places must be A(T 1 ) = A(T 4 ). Let us assume that the second one is a(T 1 ) = a(T 4 ); the other case [α(T 1 ) = α(T 4 )] will be discussed below. Then, we can conclude that in R 1 (U 1 ) and C 1 (U 1 ) we cannot have the entries '2' and '4', and in R 2 (U 4 ) and C 1 (U 4 ) we cannot have the entries '2' and '1'. To see this, note that we must have A( Here, we used in R 1 (U 1 ) that R 1 (T 3 ) has a contradiction and C(T i ) = + for all tables, so it is not possible to go there. Now, by rule 1, we may fix A(T 2 ) = a(T 2 ) = +. Then we arrive at T : Here, we must have A(T 4 ) = α(T 4 ) since C 1 (T 4 ) has no contradiction. Furthermore, R 1 (T 4 ) has no contradiction due to observation 6. The values of R 2 (U 4 ) are determined by considering sequences like c 4 a 4 c ? ; and C(U 4 ) = 3, because of c + 4 C 4 c − 3 , and C(U 4 ) = 1, because of c + 4 C 4 γ 1 c − 3 . In addition, we can conclude that A(U 4 ) = 0 and B(U 4 ) = 0, since R 1 (T 3 ) has a contradiction and C(T i ) = + for all tables, so it is not possible to go there. Then we can fill T 4 completely. Then, also C(U 4 ) = 0; otherwise the sequence B − 4 C + 4 B + 2 gives a contradiction. If we had α(U 4 ) = 3, then we must have A(T 4 ) = A(T 3 ) = − and, consequently (rule 5) B(U 3 ) = 1 or 2, but then the sequence A − 4 α − 4 B + 3 A + 1|2 leads to a contradiction, so α(U 4 ) = 0. In summary, we have T : Now T 1 is the only candidate for a table with three contradictions. In order to obey observation 6, the only possibilities for contradictions are C 2 , C 3 and R 2 , since T 4 has its contradiction in R 3 .
In particular, there must be a contradiction in C 2 (T 1 ). Then, in order to obey rule 5, we must have T : But then the proof can proceed exactly as in case 5A, with T 2 and T 4 interchanged: the only significant difference comes from c(U 1 ) = 2 = 4, but this was never used in the proof.  In this case, the tables read T : Here, the entries in U 1 have been chosen without loss of generality: From rules 4 and 5 it follows that one can restrict the attention to the cases where 4,3]. We only consider the first possibility; in the other cases the proof is analogous and is left to the gentle reader as an exercise. The zeros in U 2 , U 3 and U 4 come from rule 3. The entries 0|2 in U 4 come from possible measurement sequences such as c 4 a 4 c 3 or c 4 a 4 1 c 3 which prove that there cannot be the entries '3' or '1'. The other entries can be derived accordingly. From rule 5, it follows that in T 4 the contradiction cannot be in the rows, so it has to be in the first or second column. Let us assume, without loss of generality, that it is in C 1 (T 4 ). Further, we can assume without loss of generality that the values A and a in T 4 are both '+'. Then, the tables can be more specified as To see this, one first fills T 4 ; then, together with the entries of C 1 (U 4 ), many values of T 2 and T 3 are fixed. The entries 0|1 are justified similar to the reasoning above.
In T 2 as well as in T 3 the contradiction has to be in either R 1 or C 2 . However, there cannot be a contradiction in R 1 . To see this, assume that there was a contradiction in R 1 (T 2 ). Then, starting from T 2 we may measure the sequence C 2 A 2 B or C 2 B 2 A. According to rule 5, we must end in two different T i . But the memory state can never change to T 4 (because C(T 4 ) = −). So we must have B(U 2 ) = 3, but this will not escape the contradiction, since the values for A and C coincide in T 2 and T 3 . So there is only T 1 left, and we arrive at a contradiction.
Consequently, the contradictions have to be in both C 2 (T 2 ) and C 2 (T 3 ). In principle, our observation 6 implies already that we cannot find a solution with three contradictions in one table. But one can also directly prove that there is no solution at all. We have Here, we must have B(T 1 ) = B(T 2 ) = B(T 3 ) = + due to measurement sequences such as B + 2 B + 1 or B + 3 B + 1 and β(T 1 ) = β(T 2 ) due to β − 2 B + 2 β − 1 and b(T 1 ) = b(T 3 ) due to b + 3 B + 3 b + 1 . But then, starting from T 2 , the sequence β − 2 B + 2 b + 1 reveals a contradiction to the PM conditions. Starting from T 2 we may measure the sequence C 2 A 2 B or C 2 B 2 A. According to rule 5, we must end in two different T i . But the memory state can change neither to T 4 (because C(T 4 ) = −) nor to T 3 (as R 1 (T 3 ) contains a contradiction). So there is only T 1 left, and we arrive at a contradiction. In summary, by considering all eight different cases we have shown that no four-state solution exists in which one table has three contradictions. This proves the claim.

Appendix F. A ten-state automaton obeying all sequences
In this appendix, we show an example of a ten-state automaton that obeys the set of all sequences Q all . For that, we define ten eigenstates of two compatible observables. We let |A − B + be a quantum state with A|A − B + = −|A − B + and B|A − B + = +|A − B + . In this fashion we define the ten states |A + B + , |A − B + , |C + c + , |C − c + , |γ + β + , |γ − β + , |α + a + , |α − a + , |a + b + and |B + b + . Any measurement of an observable from the PM square projects with finite probability any state of the set onto another state of the set. If, e.g., the automaton is in state |A − B + and we measure c, QM predicts a chance of 50% to get the outcome +1 yielding the state |C − c + , and a 50% chance to obtain −1 and the state |C − c − . The former state is in the set of the ten states and hence our automaton would return +1 and change to the state |C − c + . We furthermore define that, if both states predicted by QM are in the set of the ten states, then we prefer the state corresponding to the output of +1. Together with an arbitrary choice of the initial state, this completes the definition of the automaton. By construction, this automaton is deterministic and obeys Q all .