Efficient classical simulation of the Deutsch-Jozsa and Simon's algorithms

A long-standing aim of quantum information research is to understand what gives quantum computers their advantage. This requires separating problems that need genuinely quantum resources from those for which classical resources are enough. Two examples of quantum speed-up are the Deutsch-Jozsa and Simon's problem, both efficiently solvable on a quantum Turing machine, and both believed to lack efficient classical solutions. Here we present a framework that can simulate both quantum algorithms efficiently, solving the Deutsch-Jozsa problem with probability 1 using only one oracle query, and Simon's problem using linearly many oracle queries, just as expected of an ideal quantum computer. The presented simulation framework is in turn efficiently simulatable in a classical probabilistic Turing machine. This shows that the Deutsch-Jozsa and Simon's problem do not require any genuinely quantum resources, and that the quantum algorithms show no speed-up when compared with their corresponding classical simulation. Finally, this gives insight into what properties are needed in the two algorithms, and calls for further study of oracle separation between quantum and classical computation.

Quantum computational speed-up has motivated much research to build quantum computers, to find new algorithms, to quantify the speed-up, and to separate classical from quantum computation. One important goal is to understand the reason for quantum computational speed-up; to understand what resources are needed to do quantum computation. Some candidates for such necessary resources include superposition and interference [1], entanglement [2], nonlocality [3], contextuality [4][5][6], and the continuity of state-space [7]. In this paper we look at two so-called oracle problems: the Deutsch-Jozsa problem [8,9] and Simon's problem [10,11], thought to show that quantum computation is more powerful than classical computation. There are quantum algorithms that solve these problems efficiently, and here we present a framework that can simulate these quantum algorithms, Quantum Simulation Logic (QSL), that in itself can be efficiently simulated on a classical probabilistic Turing machine. To underline this, we provide Python implementations of these simulations as supplementary material, that give the correct output in seconds for 100,000-qubit inputs to the Deutsch-Jozsa algorithm and 512-qubit inputs to Simon's algorithm, for random choice of the function under consideration. This shows that no genuinely quantum resources are needed to solve these problems efficiently, but also tells us which properties are actually needed: the possibility to choose between two aspects of the same system within which to store, process, and retrieve information.
The quantum algorithm for the Deutsch-Josza problem has been used extensively for illustrating experimental realizations of a quantum computer, while Simon's algorithm served as inspiration for the later Shor's algorithm [13]. Both problems involve finding certain properties of a function f , and this can be done efficiently in a quantum computer given a quantum gate that implements the function, known as an oracle. When using a classical function as an oracle (an oracle that is only allowed to act on classical bits as input and giving classical bits Circuits for the Deutsch-Jozsa algorithm. A. The algorithm itself. This circuit uses an n-qubit query-register prepared in the state |0 , and a target prepared in |1 . It proceeds to apply Hadamard transformations to each qubit. The function f is embedded in an oracle U f , and this is followed by another Hadamard transformation on each query-register qubit. The measurement at the end will test positive for |0 if f was constant, and negative if f was balanced. B. Oracle construction for balanced functions. The arbitrary permutation π = x |π(x) x| of the computational basis states is constructed from CNOT and Toffoli gates [12] (π −1 = π † ). At the center is a CNOT gate from the most significant qubit |xn to the target |y . With π as the identity permutation, the oracle performs the balanced function f that is 1 for all inputs with the most significant bit set. Any other balanced function f (x) = f (π(x)) can now be generated by choosing a different π. For a function that is constant zero, the CNOT gate is omitted, while the constant one function should replace the CNOT with a Pauli-X gate acting on the target. as output), the Deutsch-Jozsa problem has an efficient solution on a classical probabilistic Turing machine [8,9], but for Simon's problem it has been proven [10,11] that no efficient solution exists. In both the quantum and classical case the oracle is treated as a black box, i.e., its internal structure is not visible from the outside, and each oracle call counts as one operation; one unit of time. An algorithm that requires at most a polynomial number of oracle calls and at most a polynomial amount of additional resources is regarded as efficient, but the oracle itself does not need to be efficiently computable. In essence, the question asked is "If this oracle was efficiently computable, would the whole algorithm be efficiently computable?" For both the mentioned problems, the answer is "yes" in quantum computation. For Simon's problem, the answer is "no" for the classicalfunction oracle, giving evidence for a separation relative to the oracle between quantum computation and classical computation. For the Deutsch-Jozsa problem such a separation is only obtained by requiring a deterministic solution.

I. THE DEUTSCH-JOZSA ALGORITHM AND QUANTUM SIMULATION LOGIC
The Deutsch-Jozsa problem is the following: Suppose that you are given a Boolean function f (x) : {0, 1} n → {0, 1} with the promise that it is either constant or balanced. The function is constant if it gives the same output (1 or 0) for all possible inputs, and it is balanced if it gives the output 0 for half of the possible inputs, and 1 for the other half. Your task is now to distinguish between these two cases [9,14]. Given such a func-tion, a classical Turing machine can solve this problem by checking the output for 2 n−1 + 1 values of the input; if all are the same, the function is constant, and otherwise balanced. A stochastic algorithm with k randomized function queries gives a bounded error probability [9] less than 2 1−k , showing that the problem is in the complexity class BPP (Bounded-error Probabilistic Polynomial-time solvable problems).
A quantum computer obtains the function as a unitary that implements the function, a quantum oracle. For later convenience we use the gate implementation of the oracle U f shown in Figure 1b. This device will give the expected outcomes for regular function queries, i.e., invocations that reveal a single function value. The desired input number k should be inserted in the query-register as the quantum state |k in the computational basis, and the answer-register should be in a computational basis state (say |0 ). Applying the oracle and measuring the answer-register will reveal the output of f : if the answerregister was flipped, then the function value is 1 for that input k. Given this quantum oracle the Deutsch-Jozsa algorithm [9,14] can solve the problem with a single query (see Figure 1a). In this algorithm Hadamards are applied to the query-register state, creating a quantum superposition of all possible inputs to the oracle. When the oracle is applied, this superposition is unchanged if the function is constant, and changed to a different superposition if the function is balanced. A change can be detected by again applying Hadamards and measuring in the computational basis. In the ideal case the error probability is zero, showing that the problem is in EQP (Exact or Error-free Quantum Polynomial-time solvable problems [15]).
The QSL versions of the quantum algorithm will use the same set-up as in Figure 1, but instead of qubits it will use pairs (b z , b x ) containing two classical bits, a "computational" bit b z and a "phase" bit b x . These constitute the elementary systems of our QSL framework, the "QSL bits". State preparation of a computational single qubit state |k is associated with preparation of (k, X) where X is a random evenly distributed bit. Measurement in the computational basis is associated with readout of the computational bit followed by randomization of the phase bit, somewhat like the uncertainty relation or really measurement disturbance as seen in quantum mechanics. Accordingly, measurement of the phase bit will be followed by a randomization of the computational bit. These constructions of state preparation and measurement prohibits exact preparation and readout of the system; the upper limit is one bit of information per It is relatively simple to simulate the single qubit gates used in the quantum algorithms: an X gate inverts the computational bit (preserving the value of the phase bit b x ), a Z gate inverts the phase bit (preserving b z ), and a H gate switches the computational and phase bits. These are constructed so that the resulting gates obey the quantum identities XX = ZZ = HH = I and HZH = X. It is also possible to define QSL Y and "phase" gates, but we will not discuss these and their associated identities here as they are not needed for the present task. A simple circuit is to prepare the state |0 , apply an H gate, and measure in the computational basis. This will give a random evenly distributed bit as output.
A system of several qubits can now be associated with a system of several QSL bits containing two internal bits each. A QSL simulation of the quantum Controlled-NOT (CNOT) gate can be constructed from two classical reversible-logic CNOTs. One classical CNOT connects the computational bits in the "forward" direction, while the other connects the phase bits in the "reverse" direction, see Figure 2a. This again is constructed to enable use of the same identities as apply for the quantum CNOT, most importantly a phenomenon sometimes called "phase kick-back" in quantum computation [14], see Figure 2b.
Our QSL framework is inspired by a construction of Spekkens [16] that captures many, but not all, properties of quantum mechanics. So far, the presented framework is completely equivalent to Spekkens' model (the H gate appears in a paper by Pusey [17]). Both frameworks are efficiently simulatable on a classical Turing machine (see above and Ref. [16]). Furthermore, both have a close relation to stabilizer states and Clifford group operations [17], and perhaps more interestingly, both frameworks capture some properties of entanglement, enabling protocols like super-dense coding and quantum-like teleportation, but cannot give all consequences of entanglement, most importantly, cannot give a Bell inequality violation.
Returning to the Deutsch-Josza problem, for n = 1 the oracle for the balanced function f (x) = x is a CNOT, which means that Figure 2b contains the whole Deutsch-Josza algorithm when using the prescribed initial state |0 |1 . With this initial state, the query-register measurement result would be 1, so that this oracle gives the same output from the QSL algorithm as from the quantum algorithm. Indeed, all oracles for n = 1 and n = 2 only use CNOT and X gates, so their simulation will give the same behaviour as the quantum oracles. For n = 1 and n = 2, the Deutsch-Jozsa algorithm is already known to have an implementation that does not rely on quantum resources [18], and also, the gates used so far can be found within the stabilizer formalism, and here the Gottesmann-Knill theorem tells us that they can be simulated efficiently [19].
However, for n ≥ 3, the Deutsch-Jozsa oracle needs the Toffoli gate, and since the Toffoli gate cannot be efficiently simulated using the stabilizer formalism [19], nor is present in Spekkens' framework [16,20], it has so far been believed that the Deutsch-Jozsa algorithm does not have an efficient classical simulation. Here, we need to point out that our task is not to create exact Toffoli gate equivalents, or even simulate the full quantummechanical system as such. It suffices to give a working efficient QSL version of the Deutsch-Jozsa algorithm. We therefore choose not to represent Toffoli gates exactly, but design the gate so that it implements a classical Toffoli in the computational bits, and some other gate in the phase bits. For simplicity we choose the identity map for the phase bits, see Figure 2c.
By representing a general computational-state permutation π in the same manner as the Toffoli (see Figure 2d), the quantum oracle can immediately be translated into an oracle within the QSL framework. The balanced-function oracle in Figure 1b leaves the phase bits unchanged except for the one belonging to the most significant QSL bit in the query-register. A constantfunction oracle leaves all phase bits unchanged. Since Hadamard gates are included before and after the oracle, measurement of the computational bits will reveal the oracle's effect on the phase bits of the query-register, solving the problem by only one oracle query.
This QSL algorithm uses equally many QSL bits and QSL gates as the quantum algorithm uses qubits and quantum gates. The time and space complexity are therefore identical to the complexity of the quantum algorithm. The QSL algorithm can be efficiently simulated on a classical probabilistic Turing machine, using two classical bits for each simulated qubit and at most twice as many classical reversible gates as quantum gates. The error probability is 0, and in fact, the same correct output is generated for all possible random values in the probabilistic machine, the machine's random value could therefore be replaced with a constant value without destroying the simulation. Therefore, this QSL algorithm can be simulated on a classical deterministic Turing machine, showing that, relative to the oracle, the Deutsch-Jozsa problem is in P (Polynomial time solvable problems).

II. SIMON'S PROBLEM
Simon's problem is to decide whether a function f (x) : {0, 1} n → {0, 1} n is one-to-one or two-to-one invariant under the bitwise exclusive-OR operation with a secret string s (or equivalent, invariant under a nontrivial XORmask s [10,11]). In both cases, f (x) = f (x ) if and only if x = x ⊕ s (bit-wise addition modulo 2); if s = 0 then f is one-to-one and otherwise f is two-to-one. When using a classical function as an oracle, a classical probabilistic Turing machine needs an exponential number of oracle evaluations for this task [10,11], showing that relative to this oracle, Simon's problem is not in BPP.
Simon's quantum algorithm can distinguish these two cases in an expected linear number of oracle queries [10,11], showing that the problem is in BQP (Bounded-error Quantum Polynomial time [15]). A circuit diagram of the quantum subroutine and one realization of the oracle used in Simon's algorithm is shown in Figure 3a-b. An explicit construction of the gate U s can be obtained by choosing a basis {v k } for the part of the binary vector space orthogonal to s. If s = 0, the basis consists of n vectors, otherwise n − 1 vectors. For every entry v k j = 1, connect a CNOT from query-register bit j to ancilla- The measurement at the end will give a random bit sequence y such that y · s = 0 (mod 2). B. Oracle construction. The oracle U f uses an internal n-qubit ancilla, and the CNOT denotes a string of bit-wise CNOTs from each ancilla bit to the corresponding answer-register bit. The unitary Us is constructed from CNOTs [21] (see the main text) so that it implements one representative function for each specific secret string s, and the permutation π gives access to all functions f . The dotted gate combination U f implements |x |0 → |x |f (x) as required in Simon [10,11], and the additional circuitry in U f is there to map |x |z to |x |z ⊕ f (x) and reset the ancilla [22]. C. The modified subroutine for the deterministic algorithm. The n-qubit query-and answer-register are prepared in the state |0 |w . The circuit applies Hadamard transformations to the query-and answer-registers, the function f embedded in an oracle U f , and finally another Hadamard before measurement.
register k (in realizations, it is beneficial to choose v k to minimize the number of CNOTs [21]). The permutation after U s enables all possible functions. Let us illustrate the construction of U s with the following example. Suppose s = (1, 0, 1), then we choose the basis {v k } = {(1, 0, 1), (0, 1, 0)} which spans the binary vector space orthogonal to s (note that the scalar product is defined mod 2). Now we see that U (1,0,1) can be constructed from three CNOTs, one from the first query-register qubit to the first ancilla qubit, one from the third query-register qubit to the first ancilla qubit, and one from the second query-register qubit to the second ancilla qubit.
The quantum subroutine output is a random bit vector y such that y · s = 0 mod 2 (bit-wise dot product), uniformly distributed over all such bit vectors y. After an expected number of iterations that is linear in n, the subroutine will have produced n − 1 linearly independent values of y [10,11], so that the resulting linear system of equations for s can be solved, giving one non-trivial solution s * . If the function is one-to-one, this solution is just a random bit sequence, but if the function is two-to-one the solution is the actual secret string s. Querying the function for f (0) and f (s * ) will give equal values if the function is two-to-one, and unequal values if the function is one-to-one, solving Simon's problem. Note that as a consequence of solving Simon's problem one also obtains the secret string s.
The QSL versions of the subroutine and oracle is again obtained by substituting the quantum gates with their corresponding QSL gates. The QSL CNOT and U s constructions give the explicit map (x, p), (0, a) → The permutations π and π −1 do not influence the phase, so the complete oracle U f is the map (x, p), By the use of Hadamard gates, the simulation of Simon's subroutine sets the query-register phase entering the oracle to p = 0 n , while the answer-register phase w will be uniformly distributed. Measurement of the computational bits after the final Hadamard will therefore give a random bit vector y = g(w) that is orthogonal to s, uniformly distributed over the possible values. This reproduces the quantum predictions exactly, showing that the simulation will work with this subroutine to solve Simon's problem with the same expected linear number of iterations in n. Again, efficient simulation of the QSL framework on a classical probabilistic Turing machine shows that, relative to the oracle, Simon's problem is in BPP.
The derandomized quantum algorithm for Simon's problem [23,24] (with zero error probability), that shows that Simon's problem relative to the quantum oracle is in EQP, is not immediately usable because it incorporates a modified Grover search [25] which is not known to have an implementation within the QSL framework. The quantum algorithm is intended to remove already seen y and, crucially, prevent measuring y = 0 which would be a failed iteration of the algorithm. The modified Grover search is presented [23] as applied to the output of U f , but since the final step of the Grover search is again U f , the whole combination can be viewed as U f preceded by another quantum algorithm. This other quantum algorithm, in a sense, finds an input to U f such that the coefficient of the term |0 of the output is 0.
Since we do not have a Grover equivalent in our framework, we would like a simpler solution. One way to achieve this is to prepare the initial answer-register state as the Hadamard transformation of a chosen state |w , see Figure 3c. Iterating |w over a basis for the bit-vector space will produce n values of y that span the bit vector space orthogonal to s. Either this spans the whole space (s = 0), or gives a linear system of equations that has one non-trivial solution, equal to s. This QSL algorithm gives deterministic correct outputs just as the QSL Deutsch-Jozsa algorithm, and can therefore also be efficiently simulated on a classical deterministic Turing machine, showing that relative to the oracle, Simon's problem actually lies within P.
This linear search procedure works in our setting because the QSL permutation gate π does not influence the phase bits. In the quantum-mechanical case, the quantum gate implementing π does change what is sometimes called phase information, e.g., in the simple case when the quantum π is a CNOT. A more convoluted example that does not correspond to a simple modification of the phase information is when the quantum π is a (non-stabilizer) Toffoli gate. Thus, the derandomized quantum algorithm [23] requires the more advanced modified Grover's search algorithm. However, note that if the oracle is the smaller gate combination U f in Figure 3b that obeys only the original [10,11] requirement |x |0 → |x |f (x) (for z = 0), then the quantum version of the simpler algorithm proposed above will work as well, avoiding the modified Grover search.

III. CONCLUSIONS
In conclusion, we have devised QSL equivalents of the Deutsch-Jozsa and Simon's quantum algorithms. In the quantum algorithm, you are given a quantum oracle, a unitary gate that implements f by acting on qubits, your task is to distinguish two or more families of functions. In the presented QSL algorithms, you are given a gate that implements f by acting on QSL systems, and the same task. Using the QSL framework, we obtain the same success probability and the same time and space complexity as for the quantum algorithms, and these QSL algorithms are in turn efficiently simulatable in classical Turing machines (implementations that can be run with very large inputs are provided as Supplementary material). Therefore, the Deutsch-Jozsa and Simon's algorithms cannot anymore be used as evidence for a relativized oracle separation between EQP and BPP, or even P. Both problems are, relative to the oracles, in fact in P.
Apparently, the resource that gives these quantum algorithms their power is also available in QSL, but not when using an oracle in the form of an ordinary classical function. Each qubit is simulated by two classical bits in a classical probabilistic Turing machine, and in the above oracles one of these bits is used for computing the function, while the other is changed systematically when U f is applied. This change (in phase information) can then be revealed by choosing to insert Hadamards before and after the oracle. This choice is present in both quantum systems and our simulation, and enables revealing either function output or function structure, as desired. Our conclusion is that the needed resource is the possibility to choose between two aspects of the same system within which to store, process, and retrieve information.
While we still believe that quantum computers are more powerful than classical computers, the question arises whether oracle separation really can distinguish quantum-computational complexity classes from classical complexity classes. There are many other examples of quantum-classical oracle separation, [26][27][28] and some simple cases can be conjectured to have efficient simulations in the QSL framework (e.g., 3-level systems [16] for the three-valued Deutsch-Jozsa problem [26]), but in general the question needs further study. It is possible that the same technique can be used for direct computation using other quantum algorithms [13,25], but this will take us out of the oracle paradigm. Also, general quantum computation has been conjectured to use genuinely quantum properties such as the continuum of quantum states, or contextuality [5,6], which both are missing from the QSL framework [16]. In any case, neither the Deutsch-Jozsa nor Simon's algorithm needs genuinely quantum mechanical resources.