1 Introduction

Quantum computing is known for its potential to outperform classical computation in some specific tasks. The most popular quantum algorithms are Shor’s factorization algorithm [1] and Grover’s search algorithm [2], which provide exponential and quadratic time speedup, respectively, over the best known classical algorithms. However, other algorithms that show the potential of quantum computers have been proposed, such as the Elitzur–Vaidman bomb tester [3]. This algorithm is based on the Zeno effect [4], that is, the initial state of the circuit is slowly rotated to a different state unless measurements occur. On the other hand, in the presence of measurements, the final and initial states are the same with high probability. Zeno effect-based circuits, and mainly the Elitzur–Vaidman one, have proved to be useful in applications to multiple fields, such as cryptography or object mapping [5,6,7,8,9].

In this article, we introduce a framework for studying measurement detection in an unknown basis in circuits of the same kind. One of the aims of this work is to extend the scope of the Elitzur–Vaidman algorithm, and study its behaviour for unknown measurement bases and multiple qubits. So, we introduce quantum measurement detection algorithms (QMDA), which provide a generalization of the Zeno effect of the Elitzur–Vaidman algorithm.

A QMDA is a quantum circuit that includes three operators (\(U_0,U,U_1\)), one of them (U) being applied numerous times consecutively, and whose initial state is fixed when no foreign measurements (i.e. undesired measurements that are not expected during the execution of a circuit) occur.

Some properties of a QMDA are proved, including the detection of measurement probability of error of a QMDA for a given measurement basis and the corresponding optimal value. In addition, we find some bases that are likely to yield less accurate detections, although the probability bounds that we provide, decrease exponentially as the number of qubits increases. Such bases are given by a linear combination of eigenvectors of the operator U. This framework allows to compare the generalization of the Elitzur–Vaidman algorithm with the best possible QMDA. For more than one qubit, it can be proved to be outperformed by some rather difficult-to-describe QMDA.

Finally, we hint at some extensions of the definition of a QMDA that might overcome some problems derived from our study. Such extensions of the definition would also include algorithms such as the counterfactual communication [5] one. In addition, a QMDA might also be helpful to spot interferences that cause undesired measurements in a circuit.

The structure of this paper is as follows. In Sect. 2, we briefly describe the Elitzur–Vaidman bomb tester. In Sect. 3, we introduce the definition of QMDA, its associated detection scheme and we show the main properties of these circuits. In Sect. 4, we study the particular case of the Elitzur–Vaidman bomb tester, and finally, Sect. 6 contains the conclusions and future work.

2 Elitzur–Vaidman algorithm

This paper has been motivated by the Elitzur–Vaidman algorithm. It aims at determining whether foreign measurements have been applied to a circuit or not. Henceforth, by foreign measurements, we will mean undesired measurements that are not expected during the execution of a circuit, and they will be represented as an O in the circuits. In order to detect them, the Zeno effect is used, rotating the initial state slowly so that, if measurements are taken, the final state of the algorithm differs, with high probability, from the one when none of those measurements occur. We will briefly describe it next.

Elitzur–Vaidman bomb tester

The objective is to detect measurements in a 1-qubit quantum circuit. Such measurements represent a bomb in a quantum circuit, which explodes when \(|1\rangle \) is measured. The algorithm is designed to minimize the probability of measuring \(|1\rangle \), while detecting the presence of the measurements in the end, without triggering the bomb. As mentioned before, O will represent the place where a measurement may or may not occur.

The Elitzur–Vaidman circuit is shown in Fig. 1, where \(\theta = \frac{\pi }{2k}\) for a given \(k\in \mathbb {N}\), and the rotation \(R_{\theta }\), whose coordinate matrix with respect to the computational basis is \(\begin{pmatrix} \cos \theta &{} -\sin \theta \\ \sin \theta &{} \cos \theta \end{pmatrix}\), is applied k times. As we mentioned above, the rotation is applied multiple times in order to rotate the state slowly while the measurements may occur, so that an interruption of such rotation (a measurement) would cause different outcomes in the final measurement with high probability.

Fig. 1
figure 1

Elitzur–Vaidman algorithm for one qubit

If there are no measurements on O (no bomb), the state \(|0\rangle \) will be allowed to rotate to \(|1\rangle \), which will be the result of the last measurement with certainty. (Since this measurement is not related to O, it does not affect the bomb.)

On the other hand, if there is actually a bomb, each O will take a measurement. This is the case when the rotation is constantly being interrupted, and consequently, the state will not be able to get to \(|1\rangle \) and it is likely to stay in \(|0\rangle \) for every O measurement. More precisely, the probability of outcome \(|1\rangle \) (and so exploding the bomb) is \(\sin ^{2} \theta \) each time. Therefore, the probability of measuring \(|0\rangle \) in every O, is \(\cos ^{2k}\theta \xrightarrow [k \rightarrow \infty ]{} 1\). So, the probability of measuring \(|0\rangle \) at the end can be as close to 1 as desired, meaning the detection of bomb in the circuit despite not having sparked any explosion.

As we see, the algorithm detects the existence of measurements in a circuit. A relevant question is its performance when the measurements basis is unknown and arbitrary. This is the problem that will be addressed in this article.

3 QMDA and their properties

As shown in the previous section, we know algorithms that are able to detect, with high probability, if measurements were taken during the circuit or not, and our aim is to generalize them taking the Elitzur–Vaidman algorithms as the main reference. We will provide the theoretical framework before focusing on the Elitzur–Vaidman bomb tester.

3.1 QMDA definition

The following definition is inspired by our previous work on Quantum Abstract Detecting Systems (QADS) [10]. These systems are able to detect whether there is a marked element in a given set. This is achieved by creating circuits that fix the initial state when there are no marked elements, so that the outcome is predictable in that case. Measuring any other state at the end of the circuit would inevitably mean that there are marked elements. Different subclasses, such as combinatorial or rotational QADS, have proved to be useful for a variety of problems [11].

Since the objective of QMDA is to detect whether there are measurements in our circuit, we can employ the same strategy as QADS: fixing the initial state when none of those measurements occur, so that a predictable outcome is forced for this case. Hence, the QMDA will be expected to fix the initial state when there are no measurements, so that any other state at the end of the circuit would confirm that measurements have happened. The similarities are illustrated in Table 1.

Table 1 Comparison between QADS and QMDA

Definition 1

A quantum measurement detection algorithm of size n, henceforth \(\hbox {QMDA}_n\), is a 5-tuple \((U_0,U,U_1,k,|\psi _0\rangle )\), where \(|\psi _0\rangle \in \mathcal {H}\) represents the initial state, being \(\mathcal {H}\) a Hilbert space of dimension \(N=2^n\); \(U_0,U, U_1\) are unitary operators on \(\mathcal {H}\) and \(k>0\) is a natural number such that \(U_1U^kU_0|\psi _0\rangle = |\psi _0\rangle \).

Fig. 2
figure 2

Circuit of a QMDA

As shown in Fig. 2, \(U_0\) represents the sub-circuit before the first O (measurement or not), U the sub-circuit that will be repeated between each two O and \(U_1\) the final sub-circuit before the last measurement. It is clear, then, that the circuit is prepared for \(k+1\) applications of O. If \(O\equiv I\) (no measurement), then the gates are applied consecutively getting to the final state \(|\psi _0\rangle \). If \(O \equiv \) measure, we assume all of them measure in the same basis.

From this, the detection scheme for measurements is the following.

figure a

We would like to minimize the probability of error of the algorithm when the measurement basis is unknown. We should notice that the detection scheme does not provide a wrong answer when \(O\equiv I\), but it might fail when \(O \equiv \) measure when we obtain \(|\psi _0\rangle \) at the end, so the probability of error is only related to this case.

Our definition allows us to introduce a family of Elitzur–Vaidman algorithms.

Definition 2

We define \(\hbox {EV}_{n,k}\) as the 5-tuple \((R_{\theta _k}^{\otimes n}, R_{\theta _k}^{\otimes n}, \sigma _X \cdot R_{\theta _k}^{\otimes n}, k, |0\rangle ^{\otimes n})\), where \(\theta _k = \frac{\pi }{2(k+2)}\). \(\hbox {EV}_{n,k}\) is a \(\hbox {QMDA}_n\) for all n and k natural numbers.

Fig. 3
figure 3

Elitzur–Vaidman algorithm as a QMDA for n qubits

The circuit is shown in Fig. 3. The final NOT gate has the objective of fixing the initial state whenever \(O \equiv I_N\).

3.2 Properties of a \(\hbox {QMDA}_n\)

We begin by studying the behaviour of the circuit when the measurements occur. Let us introduce some useful notation.

Definition 3

Given a \(\hbox {QMDA}_n\) \((U_0,U,U_1,k,|\psi _0\rangle )\) and an orthonormal basis \(M = \{|m_i\rangle \}_{i=1}^{N}\), we define the auxiliary matrices

$$\begin{aligned}\begin{gathered} \hat{M}_0 := (|\langle m_i|U_0|\psi _0\rangle |^2)_{1\le i\le N} \text{(column } \text{ vector), } \\ \hat{M} := (|\langle m_i|U|m_j\rangle |^2)_{1\le i,j\le N}, \\ \hat{M}_1 := (|\langle \psi _0|U_1|m_j\rangle |^2)_{1\le j\le N} = (|\langle m_j|U_1^\dag |\psi _0\rangle |^2)_{1\le j\le N} \text{(row } \text{ vector). } \end{gathered}\end{aligned}$$

\(\hat{M}_0\) gathers the probability of the \(\hbox {QMDA}_n\) circuit collapsing into each \(|m_i\rangle \) in the first O measurement, after starting in the state \(|\psi _0\rangle \); \(\hat{M}\) gathers its probability of collapsing into each \(|m_i\rangle \) in the following O measurements, after starting each sub-circuit in the corresponding \(|m_j\rangle \) measured in the previous O; and \(\hat{M}_1\) gathers its probability of collapsing into \(|\psi _0\rangle \) at the end (which would mean a wrong detection), depending on the state \(|m_j\rangle \) it started in after the final O measurement.

The auxiliary matrices are central in our study, due to the fact that they will allow us to calculate the probability of error of the detection scheme.

Theorem 1

Given a \(\hbox {QMDA}_n\) \((U_0,U,U_1,k,|\psi _0\rangle )\), and assuming that every O represents a measurement in an orthonormal basis \(M = \{|m_i\rangle \}_{i=1}^{N}\), the probability of measuring the state \(|\psi _0\rangle \) at the end of the algorithm is given by \(\hat{M}_1\hat{M}^k \hat{M}_0\).

The proof of every result of this section can be found in “Appendix A.” This theorem theoretically allows us to calculate the probability of error of the algorithm for a given basis M. However, a practical computation of \(\hat{M}^k\) might be difficult when \(n>>1\). In this sense, a useful property that we can use to calculate the three auxiliary matrices is the fact that every row and column adds up to 1, and so some tricks to calculate \(\hat{M}^k\) are used in subsequent proofs (gathered in the appendices).

Moreover, since there may be a high number of undesired measurements in the circuits that are out of our control and that might be conditioned by an interfering environment, it is reasonable to question the effect that noisy measurements would have on QMDA. We can obtain a first insight into this subject by considering that, for every measurement in O, the probability of measuring the state \(|m_i\rangle \) when, in absence of noise, we would have measured \(|m_j\rangle \), is given by \(\langle m_i| E |m_j\rangle \), where E is a stochastic matrix. This type of noise has been used before to study measurement errors, for instance in [12].

Under these conditions, the formula for the probability of error changes, as the stochastic matrix gets represented once for each O measurement.

Theorem 2

Given a \(\hbox {QMDA}_n\) \((U_0,U,U_1,k,|\psi _0\rangle )\), and assuming that every O represents a noisy measurement in an orthonormal basis \(M = \{|m_i\rangle \}_{i=1}^{N}\), being E the associated readout error stochastic matrix, the probability of measuring the state \(|\psi _0\rangle \) at the end of the algorithm is given by \(\hat{M}_1(\hat{E} \hat{M})^k \hat{E} \hat{M_0}\), where \(\hat{E} := (\langle m_i| E |m_j\rangle )_{1\le i,j\le N}\).

The effect of more complex types of noise is an interesting subject that would deserve a more thorough and independent study. For now, our aim is to find an algorithm capable of detecting whether measurements have taken place or not, but without knowing the basis in which they occur. To guide us, we will use the following natural definition for the worst behaviour of the detection scheme.

Definition 4

Let \(\mathcal {M}\) be the set of orthonormal bases of a Hilbert space \(\mathcal {H}\) of dimension N. Given a \(\hbox {QMDA}_n\) \(\mathcal {Q}\), we define \(\delta (\mathcal {Q}) :=\) sup\(\{ \hat{M}_1\hat{M}^{k} \hat{M}_0 \}_{M\in \mathcal {M}}\), and we say that \(\mathcal {Q}\) is a \(\delta (\mathcal {Q})\)-detector algorithm.

Obviously, we aim to find a QMDA whose \(\delta (\mathcal {Q})\) is as low as possible.

It is time to prove some bounds to the probability of error and to \(\delta (\mathcal {Q})\), some of them being related to the eigenvectors of U, due to their ability to skip the influence of every U gate.

Proposition 1

Let \((U_0,U,U_1,k,|\psi _0\rangle )\) be a \(\hbox {QMDA}_n\) and M an orthonormal basis of a Hilbert space of dimension N. Then

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 \ge \frac{1}{N^{2(k+1)}} > 0. \end{aligned}$$

This immediately shows that it is impossible for a \(\hbox {QMDA}_n\) to achieve a perfect accuracy for any basis we are measuring in, so our best option is to be able to decrease the probability of error as much as desired, which will always require an increment of k. Although this can be easily overcome, in the next theorems we identify measurement bases having particularly undesired properties.

Theorem 3

Let \((U_0,U,U_1,k,|\psi _0\rangle )\) be a \(\hbox {QMDA}_n\) and let \(A = \{|a_i\rangle \}_{i=1}^N\) be an orthonormal basis of eigenvectors of U. Then \(\hat{A} = I_N\), \(\hat{A}_1^t = \hat{A}_0\) and

$$\begin{aligned} \hat{A}_1 \hat{A}^k \hat{A}_0 = \hat{A}_1 \hat{A}_1^t = \hat{A}_0^t \hat{A}_0 \ge \frac{1}{N}. \end{aligned}$$

Moreover,

$$\begin{aligned} \hat{A}_1 \hat{A}^{k} \hat{A}_0 = \frac{1}{N} \ \Leftrightarrow \ |\langle a_i|U_0|\psi _0\rangle |^2 = \frac{1}{N}, \ \ \forall i=1, \ldots , N. \end{aligned}$$

As we can see, when measurements occur in a basis of eigenvectors of U, the detection is immediately restricted to \(\frac{1}{N}\). This property suggests that eigenvectors-related bases are worth studying and will be our main concern. Several conclusions can be deduced from it, mainly bounds for \(\delta (\mathcal {Q})\) that warn us about the difficulty of dealing with these bases.

Corollary 1

If \(\mathcal {Q}\) is a \(\hbox {QMDA}_n\), then \(\delta (\mathcal {Q}) \ge \frac{1}{N}\).

Corollary 2

If \(\mathcal {Q}\) is a \(\hbox {QMDA}_n\), then \(\delta (\mathcal {Q}) = \frac{1}{N}\) if and only if the maximum of \(\hat{M}_1 \hat{M}^{k} \hat{M}_0\) is reached for any basis of eigenvectors of U and its value is \(\frac{1}{N}\).

Corollary 3

If \(\mathcal {Q}\) is a \(\hbox {QMDA}_n\) and \(\exists |a\rangle \) eigenvector of U such that \(U_0 |\psi _0\rangle = |a\rangle \), then \(|\langle a|U_0|\psi _0\rangle |^2 = 1\), and hence, \(\delta (\mathcal {Q}) = 1\).

Although the first corollary is a lower bound for the probability of error, this bound decreases exponentially with n, so it is not as restrictive as expected. Additionally, it suggests the following definition.

Definition 5

We say that a \(\hbox {QMDA}_n\) \(\mathcal {Q}\) is optimal if \(\delta (\mathcal {Q}) = \frac{1}{N}\).

Corollary 4

If a \(\hbox {QMDA}_n\) is optimal and A is a basis of eigenvectors of U, then \(|\langle a_i|U_0|\psi _0\rangle |^2 = \frac{1}{N}\), \(\forall i=1,\ldots ,N\).

It is worth pointing out that this bound does not mean that the maximum of \(\hat{M}_1 \hat{M}^{k} \hat{M}_0\) is always reached for a basis of eigenvectors of U. In fact, as we will see in the next section, the maximum probability of error in the case of any \(\hbox {EV}_{1,k}\) is not reached for the basis of eigenvectors \(\{ |+i\rangle , |-i\rangle \}\), but for \(\{ |+\rangle , |-\rangle \}\). This means that no \(\hbox {EV}_{n,k}\) is optimal. However, at least every \(\hbox {EV}_{1,k}\) will satisfy the following definition, which is inspired by the properties proved in Proposition 1 and Theorem 3.

Definition 6

We say that an infinite family \(\{ \mathcal {Q}_{p} \}_{p=1}^\infty \) of \(\hbox {QMDA}_n\), dependent on the parameter p, is asymptotically optimal if \(\delta (\mathcal {Q}_{p}) \xrightarrow [p \rightarrow \infty ]{} \frac{1}{N}\) and \(\exists M\in \mathcal {M}\) such that \(\hat{M}_{1,p} \hat{M}^{k(p)}_p \hat{M}_{0,p} \xrightarrow [p \rightarrow \infty ]{} 0\).

If a family \(\{ \mathcal {Q}_{p} \}_{p=1}^\infty \) is asymptotically optimal, then we know from Proposition 1 that \(p \rightarrow \infty \Rightarrow k(p) \rightarrow \infty \). After these two definitions, we aim at finding some \(\hbox {QMDA}_n\) that verifies the conditions presented. As we already advanced, \(\hbox {EV}_{1,k}\) does the job for \(n=1\), but as n increases, we need to consider QMDAs with clever combinations of eigenvectors of U. This is because, as we will prove, they tend to cause high probabilities of error if they are not treated correctly. We gather the bases of linear combinations of eigenvectors of U in the following definition.

Definition 7

For any basis \(A = \{|a_i\rangle \}_{i=1}^N\) and any P divisor of N, we say the basis M is a P-combination of A if

$$\begin{aligned} |m_{Pd+i}\rangle = \frac{1}{\sqrt{P}} \sum _{j=1}^P \sigma _i(j)|a_{Pd+j}\rangle , \end{aligned}$$

where \(i=1,\ldots ,P\); \(d=0,\ldots ,N/P-1\) and each \(\sigma _i(j)\) is either 1 or -1 (in other words, it just indicates the sign accompanying each \(|a_j\rangle \) for the ith element of M). Moreover, M must verify the following properties:

$$\begin{aligned}&1. \ \ \ \sigma _1(j) = \sigma _i(1) = 1, \ \ \forall i,j \\&2\text{ a }. \ \ \ \sum _{j=1}^P \sigma _{i_1}(j)\sigma _{i_2}(j) = 0, \ \ \forall i_1\not =i_2 \\&3\text{ a }. \ \ \ \forall i_1,i_2, \ \exists p \text{ such } \text{ that } \ \sigma _{i_1}(j)\sigma _{i_2}(j) = \sigma _p(j), \ \ \forall j \\&3\text{ b }. \ \ \ \forall j_1,j_2, \ \exists q \text{ such } \text{ that } \ \sigma _i(j_1)\sigma _i(j_2) = \sigma _i(q), \ \ \forall i \end{aligned}$$

This bases are just linear combinations of the vectors of A, but with every coefficient being \(\pm 1/\sqrt{P}\). We will see how to construct one soon. Property 1 means that the first element of M is the sum of the first P elements of A. Property 2a ensures the orthonormality of the basis, and 3a means that the product of the signs of two different elements of M are the signs of another element of M. We will need all of them for proving the upcoming theorems. In addition, some extra properties can be deduced from these:

Proposition 2

If M is a P-combination of the basis A, the following properties are a consequence of the properties 1 and 2a.

$$\begin{aligned}&2\text{ b }. \ \ \ \sum _{i=1}^P \sigma _i(j_1)\sigma _i(j_2) = 0, \ \ \forall j_1\not =j_2 \\&2\text{ c }. \ \ \ \sum _{j=1}^P \sigma _i(j) = 0, \ \ \forall i\not =1 \\&2\text{ d }. \ \ \ \sum _{i=1}^P \sigma _i(j) = 0, \ \ \forall j\not =1 \end{aligned}$$

We will also benefit from the property 3a and 3b to introduce some notation. Since 3a is a property of the signs ‘by rows’, and 3b is analogous ‘by columns’, we will use the notation

$$\begin{aligned} (i_1,i_2)_r = p \ :\Leftrightarrow \ \sigma _{i_1}(j)\sigma _{i_2}(j) = \sigma _p(j), \\ (j_1,j_2)_c = q \ :\Leftrightarrow \ \sigma _i(j_1)\sigma _i(j_j) = \sigma _i(q). \end{aligned}$$

In order to find an example of P-combination basis, we only have to choose a proper combination of signs. A way of doing it is by using the Sylvester matrices [13]. The Sylvester matrix S(k) of order \(2^k\) is

$$\begin{aligned} S(k) = \begin{pmatrix} + &{} + \\ + &{} - \end{pmatrix}^{\otimes k}. \end{aligned}$$

These matrices offer an example of signs election that can be used for constructing P-combination bases, as we prove in the following proposition.

Proposition 3

If S(k) is a Sylvester matrix and \(\sigma _i(j) := S(k)_{ij}\), then, for all k and any given a basis A,

$$\begin{aligned} |m_{Pd+i}\rangle = \frac{1}{\sqrt{P}} \sum _{j=1}^P \sigma _i(j)|a_{Pd+j}\rangle \end{aligned}$$

is a P-combination of the basis A for \(P=2^k\).

The first Sylvester matrices are:

$$\begin{aligned} S(1) = \begin{pmatrix} + &{} + \\ + &{} - \end{pmatrix}, \ S(2) = \begin{pmatrix} + &{} + &{} + &{} + \\ + &{} - &{} + &{} - \\ + &{} + &{} - &{} - \\ + &{} - &{} - &{} + \end{pmatrix}, \ S(3) = \begin{pmatrix} + &{} + &{} + &{} + &{} + &{} + &{} + &{} + \\ + &{} - &{} + &{} - &{} + &{} - &{} + &{} - \\ + &{} + &{} - &{} - &{} + &{} + &{} - &{} - \\ + &{} - &{} - &{} + &{} + &{} - &{} - &{} + \\ + &{} + &{} + &{} + &{} - &{} - &{} - &{} - \\ + &{} - &{} + &{} - &{} - &{} + &{} - &{} + \\ + &{} + &{} - &{} - &{} - &{} - &{} + &{} + \\ + &{} - &{} - &{} + &{} - &{} + &{} + &{} - \end{pmatrix}. \end{aligned}$$

So, given any basis A, an example of 2-combination basis of A for \(n=2\) is:

$$\begin{aligned}&|m_1\rangle = \frac{1}{\sqrt{2}}\left( |a_1\rangle +|a_2\rangle \right) |m_3\rangle = \frac{1}{\sqrt{2}}\left( |a_3\rangle +|a_4\rangle \right) \\&|m_2\rangle = \frac{1}{\sqrt{2}}\left( |a_1\rangle -|a_2\rangle \right) |m_4\rangle = \frac{1}{\sqrt{2}}\left( |a_3\rangle -|a_4\rangle \right) . \end{aligned}$$

For \(n=3\), an example of 4-combination basis is

$$\begin{aligned}&|m_1\rangle = \frac{1}{2}\left( |a_1\rangle +|a_2\rangle +|a_3\rangle +|a_4\rangle \right) |m_5\rangle = \frac{1}{2}\left( |a_5\rangle +|a_6\rangle +|a_7\rangle +|a_8\rangle \right) \\&|m_2\rangle = \frac{1}{2}\left( |a_1\rangle -|a_2\rangle +|a_3\rangle -|a_4\rangle \right) |m_6\rangle = \frac{1}{2}\left( |a_5\rangle -|a_6\rangle +|a_7\rangle -|a_8\rangle \right) \\&|m_3\rangle = \frac{1}{2}\left( |a_1\rangle +|a_2\rangle -|a_3\rangle -|a_4\rangle \right) |m_7\rangle = \frac{1}{2}\left( |a_5\rangle +|a_6\rangle -|a_7\rangle -|a_8\rangle \right) \\&|m_4\rangle = \frac{1}{2}\left( |a_1\rangle -|a_2\rangle -|a_3\rangle +|a_4\rangle \right) |m_8\rangle = \frac{1}{2}\left( |a_5\rangle -|a_6\rangle -|a_7\rangle +|a_8\rangle \right) . \end{aligned}$$

In this last example, we have combined elements 1-2-3-4 and 5-6-7-8 of A, but any other combination could be possible, for example, 1-5-7-8 and 2-3-4-6. For any A basis, and for any given n and P, there are

$$\begin{aligned} \left( {\begin{array}{c}N\\ P\end{array}}\right) \cdot \left( {\begin{array}{c}N-P\\ P\end{array}}\right) \cdot \left( {\begin{array}{c}N-2P\\ P\end{array}}\right) \cdot \ldots \cdot \left( {\begin{array}{c}2P\\ P\end{array}}\right) = \frac{N!}{(P!)^{N/P}} \end{aligned}$$

different possible P-combination bases. Our theorems provide results for one of the P combination bases, but the optimality requires an acceptable behaviour for every possible basis.

We will focus on bases of eigenvectors of U. Their P-combination bases challenge the optimality of the algorithm and their properties simplify the calculations considerably.

Theorem 4

Given a \(\hbox {QMDA}_n\), A an orthonormal basis of eigenvectors of U and M a P-combination basis of A, then, if the eigenvalue associated with \(|a_i\rangle \) is \(\lambda _i = e^{i\varphi _i}\),

$$\begin{aligned} \hat{M}_1\hat{M}^k\hat{M}_0= & {} \sum _{d=0}^{N/P-1} \frac{1}{P} \left( \sum _{j=1}^{P} |\beta _{Pd+j}|^2 \right) ^2 \\&+ \sum _{i=2}^P \left( \frac{1}{P} \sum _{j=1}^{P} \cos \varphi _{Pd+j,Pd+(i,j)_c} \right) ^k \\&\cdot \left( \frac{1}{P} \sum _{j=1}^{P} |\beta _{Pd+j}||\beta _{Pd+(i,j)_c}|\cos \beta _{Pd+j,Pd+(i,j)_c} \right) \\&\cdot \left( \frac{1}{P} \sum _{j=1}^{P} |\beta _{Pd+j}||\beta _{Pd+(i,j)_c}|\cos (\beta _{Pd+j,Pd+(i,j)_c} + k\varphi _{Pd+j,Pd+(i,j)_c}) \right) , \end{aligned}$$

where \(\varphi _{ij} = \varphi _i-\varphi _j\), and \(\beta _{ij}\) is the angle between \(\beta _i := \langle a_i|U_0|\psi _0\rangle \) and \(\beta _j := \langle a_j|U_0|\psi _0\rangle \).

The optimality of the \(\hbox {QMDA}_n\) requires this probability not to exceed \(\frac{1}{N}\). We can simplify the formula assuming that \(|\beta _i|^2 = |\langle a_i|U_0|\psi _0\rangle |^2 = \frac{1}{N}\), which is a necessary condition for the optimality.

Theorem 5

In the conditions of the previous theorem, if \(|\beta _i|^2 := |\langle a_i|U_0|\psi _0\rangle |^2 = \frac{1}{N}\) and \(P = 2^q\), then

$$\begin{aligned} \hat{M}_1\hat{M}^k\hat{M}_0= & {} \frac{1}{2^n} + \frac{1}{2^{2n-q}} \sum _{d=0}^{N/P-1} \sum _{i=2}^P \left( \frac{1}{P} \sum _{j=1}^{P} \cos \varphi _{Pd+j,Pd+(i,j)_c} \right) ^k\\&\cdot \left( \frac{1}{P} \sum _{j=1}^{P} \cos \beta _{Pd+j,Pd+(i,j)_c} \right) \\&\cdot \left( \frac{1}{P} \sum _{j=1}^{P} \cos (\beta _{Pd+j,Pd+(i,j)_c} + k\varphi _{Pd+j,Pd+(i,j)_c}) \right) . \end{aligned}$$

This formula does not imply that \(\hat{M}_1 \hat{M}^{k} \hat{M}_0 \ge \frac{1}{N}\), due to the fact that the cosines may be negative. Unfortunately, making the cosines negative requires large angles, and since the number of angles increases exponentially with n, getting large ones becomes a problem of unclear solution. Moreover, we have to remember that the P combination can be done with any group of P eigenvectors of A, so the angles of the cosines can be combined however we desire to, and the summation must be negative (or 0) for all of them in order to achieve the optimality.

Minimizing the formula analytically is difficult in general, but in the case of \(P=2\) it can be cleverly done. The trick is based on the fact that 2-combination bases are the only ones in which there is no mixture of angles in the cosines, so that they can be treated independently.

Theorem 6

Given a \(\hbox {QMDA}_n\), A an orthonormal basis of eigenvectors of U, and M a 2-combination basis, then

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0= & {} \frac{1}{2}\left[ \sum _{i=1}^{N/2}\left( |\beta _{2i-1}|^2 + |\beta _{2i}|^2\right) ^2 \right. \\&\left. + 4\sum _{i=1}^{N/2} |\beta _{2i-1}|^2|\beta _{2i}|^2\cos ^k \varphi _{2i-1,2i} \cos \beta _{2i-1,2i} \cos (\beta _{2i-1,2i}+k\varphi _{2i-1,2i}) \right] . \end{aligned}$$

Moreover, defining \(C_i := \cos ^k \varphi _{2i-1,2i} \cos \beta _{2i-1,2i} \cos (\beta _{2i-1,2i}+k\varphi _{2i-1,2i})\), the following bound is verified:

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 \ge \frac{1}{2\sum \limits _{i=1}^{N/2} \frac{1}{C_i+1}}. \end{aligned}$$

The equality is satisfied if and only if

$$\begin{aligned} \forall j=1,\ldots ,N/2, \ |\beta _{2j-1}|^2 + |\beta _{2j}|^2= & {} \frac{1}{\sum \limits _{i=1}^{N/2} \frac{C_j+1}{C_i+1}}, \ \text{ and, } \text{ if } C_j \not = 0 \\&\ \Rightarrow \ |\beta _{2j-1}|^2 = |\beta _{2j}|^2. \end{aligned}$$

The condition for the equality is rather cumbersome. Consequently, since we aim at a minimization for every 2-combination basis, we focus on the case of independence of the constants, i.e. \(|\beta _i|^2 = |\beta _j|^2 = \frac{1}{N}\), \(\forall i,j\). This condition is convenient for a \(\hbox {QMDA}_n\) since it unifies the probability formulas for every P-combination basis for any given P and is a necessary condition for the optimality. Applied to a 2-combination basis, the probability under this condition is

$$\begin{aligned} \hat{M}_1\hat{M}^k\hat{M}_0 = \frac{1}{2^n} + \frac{1}{2^{2n-1}}\sum _{i=1}^{N/2} \cos ^k \varphi _{2i-1,2i} \cos \beta _{2i-1,2i} \cos (\beta _{2i-1,2i}+k\varphi _{2i-1,2i}). \end{aligned}$$
(1)

However, being able to minimize the probability of error under one 2-combination basis does not provide a way of minimizing the probability of error under every 2-combination basis at the same time, especially for great values of n.

Finally, before getting into the study of \(\hbox {EV}_{n,k}\), we will prove a very useful result for calculating probabilities of a \(\hbox {QMDA}_{n+m}\) constructed from other \(\hbox {QMDA}_n\) and \(\hbox {QMDA}_m\) of smaller size.

Theorem 7

Let \((U_0,U,U_1,k,|\psi _0\rangle )\) be a \(\hbox {QMDA}_n\), \((V_0,V_1,V,k,|\varphi _0\rangle )\) a \(\hbox {QMDA}_m\) and XY two orthonormal bases of dimension \(2^n\) and \(2^m\), respectively. Then, given the \(\hbox {QMDA}_{n+m}\) \((U_1\otimes V_1, U\otimes V, U_0\otimes V_0, k, |\psi _0\rangle \otimes |\varphi _0\rangle )\), the basis \(Z = \{|x_i\rangle \otimes |y_j\rangle , \forall i=1,\ldots , 2^n, \forall j=1,\ldots , 2^m\}\) verifies

$$\begin{aligned} \hat{Z}_0 = \hat{X}_0\otimes \hat{Y}_0\text{, } \hat{Z}_1 = \hat{X}_1\otimes \hat{Y}_1 \text{, } \text{ and } \hat{Z} = \hat{X}\otimes \hat{Y}. \end{aligned}$$

As a consequence, \(\hat{Z}_1 \hat{Z}^{k} \hat{Z}_0 = \hat{X}_1 \hat{X}^{k} \hat{X}_0\cdot \hat{Y}_1 \hat{Y}^{k} \hat{Y}_0\).

This intuitive property allows us to calculate probabilities associated to any basis that verifies the given conditions whenever we are working with a \(\hbox {QMDA}_n\) constructed from a tensor product, as it is the case of any \(\hbox {EV}_{n,k}\) \(=\) \(\hbox {EV}_{1,k} \otimes \ldots \otimes \) \(\hbox {EV}_{1,k}\).

4 Study of the Elitzur–Vaidman algorithm

In this last section, we will analyse the behaviour of the Elitzur–Vaidman algorithm. We will prove that, for \(n=1\), \(\hbox {EV}_{1,k}\) is an asymptotically optimal family of \(\hbox {QMDA}_n\). However, this is not the case for \(n>1\), due to the P-combination bases, as the angles involved in the formula of Theorem 4 get smaller when \(k \longrightarrow \infty \). We will suggest an adjustment that overcomes this for \(n=2\), but for greater n the solution in unclear. The main theorem of this section is the following.

Theorem 8

Given k, we consider the \(\hbox {QMDA}_1\) \(\hbox {EV}_{1,k}\) and we define \(c := \cos {\theta _k}, s := \sin {\theta _k}\). If every O is equivalent to a measurement in the basis M where \(|m_1\rangle = \cos {\frac{\theta }{2}}|0\rangle +e^{i\varphi }\sin {\frac{\theta }{2}}|1\rangle \) and \(|m_2\rangle = \sin {\frac{\theta }{2}}|0\rangle -e^{i\varphi }\cos {\frac{\theta }{2}}|1\rangle \), then

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 = \frac{1}{2} + \frac{(c^2-s^2+2s^2\sin ^2{\theta }\sin ^2{\varphi })^k(4c^2s^2\sin ^2{\theta }\cos ^2{\varphi }-(c^2-s^2)^2\cos ^2{\theta })}{2}. \end{aligned}$$

The proofs of the two main results of this section can be found in “Appendix B.” As a consequence, when we measure in the basis of eigenvalues of \(U = R_{\theta _k}\), which is \(A = |+i\rangle ,|-i\rangle \), we get \(\hat{A}_1 \hat{A}^{k} \hat{A}_0 = \frac{1}{2} = \frac{1}{N}\). Unfortunately, this does not imply its optimality, as we are about to prove.

Theorem 9

Given k and \(\hbox {EV}_{1,k}\), the critical points of the formula in Theorem 8 are reached for the bases \(\{|0\rangle ,|1\rangle \}\), \(\{|+\rangle ,|-\rangle \}\) and \(\{|+i\rangle ,|-i\rangle \}\).

Obviously, the basis \(\{|0\rangle ,|1\rangle \}\) corresponds to the minimum, and we need to confirm where the maximum is.

Corollary 5

Given k and \(\hbox {EV}_{1,k}\), if measurements occur in the basis \(M = \{|0\rangle ,|1\rangle \}\), then

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 = \frac{1-(\cos \frac{\pi }{k+2})^{k+2}}{2}. \end{aligned}$$

Proof

We substitute directly in the formula of Theorem 8 taking into account that, for \(|0\rangle \), \(\theta = 0\), obtaining

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 = \frac{1-(c^2-s^2)^{k+2}}{2} = \frac{1-(\cos 2\theta _k)^{k+2}}{2}. \nonumber \\ \end{aligned}$$

\(\square \)

As expected, \(\frac{1-(\cos \frac{\pi }{k+2})^{k+2}}{2} \xrightarrow [k \rightarrow \infty ]{} 0\), so one of the conditions for the asymptotical optimality is verified. For the second one, we have the following result.

Corollary 6

Given k and \(\hbox {EV}_{1,k}\), if measurements occur in the basis \(A = \{|+i\rangle ,|-i\rangle \}\), then \(\hat{A}_1 \hat{A}^{k} \hat{A}_0 = \frac{1}{2}\). If measurements occur in the basis \(M = \{|+\rangle ,|-\rangle \}\), then

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 = \frac{1}{2} + 2\cos ^k\frac{\pi }{k+2}\cos ^2\frac{\pi }{2(k+2)}\sin ^2 \frac{\pi }{2(k+2)} > \frac{1}{2}. \end{aligned}$$

Proof

We can substitute directly in the formula of Theorem 8 knowing that, for \(|+i\rangle \), \(\theta = \varphi = \frac{\pi }{2}\). The same applies for M, taking into account that for \(|+\rangle \), \(\theta = \frac{\pi }{2}\) and \(\varphi = 0\). \(\square \)

As we can see, the maximum is reached for \(M = \{|+\rangle ,|-\rangle \}\), for which \(\hat{M}_1 \hat{M}^{k} \hat{M}_0 > \frac{1}{2}\). However, the fact that \(\hat{M}_1 \hat{M}^{k} \hat{M}_0 \xrightarrow [k \rightarrow \infty ]{} \frac{1}{2} = \frac{1}{N}\) allows us to conclude:

Theorem 10

The family \(\hbox {EV}_{1,k}\) of \(\hbox {QMDA}_1\) is asymptotically optimal.

This confirms that there exists a family of \(\hbox {QMDA}_1\) with the desirable properties. For \(n>1\), the \(\hbox {EV}_{n,k}\) circuit looks like:

Because \(\hbox {EV}_{n,k}\) \(=\) \(\hbox {EV}_{1,k} \otimes \ldots \otimes \) \(\hbox {EV}_{1,k}\), Theorem 7 guarantees a good behaviour for any basis built from a tensor product of 1-qubit bases. The next step is to study entangled bases, as P-combination bases can be.

The eigenvectors of \(R_{\theta _k}\) are \(|+i\rangle , |-i\rangle \), with eigenvalues \(e^{i\theta }, e^{-i\theta }\), respectively, so we can consider the basis A of eigenvectors of \(R_{\theta _k}^{\otimes 2}\) as

$$\begin{aligned} |a_1\rangle = |+i\rangle |+i\rangle , \ \ |a_2\rangle = |-i\rangle |-i\rangle , \ \ |a_3\rangle = |+i\rangle |-i\rangle , \ \ |a_4\rangle = |-i\rangle |+i\rangle . \end{aligned}$$

Their eigenvalues would be, respectively, \(e^{i2\theta }, e^{-i2\theta }, 1, 1\). Keeping this in mind, the following result is verified.

Theorem 11

Given k and \(\hbox {EV}_{2,k}\), we consider M a 2-combination basis of A. Then,

$$\begin{aligned} \hat{M}_1 \hat{M}^{k} \hat{M}_0 = \frac{1}{4} + \frac{\cos ^{k+2} \frac{2\pi }{k+2} + 1}{8}. \end{aligned}$$

Proof

Combining Theorem 6 with the fact that \(|\langle a_i|R_\theta ^{\otimes 2}|00\rangle |^2 = \frac{1}{4}, \forall i=1,2,3,4\), we can substitute on formula (1) knowing that \(n=2\), \(\theta _k = \frac{\pi }{2(k+2)}\), \(\varphi _{12} = \beta _{12} = 4\theta \) and \(\varphi _{34} = \beta _{34} = 0\). We should notice that \(\beta _{12} + k\varphi _{12} = (k+1)4\theta = \frac{(k+1)2\pi }{k+2} = -\frac{2\pi }{k+2} = -4\theta _k\), and \(\cos -4\theta _k = \cos 4\theta _k\). \(\square \)

The important observation is that \(\frac{1}{4} + \frac{\cos ^{k+2} 4\theta _k + 1}{8} \xrightarrow [k \rightarrow \infty ]{} \frac{1}{2}\). Moreover, \(\frac{1}{4} + \frac{\cos ^{k+2} 4\theta _k + 1}{8} < \frac{1}{2}\), which means that the probability of error increases as \(k \longrightarrow \infty \)! This leads us inevitably to the conclusion:

Theorem 12

The family \(\hbox {EV}_{n,k}\) of \(\hbox {QMDA}_n\) is asymptotically optimal if and only if \(n=1\).

The reason why the previous theorem prevents the optimality also for \(n>2\) is due to Theorem 7, which can be used to generate bases from the tensor product of this 2-combination basis and yield a probability of error higher than \(\frac{1}{N}\).

A way of overcoming this issue with 2-combination bases is by adjusting the angles involved. For example, if \(\{\varphi _i\}_{i=1}^4 = \{0, \frac{\pi }{2}, \pi , \frac{3\pi }{2}\}\) and \(\widetilde{\beta }_i \}_{i=1}^4 = \{\frac{\pi }{2}, 0, \pi , \frac{3\pi }{2}\}\), where \(\widetilde{\beta }_i\) is the argument of \(\beta _i = \langle a_i|U_0|00\rangle \). This means that \(U := \sum _{j=1}^{4} e^{i\varphi _j} |a_j\rangle \langle a_j|\). And, for example, we can define \(U_0 := \sum _{j=1}^{4} \beta _j |a_j\rangle \langle 00| + \sum _{j=1}^{4} \beta _j |a_j\rangle \langle 11|\). The angles are chosen so that, no matters how the eigenvectors are paired in the 2-combination basis, the product of cosines is always equal to 0. Unfortunately, this alternative does not generalize for greater values of n.

However, the Elitzur–Vaidman circuit of any number of qubits can be adapted to any basis in which we desire to achieve maximum accuracy by adjusting the initial state and the rotation axis of U. This is already suggesting a possibility for the future: mixing or nesting two different \(\hbox {QMDA}_n\) so that one can fix the weaknesses of the other by providing high detecting probabilities over those bases where the other struggles.

5 Possible extensions of \(\hbox {QMDA}_n\) and counterfactual communication

As mentioned throughout the article, there are some possible extensions of the \(\hbox {QMDA}_n\) definition that can be considered in order to generalize their behaviour further, which we want to address in the future. Some extensions include the study when each O only measures on certain qubits (and not on all of them), or the study of properties of the \(\hbox {QMDA}_n\) circuits having intentional, intermediate measurements. These extensions of our framework, along with some others, would lead to other well-known algorithms, such as the counterfactual communication [5] one.

The counterfactual communication algorithm works with three-qubit modelling photons, and the objective is to establish a communication between two parties, Alice and Bob, in such a way that Bob can communicate a decision (blocking Alice’s photon or not) to Alice without any photon crossing the transmission channel. This means that Bob and Alice have communicated without actually sharing any information. The circuit is shown in Fig. 4.

Fig. 4
figure 4

Counterfactual communication algorithm

A \(|1\rangle \) in one of the arms means that Alice’s photon is currently in that arm. The two upper arms belong to Alice’s side and the lower one to Bob’s side. This means that, whenever we have the state \(|001\rangle \), the photon would have crossed the transmission channel. Here, \(BS_P\) stands for beam splitter with reflectivity \(\cos ^2 \theta _P\), being \(\theta _P = \frac{\pi }{2P}\). In other words, with respect to the computational basis,

$$\begin{aligned} BS_P = \begin{pmatrix} 1 &{} 0 &{} 0 &{} 0 \\ 0 &{} \cos \theta _P &{} -\sin \theta _P &{} 0 \\ 0 &{} \sin \theta _P &{} \cos \theta _P &{} 0 \\ 0 &{} 0 &{} 0 &{} 1 \end{pmatrix}. \end{aligned}$$

The \(BS_M\) gate will be applied M times to the two upper arms, and after each one (except the last one) a whole cycle of N applications of \(BS_N\) gates to the two lower arms. The natural numbers M and N can be chosen unrestrictedly. The algorithm ensures that Alice, based on the measured state at the end, will be able to infer Bob’s choice with a probability as close to 1 as desired and without \(|1\rangle \) being ever measured in the third qubit. (No photon has crossed the transmission channel.)

The similarities with \(\hbox {QMDA}_n\) are clear, since the algorithm, from Alice’s perspective, intends to detect whether measurements have been taken in every O (Bob has decided to block her photon) or not (Bob has decided to let her photon pass). However, the intermediate measurements, the nested loops of \(BS_M\) and \(BS_N\) and the measurements on a specific qubit instead of on all of them, prevents this algorithm from being a \(\hbox {QMDA}_n\) yet, but makes its study interesting enough to deserve another work.

6 Conclusions and future work

In this paper, we have introduced a general framework to detect foreign measurements in circuits with respect to an unknown basis. The definition of quantum measurement detection algorithms generalizes the Elitzur–Vaidman bomb tester circuit.

Our results show the key properties and scope of QMDA. We have obtained the measurement detection probability error in terms of three matrices. In particular, for high number of qubits, we have derived explicit expressions of such a probability. Optimality of QMDA has been addressed, showing that bases that do not contain eigenvectors of the above-mentioned matrices yield better results. Finally, we study the performance of the Elitzur–Vaidman bomb tester and conclude its asymptotic optimality for the single-qubit circuit.

Future work includes the study when each O only measures on certain qubits (and not on all of them). Also, the study of properties of the QMDA circuits having internal measurements. Other extensions of our framework may include the counterfactual communication algorithm. Finally, we intend to provide a deeper insight into the effect of different types of noisy measurements on the detection power of QMDA.