Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
11institutetext: Institute of Computational Mathematics and Information Technologies, Kazan Federal University, Kazan, Russia
11email: kamilhadi@gmail.com

Quantum Property Testing Algorithm for the Concatenation of Two Palindromes Language

Kamil Khadiev 11    Danil Serov 11
Abstract

In this paper, we present a quantum property testing algorithm for recognizing a context-free language that is a concatenation of two palindromes LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT. The query complexity of our algorithm is O(1εn1/3logn)𝑂1𝜀superscript𝑛13𝑛O(\frac{1}{\varepsilon}n^{1/3}\log n)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n ), where n𝑛nitalic_n is the length of an input. It is better than the classical complexity that is Θ(n)superscriptΘ𝑛\Theta^{*}(\sqrt{n})roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( square-root start_ARG italic_n end_ARG ).

At the same time, in the general setting, the picture is different a little. Classical query complexity is Θ(n)Θ𝑛\Theta(n)roman_Θ ( italic_n ), and quantum query complexity is Θ(n)superscriptΘ𝑛\Theta^{*}(\sqrt{n})roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( square-root start_ARG italic_n end_ARG ). So, we obtain polynomial speed-up for both cases (general and property testing).

Keywords: palindromes, property testing, strings, quantum algorithms, query complexity, context-free languages

1 Introduction

In this paper, we investigate property testing [50, 24] that is a relaxation of the standard notion of a decision problem. A property testing algorithm distinguishes between inputs with a certain property and inputs that are far from any input that has the property. By “far” we mean a large Hemming distance. More specifically, for a given property α𝛼\alphaitalic_α, a testing algorithm should accept an input that has the property, and reject if the input is ε𝜀\varepsilonitalic_ε-far from any input with the property. Here ε𝜀\varepsilonitalic_ε-far means that the Hemming distance is at least εn𝜀𝑛\varepsilon\cdot nitalic_ε ⋅ italic_n, where n𝑛nitalic_n is the length of the input. In [48, 23], one can find examples of testing algorithms whose query complexity is sublinear or independent of the input size.

Researchers investigate formal languages with respect to the property testing. Alon, Krivelevich, Newman, and Szegedy [5] presented a property testing algorithm for any regular language L𝐿Litalic_L with query complexity O(1/ε)superscript𝑂1𝜀O^{*}(1/\varepsilon)italic_O start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( 1 / italic_ε ) that does not depend on the input size. Here Osuperscript𝑂O^{*}italic_O start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT hides constant and log factors. Newman [45] extended this result to properties defined by bounded-width branching programs.

At the same time, Alon et al. [5] showed that the situation for context-free languages is completely different. Context-free languages are not testable even in time square root in the input size. As an example, the context-free language LREV={uurvvr:u,vΣ}subscript𝐿𝑅𝐸𝑉conditional-set𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟𝑢𝑣superscriptΣL_{REV}=\{uu^{r}vv^{r}:u,v\in\Sigma^{*}\}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT = { italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT : italic_u , italic_v ∈ roman_Σ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT } that is a concatenation of two palindromes, where ΣΣ\Sigmaroman_Σ is a finite size alphabet (binary as an example), and ursuperscript𝑢𝑟u^{r}italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT is a reverse of u𝑢uitalic_u. For the language, they proved Ω(n)Ω𝑛\Omega(\sqrt{n})roman_Ω ( square-root start_ARG italic_n end_ARG ) lower bound for query complexity, where n𝑛nitalic_n is a length of an input. Parnas, Ron, and Rubinfeld presented a property testing algorithm that almost reaches this lower bound. Its query complexity is O(1εnlogn)𝑂1𝜀𝑛𝑛O\left(\frac{1}{\varepsilon}\sqrt{n}\log n\right)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG square-root start_ARG italic_n end_ARG roman_log italic_n ).

Buhrman, Fortnow, Newman, and Röhrig [17] introduced quantum property testing. They developed quantum property testing algorithms for some problems that are better than classical counterparts in terms of query complexity. A nice survey on quantum property testing can be found in [44]. At the same time, context-free languages like LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT were not considered. We are interested in developing a quantum property testing algorithm for a context-free language that is better than the classical lower bound.

There are many examples of quantum algorithms [46, 6, 30, 2] that are faster than classical counterparts [51, 27] in the general setting (not property testing). Problems for strings are examples of such problems [3, 4, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 41, 42, 43].

A new interest in recognizing formal languages, including context-free languages, is started from the paper of Aaronson, Grier, and Schaeffer [1]. Dyck language was investigated by different researches [7, 8, 18, 34]. Other formal languages were explored in papers [11, 19].

In this paper, we present a quantum property testing algorithm for recognizing LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT language that has O(1εn1/3logn)𝑂1𝜀superscript𝑛13𝑛O(\frac{1}{\varepsilon}n^{1/3}\log n)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n ) query complexity. It shows quantum speed-up and it is better than the classical lower bound Ω(n)Ω𝑛\Omega(\sqrt{n})roman_Ω ( square-root start_ARG italic_n end_ARG ). For this result, we use the meet-in-the-middle technique and Grover’s search algorithm [25, 14].

At the same time, in the general setting (not a property testing algorithm), we show that the problem has Θ(n)Θ𝑛\Theta(n)roman_Θ ( italic_n ) classical query complexity; and Θ(n)superscriptΘ𝑛\Theta^{*}(\sqrt{n})roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( square-root start_ARG italic_n end_ARG ) quantum query complexity. We present a quantum lower bound Ω(n)Ω𝑛\Omega(\sqrt{n})roman_Ω ( square-root start_ARG italic_n end_ARG ), and a quantum algorithm with query complexity O(n(logn)2)𝑂𝑛superscript𝑛2O\left(\sqrt{n}(\log n)^{2}\right)italic_O ( square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ). So, we obtain almost quadratic speed-up. We see that in the general setting, the classical lower bound differs from the property testing setting. At the same time, we see quantum speed-up for both cases.

The structure of this paper is the following. Section 2 describes some conventional notions for quantum computation. Section 3 provides quantum and classical algorithms and lower bounds for general setting. The quantum property testing algorithm is given in subsection 4. The final Section 5 concludes the paper and contains open questions.

2 Preliminaries

For a string u=(u1,,uM)𝑢subscript𝑢1subscript𝑢𝑀u=(u_{1},\dots,u_{M})italic_u = ( italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_u start_POSTSUBSCRIPT italic_M end_POSTSUBSCRIPT ), let |u|=M𝑢𝑀|u|=M| italic_u | = italic_M be a length of the string, and let ur=(uM,,u1)superscript𝑢𝑟subscript𝑢𝑀subscript𝑢1u^{r}=(u_{M},\dots,u_{1})italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT = ( italic_u start_POSTSUBSCRIPT italic_M end_POSTSUBSCRIPT , … , italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) be the reverse of the string u𝑢uitalic_u.

Let us formally define the Two Palindromes Concatenation problem.

Suppose ΣΣ\Sigmaroman_Σ is a finite-size alphabet. Let LREV={uurvvr:u,vΣ}subscript𝐿𝑅𝐸𝑉conditional-set𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟𝑢𝑣superscriptΣL_{REV}=\{uu^{r}vv^{r}:u,v\in\Sigma^{*}\}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT = { italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT : italic_u , italic_v ∈ roman_Σ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT } be a language of concatenations for two palindromes. We assume that in the definition of LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT u𝑢uitalic_u and v𝑣vitalic_v are not empty strings. For simplicity, in the paper, we assume that the alphabet is binary, Σ={0,1}Σ01\Sigma=\{0,1\}roman_Σ = { 0 , 1 }. At the same time, all results are correct for any finite-size alphabet.

For an integer n>0𝑛0n>0italic_n > 0, let the function REVn:Σn{0,1}:subscriptREV𝑛superscriptΣ𝑛01\texttt{REV}_{n}:\Sigma^{n}\to\{0,1\}REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT : roman_Σ start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT → { 0 , 1 } be such that REVn(x)=1subscriptREV𝑛𝑥1\texttt{REV}_{n}(x)=1REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT ( italic_x ) = 1 iff xLREV𝑥subscript𝐿𝑅𝐸𝑉x\in L_{REV}italic_x ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT.

For an integer n>0𝑛0n>0italic_n > 0 and a non-negative ε<1𝜀1\varepsilon<1italic_ε < 1, let REVn,εsubscriptREV𝑛𝜀\texttt{REV}_{n,\varepsilon}REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT be a property testing problem such that for an input x=(x0,,xn1)𝑥subscript𝑥0subscript𝑥𝑛1x=(x_{0},\dots,x_{n-1})italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) there is a promise that if x𝑥xitalic_x is not in LREVsubscript𝐿𝑅𝐸𝑉L_{R}EVitalic_L start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT italic_E italic_V, then x𝑥xitalic_x is at least εn𝜀𝑛\varepsilon\cdot nitalic_ε ⋅ italic_n far from the closest word from LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT. Formally, if x𝑥xitalic_x is not in LREVsubscript𝐿𝑅𝐸𝑉L_{R}EVitalic_L start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT italic_E italic_V, then for any uLREV𝑢subscript𝐿𝑅𝐸𝑉u\in L_{REV}italic_u ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT we have |{i:xiui}|εnconditional-set𝑖subscript𝑥𝑖subscript𝑢𝑖𝜀𝑛|\{i:x_{i}\neq u_{i}\}|\geq\varepsilon\cdot n| { italic_i : italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ≠ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT } | ≥ italic_ε ⋅ italic_n.

In the paper, we use a trie (prefix tree) data structure [21, 13, 15, 39]. It is a tree that allows us to add a string s𝑠sitalic_s and check whether s𝑠sitalic_s is in the tree with running time O(|s|)𝑂𝑠O(|s|)italic_O ( | italic_s | ). The data structure implements a “set of strings” data structure. Let us have the following operations with a trie T𝑇Titalic_T:

  • InitTrie() returns an empty trie. The running time of the operation is O(1)𝑂1O(1)italic_O ( 1 ).

  • AddToTrie(T,s) adds a string s𝑠sitalic_s to the trie T𝑇Titalic_T. The running time of the operation is O(|s|)𝑂𝑠O(|s|)italic_O ( | italic_s | ).

  • Contains(T,s) returns 1111 if a string s𝑠sitalic_s belongs to the trie T𝑇Titalic_T, and False𝐹𝑎𝑙𝑠𝑒Falseitalic_F italic_a italic_l italic_s italic_e otherwise. The running time of the operation is O(|s|)𝑂𝑠O(|s|)italic_O ( | italic_s | ).

2.1 Quantum query model

One of the most popular computation models for quantum algorithms is the query model. We use the standard form of the quantum query model. Let f:D{0,1},D{0,1}M:𝑓formulae-sequence𝐷01𝐷superscript01𝑀f:D\rightarrow\{0,1\},D\subseteq\{0,1\}^{M}italic_f : italic_D → { 0 , 1 } , italic_D ⊆ { 0 , 1 } start_POSTSUPERSCRIPT italic_M end_POSTSUPERSCRIPT be an M𝑀Mitalic_M variable function. Our goal is to compute it on an input xD𝑥𝐷x\in Ditalic_x ∈ italic_D. We are given oracle access to the input x𝑥xitalic_x, i.e. it is implemented by a specific unitary transformation usually defined as |i|z|w|i|z+xi(mod2)|wmaps-toket𝑖ket𝑧ket𝑤ket𝑖ketannotated𝑧subscript𝑥𝑖pmod2ket𝑤|i\rangle|z\rangle|w\rangle\mapsto|i\rangle|z+x_{i}\pmod{2}\rangle|w\rangle| italic_i ⟩ | italic_z ⟩ | italic_w ⟩ ↦ | italic_i ⟩ | italic_z + italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT start_MODIFIER ( roman_mod start_ARG 2 end_ARG ) end_MODIFIER ⟩ | italic_w ⟩, where the |iket𝑖|i\rangle| italic_i ⟩ register indicates the index of the variable we are querying, |zket𝑧|z\rangle| italic_z ⟩ is the output register, and |wket𝑤|w\rangle| italic_w ⟩ is some auxiliary work-space. An algorithm in the query model consists of alternating applications of arbitrary unitaries which are independent of the input and the query unitary, and a measurement at the end. The smallest number of queries for an algorithm that outputs f(x)𝑓𝑥f(x)italic_f ( italic_x ) with probability 23absent23\geq\frac{2}{3}≥ divide start_ARG 2 end_ARG start_ARG 3 end_ARG on all x𝑥xitalic_x is called the quantum query complexity of the function f𝑓fitalic_f and is denoted by Q(f)𝑄𝑓Q(f)italic_Q ( italic_f ). We refer the readers to [46, 6, 2, 30] for more details on quantum computing.

In this paper, we are interested in the query complexity of the quantum algorithms. We use modifications of Grover’s search algorithm [25, 14] as quantum subroutines. For these subroutines, time complexity can be obtained from query complexity by multiplication to a log factor [9, 26].

3 The General Case

In this section, we consider the REVnsubscriptREV𝑛\texttt{REV}_{n}REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT problem. Here we show quantum upper and lower bounds that are almost equal up to log factors.

3.1 Quantum and Classical Algorithms

Let us start with the upper bound.

Firstly, let us show one useful property. For the input string x=(x0,,xn1)𝑥subscript𝑥0subscript𝑥𝑛1x=(x_{0},\dots,x_{n-1})italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ), let x¯=(x1,,xn1)¯𝑥subscript𝑥1subscript𝑥𝑛1\bar{x}=(x_{1},\dots,x_{n-1})over¯ start_ARG italic_x end_ARG = ( italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) be the string x𝑥xitalic_x without the first symbol. Let x^=(x0,,xn2)^𝑥subscript𝑥0subscript𝑥𝑛2\hat{x}=(x_{0},\dots,x_{n-2})over^ start_ARG italic_x end_ARG = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 2 end_POSTSUBSCRIPT ) be the string x𝑥xitalic_x without the last symbol. Let

y(x)=x¯x^=(x1,,xn1,x0,,xn2),𝑦𝑥¯𝑥^𝑥subscript𝑥1subscript𝑥𝑛1subscript𝑥0subscript𝑥𝑛2y(x)=\bar{x}\circ\hat{x}=(x_{1},\dots,x_{n-1},x_{0},\dots,x_{n-2}),italic_y ( italic_x ) = over¯ start_ARG italic_x end_ARG ∘ over^ start_ARG italic_x end_ARG = ( italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT , italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 2 end_POSTSUBSCRIPT ) ,

where \circ is the concatenation operation. Then, we have the following result

Lemma 1

A string xLREV𝑥subscript𝐿𝑅𝐸𝑉x\in L_{REV}italic_x ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT if and only if y(x)𝑦𝑥y(x)italic_y ( italic_x ) contains xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT as a substring.

Proof

Assume that xLREV𝑥subscript𝐿𝑅𝐸𝑉x\in L_{REV}italic_x ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT. It means that we can find two strings u𝑢uitalic_u and v𝑣vitalic_v such that x=uurvvr𝑥𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟x=uu^{r}vv^{r}italic_x = italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT. Note that vr^=v¯r^superscript𝑣𝑟superscript¯𝑣𝑟\hat{v^{r}}=\bar{v}^{r}over^ start_ARG italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT end_ARG = over¯ start_ARG italic_v end_ARG start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT which means we can either remove the last symbol of a reversed string, or remove the first symbol of the original string and then reverse. Hence, the string y(x)𝑦𝑥y(x)italic_y ( italic_x ) has the following form

y(x)=u¯urvvruurvv¯r𝑦𝑥¯𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟𝑢superscript𝑢𝑟𝑣superscript¯𝑣𝑟y(x)=\bar{u}u^{r}vv^{r}uu^{r}v\bar{v}^{r}italic_y ( italic_x ) = over¯ start_ARG italic_u end_ARG italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v over¯ start_ARG italic_v end_ARG start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT

We can see that it has xr=vvruursuperscript𝑥𝑟𝑣superscript𝑣𝑟𝑢superscript𝑢𝑟x^{r}=vv^{r}uu^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT = italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT as a substring because y(x)=u¯urxrvv¯r𝑦𝑥¯𝑢superscript𝑢𝑟superscript𝑥𝑟𝑣superscript¯𝑣𝑟y(x)=\bar{u}u^{r}\circ x^{r}\circ v\bar{v}^{r}italic_y ( italic_x ) = over¯ start_ARG italic_u end_ARG italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ∘ italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ∘ italic_v over¯ start_ARG italic_v end_ARG start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT.

Assume that xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT is a substring of y(x)𝑦𝑥y(x)italic_y ( italic_x ). Let n=|x|𝑛𝑥n=|x|italic_n = | italic_x |, and k=|y(x)|=2n2𝑘𝑦𝑥2𝑛2k=|y(x)|=2n-2italic_k = | italic_y ( italic_x ) | = 2 italic_n - 2. Assume that xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT starts in y(x)𝑦𝑥y(x)italic_y ( italic_x ) from a position in1𝑖𝑛1i\leq n-1italic_i ≤ italic_n - 1. It means that y(x)i=(xr)0𝑦subscript𝑥𝑖subscriptsuperscript𝑥𝑟0y(x)_{i}=(x^{r})_{0}italic_y ( italic_x ) start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT. At the same time, (xr)0=xn1subscriptsuperscript𝑥𝑟0subscript𝑥𝑛1(x^{r})_{0}=x_{n-1}( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT because xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT is the reverse of x𝑥xitalic_x. We also can say, that y(x)i=xi+1𝑦subscript𝑥𝑖subscript𝑥𝑖1y(x)_{i}=x_{i+1}italic_y ( italic_x ) start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT. So, we have

xi+1=y(x)i=(xr)0=xn1,subscript𝑥𝑖1𝑦subscript𝑥𝑖subscriptsuperscript𝑥𝑟0subscript𝑥𝑛1x_{i+1}=y(x)_{i}=(x^{r})_{0}=x_{n-1},italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ,
xi+2=y(x)i+1=(xr)1=xn2,subscript𝑥𝑖2𝑦subscript𝑥𝑖1subscriptsuperscript𝑥𝑟1subscript𝑥𝑛2x_{i+2}=y(x)_{i+1}=(x^{r})_{1}=x_{n-2},italic_x start_POSTSUBSCRIPT italic_i + 2 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_n - 2 end_POSTSUBSCRIPT ,
xi+3=y(x)i+2=(xr)2=xn3,subscript𝑥𝑖3𝑦subscript𝑥𝑖2subscriptsuperscript𝑥𝑟2subscript𝑥𝑛3x_{i+3}=y(x)_{i+2}=(x^{r})_{2}=x_{n-3},italic_x start_POSTSUBSCRIPT italic_i + 3 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_i + 2 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_n - 3 end_POSTSUBSCRIPT ,
...
xn1=y(x)n2=(xr)ni2=xi+1subscript𝑥𝑛1𝑦subscript𝑥𝑛2subscriptsuperscript𝑥𝑟𝑛𝑖2subscript𝑥𝑖1x_{n-1}=y(x)_{n-2}=(x^{r})_{n-i-2}=x_{i+1}italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n - 2 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - italic_i - 2 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT

Therefore, (xi+1,,xn1)subscript𝑥𝑖1subscript𝑥𝑛1(x_{i+1},\dots,x_{n-1})( italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) is a palindrome. Let it be vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT for some string v𝑣vitalic_v (See Figure 1).

Refer to caption
Figure 1: The string xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT is a substring of y(x)𝑦𝑥y(x)italic_y ( italic_x ) and it starts from position i𝑖iitalic_i. We can see that (xi+1,,xn1)subscript𝑥𝑖1subscript𝑥𝑛1(x_{i+1},\dots,x_{n-1})( italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) is a palindrome.

Since xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT starts from the i𝑖iitalic_i-th symbol of y(x)𝑦𝑥y(x)italic_y ( italic_x ), we have y(x)n1=(xr)ni1𝑦subscript𝑥𝑛1subscriptsuperscript𝑥𝑟𝑛𝑖1y(x)_{n-1}=(x^{r})_{n-i-1}italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - italic_i - 1 end_POSTSUBSCRIPT. At the same time, y(x)n1=x0𝑦subscript𝑥𝑛1subscript𝑥0y(x)_{n-1}=x_{0}italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT; and (xr)ni1=xisubscriptsuperscript𝑥𝑟𝑛𝑖1subscript𝑥𝑖(x^{r})_{n-i-1}=x_{i}( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - italic_i - 1 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT. So, we have

x0=y(x)n1=(xr)ni1=xi,subscript𝑥0𝑦subscript𝑥𝑛1subscriptsuperscript𝑥𝑟𝑛𝑖1subscript𝑥𝑖x_{0}=y(x)_{n-1}=(x^{r})_{n-i-1}=x_{i},italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - italic_i - 1 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ,
x1=y(x)n=(xr)ni=xi1,subscript𝑥1𝑦subscript𝑥𝑛subscriptsuperscript𝑥𝑟𝑛𝑖subscript𝑥𝑖1x_{1}=y(x)_{n}=(x^{r})_{n-i}=x_{i-1},italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - italic_i end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i - 1 end_POSTSUBSCRIPT ,
x2=y(x)n+1=(xr)ni+1=xi2,subscript𝑥2𝑦subscript𝑥𝑛1subscriptsuperscript𝑥𝑟𝑛𝑖1subscript𝑥𝑖2x_{2}=y(x)_{n+1}=(x^{r})_{n-i+1}=x_{i-2},italic_x start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n + 1 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - italic_i + 1 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_i - 2 end_POSTSUBSCRIPT ,
...
xi=y(x)n+i1=(xr)n1=x0subscript𝑥𝑖𝑦subscript𝑥𝑛𝑖1subscriptsuperscript𝑥𝑟𝑛1subscript𝑥0x_{i}=y(x)_{n+i-1}=(x^{r})_{n-1}=x_{0}italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_y ( italic_x ) start_POSTSUBSCRIPT italic_n + italic_i - 1 end_POSTSUBSCRIPT = ( italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ) start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT

Therefore, (x0,,xi)subscript𝑥0subscript𝑥𝑖(x_{0},\dots,x_{i})( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) is a palindrome. Let it be uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT for some string u𝑢uitalic_u (See Figure 2).

Refer to caption
Figure 2: The string xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT is a substring of y(x)𝑦𝑥y(x)italic_y ( italic_x ) and it starts from position i𝑖iitalic_i. We can see that (x0,,xi)subscript𝑥0subscript𝑥𝑖(x_{0},\dots,x_{i})( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) is a palindrome.

So, we can say that x=(x0,,xi)(xi+1,,xn1)=uurvvrLREV𝑥subscript𝑥0subscript𝑥𝑖subscript𝑥𝑖1subscript𝑥𝑛1𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟subscript𝐿𝑅𝐸𝑉x=(x_{0},\dots,x_{i})\circ(x_{i+1},\dots,x_{n-1})=uu^{r}vv^{r}\in L_{REV}italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) ∘ ( italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) = italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT. \Box

In fact, we do not construct y(x)𝑦𝑥y(x)italic_y ( italic_x ). To access the symbol y(x)i𝑦subscript𝑥𝑖y(x)_{i}italic_y ( italic_x ) start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, we use a function Get(i)Get𝑖\textsc{Get}(i)Get ( italic_i ) that returns xi+1subscript𝑥𝑖1x_{i+1}italic_x start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT if i<n1𝑖𝑛1i<n-1italic_i < italic_n - 1, and returns xin+1subscript𝑥𝑖𝑛1x_{i-n+1}italic_x start_POSTSUBSCRIPT italic_i - italic_n + 1 end_POSTSUBSCRIPT if n1absent𝑛1\geq n-1≥ italic_n - 1. The complexity of this function is O(1)𝑂1O(1)italic_O ( 1 ) if we use array-like data structures, but not Linked List data structure.

In the classical case, the substring problem can be solved using the Knuth–Morris–Pratt algorithm [20, 40]. The complexity of the algorithm is O(k+n)𝑂𝑘𝑛O(k+n)italic_O ( italic_k + italic_n ), where n=|xr|𝑛superscript𝑥𝑟n=|x^{r}|italic_n = | italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT |, and k=|y(x)|=2n2𝑘𝑦𝑥2𝑛2k=|y(x)|=2n-2italic_k = | italic_y ( italic_x ) | = 2 italic_n - 2. So, the complexity is O(n)𝑂𝑛O(n)italic_O ( italic_n ).

In the quantum case, we can solve the problem using the Ramesh-Vinay algorithm [49]. The complexity of the algorithm is O(klogknlogn+n(logn)2)𝑂𝑘𝑘𝑛𝑛𝑛superscript𝑛2O\left(\sqrt{k}\log{\sqrt{\frac{k}{n}}}\log n+\sqrt{n}(\log n)^{2}\right)italic_O ( square-root start_ARG italic_k end_ARG roman_log square-root start_ARG divide start_ARG italic_k end_ARG start_ARG italic_n end_ARG end_ARG roman_log italic_n + square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ).

The final complexity of both algorithms is presented in the next theorem.

Theorem 3.1

For a positive integer n𝑛nitalic_n and the problem REVnsubscriptREV𝑛\texttt{REV}_{n}REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT, there is a classical algorithm that works with query and time complexity O(n)𝑂𝑛O(n)italic_O ( italic_n ); and a quantum algorithm that works with query complexity O(n(logn)2)𝑂𝑛superscript𝑛2O\left(\sqrt{n}(\log n)^{2}\right)italic_O ( square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) and two-side error probability strictly less than 0.50.50.50.5.

Proof

Due to Lemma 1, the problem is equivalent to searching xrsuperscript𝑥𝑟x^{r}italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT in y(x)𝑦𝑥y(x)italic_y ( italic_x ). Let k=|y(x)|=2n2𝑘𝑦𝑥2𝑛2k=|y(x)|=2n-2italic_k = | italic_y ( italic_x ) | = 2 italic_n - 2, and n=|x|=|xr|𝑛𝑥superscript𝑥𝑟n=|x|=|x^{r}|italic_n = | italic_x | = | italic_x start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT |.

In the classical case, time and query complexity of Knuth–Morris–Pratt algorithm [20, 40] is O(n+k)=O(n+2n2)=O(n)𝑂𝑛𝑘𝑂𝑛2𝑛2𝑂𝑛O(n+k)=O(n+2n-2)=O(n)italic_O ( italic_n + italic_k ) = italic_O ( italic_n + 2 italic_n - 2 ) = italic_O ( italic_n ).

In the quantum case, the query complexity of the Ramesh-Vinay algorithm [49] is

O(klogknlogn+n(logn)2)=𝑂𝑘𝑘𝑛𝑛𝑛superscript𝑛2absentO\left(\sqrt{k}\log{\sqrt{\frac{k}{n}}}\log n+\sqrt{n}(\log n)^{2}\right)=italic_O ( square-root start_ARG italic_k end_ARG roman_log square-root start_ARG divide start_ARG italic_k end_ARG start_ARG italic_n end_ARG end_ARG roman_log italic_n + square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) =
O(2n2log2n2nlogn+n(logn)2)=𝑂2𝑛22𝑛2𝑛𝑛𝑛superscript𝑛2absentO\left(\sqrt{2n-2}\log{\sqrt{\frac{2n-2}{n}}}\log n+\sqrt{n}(\log n)^{2}\right)=italic_O ( square-root start_ARG 2 italic_n - 2 end_ARG roman_log square-root start_ARG divide start_ARG 2 italic_n - 2 end_ARG start_ARG italic_n end_ARG end_ARG roman_log italic_n + square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) =
O(nlogn+n(logn)2)=O(n(logn)2).𝑂𝑛𝑛𝑛superscript𝑛2𝑂𝑛superscript𝑛2O\left(\sqrt{n}\log n+\sqrt{n}(\log n)^{2}\right)=O\left(\sqrt{n}(\log n)^{2}% \right).italic_O ( square-root start_ARG italic_n end_ARG roman_log italic_n + square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) = italic_O ( square-root start_ARG italic_n end_ARG ( roman_log italic_n ) start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) .

The error probability is strictly less than 0.50.50.50.5 due to [49]. \Box

3.2 Lower Bound

Let us present the lower bound for the REVnsubscriptREV𝑛\texttt{REV}_{n}REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT problem. In the next theorem, we show that the problem is at least as hard as an unstructured search among n𝑛nitalic_n elements.

Theorem 3.2

The lower bound for quantum query complexity of REVnsubscriptREV𝑛\texttt{REV}_{n}REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT is Ω(n)Ω𝑛\Omega(\sqrt{n})roman_Ω ( square-root start_ARG italic_n end_ARG ), and for classical (randomized or deterministic) query complexity is Ω(n)Ω𝑛\Omega(n)roman_Ω ( italic_n ).

Proof

Assume that n=2t+2𝑛2𝑡2n=2t+2italic_n = 2 italic_t + 2 for some integer t𝑡titalic_t. Let us consider only inputs of two forms:

  • σ=(0,,0)𝜎00\sigma=(0,\dots,0)italic_σ = ( 0 , … , 0 ) is a 00-string. Let u=(0)𝑢0u=(0)italic_u = ( 0 ), and v=(0,,0)𝑣00v=(0,\dots,0)italic_v = ( 0 , … , 0 ). Here |u|=1𝑢1|u|=1| italic_u | = 1, and |v|=t𝑣𝑡|v|=t| italic_v | = italic_t. In that case, u=ur𝑢superscript𝑢𝑟u=u^{r}italic_u = italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT, and v=vr𝑣superscript𝑣𝑟v=v^{r}italic_v = italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT. So, we can say that σ=uurvvr𝜎𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟\sigma=uu^{r}vv^{r}italic_σ = italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT, and REVn(σ)=1subscriptREV𝑛𝜎1\texttt{REV}_{n}(\sigma)=1REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT ( italic_σ ) = 1.

  • For i{0,,n1}𝑖0𝑛1i\in\{0,\dots,n-1\}italic_i ∈ { 0 , … , italic_n - 1 }, the string γi=(0,,0,1,0,0)superscript𝛾𝑖00100\gamma^{i}=(0,\dots,0,1,0,\dots 0)italic_γ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT = ( 0 , … , 0 , 1 , 0 , … 0 ) has 1111 on the position i𝑖iitalic_i, and 00s on other positions. There is only one position with a 1111-value, and it has not a symmetric pair. Therefore, REVn(γi)=0subscriptREV𝑛superscript𝛾𝑖0\texttt{REV}_{n}(\gamma^{i})=0REV start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT ( italic_γ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT ) = 0.

Distinguishing between two cases σ𝜎\sigmaitalic_σ and γisuperscript𝛾𝑖\gamma^{i}italic_γ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT is equivalent to searching 1111 among n𝑛nitalic_n elements.

Assume, that we have a quantum algorithm with quantum query complexity o(n)𝑜𝑛o(\sqrt{n})italic_o ( square-root start_ARG italic_n end_ARG ) or a classical algorithm with query complexity o(n)𝑜𝑛o(n)italic_o ( italic_n ). Then, we can distinguish between two cases σ𝜎\sigmaitalic_σ and γisuperscript𝛾𝑖\gamma^{i}italic_γ start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT, and find 1111 among n𝑛nitalic_n elements with proposed complexity. This claim contradicts the lower bound for unstructured search [12] that is Ω(n)Ω𝑛\Omega(\sqrt{n})roman_Ω ( square-root start_ARG italic_n end_ARG ) in the quantum case, and Ω(n)Ω𝑛\Omega(n)roman_Ω ( italic_n ) in the classical case. \Box

Finally, we see that the classical complexity for the problem is Θ(n)Θ𝑛\Theta(n)roman_Θ ( italic_n ), and the quantum complexity is Θ(n)superscriptΘ𝑛\Theta^{*}(\sqrt{n})roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( square-root start_ARG italic_n end_ARG ), where ΘsuperscriptΘ\Theta^{*}roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT hides logarithmic factors. So, we obtain an almost quadratic speed-up for this problem.

4 The Property Testing Case

In this section, we consider the REVn,εsubscriptREV𝑛𝜀\texttt{REV}_{n,\varepsilon}REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT problem. Here, we use ideas from [47] paper that provides a randomized algorithm for the problem.

The classical upper bound [47] for the problem is O(1εnlogn)𝑂1𝜀𝑛𝑛O\left(\frac{1}{\varepsilon}\sqrt{n}\log n\right)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG square-root start_ARG italic_n end_ARG roman_log italic_n ), and the lower bound [5] is Ω(n)Ω𝑛\Omega(\sqrt{n})roman_Ω ( square-root start_ARG italic_n end_ARG ). We can see, that in the property testing case, we have significant improvement. A situation simulation happens for quantum algorithms.

Firstly, let us discuss some observations on properties of a word x=(x0,,xn1)=uurvvr𝑥subscript𝑥0subscript𝑥𝑛1𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟x=(x_{0},\dots,x_{n-1})=uu^{r}vv^{r}italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) = italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT from the language LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT. Let us consider two indexes i,j{0,,n1}𝑖𝑗0𝑛1i,j\in\{0,\dots,n-1\}italic_i , italic_j ∈ { 0 , … , italic_n - 1 }, and assume that i<j𝑖𝑗i<jitalic_i < italic_j without limiting the generality of the foregoing.

We say that they are in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT if i,j<2|u|𝑖𝑗2𝑢i,j<2|u|italic_i , italic_j < 2 | italic_u |, and there is an integer δ|u|𝛿𝑢\delta\leq|u|italic_δ ≤ | italic_u | such that i+δ=|u|1𝑖𝛿𝑢1i+\delta=|u|-1italic_i + italic_δ = | italic_u | - 1, and jδ=|u|𝑗𝛿𝑢j-\delta=|u|italic_j - italic_δ = | italic_u |. In other words, they are symmetric with respect to the middle of the palindrome uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT (See Figure 3).

Refer to caption
Figure 3: Indexes i𝑖iitalic_i and j𝑗jitalic_j are symmetric with respect to the middle of the palindrome uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT.

We say that indexes i𝑖iitalic_i and j𝑗jitalic_j are in symmetric positions with respect to vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT if i,j2|u|𝑖𝑗2𝑢i,j\geq 2|u|italic_i , italic_j ≥ 2 | italic_u |, and there is an integer δ|v|superscript𝛿𝑣\delta^{\prime}\leq|v|italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ≤ | italic_v | such that i+δ=2|u|+|v|1𝑖superscript𝛿2𝑢𝑣1i+\delta^{\prime}=2|u|+|v|-1italic_i + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | + | italic_v | - 1, and jδ=2|u|+|v|𝑗superscript𝛿2𝑢𝑣j-\delta^{\prime}=2|u|+|v|italic_j - italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | + | italic_v |. In other words, they are symmetric with respect to the middle of the palindrome vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT (See Figure 4).

Refer to caption
Figure 4: Indexes i𝑖iitalic_i and j𝑗jitalic_j are symmetric with respect to the middle of the palindrome vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT.

Let us consider any two indexes i𝑖iitalic_i and j𝑗jitalic_j that are in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT or vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT. In that case, we have the following lemma about these indexes:

Lemma 2

Indexes i𝑖iitalic_i and j𝑗jitalic_j are in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT or vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT if and only if i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 ((((mod n)n)italic_n ). Remember that n=2|u|+2|v|𝑛2𝑢2𝑣n=2|u|+2|v|italic_n = 2 | italic_u | + 2 | italic_v |.

Proof

Without limiting the generality of the foregoing, we can assume that i<j𝑖𝑗i<jitalic_i < italic_j. Note that 0i+j2n0𝑖𝑗2𝑛0\leq i+j\leq 2n0 ≤ italic_i + italic_j ≤ 2 italic_n because i,jn𝑖𝑗𝑛i,j\leq nitalic_i , italic_j ≤ italic_n. Therefore, i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 ((((mod n)n)italic_n ) means either i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 or i+j=2|u|1+n𝑖𝑗2𝑢1𝑛i+j=2|u|-1+nitalic_i + italic_j = 2 | italic_u | - 1 + italic_n. We have three cases. Let us consider each of them.

  • Case 1.

    Assume that i,j<2|u|𝑖𝑗2𝑢i,j<2|u|italic_i , italic_j < 2 | italic_u |. Let i𝑖iitalic_i and j𝑗jitalic_j be in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT. So, there is δ𝛿\deltaitalic_δ such that i+δ=|u|1𝑖𝛿𝑢1i+\delta=|u|-1italic_i + italic_δ = | italic_u | - 1 and jδ=|u|𝑗𝛿𝑢j-\delta=|u|italic_j - italic_δ = | italic_u |. Hence, i+j=|u|1δ+|u|+δ=2|u|1=2|u|1𝑖𝑗𝑢1𝛿𝑢𝛿2𝑢12𝑢1i+j=|u|-1-\delta+|u|+\delta=2|u|-1=2|u|-1italic_i + italic_j = | italic_u | - 1 - italic_δ + | italic_u | + italic_δ = 2 | italic_u | - 1 = 2 | italic_u | - 1 ((((mod n)n)italic_n ).

    Let i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 ((((mod n)n)italic_n ). Let δ=|u|1i𝛿𝑢1𝑖\delta=|u|-1-iitalic_δ = | italic_u | - 1 - italic_i. Then

    i=|u|δ1, and j=2|u|1i=2|u|1|u|+1+δ=|u|+δ.formulae-sequence𝑖𝑢𝛿1 and 𝑗2𝑢1𝑖2𝑢1𝑢1𝛿𝑢𝛿i=|u|-\delta-1,\mbox{ and }j=2|u|-1-i=2|u|-1-|u|+1+\delta=|u|+\delta.italic_i = | italic_u | - italic_δ - 1 , and italic_j = 2 | italic_u | - 1 - italic_i = 2 | italic_u | - 1 - | italic_u | + 1 + italic_δ = | italic_u | + italic_δ .

    Due to the definition, i𝑖iitalic_i and j𝑗jitalic_j are in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT.

  • Case 2.

    Assume that i,j2|u|𝑖𝑗2𝑢i,j\geq 2|u|italic_i , italic_j ≥ 2 | italic_u |. Let i𝑖iitalic_i and j𝑗jitalic_j be in symmetric positions with respect to vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT. So, there is δsuperscript𝛿\delta^{\prime}italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT such that i+δ=2|u|+|v|1𝑖superscript𝛿2𝑢𝑣1i+\delta^{\prime}=2|u|+|v|-1italic_i + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | + | italic_v | - 1 and 2|u|+|v|=jδ2𝑢𝑣𝑗superscript𝛿2|u|+|v|=j-\delta^{\prime}2 | italic_u | + | italic_v | = italic_j - italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. Hence,

    i+j=2|u|+|v|1δ+2|u|+|v|+δ=2|u|1+(2|u|+2|v|) (mod n).i+j=2|u|+|v|-1-\delta^{\prime}+2|u|+|v|+\delta^{\prime}=2|u|-1+(2|u|+2|v|)% \mbox{ $($mod }n).italic_i + italic_j = 2 | italic_u | + | italic_v | - 1 - italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT + 2 | italic_u | + | italic_v | + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | - 1 + ( 2 | italic_u | + 2 | italic_v | ) ( mod italic_n ) .

    Note that 2|u|+2|v|=n2𝑢2𝑣𝑛2|u|+2|v|=n2 | italic_u | + 2 | italic_v | = italic_n. Therefore, i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 ((((mod n)n)italic_n ).

    Let i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 ((((mod n)n)italic_n ). Let δ=2|u|+|v|1isuperscript𝛿2𝑢𝑣1𝑖\delta^{\prime}=2|u|+|v|-1-iitalic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | + | italic_v | - 1 - italic_i. We remember that n=2|u|+2|v|𝑛2𝑢2𝑣n=2|u|+2|v|italic_n = 2 | italic_u | + 2 | italic_v |. Then

    i=2|u|+|v|1δ, and j=2|u|1i (mod n)i=2|u|+|v|-1-\delta^{\prime},\mbox{ and }j=2|u|-1-i\mbox{ $($mod }n)italic_i = 2 | italic_u | + | italic_v | - 1 - italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT , and italic_j = 2 | italic_u | - 1 - italic_i ( mod italic_n )
    j=n+2|u|1i (mod n)j=n+2|u|-1-i\mbox{ $($mod }n)italic_j = italic_n + 2 | italic_u | - 1 - italic_i ( mod italic_n )
    j=n+2|u|12|u||v|+1+δ=n|v|+δ=2|u|+2|v||v|+δ (mod n)j=n+2|u|-1-2|u|-|v|+1+\delta^{\prime}=n-|v|+\delta^{\prime}=2|u|+2|v|-|v|+% \delta^{\prime}\mbox{ $($mod }n)italic_j = italic_n + 2 | italic_u | - 1 - 2 | italic_u | - | italic_v | + 1 + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = italic_n - | italic_v | + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | + 2 | italic_v | - | italic_v | + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( mod italic_n )
    j=2|u|+|v|+δ (mod n).j=2|u|+|v|+\delta^{\prime}\mbox{ $($mod }n).italic_j = 2 | italic_u | + | italic_v | + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( mod italic_n ) .

    Note that 2|u|+|v|+δ=2|u|+|v|+2|u|+|v|1i2|u|+|v|+2|u|+|v|12|u|=2|u|+2|v|1<n2𝑢𝑣superscript𝛿2𝑢𝑣2𝑢𝑣1𝑖2𝑢𝑣2𝑢𝑣12𝑢2𝑢2𝑣1𝑛2|u|+|v|+\delta^{\prime}=2|u|+|v|+2|u|+|v|-1-i\leq 2|u|+|v|+2|u|+|v|-1-2|u|=2|% u|+2|v|-1<n2 | italic_u | + | italic_v | + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT = 2 | italic_u | + | italic_v | + 2 | italic_u | + | italic_v | - 1 - italic_i ≤ 2 | italic_u | + | italic_v | + 2 | italic_u | + | italic_v | - 1 - 2 | italic_u | = 2 | italic_u | + 2 | italic_v | - 1 < italic_n. Therefore, j<n𝑗𝑛j<nitalic_j < italic_n, and we can say that j=2|u|+|v|+δ𝑗2𝑢𝑣superscript𝛿j=2|u|+|v|+\delta^{\prime}italic_j = 2 | italic_u | + | italic_v | + italic_δ start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT. Due to the definition, i𝑖iitalic_i and j𝑗jitalic_j are in symmetric positions with respect to vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT.

  • Case 3.

    Assume that i<2|u|𝑖2𝑢i<2|u|italic_i < 2 | italic_u |, and j2|u|𝑗2𝑢j\geq 2|u|italic_j ≥ 2 | italic_u |. In that case, i𝑖iitalic_i and j𝑗jitalic_j are not in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT nor vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT. Let us show that i+j2|u|1(i+j\neq 2|u|-1(italic_i + italic_j ≠ 2 | italic_u | - 1 ( mod n𝑛nitalic_n).

    Let i<nj1𝑖𝑛𝑗1i<n-j-1italic_i < italic_n - italic_j - 1, then i+j<n1𝑖𝑗𝑛1i+j<n-1italic_i + italic_j < italic_n - 1. It means that (i+j)𝑖𝑗(i+j)( italic_i + italic_j ) mod n=i+j𝑛𝑖𝑗n=i+jitalic_n = italic_i + italic_j. At the same time, i+jj2|u|>2|u|+1𝑖𝑗𝑗2𝑢2𝑢1i+j\geq j\geq 2|u|>2|u|+1italic_i + italic_j ≥ italic_j ≥ 2 | italic_u | > 2 | italic_u | + 1. Therefore i+j2|u|1𝑖𝑗2𝑢1i+j\neq 2|u|-1italic_i + italic_j ≠ 2 | italic_u | - 1.

    Let inj1𝑖𝑛𝑗1i\geq n-j-1italic_i ≥ italic_n - italic_j - 1. It means that (i+j)𝑖𝑗(i+j)( italic_i + italic_j ) mod n=i(nj)<i1<2|u|1𝑛𝑖𝑛𝑗bra𝑖1bra2𝑢1n=i-(n-j)<i-1<2|u|-1italic_n = italic_i - ( italic_n - italic_j ) < italic_i - 1 < 2 | italic_u | - 1. Therefore (i+j)𝑖𝑗(i+j)( italic_i + italic_j ) mod n2|u|1𝑛2𝑢1n\neq 2|u|-1italic_n ≠ 2 | italic_u | - 1.

\Box

So, we can say that for any i𝑖iitalic_i and j𝑗jitalic_j such that i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 (((( mod n)n)italic_n ), we have xi=xjsubscript𝑥𝑖subscript𝑥𝑗x_{i}=x_{j}italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT.

For an integer p{0,,n1}𝑝0𝑛1p\in\{0,\dots,n-1\}italic_p ∈ { 0 , … , italic_n - 1 }, let us look at two indexes (ip) mod n𝑖𝑝 mod 𝑛(i-p)\mbox{ mod }n( italic_i - italic_p ) mod italic_n and (j+p) mod n𝑗𝑝 mod 𝑛(j+p)\mbox{ mod }n( italic_j + italic_p ) mod italic_n where i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 (((( mod n)n)italic_n ). We have

(ip)+(j+p)=i+j=2|u|1( mod n)𝑖𝑝𝑗𝑝𝑖𝑗2𝑢1 mod 𝑛(i-p)+(j+p)=i+j=2|u|-1(\mbox{ mod }n)( italic_i - italic_p ) + ( italic_j + italic_p ) = italic_i + italic_j = 2 | italic_u | - 1 ( mod italic_n )

Therefore, x(ip) mod n=x(j+p) mod nsubscript𝑥𝑖𝑝 mod 𝑛subscript𝑥𝑗𝑝 mod 𝑛x_{(i-p)\mbox{ mod }n}=x_{(j+p)\mbox{ mod }n}italic_x start_POSTSUBSCRIPT ( italic_i - italic_p ) mod italic_n end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT ( italic_j + italic_p ) mod italic_n end_POSTSUBSCRIPT.

Let us consider the number 2|u|12𝑢12|u|-12 | italic_u | - 1. Due to the integer division rule and the statement 2|u|1<2|u|+2|v|=n2𝑢12𝑢2𝑣𝑛2|u|-1<2|u|+2|v|=n2 | italic_u | - 1 < 2 | italic_u | + 2 | italic_v | = italic_n, we can say that

2|u|1=αn1/3+β,2𝑢1𝛼superscript𝑛13𝛽2|u|-1=\alpha\cdot\lfloor n^{1/3}\rfloor+\beta,2 | italic_u | - 1 = italic_α ⋅ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ + italic_β ,

where 0α2|u|1n1/3nn1/3n2/30𝛼2𝑢1superscript𝑛13𝑛superscript𝑛13superscript𝑛230\leq\alpha\leq\left\lfloor\frac{2|u|-1}{\lfloor n^{1/3}\rfloor}\right\rfloor% \leq\left\lfloor\frac{n}{\lfloor n^{1/3}\rfloor}\right\rfloor\approx n^{2/3}0 ≤ italic_α ≤ ⌊ divide start_ARG 2 | italic_u | - 1 end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ ≤ ⌊ divide start_ARG italic_n end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ ≈ italic_n start_POSTSUPERSCRIPT 2 / 3 end_POSTSUPERSCRIPT and 0βn1/310𝛽superscript𝑛1310\leq\beta\leq\lfloor n^{1/3}\rfloor-10 ≤ italic_β ≤ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ - 1.

Let us consider two sets of integers that are

n={0,,n1/31}subscript𝑛0superscript𝑛131{\cal I}_{n}=\{0,\dots,\lfloor n^{1/3}\rfloor-1\}caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT = { 0 , … , ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ - 1 }

and

𝒥n={αn1/3, for 0α2|u|1n1/3}=subscript𝒥𝑛𝛼superscript𝑛13 for 0𝛼2𝑢1superscript𝑛13absent{\cal J}_{n}=\{\alpha\cdot\lfloor n^{1/3}\rfloor,\mbox{ for }0\leq\alpha\leq% \left\lfloor\frac{2|u|-1}{\lfloor n^{1/3}\rfloor}\right\rfloor\}=caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT = { italic_α ⋅ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ , for 0 ≤ italic_α ≤ ⌊ divide start_ARG 2 | italic_u | - 1 end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ } =
{0,n1/3,2n1/3,3n1/3,,2|u|1n1/3n1/3}.0superscript𝑛132superscript𝑛133superscript𝑛132𝑢1superscript𝑛13superscript𝑛13\{0,\lfloor n^{1/3}\rfloor,2\lfloor n^{1/3}\rfloor,3\lfloor n^{1/3}\rfloor,% \dots,\left\lfloor\frac{2|u|-1}{\lfloor n^{1/3}\rfloor}\right\rfloor\cdot% \lfloor n^{1/3}\rfloor\}.{ 0 , ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ , 2 ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ , 3 ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ , … , ⌊ divide start_ARG 2 | italic_u | - 1 end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ ⋅ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ } .

Note that |𝒥n|=2|u|1n1/3nn1/3n2/3subscript𝒥𝑛2𝑢1superscript𝑛13𝑛superscript𝑛13superscript𝑛23|{\cal J}_{n}|=\left\lfloor\frac{2|u|-1}{\lfloor n^{1/3}\rfloor}\right\rfloor% \leq\left\lfloor\frac{n}{\lfloor n^{1/3}\rfloor}\right\rfloor\approx n^{2/3}| caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT | = ⌊ divide start_ARG 2 | italic_u | - 1 end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ ≤ ⌊ divide start_ARG italic_n end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ ≈ italic_n start_POSTSUPERSCRIPT 2 / 3 end_POSTSUPERSCRIPT, and |n|=n1/3subscript𝑛superscript𝑛13|{\cal I}_{n}|=\lfloor n^{1/3}\rfloor| caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT | = ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋.

We are ready to present one more lemma about these indexes.

Lemma 3

If x=(x0,,xn1)LREV𝑥subscript𝑥0subscript𝑥𝑛1subscript𝐿𝑅𝐸𝑉x=(x_{0},\dots,x_{n-1})\in L_{REV}italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT, then there is in𝑖subscript𝑛i\in{\cal I}_{n}italic_i ∈ caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT and j𝒥n𝑗subscript𝒥𝑛j\in{\cal J}_{n}italic_j ∈ caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT such that x(ip) mod n=x(j+p) mod nsubscript𝑥𝑖𝑝 mod 𝑛subscript𝑥𝑗𝑝 mod 𝑛x_{(i-p)\mbox{ mod }n}=x_{(j+p)\mbox{ mod }n}italic_x start_POSTSUBSCRIPT ( italic_i - italic_p ) mod italic_n end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT ( italic_j + italic_p ) mod italic_n end_POSTSUBSCRIPT for any p{0,,n1}𝑝0𝑛1p\in\{0,\dots,n-1\}italic_p ∈ { 0 , … , italic_n - 1 }.

Proof

If x=(x0,,xn1)LREV𝑥subscript𝑥0subscript𝑥𝑛1subscript𝐿𝑅𝐸𝑉x=(x_{0},\dots,x_{n-1})\in L_{REV}italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ) ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT, then there is u𝑢uitalic_u and v𝑣vitalic_v from ΣsuperscriptΣ\Sigma^{*}roman_Σ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT such that x=uurvvr𝑥𝑢superscript𝑢𝑟𝑣superscript𝑣𝑟x=uu^{r}vv^{r}italic_x = italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT.

As we discussed before, 2|u|1=αn1/3+β2𝑢1𝛼superscript𝑛13𝛽2|u|-1=\alpha\cdot\lfloor n^{1/3}\rfloor+\beta2 | italic_u | - 1 = italic_α ⋅ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ + italic_β, where 0α2|u|1n1/30𝛼2𝑢1superscript𝑛130\leq\alpha\leq\left\lfloor\frac{2|u|-1}{\lfloor n^{1/3}\rfloor}\right\rfloor0 ≤ italic_α ≤ ⌊ divide start_ARG 2 | italic_u | - 1 end_ARG start_ARG ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ end_ARG ⌋ and 0βn1/310𝛽superscript𝑛1310\leq\beta\leq\lfloor n^{1/3}\rfloor-10 ≤ italic_β ≤ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ - 1. Let i=β𝑖𝛽i=\betaitalic_i = italic_β and j=αn1/3𝑗𝛼superscript𝑛13j=\alpha\cdot\lfloor n^{1/3}\rflooritalic_j = italic_α ⋅ ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋.

Therefore, i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1 and they are in symmetric positions with respect to uur𝑢superscript𝑢𝑟uu^{r}italic_u italic_u start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT or vvr𝑣superscript𝑣𝑟vv^{r}italic_v italic_v start_POSTSUPERSCRIPT italic_r end_POSTSUPERSCRIPT due to Lemma 2. Hence, for any p{0,,n1}𝑝0𝑛1p\in\{0,\dots,n-1\}italic_p ∈ { 0 , … , italic_n - 1 } we have x(ip) mod n=x(j+p) mod nsubscript𝑥𝑖𝑝 mod 𝑛subscript𝑥𝑗𝑝 mod 𝑛x_{(i-p)\mbox{ mod }n}=x_{(j+p)\mbox{ mod }n}italic_x start_POSTSUBSCRIPT ( italic_i - italic_p ) mod italic_n end_POSTSUBSCRIPT = italic_x start_POSTSUBSCRIPT ( italic_j + italic_p ) mod italic_n end_POSTSUBSCRIPT. \Box

We are ready to formulate the algorithm.

4.1 Quantum Algorithm

Let us present an algorithm for computing REVn,ε(x)subscriptREV𝑛𝜀𝑥\texttt{REV}_{n,\varepsilon}(x)REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT ( italic_x ). The algorithm is based on the meet-in-the-middle technique [30](Section 8) that is widely used in algorithms design and cryptography [22]. The main idea is to split a large set into two small parts, small enough for handling them. Similar ideas were used, for example, in [16, 10].

Let us consider the sets nsubscript𝑛{\cal I}_{n}caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT and 𝒥nsubscript𝒥𝑛{\cal J}_{n}caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT, and an integer m=2εlog2n𝑚2𝜀subscript2𝑛m=\frac{2}{\varepsilon}\log_{2}nitalic_m = divide start_ARG 2 end_ARG start_ARG italic_ε end_ARG roman_log start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT italic_n.

  • Step 1. We choose randomly m𝑚mitalic_m numbers p1,,pmR{0,,n1}subscript𝑅subscript𝑝1subscript𝑝𝑚0𝑛1p_{1},\dots,p_{m}\in_{R}\{0,\dots,n-1\}italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT ∈ start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT { 0 , … , italic_n - 1 }

  • Step 2. We add all strings xi=(x(ip1) mod n,,x(ipm) mod n)superscript𝑥𝑖subscript𝑥𝑖subscript𝑝1 mod 𝑛subscript𝑥𝑖subscript𝑝𝑚 mod 𝑛x^{i}=(x_{(i-p_{1})\mbox{ mod }n},\dots,x_{(i-p_{m})\mbox{ mod }n})italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT = ( italic_x start_POSTSUBSCRIPT ( italic_i - italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) mod italic_n end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT ( italic_i - italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT ) mod italic_n end_POSTSUBSCRIPT ) for in𝑖subscript𝑛i\in{\cal I}_{n}italic_i ∈ caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT to a trie ( prefix tree) T𝑇Titalic_T.

  • Step 3. We search j𝒥n𝑗subscript𝒥𝑛j\in{\cal J}_{n}italic_j ∈ caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT such that x~j=(x(j+p1) mod n,,x(j+pm) mod n)superscript~𝑥𝑗subscript𝑥𝑗subscript𝑝1 mod 𝑛subscript𝑥𝑗subscript𝑝𝑚 mod 𝑛\tilde{x}^{j}=(x_{(j+p_{1})\mbox{ mod }n},\dots,x_{(j+p_{m})\mbox{ mod }n})over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT = ( italic_x start_POSTSUBSCRIPT ( italic_j + italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) mod italic_n end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT ( italic_j + italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT ) mod italic_n end_POSTSUBSCRIPT ) is presented in the trie T𝑇Titalic_T. We search them using Grover’s search algorithm [25, 14]. We define a search function f:𝒥n{0,1}:𝑓subscript𝒥𝑛01f:{\cal J}_{n}\to\{0,1\}italic_f : caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT → { 0 , 1 } such that f(j)=1𝑓𝑗1f(j)=1italic_f ( italic_j ) = 1 iff x~jsuperscript~𝑥𝑗\tilde{x}^{j}over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT is presented in T𝑇Titalic_T. The algorithm searches any j0subscript𝑗0j_{0}italic_j start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT such that f(j0)=1𝑓subscript𝑗01f(j_{0})=1italic_f ( italic_j start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) = 1.

If we found an index j0subscript𝑗0j_{0}italic_j start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT on Step 3, then there is x~j=xisuperscript~𝑥𝑗superscript𝑥𝑖\tilde{x}^{j}=x^{i}over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT = italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT and i+j=2|u|1𝑖𝑗2𝑢1i+j=2|u|-1italic_i + italic_j = 2 | italic_u | - 1. Therefore, REVn,ε(x)=1subscriptREV𝑛𝜀𝑥1\texttt{REV}_{n,\varepsilon}(x)=1REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT ( italic_x ) = 1.

Assume that we have a GroverSearch(𝒟,f)GroverSearch𝒟𝑓\textsc{GroverSearch}({\cal D},f)GroverSearch ( caligraphic_D , italic_f ) procedure, that implements Grover’s search algorithm for search space 𝒟𝒟{\cal D}caligraphic_D and a function f:𝒟{0,1}:𝑓𝒟01f:{\cal D}\to\{0,1\}italic_f : caligraphic_D → { 0 , 1 }. The algorithm finds j0𝒟subscript𝑗0𝒟j_{0}\in{\cal D}italic_j start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ∈ caligraphic_D such that f(j0)=1𝑓subscript𝑗01f(j_{0})=1italic_f ( italic_j start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ) = 1. The algorithm works with O(|𝒟|T(f))𝑂𝒟𝑇𝑓O(\sqrt{|{\cal D}|}\cdot T(f))italic_O ( square-root start_ARG | caligraphic_D | end_ARG ⋅ italic_T ( italic_f ) ) query complexity, where T(f)𝑇𝑓T(f)italic_T ( italic_f ) is the complexity of computing the function f𝑓fitalic_f. The error probability is at most 0.10.10.10.1. Assume that the procedure returns True𝑇𝑟𝑢𝑒Trueitalic_T italic_r italic_u italic_e in the case of finding the element j0subscript𝑗0j_{0}italic_j start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and False𝐹𝑎𝑙𝑠𝑒Falseitalic_F italic_a italic_l italic_s italic_e otherwise. In our algorithm we use Contains(T,x~j)Contains𝑇superscript~𝑥𝑗\textsc{Contains}(T,\tilde{x}^{j})Contains ( italic_T , over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT ) function as f(j)𝑓𝑗f(j)italic_f ( italic_j ). This function checks whether x~jsuperscript~𝑥𝑗\tilde{x}^{j}over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT belongs to the trie T𝑇Titalic_T. The query complexity of the function is O(m)𝑂𝑚O(m)italic_O ( italic_m ) due to properties of the trie data structure that were discussed in Section 2. The main operations with the trie data structure are listed in Section 2.

The implementation of the algorithm is presented in Algorithm 1; the complexity is analyzed in Theorem 4.1.

Algorithm 1 The Quantum Algorithm for REVn,εsubscriptREV𝑛𝜀\texttt{REV}_{n,\varepsilon}REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT problem and input x=(x0,,xn1)𝑥subscript𝑥0subscript𝑥𝑛1x=(x_{0},\dots,x_{n-1})italic_x = ( italic_x start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_n - 1 end_POSTSUBSCRIPT ).
m2εlog2n𝑚2𝜀subscript2𝑛m\leftarrow\frac{2}{\varepsilon}\log_{2}nitalic_m ← divide start_ARG 2 end_ARG start_ARG italic_ε end_ARG roman_log start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT italic_n
for i{1,,m}𝑖1𝑚i\in\{1,\dots,m\}italic_i ∈ { 1 , … , italic_m } do
     piR{0,,n1}subscript𝑅subscript𝑝𝑖0𝑛1p_{i}\leftarrow_{R}\{0,\dots,n-1\}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ← start_POSTSUBSCRIPT italic_R end_POSTSUBSCRIPT { 0 , … , italic_n - 1 }\triangleright pisubscript𝑝𝑖p_{i}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT is chosen randomly
end for
TInitTrie()𝑇InitTrieT\leftarrow\textsc{InitTrie}()italic_T ← InitTrie ( )
for i{1,,n1/31}𝑖1superscript𝑛131i\in\{1,\dots,\lfloor n^{1/3}\rfloor-1\}italic_i ∈ { 1 , … , ⌊ italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⌋ - 1 } do
     xi(x(ip1) mod n,,x(ipm) mod n)superscript𝑥𝑖subscript𝑥𝑖subscript𝑝1 mod 𝑛subscript𝑥𝑖subscript𝑝𝑚 mod 𝑛x^{i}\leftarrow(x_{(i-p_{1})\mbox{ mod }n},\dots,x_{(i-p_{m})\mbox{ mod }n})italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT ← ( italic_x start_POSTSUBSCRIPT ( italic_i - italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) mod italic_n end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT ( italic_i - italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT ) mod italic_n end_POSTSUBSCRIPT )
     AddToTrie(T,xj)AddToTrie𝑇superscript𝑥𝑗\textsc{AddToTrie}(T,x^{j})AddToTrie ( italic_T , italic_x start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT )
end for
ResultGroverSearch(𝒥n,Contains(T,x~j))𝑅𝑒𝑠𝑢𝑙𝑡GroverSearchsubscript𝒥𝑛Contains𝑇superscript~𝑥𝑗Result\leftarrow\textsc{GroverSearch}({\cal J}_{n},\textsc{Contains}(T,\tilde{% x}^{j}))italic_R italic_e italic_s italic_u italic_l italic_t ← GroverSearch ( caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT , Contains ( italic_T , over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT ) )
return Result𝑅𝑒𝑠𝑢𝑙𝑡Resultitalic_R italic_e italic_s italic_u italic_l italic_t
Theorem 4.1

The provided algorithm computes REVn,εsubscriptREV𝑛𝜀\texttt{REV}_{n,\varepsilon}REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT with O(1εn1/3logn)𝑂1𝜀superscript𝑛13𝑛O\left(\frac{1}{\varepsilon}n^{1/3}\log n\right)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n ) query complexity and at most 1414\frac{1}{4}divide start_ARG 1 end_ARG start_ARG 4 end_ARG error probability.

Proof

Let us discuss complexity of the algorithm. Step 2 which is adding all strings xisuperscript𝑥𝑖x^{i}italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT requires O(|n|m)=O(n1/3m)𝑂subscript𝑛𝑚𝑂superscript𝑛13𝑚O(|{\cal I}_{n}|\cdot m)=O(n^{1/3}\cdot m)italic_O ( | caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT | ⋅ italic_m ) = italic_O ( italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⋅ italic_m ) query complexity. Grover search works with O(|𝒥n|m)=O(n2/3m)=O(n1/3m)𝑂subscript𝒥𝑛𝑚𝑂superscript𝑛23𝑚𝑂superscript𝑛13𝑚O(|{\cal J}_{n}|\cdot m)=O(\sqrt{n^{2/3}}\cdot m)=O(n^{1/3}\cdot m)italic_O ( | caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT | ⋅ italic_m ) = italic_O ( square-root start_ARG italic_n start_POSTSUPERSCRIPT 2 / 3 end_POSTSUPERSCRIPT end_ARG ⋅ italic_m ) = italic_O ( italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⋅ italic_m ) query complexity. Note that m=2εlogn𝑚2𝜀𝑛m=\frac{2}{\varepsilon}\log nitalic_m = divide start_ARG 2 end_ARG start_ARG italic_ε end_ARG roman_log italic_n, that is why the total complexity is

O(1εn1/3logn+1εn1/3logn)=O(1εn1/3logn)𝑂1𝜀superscript𝑛13𝑛1𝜀superscript𝑛13𝑛𝑂1𝜀superscript𝑛13𝑛O\left(\frac{1}{\varepsilon}n^{1/3}\log n+\frac{1}{\varepsilon}n^{1/3}\log n% \right)=O\left(\frac{1}{\varepsilon}n^{1/3}\log n\right)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n + divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n ) = italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n )

As we discuss in Lemma 3, if xLREV𝑥subscript𝐿𝑅𝐸𝑉x\in L_{REV}italic_x ∈ italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT, then there are in𝑖subscript𝑛i\in{\cal I}_{n}italic_i ∈ caligraphic_I start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT and j𝒥n𝑗subscript𝒥𝑛j\in{\cal J}_{n}italic_j ∈ caligraphic_J start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT such that xi=x~jsuperscript𝑥𝑖superscript~𝑥𝑗x^{i}=\tilde{x}^{j}italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT = over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT for any choice of (p1,,pm)subscript𝑝1subscript𝑝𝑚(p_{1},\dots,p_{m})( italic_p start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_p start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT ). Therefore, the algorithm finds the required i𝑖iitalic_i and j𝑗jitalic_j and returns the correct answer with an error probability at most 0.10.10.10.1 because of the error probability for Grover’s search algorithm.

Assume that x𝑥xitalic_x is εn𝜀𝑛\varepsilon\cdot nitalic_ε ⋅ italic_n far from any word from the language LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT. In other words, REVn,ε(x)=0subscriptREV𝑛𝜀𝑥0\texttt{REV}_{n,\varepsilon}(x)=0REV start_POSTSUBSCRIPT italic_n , italic_ε end_POSTSUBSCRIPT ( italic_x ) = 0. Let us show that with high probability we cannot find the i𝑖iitalic_i and j𝑗jitalic_j indexes.

For fixed j𝑗jitalic_j and i𝑖iitalic_i, the probability of obtaining a position k𝑘kitalic_k of equal symbols, xki=x~kjsubscriptsuperscript𝑥𝑖𝑘subscriptsuperscript~𝑥𝑗𝑘x^{i}_{k}=\tilde{x}^{j}_{k}italic_x start_POSTSUPERSCRIPT italic_i end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT = over~ start_ARG italic_x end_ARG start_POSTSUPERSCRIPT italic_j end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT, is (1ε)1𝜀(1-\varepsilon)( 1 - italic_ε ). The total error probability that is the probability of obtaining all m𝑚mitalic_m equal positions is

(1ε)m=(1ε)2εlog2n=((1ε)1ε)2log2n<(12)2log2n=(2log2n)2=n2.superscript1𝜀𝑚superscript1𝜀2𝜀subscript2𝑛superscriptsuperscript1𝜀1𝜀2subscript2𝑛superscript122subscript2𝑛superscriptsuperscript2subscript2𝑛2superscript𝑛2(1-\varepsilon)^{m}=(1-\varepsilon)^{\frac{2}{\varepsilon}\log_{2}n}=\left((1-% \varepsilon)^{\frac{1}{\varepsilon}}\right)^{2\log_{2}n}<\left(\frac{1}{2}% \right)^{2\log_{2}n}=\left(2^{\log_{2}n}\right)^{-2}=n^{-2}.( 1 - italic_ε ) start_POSTSUPERSCRIPT italic_m end_POSTSUPERSCRIPT = ( 1 - italic_ε ) start_POSTSUPERSCRIPT divide start_ARG 2 end_ARG start_ARG italic_ε end_ARG roman_log start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT italic_n end_POSTSUPERSCRIPT = ( ( 1 - italic_ε ) start_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT 2 roman_log start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT italic_n end_POSTSUPERSCRIPT < ( divide start_ARG 1 end_ARG start_ARG 2 end_ARG ) start_POSTSUPERSCRIPT 2 roman_log start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT italic_n end_POSTSUPERSCRIPT = ( 2 start_POSTSUPERSCRIPT roman_log start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT italic_n end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT = italic_n start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT .

Here (1ε)1ε<12superscript1𝜀1𝜀12(1-\varepsilon)^{\frac{1}{\varepsilon}}<\frac{1}{2}( 1 - italic_ε ) start_POSTSUPERSCRIPT divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG end_POSTSUPERSCRIPT < divide start_ARG 1 end_ARG start_ARG 2 end_ARG for any ε𝜀\varepsilonitalic_ε such that 0<ε<10𝜀10<\varepsilon<10 < italic_ε < 1.

For all pairs of i𝑖iitalic_i and j𝑗jitalic_j, the probability of success on all pairs of strings is (1n2)n1/3n2/3>34superscript1superscript𝑛2superscript𝑛13superscript𝑛2334(1-n^{-2})^{n^{1/3}\cdot n^{2/3}}>\frac{3}{4}( 1 - italic_n start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ⋅ italic_n start_POSTSUPERSCRIPT 2 / 3 end_POSTSUPERSCRIPT end_POSTSUPERSCRIPT > divide start_ARG 3 end_ARG start_ARG 4 end_ARG for n4𝑛4n\geq 4italic_n ≥ 4 because limn(1n2)n=1subscript𝑛superscript1superscript𝑛2𝑛1\lim_{n\to\infty}(1-n^{-2})^{n}=1roman_lim start_POSTSUBSCRIPT italic_n → ∞ end_POSTSUBSCRIPT ( 1 - italic_n start_POSTSUPERSCRIPT - 2 end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT = 1. So, with probability 3434\frac{3}{4}divide start_ARG 3 end_ARG start_ARG 4 end_ARG all elements in the search space of Grover’s Search are 00. If the whole input contains only zeroes, then Grover’s search algorithm returns 00 with probability 1111. So, the Total success probability in that case is at least 3434\frac{3}{4}divide start_ARG 3 end_ARG start_ARG 4 end_ARG. The error probability is at most 1414\frac{1}{4}divide start_ARG 1 end_ARG start_ARG 4 end_ARG. \Box

5 Conclusion

In this paper, we present a quantum property testing algorithm for recognizing the context-free language LREVsubscript𝐿𝑅𝐸𝑉L_{REV}italic_L start_POSTSUBSCRIPT italic_R italic_E italic_V end_POSTSUBSCRIPT that has O(1εn1/3logn)𝑂1𝜀superscript𝑛13𝑛O(\frac{1}{\varepsilon}n^{1/3}\log n)italic_O ( divide start_ARG 1 end_ARG start_ARG italic_ε end_ARG italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT roman_log italic_n ) query complexity. It is better than classical counterparts that have Θ(n)superscriptΘ𝑛\Theta^{*}(\sqrt{n})roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( square-root start_ARG italic_n end_ARG ) query complexity. At the same time, we do not know a quantum lower bound in the property testing setting. We have a feeling that it is Ω(n1/3)Ωsuperscript𝑛13\Omega(n^{1/3})roman_Ω ( italic_n start_POSTSUPERSCRIPT 1 / 3 end_POSTSUPERSCRIPT ).

At the same time, in the general setting, the picture is almost clear. Classical query complexity is Θ(n)Θ𝑛\Theta(n)roman_Θ ( italic_n ), and quantum query complexity is Θ(n)superscriptΘ𝑛\Theta^{*}(\sqrt{n})roman_Θ start_POSTSUPERSCRIPT ∗ end_POSTSUPERSCRIPT ( square-root start_ARG italic_n end_ARG ). So, we almost obtain quadratic speed-up. The open question is to develop a quantum algorithm that reaches the lower bound without additional log factors.

The third open question is to investigate other context-free languages for quantum property testing.

Acknowledgements. We thank Frédéric Magniez and Yixin Shen for useful discussions.

This paper has been supported by the Kazan Federal University Strategic Academic Leadership Program (”PRIORITY-2030”).

References

  • [1] Aaronson, S., Grier, D., Schaeffer, L.: A quantum query complexity trichotomy for regular languages. In: 2019 IEEE 60th Annual Symposium on Foundations of Computer Science (FOCS). pp. 942–965. IEEE (2019)
  • [2] Ablayev, F., Ablayev, M., Huang, J.Z., Khadiev, K., Salikhova, N., Wu, D.: On quantum methods for machine learning problems part i: Quantum tools. Big Data Mining and Analytics 3(1), 41–55 (2019)
  • [3] Ablayev, F., Ablayev, M., Khadiev, K., Salihova, N., Vasiliev, A.: Quantum algorithms for string processing. In: Mesh Methods for Boundary-Value Problems and Applications. Lecture Notes in Computational Science and Engineering, vol. 141 (2022)
  • [4] Akmal, S., Jin, C.: Near-optimal quantum algorithms for string problems. In: Proceedings of the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA). pp. 2791–2832. SIAM (2022)
  • [5] Alon, N., Krivelevich, M., Newman, I., Szegedy, M.: Regular languages are testable with a constant number of queries. SIAM Journal on Computing 30(6), 1842–1862 (2001)
  • [6] Ambainis, A.: Understanding quantum algorithms via query complexity. In: Proc. Int. Conf. of Math. 2018. vol. 4, pp. 3283–3304 (2018)
  • [7] Ambainis, A., Balodis, K., Iraids, J., Khadiev, K., Kļevickis, V., Prūsis, K., Shen, Y., Smotrovs, J., Vihrovs, J.: Quantum Lower and Upper Bounds for 2D-Grid and Dyck Language. In: 45th International Symposium on Mathematical Foundations of Computer Science (MFCS 2020). Leibniz International Proceedings in Informatics (LIPIcs), vol. 170, pp. 8:1–8:14 (2020)
  • [8] Ambainis, A., Balodis, K., Iraids, J., Khadiev, K., Kļevickis, V., Prūsis, K., Shen, Y., Smotrovs, J., Vihrovs, J.: Quantum bounds for 2d-grid and dyck language. Quantum Information Processing 22(5), 194 (2023)
  • [9] Arunachalam, S., de Wolf, R.: Optimizing the number of gates in quantum search. Quantum Information and Computation 17(3&\&&4), 251–261 (2017)
  • [10] Arvind, V., Schuler, R.: The quantum query complexity of 0-1 knapsack and associated claw problems. In: International Symposium on Algorithms and Computation (ISAAC 2003). pp. 168–177. Springer (2003)
  • [11] Barr, K., Fleming, T., Kendon, V.: Simulation methods for quantum walks on graphs applied to formal language recognition. Natural Computing 14(1), 145–156 (2015)
  • [12] Bennett, C.H., Bernstein, E., Brassard, G., Vazirani, U.: Strengths and weaknesses of quantum computing. SIAM journal on Computing 26(5), 1510–1523 (1997)
  • [13] Black, P.E.: Dictionary of algorithms and data structures— nist. Tech. rep. (1998)
  • [14] Boyer, M., Brassard, G., Høyer, P., Tapp, A.: Tight bounds on quantum searching. Fortschritte der Physik 46(4-5), 493–505 (1998)
  • [15] Brass, P.: Advanced data structures, vol. 193. Cambridge University Press Cambridge (2008)
  • [16] Brassard, G., Hoyer, P., Tapp, A.: Quantum algorithm for the collision problem. arXiv preprint quant-ph/9705002 (1997)
  • [17] Buhrman, H., Fortnow, L., Newman, I., Röhrig, H.: Quantum property testing. SIAM Journal on Computing 37(5), 1387–1400 (2008)
  • [18] Buhrman, H., Patro, S., Speelman, F.: A Framework of Quantum Strong Exponential-Time Hypotheses. In: 38th International Symposium on Theoretical Aspects of Computer Science (STACS 2021). Leibniz International Proceedings in Informatics (LIPIcs), vol. 187, pp. 19:1–19:19 (2021)
  • [19] Childs, A.M., Kothari, R., Kovacs-Deak, M., Sundaram, A., Wang, D.: Quantum divide and conquer. arXiv preprint arXiv:2210.06419 (2022)
  • [20] Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms. McGraw-Hill (2001)
  • [21] De La Briandais, R.: File searching using variable length keys. In: Papers presented at the the March 3-5, 1959, western joint computer conference. pp. 295–298. ACM (1959)
  • [22] Diffie, W., Hellman, M.E.: Special feature exhaustive cryptanalysis of the nbs data encryption standard. Computer 10(6), 74–84 (1977)
  • [23] Fischer, E.: The art of uninformed decisions: A primer to property testing. In: Current Trends in Theoretical Computer Science: The Challenge of the New Century Vol 1: Algorithms and Complexity Vol 2: Formal Models and Semantics, pp. 229–263. World Scientific (2004)
  • [24] Goldreich, O., Goldwasser, S., Ron, D.: Property testing and its connection to learning and approximation. Journal of the ACM (JACM) 45(4), 653–750 (1998)
  • [25] Grover, L.K.: A fast quantum mechanical algorithm for database search. In: Proceedings of the twenty-eighth annual ACM symposium on Theory of computing. pp. 212–219. ACM (1996)
  • [26] Grover, L.K.: Trade-offs in the quantum search algorithm. Physical Review A 66(5), 052314 (2002)
  • [27] Jordan, S.: Quantum algorithms zoo (2023), http://quantumalgorithmzoo.org/
  • [28] Kapralov, R., Khadiev, K., Mokut, J., Shen, Y., Yagafarov, M.: Fast classical and quantum algorithms for online k-server problem on trees. CEUR Workshop Proceedings 3072, 287–301 (2022)
  • [29] Khadiev, K., Ilikaev, A.: Quantum algorithms for the most frequently string search, intersection of two string sequences and sorting of strings problems. In: International Conference on Theory and Practice of Natural Computing. pp. 234–245 (2019)
  • [30] Khadiev, K.: Lecture notes on quantum algorithms. arXiv preprint arXiv:2212.14205 (2022)
  • [31] Khadiev, K., Bosch-Machado, C.M., Chen, Z., Wu, J.: Quantum algorithms for the shortest common superstring and text assembling problems. Quantum Information and Computation 24(3-4), 267–294 (2024)
  • [32] Khadiev, K., Enikeeva, S.: Quantum version of self-balanced binary search tree with strings as keys and applications. In: International Conference on Micro- and Nano-Electronics 2021. vol. 12157, pp. 587 – 594. International Society for Optics and Photonics, SPIE (2022)
  • [33] Khadiev, K., Ilikaev, A., Vihrovs, J.: Quantum algorithms for some strings problems based on quantum string comparator. Mathematics 10(3), 377 (2022)
  • [34] Khadiev, K., Kravchenko, D.: Quantum algorithm for dyck language with multiple types of brackets. In: Unconventional Computation and Natural Computation. pp. 68–83 (2021)
  • [35] Khadiev, K., Machado, C.M.B.: Quantum algorithm for the shortest superstring problem. In: International Conference on Micro- and Nano-Electronics 2021. vol. 12157, pp. 579 – 586. International Society for Optics and Photonics, SPIE (2022)
  • [36] Khadiev, K., Remidovskii, V.: Classical and quantum algorithms for assembling a text from a dictionary. NONLINEAR PHENOMENA IN COMPLEX SYSTEMS 24(3), 207–221 (2021)
  • [37] Khadiev, K., Remidovskii, V.: Classical and quantum algorithms for constructing text from dictionary problem. Natural Computing 20(4), 713–724 (2021)
  • [38] Khadiev, K., Savelyev, N., Ziatdinov, M., Melnikov, D.: Noisy tree data structures and quantum applications. Mathematics 11(22), 4707 (2023)
  • [39] Knuth, D.: Searching and sorting, the art of computer programming, vol. 3 (1973)
  • [40] Knuth, D.E., Morris, Jr, J.H., Pratt, V.R.: Fast pattern matching in strings. SIAM journal on computing 6(2), 323–350 (1977)
  • [41] Le Gall, F., Seddighin, S.: Quantum meets fine-grained complexity: Sublinear time quantum algorithms for string problems. Algorithmica pp. 1–36 (2022)
  • [42] Le Gall, F., Seddighin, S.: Quantum meets fine-grained complexity: Sublinear time quantum algorithms for string problems. In: 13th Innovations in Theoretical Computer Science Conference (ITCS 2022). Schloss Dagstuhl-Leibniz-Zentrum für Informatik (2022)
  • [43] Montanaro, A.: Quantum pattern matching fast on average. Algorithmica 77(1), 16–39 (2017)
  • [44] Montanaro, A., de Wolf, R.: A survey of quantum property testing. Theory of Computing pp. 1–81 (2016)
  • [45] Newman, I.: Testing of function that have small width branching programs. In: Proceedings 41st Annual Symposium on Foundations of Computer Science. pp. 251–258. IEEE (2000)
  • [46] Nielsen, M.A., Chuang, I.L.: Quantum computation and quantum information. Cambridge univ. press (2010)
  • [47] Parnas, M., Ron, D., Rubinfeld, R.: Testing membership in parenthesis languages. Random Structures & Algorithms 22(1), 98–138 (2003)
  • [48] Rajasekaran, S.: Handbook of randomized computing, vol. 9. Springer Science & Business Media (2001)
  • [49] Ramesh, H., Vinay, V.: String matching in O(n+m)O𝑛𝑚\mbox{O}(\sqrt{n}+\sqrt{m})O ( square-root start_ARG italic_n end_ARG + square-root start_ARG italic_m end_ARG ) quantum time. Journal of Discrete Algorithms 1(1), 103–110 (2003)
  • [50] Rubinfeld, R., Sudan, M.: Robust characterizations of polynomials with applications to program testing. SIAM Journal on Computing 25(2), 252–271 (1996)
  • [51] de Wolf, R.: Quantum computing and communication complexity. University of Amsterdam (2001)