 # Quantum algorithms for computational geometry problems

We study quantum algorithms for problems in computational geometry, such as POINT-ON-3-LINES problem. In this problem, we are given a set of lines and we are asked to find a point that lies on at least 3 of these lines. POINT-ON-3-LINES and many other computational geometry problems are known to be 3SUM-HARD. That is, solving them classically requires time Ω(n^2-o(1)), unless there is faster algorithm for the well known 3SUM problem (in which we are given a set S of n integers and have to determine if there are a, b, c ∈ S such that a + b + c = 0). Quantumly, 3SUM can be solved in time O(n log n) using Grover's quantum search algorithm. This leads to a question: can we solve POINT-ON-3-LINES and other 3SUM-HARD problems in O(n^c) time quantumly, for c<2? We answer this question affirmatively, by constructing a quantum algorithm that solves POINT-ON-3-LINES in time O(n^1 + o(1)). The algorithm combines recursive use of amplitude amplification with geometrical ideas. We show that the same ideas give O(n^1 + o(1)) time algorithm for many 3SUM-HARD geometrical problems.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

The 3Sum problem is as follows: given a set of numbers , do there exist such that ? There is a nearly trivial classical algorithm that solves this problem in time . More advanced algorithms give only a logarithmic improvement to this quadratic complexity [JP14]. It is conjectured that no classical algorithm can solve 3Sum problem in time.
Many problems in computational geometry (for example, determining whether a given set of points contains points that lie on a line) also seem to require time classically. Gajentaan and Overmars [GO95] showed that the 3Sum problem can be embedded into them. This implies that they cannot be solved in time, unless the 3Sum problem can also be solved in time. Such problems are called 3Sum-Hard. Besides 3 points on a line, examples of 3Sum-Hard problems include determining whether a given set of points contain points that lie on a line, determining whether a given set of triangles covers given polygon, and determining whether a given set of axis-parallel segments are separable with a line into two nonempty subsets [GO95].
Quantum computing allows designing quantum algorithms that outperform classical algorithms. One such example is Grover search [Gro96] which achieves quadratic speedup over classical exhaustive search and can be used as a subroutine to speedup more complicated problems [ABI19, MSS05].

In particular, the 3Sum problem can be solved by a quantum algorithm in time, by a fairly simple application of Grover search procedure. Indeed, we can do an exhaustive search over pairs and look for using some data structure (for example, we can use a balanced search tree). However, a direct application of Grover search does not give a quadratic speedup for many geometrical 3Sum-Hard class problems. For example, if we need to determine whether a set of points contain three points that lie on the same line, we need to search for all possible triplets of points, which results in time quantum algorithm [Fur08].
In this paper we combine quantum effects with more sophisticated geometric techniques to design a quantum algorithm with complexity for Point-On-3-Lines problem. We use ideas from this algorithm to solve many other 3Sum-Hard problems in time .

Related work. The he 3Sum problem has been studied in the context of query complexity and it can be solved with queries, as it is a special case of the subset finding problem of Childs and Eisenberg [CE05] in which one has to find constant-size subset of an -element set, with satisfying a certain property. A matching quantum query lower bound is known [BS13]. However, the subset finding algorithm of [CE05] does not have a time-efficient implementation in the general case. Some special cases (for example, the element distinctness and -distinctness algorithms of [Amb07]) can be implemented efficiently but no efficient implementation is known for the 3-SUM case.

We think that it is unlikely that this line of work would lead to an time quantum algorithm for the 3Sum problem. The element distinctness algorithm [Amb07] and the subset finding algorithm [CE05]

are special cases of a quadratic speedup for hitting times of Markov chains

[Sze04, AGJK19, AGJ19]. It is unlikely that these methods will lead to a quantum algorithm that is more than quadratically faster than the best classical algorithm.

More generally, we conjecture that the 3Sum problem cannot be solved in quantum time in the QRAM model, neither with methods based on subset finding nor any oher approach. This could serve as a basis for a quantum version of fine-grained complexity, similarly to recent quantum fine grained lower bounds of [ACL19, BPS19] based on quantum versions of Strong Exponential Time Hypothesis (SETH).

## 2 Preliminaries

### 2.1 Problems

Here we define problems we focus on in this paper. All of them belong to 3Sum-Hard class. [GO95]

• Point-On-3-Lines: Given a set of lines in the plane, is there a point that lies on at least three of them? [GO95]

• 3-Points-On-Line: Given a a set of points in the plane, is there a line that contains at least three points? [GO95]

• Strips-Cover-Box: Given a set of strips in the plane (strip is defined as an infinite area between two parallel lines (see Figure 2)), does their union contain a given axis-parallel rectangle? [GO95]

• Triangles-Cover-Triangle: Given a set of triangles in the plane, does their union contain another given triangle? [GO95]

• Point-Covering: Given a set of half-planes and a number , determine whether there is a point that is covered by at least half-planes. [GO95]

• Segment-Separator: Given a set of vertical line segments, does there exists a non vertical line that does not intersect any of given segments and contaisn at least one given segment in each of two half-planes? [GO95]

• Visibility-Between-Segments: Given a set of vertical line segments and two particular line segments and , determine whether there is a point on and a point on , such that segment between these two points doesn’t intersect any segment from . [GO95]

We also define General-Covering problem. We will design quantum algorithm for this problem with complexity and then reduce many 3Sum-Hard problems to this problem.

• General-Covering: We are given a set of strips and angles (angle is defined as an infinite area between two non-parallel lines (see Figure 2)) in the plane. The task is to find a point that satisfies the following conditions:

• the point is an intersection of two angle or strip boundary lines ( and may be boundary lines of two different angles/strips);

• the point does not belong to the interior of any angle or strip;

• the point satisfies a given predicate that can be computed in time.

### 2.2 Model

We assume a query model in which the query returns the description of the object (point, line, strip, triangle, etc.), given . The description consists of several numbers that specify the object (e.g. coordinates of a point or values of coefficients in the equation that specifies a line). In the quantum case, we can query superpositions of indices . The input to quantum query consists of two registers, with one register holding and the other register provides the space for . The query transformation acts as . In particular, given a superposition in which , applying gives the state . Applying to gives the state in which the descriptions are erased from the second register.

Our algorithms work in the commonly used QRAM (quantum random access memory) model of computation [GLM08] which assumes quantum memory can be accessed in a superposition. QRAM has the property that any time- classical algorithm that uses random access memory can be invoked as a subroutine for a quantum algorithm in time . We can thus use primitives for quantum search (e.g., Grover’s quantum search or Amplitude amplification) with conditions checking which requires data stored in a random access memory.

### 2.3 Tools

We will use two well known quantum procedures in our algorithm.

(Grover search) [KG97] Given a set of elements and a boolean function . The task is to find such that . There is a bounded-error quantum procedure that solves this problem using quantum queries.

(Amplitude amplification) [BHMT02] Let

be a quantum procedure with one-sided error and success probability at least

. Then, there is a quantum procedure that solves the same problem with success probability invoking times. Note that any constant success probability can be achieved with repeating Amplitude Amplification constantly many times.

We will also use the following well known computational geometry algorithm.

(Arrangement of lines) [CGL85] Given a set of lines in the plane, we can compute partition of the plane formed by those lines in time .

We will also use point-line dualization for problem reductions. Point-line dualization is a plane transformation that maps points to lines and lines to points in the following way:

• Line is mapped to point

• Point is mapped to line

One may note, that the following properties are true:

1. and

2. If point lie on one non-vertical line, then lines meet at one point.

3. If non-vertical lines meet at one point, then points lie on one line.

4. Points from vertical line segment are mapped to a strip.

5. Points from non-vertical line segment are mapped to an angle.

## 3 Point on three lines

In this part we describe a quantum algorithm which solves Point-On-3-Lines problem in time, improving over the time quantum algorithm of Furrow [Fur08]. The idea behind our algorithm is as follows. Suppose we are given a set of lines in the plane. From this set we randomly pick lines. Those lines split plane into no more than regions. Each line from set intersects regions. So, on average, a region contains lines crossing that region.
These facts give an opportunity to design a quantum algorithm that improves over the complexity of simple quantum search (as in Furrow’s algorithm [Fur08]). If we have a point , then we can decide if belongs to some line from using quantum time. To do so, we need to find a region which contains point and check if belongs to a line which crosses that region. For finding the region, time suffices. Checking if belongs to a line from can be done by Grover’s search over lines that cross this region. For this, time suffices.
If we need to find three lines that intersect in one point, we run Grover search over all pairs of lines . For each pair, we find the intersection point and check if point belongs to a third line using algorithm described earlier. If the subdivision of the plane into regions can be done in time , this algorithm runs in time . Setting gives . But we can find even better algorithm. After dividing the plane into regions, instead of searching for an intersection point of three lines, we search for a region which has this point (search is done using Grover search) and we recursively apply algorithm to find the intersection point of three lines inside that region. We can then add more levels of recursion to decrease the complexity further. We now describe the final algorithm (in which we recurse at the optimal choice of and the number of levels of recursion grows with ).
Let be the given set of lines in a plane. Let be a subset of containing exactly lines. Lines in divide plane into convex (possibly infinite) polygons. We arbitrarily triangulate regions, which are bounded by at least lines. This results in a subdivision of the plane into regions where each region is bounded by at most segments (see Figure 3). Let . Figure 3: Blue lines divide plate into 13 regions: R1,R2,...,R13. Red line ℓ passes through regions: ℓ∈s(R1),s(R3),s(R6),s(R7),s(R8),s(R10)

If after the triangulation we get regions: , then

###### Proof.

If is the number of faces bounded by lines before the triangulation, then

 t=f1+f2+f3+2f4+3f5+...+(k−2)fk≤k∑i=1ifi≤2k2 (1)

The last inequality holds because is equal to twice the total number of line segments before the triangulation (because each line segment is on the boundary of two faces, one on each side) and the number of line segments is at most (because each of lines is split by the other lines into at most segments). ∎

Sets can be built classically in time .

###### Proof.

We can construct regions in time using Theorem 2.3. We build by iterating through each line from and checking whether the line intersects region . This step takes time . ∎

If is chosen uniformly at random, then

 Pr[maxi|s(Ri)|≥3|S||P|(5log(|S|)+log(ϵ−1))]≤ϵ (2)
###### Proof.

Let be an arbitrary line (possibly not from the set ). Lines from set intersect line in points in this order (if two lines and intersect in the same point, then ). We note that , since some lines from might be parallel to . We color a point with white color if the corresponding line from is in the set . Otherwise we color the point with black color. We define and we assume that , since otherwise lemma is obviously true.

We say that a line is bad, if there exists index , such that is black for all . The probability of being bad can be upper bounded as follows

 Pr[m−L+1⋁i=1(Xi,Xi+1,...,Xi+L−1% are all black)]= (3) ≤m−L+1∑i=1Pr[Xi,Xi+1,...,Xi+L−1 are % all black]=(m−L+1)(|S|−L|P|)(|S||P|) (4) ≤|S|(|S|−L|S|)|P|≤|S|[(1−L|S|)|S|L]L|P||S|≤|S|e5log|S|+logϵ−1=ϵ|S|4 (5)

Consider set which consists of lines from and lines that pass through at least two intersection points of lines from . Then, every edge of every region lies on a line that belongs to (because is either a segment of one of original lines from or is created during the triangulation and, in the second case, both endpoints of are intersection points of two lines from ) Since there are at most intersection points of lines from , we have and

To finish the proof, it is enough to see that the fact that doesn’t contain bad line implies for all . Indeed, if no lines in is bad, then each side of each region contains less than black points. Since a black point corresponds to a line which intersects a region and each region is bounded by at most three segments, the region is intersected by no more than lines from .

There is a bounded error quantum algorithm for Point-On-3-Lines problem, that runs in time .

###### Proof.

The algorithm has a parameter and allowable error probability . The algorithm consists of a recursive procedure that takes a set of lines as input and returns lines from the set which intersects at one point or tells that there are no such lines.

algocf[htbp]

The recursive procedure can be described as follows. If the input set contains less than lines, we solve Point-On-3-Lines classically in time . Otherwise, we split the plane into regions with random lines from and build sets . If there are three lines that intersect at one point, then this point is located in one of the regions (if this point is on the boundary of a region, then this point can be found during the construction of sets ). We use amplitude amplification to find the region which contains intersection point of three lines and recursively apply the procedure to lines from .

Suppose that contains three lines that intersect at one point. If , the algorithm finds those lines with certainty. Let . The probability that for some and the algorithm returns an error is less than . By executing amplitude amplification (running times), we can reduce probability of not finding the lines to . So, finds desired three lines with probability at least .

If is a runtime of , then:

 T(|X|)=O(|X|×k2)+O(√k2)×T(3|X|k(5log(|X|)+log(2ϵ))) (7)

If , then:

 T(|X|)≤O(|X|×|S|2αlog2(|S|))+O(√k2)×T(|X|×|S|−1α) (8)

There are problems on recursion level for some constant and each problem size is at most .

 T(|S|)≤α∑j=0√(C1k)2j×[|S|1−jα×|S|2αlog2(|S|)]= (9) =α∑j=0(C1k|S|1α)j(|S|1+2αlog2(|S|))≤ ≤α(C2log(|S|))α(|S|1+2αlog2(|S|))

If , then

## 4 Other 3SUM hard problems

In this section, we show how it is possible to apply plane separation ideas, described in the previous section, to speed up other 3-Sum-Hard problems defined in [GO95].

• 3-Points-On-Line
This problem is dual to the Point-On-3-Lines problem [GO95], and so is solvable with the same quantum algorithm in time , as described in the previous section.

• General-Covering
The given strips and angles form lines. We divide the plane into regions by randomly choosing out of those lines, similarly to the algorithm described in the previous section. A region and a strip/angle can be in one of the following relations: the strip/angle fully covers the region, the strip/angle partly covers the region or the strip/angle has no common points with the region. We can identify all regions that are fully covered by some strip/angle in time . For regions that are not fully covered by some strip/angle, we identify the set of strips and angles which cross that region. Non covered regions may contain the desired intersection point, but this intersection point is formed by the lines that are boundary lines of the strips/angles in the set . Similarly to the algorithm Point-On-3-Lines, our task is divided into tasks, each of which involved objects. The time complexity is

 T(n)=O(nk2)+O(√k2)×T(32nk(5log(2n)+log(2ϵ))). (10)

Similarly to the analysis of Point-On-3-Lines problem, we get .

• Strips-Cover-Box
This problem is just the special case of the General-Covering problem with the predicate being true if the point is located inside the given box. Then, the point from General-Covering problem corresponds to an uncovered point in Strips-Cover-Box problem. So, Strips-Cover-Box can also be solved in time .

• Triangles-Cover-Triangle
The given triangles consist of segments. We extend each segment to a line and separate the plane into regions, similarly to the Point-On-3-Lines problem with randomly chosen lines. A triangle and a region can be in one of the following relations: the triangle fully covers the region, the triangle partly covers the region or the triangle has no common point with the region. We can identify all regions that are fully covered by some triangle in time . All other regions may contain a point which is not covered by any triangle. Similarly to the Point-On-3-Lines problem, we search for the region which contains that point. Note that, if a triangle partly covers the region , then at least one of the segments that form this triangle is in . So, we can finish our algorithm, just as in General-Covering problem, with the predicate being true, if the point is located inside the triangle that must be covered.

• Point-Covering
The given half-planes are specified by lines. We separate the plane into regions, similarly to the Point-On-3-Lines problem, by randomly choosing out of given lines. For each region we compute the number of half-planes that fully cover this region. This takes time. To determine if there exists a point that is covered by at least half-planes, we need to tell, if there exists a point inside a region that is covered by at least half-planes from . As in the General-Covering problem, the algorithm takes time.

• Visibility-Between-Segments
We dualize the given vertical segments, to get strips. We need to find a point that does not belong to any of the strips and has the property that the corresponding line in the initial plane intersects two given segments and . This problem is just the special case of the General-Covering problem, where the predicate is true if the line corresponding to intersects two given segments and . Just like in the General-Covering problem, this problem can also be solved in time.

• Segment-Separator
This problem can be solved in exactly the same way as the Visibility-Between-Segments problem, with the only difference being the predicate . Now this predicate is true, if the line corresponding to a point separates the given segments in the way required for the Segment-Separator problem. Since is the intersection point of two lines in the dual plane, the line, corresponding to the point , must go through two endpoints of two different given segments. So, is false, if the corresponding line goes through an edge of the convex hull of the endpoints of given segments. This can be detemined in time , after we precompute the convex hull in time . This results in an time quantum algorithm.