A generalisation of the Phase Kick-Back

In this paper, we present a generalisation of the Phase Kick-Back technique, which is central to some of the classical algorithms in quantum computing. We will begin by recalling the Phase Kick-Back technique to then introduce the new generalised version for f:{0,1}n→{0,1}m\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$f:\{0,1\}^{n}\rightarrow \{0,1\}^{m}$$\end{document} functions using the eigenvalues of the oracle function Uf\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{U}_f$$\end{document}. After that, we will present a new generalised version of the Deutsch–Jozsa problem and how it can be solved using the previously defined technique. We will also deal with a generalised version of the Bernstein–Vazirani problem and solve it using the generalised Phase Kick-Back. Finally, we show how we can use this technique to obtain an algorithm for Simon’s problem that improves the classical one.


Introduction: Phase Kick-Back and notation
Let us begin by introducing the notation we will use, which will be that of [1,2].These two books, along with [3,4] can be consulted for more context on the topic of quantum computing.
Remark 1.First of all, we will call the elements x ∈ {0, 1} n binary strings and note them in bold, underlining their structure as vectors in the space F n 2 .Let y, z ∈ {0, 1} n be two strings, written y = y n−1 . . .y 1 y 0 , z = z n−1 . . .z 1 z 0 , and let ⊕ denote the exclusive or addition (which is addition modulo 2).We define the exclusive or operation for strings as the exclusive or bitwise, that is, y ⊕ z = (y n−1 ⊕ z n−1 ) . . .(y 1 ⊕ z 1 ) (y 0 ⊕ z 0 ) , and we will denote the pairing in {0, 1} n (not a scalar product, though) by Note that, as the xor operation is performed bitwise, we have We will also write 0 to refer to the zero n-string 0 = 00 • • • 0.
To represent quantum states we will use the Bra-Ket or Dirac notation, where given a binary string x ∈ {0, 1} n of length n we represent the n-dimensional qubit state of the computational basis corresponding to x by |x n .For one-dimensional qubit systems, we will often simply write the ket |x without the subindex.If we have more than one qubit system, we will write the number of qubits of each register separated by commas.For example, in |x n,m,r we would have three registers of n, m and r qubits respectively.
Let R be an m × n Boolean matrix-i.e., a matrix whose components are either 0s or 1s-and let r i be the binary string determined by the i-th file of R, we will define the result of the operation R • x as the string whose i-th component is r i • x (that is, the usual matrix-vector operation).
We will say that a Boolean function is a function f : {0, 1} n → {0, 1} m .It is well known-consult [3] for more information-that given a Boolean function one can construct the quantum gate U f whose effect is the following: Let us now review the Phase Kick-Back.To do so we must recall the Hadamard basis: Lemma 1.1.Let f : {0, 1} n → {0, 1} be a Boolean function, and let U f be the quantum gate that computes it.Then, in the n + 1 qubit system, vectors of the form |x n ⊗ |− are eigenvectors with eigenvalue (−1) f (x) for every x ∈ {0, 1} n .
Proof.To prove this result we must expand the following expression: If f (x) = 0, then the state does not change and we have: The Phase Kick-Back technique is almost always used to mark the amplitudes of the states of the computational basis whose image through f is 1.In that sense, we would have where H n is the Hadamard matrix of dimension n, which can be defined as: and whose effect on an element of the computational basis x ∈ {0, 1} n is the following: This can be easily proven by induction.In particular, when x = 0, we would have: Summarising, we would have a summation over all the states of the computational basis, all of them with the same amplitude in the first n-qubit register.The idea of the Phase Kick-Back is to apply U f to this state and mark the aforementioned elements with a negative amplitude.
Remark 2. (Deutsch-Jozsa algorithm.)Let us recall the Deutsch-Jozsa algorithm as an example of usage of this technique, which was presented in [5] but can be reviewed in any of the manuals of quantum computing already presented.Deutsch's problem is defined as follows.We have an unknown Boolean function f : {0, 1} n → {0, 1} which can either be constant-that is, f (x) is the same for every x ∈ {0, 1} n -or balanced, which means that for half of the values x ∈ {0, 1} n we have f (x) = 0 and for the other half f (x) = 1.
Deutsch's problem consists in determining whether f is constant or balanced using the function as a black box.In terms of time efficiency, this problem is actually quite hard to solve in the classical deterministic situation, as it would take 2 n−1 + 1 evaluations of f to solve in the worst scenario, but the Deutsch-Jozsa algorithm solves it with certainty with a single call to U f .
Let us review the role of the Phase Kick-Back in this algorithm.
Starting with the state |ϕ 0 n,1 = |0 n ⊗ |0 , we apply the Pauli X gate to the second register, obtaining |ϕ 1 n,1 = |0 n ⊗ |1 .Then, after applying Hadamard gates we get the state already introduced given by |ϕ 2 n,1 = H n |0 n ⊗ |− , and apply U f .Thus, we make use of the Phase Kick-Back technique: and we end up getting: And using that: We can expand the previous expression: Here, the amplitude of a state of the computational basis |z n is given by: In particular, if |z n = |0 n , then we would get the amplitude: That is, 0 when the function is balanced and 1 when it is constant.Thus, we end up with the state |0 n if the function is constant and a combination of the rest of states in the computational basis if the function is balanced.If we finish by measuring this register, we will get 0 if the function is constant and any other result if instead it is balanced.

Generalised Phase Kick-Back
Let us now present a generalisation of the Phase Kick-Back idea.This generalisation will consist on the expansion of the technique to general Boolean functions f : {0, 1} n → {0, 1} m , where the target qubit-the one in the second register of the Deutsch-Jozsa algorithm-becomes a register of m qubits.
During this generalisation we will take U f as presented before and we will notate the states given by H n |y n as |γ y n , where |y n are the elements of the computational basis.
Let us begin by presenting an analogous version to that of Lemma 1.1, which will constitute the core idea of this technique.Proof.We know that If we now apply U f to |x n ⊗ |γ y m , we get the following: And doing some manipulation, this expression becomes: as for a fixed f (x), |z ⊕ f (x) m runs through all of {0, 1} m just as z does.
As we can see, it is a completely analogous idea to the previous one, with the difference that we can now choose a marker, y ∈ {0, 1} n , which will work as a fixed reference and multiply each f (x).Let us take a look at the inner work of this idea using an example.
To use our new tool, we will need a 5-qubit system divided into a 3-qubit register and a 2-qubit register, both of them starting on |0 : We will begin by choosing a marker, i.e., the y ∈ {0, 1} 2 that will encode the information we want to look for in f .In this case, we will take y = 01, that is, we will mark those values whose image through f is 01 or 11.To do so, we will begin by preparing the second register to y, which is easily achieved by applying the Pauli X gate on the last qubit.
Once we have prepared our basic state, we will apply Hadamard gates to all qubits to obtain a superposition state.
Let us remark now that each state of the aforementioned superposition satisfies the conditions of Lemma 2.1, and thus if we apply the U f gate we will mark the states of the superposition depending on their image.
Remark 3. Another way of looking at this Generalised Phase Kick-Back idea is to write the state |γ y as a tensor product of |+ and |− states.As an example, in the instance we are dealing with we have: In general, for a given y ∈ {0, 1} m we would have a |+ in the i-th position if the i-th bit of y is 0 and |− if it is 1.In that sense, we could look at this Generalised Phase Kick-Back as a cascade of Phase Kick-Backs in those positions of y in which there is a 1.
Let us now focus our attention on the first 3-qubit register and use that f (x) • 01 = x • 010: And finally, if we apply Hadamard gates to this 3-qubit system, we will get the state |010 3 .
It is not clear now how this idea is helpful, as the final result is directly determined by the initial y we chose, and if we had fixed y = 10, then the final result would have been 100.However, suppose now that we do not know which of the bits f eliminates, and we want to determine which one it is.We only have three possibilities, and we could easily check with one classical call to f which of the bits is eliminated-simply compute f (010)-but it is interesting to do it by using our new tool.Lemma 2.2.Let f : {0, 1} n → {0, 1} n−1 be a Boolean function that eliminates one bit, then we can use the algorithm above to determine which bit is eliminated.
Proof.To do so, we just apply the generalised version of the algorithm mentioned above n − 1 times, using each time one of the vectors of the canonical basis of {0, 1} n−1 as an F 2 vector space.If we denote by e i the string of bits whose only 1 is in the i-th position (starting by 0)-i.e., the i-th element of the canonical basis-then each of the n − 1 iterations of the algorithm would go as follows: First, we obtain e i in the second register by applying the X gate wherever we need: Second, we apply Hadamard gates: Then, we use the GPK (Generalised Phase Kick-Back): And finally, we apply Hadamard gates to the first register and measure: After we have done so with all n − 1 possible e i , we will have obtained n − 1 of the n vectors of the canonical basis of F n 2 , and the one left indicates which of the bits is eliminated.This, of course, does not give us an improvement of any sort over the classical case-it is actually the opposite, as we could have just computed the image of x = 101010 . . .and checked for repeated characters-but it illustrates the inner workings of the technique.
Some other examples such as this could be constructed.Another one is the problem of, given an f that switches one unknown bit, finding out which one.However, we will now focus on a problem in which this idea allows for an improvement over the classical situation.

The generalised Deutsch-Jozsa problem
An easy follow-up to the previous section would be to solve a generalised version of the Deutsch-Jozsa problem using this technique.Let us begin by presenting the promised problem.
Definition 3.1.(Generalised Deutsch-Jozsa problem.) We say that a Boolean function is balanced if half of the input values output one string and the other half output another.
Given then a Boolean function f : {0, 1} n → {0, 1} m that can either be constant or balanced, we will denote by Generalised Deutsch-Jozsa problem the one of finding out in which of the cases are we.
The Deutsch-Jozsa problem is clearly one instance of this general problem where m = 1, and thus we will show how we can solve this problem by using an algorithm inspired by that of Deutsch and Jozsa.Let us begin by taking a moment to think about the complexity we are dealing with.
Remark 4. It is clear that if we want to solve this problem using classical deterministic methods, we will need something of the order of O(2 n−1 ) applications of f .We will see how we can improve this with a quantum algorithm to an order of O(m) calls to f .Note also that this includes the already known case where m = 1.
To begin taking a look at this problem, let us limit ourselves to the instance where constant means that f (x) = 0 for every x ∈ {0, 1} n and balanced means that half of the values are 0 and the other half a fixed string different from 0.
Let us first expose our algorithm and then worry about the analysis.Given e i = 0 (m−1)−i 1 0 i , where i = 0, . . ., m − 1, we will repeat the following algorithm for each e i , but it could actually be done for any binary string y ∈ {0, 1} m .
We begin with two registers of n and m qubits, both at the state |0 .
We apply the X gate to achieve the desired |e i state in the second register.If we want any other binary string y to act as a marker, we should apply the corresponding X gates in the necessary positions.
We apply Hadamard gates to obtain the desired superposition in the first register and |γ ei in the second.
We apply U f to use the GPK technique.At this point, the second register might be discarded and we apply Hadamard gates to the first one.

STEP 6
We measure the first register and name the result δ i .
If after repeating these steps for each i we obtain only δ i = 0 strings, then the function is constant; otherwise it is balanced.Definition 3.2.(Generalised Phase Kick-Back algorithm.)The only variable in the algorithm is the choice of the marker y used for the Phase Kick-Back.We will refer to this algorithm as GPK algorithm for y or GPK(y).From now on, the notation regarding this algorithm will be the same as before.
Theorem 3.3.(Correctness of the algorithm.)The aforementioned algorithm correctly determines whether a function is constant or balanced in the case where the image set of f includes 0.
Proof.Given i = 0, . . ., m − 1, let us keep track of the states step by step: As we are applying the X gate on the i-th qubit of the second register (counting from 0), then just by the definition of |γ ei and the known effect of Hadamard gates on the |0 state.Finally, we obtain where N = 2 n by applying Lemma 2.1.
If we focus now only on the first register, we will have the following state: Then, after applying the Hadamard gates, we will have: It is easy to check that if the function is constant and equal to 0, then regardless of the value of i the amplitude of |0 n in the previous superposition is the following: Thus, we will always obtain δ i = 0 no matter which marker we use.If f is not constant, then when f (x) = 0 there must be an i ∈ {0, . . ., m − 1} for which f (x) • e i = 1.If we take such a e i , then the amplitude for |0 n is: because f (x) is balanced and thus half the elements of the sum will be 1 and the other half −1.This implies that we would get a result different from 0 for that i.
Note that the choice of the canonical basis is not compulsory and that we could have chosen any other basis of F m 2 as our markers.Let us take a moment to prove that the same idea works for the general case of the Generalised Deutsch-Jozsa problem.

Theorem 3.4. (General correctness.) The previous algorithm correctly determines whether a function is constant or balanced.
Proof.The only thing left to analyse is the final amplitudes in the general case.To do so, we need to recall that the final state is: If we analyse now the amplitude of |z n = |0 n , we would be left with: •e i is either always 0 or always 1, as x varies.Whichever the case, the final amplitude will be either 1 or −1 and thus we will always get 0 at the end of the algorithm.
On the other hand, if f (x) is balanced with possible values f 1 , f 2 ∈ {0, 1} m such that f 1 = f 2 , then there is a i ∈ {0, . . ., m − 1} such that f 1 • e i = f 2 • e i , and for that i the amplitude of z = 0 would be: As the function is balanced between f 1 and f 2 , that amplitude is 0 and thus we would get a result different from 0.
This algorithm not only allows us to distinguish constant and balanced functions, but it also allows us to determine the values of the function.In the balanced situation, it would not be possible to do that efficiently in a deterministic way.

Corollary 3.5. It is possible to determine the possible values of f by applying the aforementioned algorithm and making a classical call to the function.
Proof.Let us begin by the case in which the possible images are 0 and f 1 .In this situation, the values of i for which we obtain a result different from δ i = 0 mark the bits of f 1 that are different from 0, thus determining exactly the value of f 1 , so f 1 = λ = λ m−1 . . .λ 1 λ 0 , where we define λ i as: In the general case, if we note the two possible images by f 1 and f 2 , the λ = λ m−1 . . .λ 1 λ 0 string tells us that the Boolean bitwise difference between f 1 and f 2i.e., f 1 ⊕ f 2 -.Thus, we would know that f 1 = f 2 ⊕ λ.If we now classically calculate one of the possible images-for instance f (0)-we would be able to retrieve both values.
Remark 5. We also have to point out that we have solved the problem by applying the quantum gate U f m times, which is an exponential improvement over the deterministic classical situation when m is of linear order with respect to n.
Before we move on to the next generalised problem, let us take a moment to make two important remarks.Remark 6.The first is about a certain pattern that will reappear in the next section, which is that the GPK algorithm is unable to detect translations.That is, given two Boolean functions f 1 , f 2 : {0, 1} n → {0, 1} m for which there is an s ∈ {0, 1} n such that f 1 (x) = f 2 (x) ⊕ s for every x ∈ {0, 1} n , if we analyse the first register of |ϕ 4 n+m for function f 2 using y ∈ {0, 1} m as a marker, we get: And if we now use that f 2 (x) = f 1 (x) ⊕ s, we get: And, as we can observe, we end up getting a quantum state equivalent to the one we would get by applying the GPK algorithm for the function f 1 which does not affect the probabilities of the final result.This is the reason behind the fact that what we get in the general case of the balanced situation in the Generalised Deutsch-Jozsa algorithm is the sum of the two possible values λ, and why we must make an extra step to find both values.
The other thing we want to point out has to do with the choice of markers.
Remark 7. In order to solve the generalised Deutsch-Jozsa problem we have computed m applications of the GPK algorithm with the elements of the computational basis as markers.What we want to show now is that this choice of markers is not compulsory and that any basis of {0, 1} m would suffice.
Let y 1 , . . ., y m ∈ {0, 1} m be any such basis, we will compute now the GPK algorithm for each of these markers.It becomes clear that if f (x)•y i is constant for all x ∈ {0, 1} n , then the result of the i-th iteration of the algorithm will be 0, while if f (x) • y i = 0 for half of the values and 1 for the other half, then the result will be any other binary string.
Let λ = f 1 ⊕ f 2 be the sum of the two possible values of the function as before-if the function is constant we would have λ = 0-then what we end up with is a system of equations: Where λ is the string of unknowns.This system is always made up of m linearly independent equations, as the y i are a basis of {0, 1} m , so the sole solution will be the desired λ.

A Bernstein-Vazirani inspired algorithm
Once again we will put our focus on generalising an already known problem which was studied in [6].Let us begin by recalling the Bernstein-Vazirani problem in the one-dimensional situation.Definition 4.1.(Bernstein-Vazirani problem.)Let f : {0, 1} n → {0, 1} be a function such that there is an r ∈ {0, 1} n for which f (x) = r • x, we want to find the binary string r.
Before analysing this problem, let us note that the condition stated in the Bernstein-Vazirani problem just asks for f to be linear.This is relevant because in the generalisation of this problem we will consider a linear f : {0, 1} n → {0, 1} m and ask to exactly determine it.
Regarding the complexity of this problem, we should note that a linear function f : {0, 1} n → {0, 1} can be determined in n calls to f , as we only have to calculate the image through f of the elements of one basis of {0, 1} n .In particular, we can calculate f (e i ) for each element in the canonical basis and the i-th element of r would be r i = f (e i ).
We will show how we can solve this problem with a quantum algorithm making a single call to U f .The algorithm we will describe is exactly the same as we used to solve the Deutsch-Jozsa problem.
First, we will have two registers of n and 1 qubits respectively: We can obtain the |1 in the second register by applying the X gate to the last qubit.Secondly, we will apply Hadamard gates to all the qubits in order to obtain the state: where N = 2 n .This state is now ready to use the Phase Kick-Back technique by applying U f : Using now that f (x) = r • x, we arrive at: Recalling the effect of H n on the computational basis, we can easily check that the first register of this state is exactly H n |r , so after applying H n to the first register we obtain: Then, after measuring the first register we will obtain r.Before considering the generalised problem, we will take the liberty to consider a slight modification to the Bernstein-Vazirani problem.Definition 4.2.(Modified Bernstein-Vazirani problem.)Let f : {0, 1} n → {0, 1} be a Boolean affine function-i.e., a Boolean function such that there are r ∈ {0, 1} n and r 0 ∈ {0, 1} for which f (x) = r 0 ⊕ r • x for all x-then we want to exactly determine said function.
What we will find out is that this problem can be solved by the previous algorithm with just a final step to determine r 0 .Proposition 4.3.The Bernstein-Vazirani algorithm solves the modified Bernstein-Vazirani problem with certainty with a final classical deterministic call to f to determine r 0 .
Proof.Following the previous exposition of the Bernstein-Vazirani algorithm, the only difference in this situation is that we would end up with the state: This is equivalent to the state we had in the previous situation, and thus we would end up getting r after measuring |ϕ 3 n,1 .
To get r 0 , we must only classically calculate f (0) = r 0 .
Again, we arrive at the same pattern, where the GPK cannot distinguish a translation in f , but only the linear structure it has.
Let us now use this idea to generalise the Bernstein-Vazirani problem to an arbitrary dimension.Definition 4.4.(Generalised Bernstein-Vazirani problem.)Let f : {0, 1} n → {0, 1} m be an affine function, i.e., one such that there is an m×n matrix R and an r 0 ∈ {0, 1} m for which f (x) = r 0 ⊕ R • x.The Generalised Bernstein-Vazirani problem is that of exactly determining f .Remark 8. Let us analyse the classical deterministic complexity of this problem.It is easy to prove that we can exactly determine R by calculating f (e i ) for each element of the computational basis, as the binary string determined by the i-th file of R, r i , will be exactly f (e i ) ⊕ r 0 .We can finally calculate r 0 by computing f (0), so the total calls to f will be n + 1.
It can be seen that with the GPK we can do this with m + 1 calls to the function, so in a way we will switch the roles of {0, 1} n and {0, 1} m .
We will now prove that we can solve the Generalised Bernstein-Vazirani problem by computing m iterations of the GPK algorithm by each of the elements of the computational basis of {0, 1} m and a final classical computation of f (0).Proof.We will only prove that the result of the algorithm GPK(e i ) is the binary string that determines the i-th row of R, which is an r i such that f (x) i = (r 0 ) i ⊕ r i • x.
Let us calculate the amplitude of r i in the final state of the GPK algorithm using e i as marker.
Therefore, the amplitude of r i is: As f (x) • e i = (r 0 ) i ⊕ r i • x.If we expand now the expression, we get: and we are assured to get r i .Once again, GPK only allows us to determine R, but tells us nothing about the translation r 0 , which we have to classically determine by computing f (0).Remark 9.The choice of computing the GPK algorithm with the elements of the computational basis is actually arbitrary, if we chose to do so with any other basis, we would end up getting the matrix of the linear application in said basis.
Again, we see that the GPK shines the most when applied to functions with a certain linear structure.

Conclusion and further research
In this paper we have presented a generalisation of a core technique in quantum computing, which has allowed us to generalise two classical problems in the field.This is important for two reasons.
Firstly, these new generalised problems and theirs solutions allow us to reach further into the understanding of the possibilities and limitations of quantum computing, giving us a deeper look into some of the problems that constitute the foundation of quantum algorithms.
Secondly, this technique may be used for solving some other problems, so we are effectively enlarging the arsenal at our disposal when faced with the uncertainty and unfamiliarity of quantum algorithms.
In future work, we hope to use this technique to target some new and old problems, further exploring the idea of balanced functions in the multidimensional situation.

Theorem 4 . 5 .
(Correctness of the algorithm.)It is possible to exactly determine the matrix R by computing GPK(e i ) for each of the elements e i of the computational basis of {0, 1} m .
if f were constant, then we would actually have gotten H n |0 n ⊗ |− again, so after applying H n to the first n-qubit register we would get |0 n .Let us do the calculations.