The Complexity of the Hausdorff Distance

We investigate the computational complexity of computing the Hausdorff distance. Specifically, we show that the decision problem of whether the Hausdorff distance of two semi-algebraic sets is bounded by a given threshold is complete for the complexity class $\forall\exists_<\mathbb{R}$. This implies that the problem is NP-, co-NP-, $\exists\mathbb{R}$- and $\forall\mathbb{R}$-hard.


Introduction
The question of 'how similar are two given objects' occurs in numerous settings.For three concrete examples, consider Figure 1.A typical tool to quantify their similarity is the Hausdorff distance.Two sets have a small Hausdorff distance if every point of one set is close to some point of the other set and vice versa.It is well known that the Hausdorff distance appears in many branches of science.To illustrate the range of use cases, we consider two examples, for illustrations see Figure 2. In mathematics, the Hausdorff distance provides a metric on sets and henceforth also a topology.This topology can be used to discuss continuous transformations of one set to another [18].In computer vision and geographical information science, the Hausdorff distance is used to measure the similarity between spacial objects [38,45], for example the quality of quadrangulations of complex 3D models [51].In this paper, we study the computational complexity of the Hausdorff distance from a theoretical perspective.
(a) Continuous deformation of a cup into a doughnut [53].
(b) Quadrangulation of a smooth surface used for rendering [51].

Problem Definition
The directed Hausdorff distance between two non-empty sets A, B ⊆ R n is defined as The directed Hausdorff distance between A and B can be interpreted as the smallest value t ≥ 0 such that the (closed) t-neighborhood of B contains A. Hence, it nicely captures the intuition of how much B has to be expanded uniformly in all directions to contain A. Note that this definition is not symmetric, so d H (A, B) and d H (B, A) may differ.For an example, consider Figure 1a; while A 1 ⊆ B 1 and thus d H (A 1 , B 1 ) = 0, it holds that d H (B 1 , A 1 ) > 0. In contrast, the (undirected) Hausdorff distance is symmetric and defined as In this paper, we investigate the computational complexity of deciding whether the Hausdorff distance of two sets is at most a given threshold.

Semi-Algebraic Sets
The algorithmic complexity of computing the Hausdorff distance clearly depends on the type of the underlying sets: If both sets consist of finitely many points, their Hausdorff distance can be easily computed in polynomial time by checking all pairs of points.However in practice, one often considers infinite sets such as collections of disks in the plane, cubic splines or surfaces in three (or more) dimensions, see also Figure 3. (c) Two surfaces with different meshes in R 3 , image from [51].In this paper, we focus on semi-algebraic subsets of R n that can be described by polynomial inequalities with integer coefficients.For simplicity, we use the term semi-algebraic set in this paper.Formally, a semi-algebraic set is the finite union of basic semi-algebraic sets.A basic semi-algebraic set S is specified by two families of polynomials P and Q with integer coefficients such that Semi-algebraic sets cover clearly the vast majority of practical cases.Simultaneously, even in supposedly simple cases, i.e., when considering circles, ellipses or cubic splines, one has to use polynomial equations to describe the sets.

Concrete Example
In order to demonstrate how difficult it is in practice to compute the Hausdorff distance even between two curves in R 2 , let us consider the following example (given by Bernd Sturmfels at a workshop in Saarbrücken in 2019).The two polynomials f (x, y) := x 4 + y 4 + 12x 3  The Hausdorff distance between the compact semi-algebraic sets (in blue and green) is attained at points (a2, b2) such that the segment a2b2 is orthogonal to the tangents at a2 and b2.While the segment a1b1 is longer than a2b2, the pair (a1, b1) does not realize the Hausdorff distance because the segment a1b1 crosses both A and B.
It can be argued using convexity and continuity that the Hausdorff distance is attained at points a ∈ A and b ∈ B such that the segment ab is orthogonal to the tangents at a and b.This yields a set of polynomial equations in four variables.The system has 240 complex solutions, eight of which are real.These 240 solutions can be computed using computer algebra systems based on Gröbner bases.For some real solutions (a, b), the segment ab crosses A and B, for example a 1 b 1 as in Figure 4.These solutions can be discarded.Among the remaining solutions the points a 2 ≈ (−11.48362,−6.1760) and b 2 ≈ (−0.56460, −0.43583) realize the Hausdorff distance of approximately 12.33591.This approach does not easily generalize to general semi-algebraic sets.In the next paragraph, we present a slower, but more general method.

General Decision Algorithm
Consider a situation where we are given two semi-algebraic sets A and B as well as a threshold t ∈ N. The statement d H (A, B) ≤ t can be encoded into a logical sentence of the form where ε is needed to also consider points in the closure of B. We can decide the truth of this sentence by employing sophisticated algorithms from real algebraic geometry that can deal with two blocks of quantifiers [11,Chapter 14].These algorithms are so slow that they are impractical in practice, even for small instances like the above example.Our main result roughly states that in general there is little hope for an improvement.To state this formally, we continue by defining suitable complexity classes.

Algorithmic Complexity
Let ϕ be a quantifier-free formula in the first-order theory of the reals with free variables X = (X 1 , . . ., X n ) and Y = (Y 1 , . . ., Y m ).See Section 2.1 for a formal definition of the syntax and semantics.For now, think of a set of polynomial equations and inequalities, called atoms, with integer coefficients in the variables X and Y .These atoms are combined into formula ϕ using the logical connectives ∧, ∨ and ¬ (also, parenthesis are allowed).The Universal Existential Theory of the Reals (UETR) asks to decide whether a sentence of the form is true.We define the following restriction of UETR: If ϕ does not contain negations (no ¬) and all atoms are strict inequalities (only <, > or =), then we denote the corresponding decision problem by Strict-UETR.Of course, Strict-UETR is a special case of UETR, so it is at most as difficult.
We capture this by defining the complexity classes ∀∃R and ∀∃ < R to contain all decision problems that polynomial-time many-one reduce to UETR and Strict-UETR, respectively.We propose to pronounce the complexity class ∀∃R as 'UER' or 'forall exists R' and ∀∃ < R as 'strict-UER' or 'strict forall exists R'.Let us emphasize that we work in the bit-model of computation; all inputs have finite precision and their overall length determines the size of the problem instance.To the best of our knowledge, ∀∃R was first introduced by Bürgisser and Cucker [20,Section 9] under the name BP 0 (∀∃) (in the constant-free Boolean part of the Blum-Shub-Smale-model [17]).The notation ∀∃R arised later in [28] extending the notation from Schaefer and Števankovič [48].The class co∀∃ < R = ∃∀ ≤ R was first studied by D'Costa, Lefaucheux, Neumann, Ouaknine and Worrel [26].
Concerning the relation of these complexity classes,

Problem and Results
We now have all ingredients to state our problem and main results.Let ϕ A (X) and ϕ B (X) be quantifier-free formulas with free variables X = (X 1 , . . ., X n ).Further, let } and let t ∈ N be a natural number.The Hausdorff problem asks whether d H (A, B) ≤ t.Here the dimension n of the ambient space of A and B is part of the input.We note that there is a polynomial-time algorithm for every fixed n, see the related work in Section 1.7.Our main result determines the algorithmic complexity.

Theorem 1. The Hausdorff problem is ∀∃
While we discuss the input encoding of ϕ A and ϕ B in Section 2.1, let us briefly note here that t is encoded in binary.A generalization to t ∈ Q is straight forward, by representing t as a reduced fraction and encoding the numerator and denominator in binary.How to generalize further to t ∈ R is not clear, as the input must be a bitstring of finite length.
Prior to our result, it was not even known whether computing the Hausdorff distance is NP-hard.As ∀∃ < R contains the complexity classes NP, coNP, ∃R and ∀R, our result implies hardness for these classes.Theorem 1 answers an open question posed by Dobbins, Kleist, Miltzow and Rzążewski [28].
One may wonder whether it is crucial for our results that the Hausdorff problem asks if the distance ≤ t rather than < t.We remark that all our proofs work with tiny modifications also for the case of a strict inequality.Furthermore, our results also hold for the directed Hausdorff distance.Note that one can compute the undirected Hausdorff distance trivially, by computing twice the directed Hausdorff distance.Thus intuitively, the directed Hausdorff distance is computationally at least as hard.Yet, this is not a many-one reduction, as we need to compute the directed Hausdorff distance twice.
In the proof of ∀∃ < R-hardness for Theorem 1, we create instances with some additional properties.First, our reduction is a gap reduction and the Hausdorff distance of the obtained instance is either below the threshold t or at least t • 2 2 Ω(n) , where n denotes the number of variables of ϕ A and ϕ B .Thus, our result also yields the following inapproximability result: Second, our reduction can be modified slightly to obtain a Hausdorff instance in which A and B are described by relatively simple formulas.
Corollary 3. The Hausdorff problem remains ∀∃ < R-complete, even if the two sets A and B are both described either by (i) a conjunction of quadratic polynomial equations, or (ii) a single polynomial equation of degree at most four.
Our last result concerns the complexity class ∀∃ < R itself.As shown in Theorem 1, the complexity class ∀∃ < R exactly captures the complexity of the Hausdorff problem.It is defined via the decision problem Strict-UETR which adds the syntactical restriction to UETR of only allowing strict inequalities as atoms.There are other complexity classes between ∃R/∀R and ∀∃R, one of them is described by Bürgisser and Cucker [20].They define new quantifiers that make topological restrictions to UETR.Among others they define the exotic quantifier ∀ * as Intuitively, ∀ * X ∈ R n : ϕ(X) does not require that ϕ(x) holds for all x ∈ R n but only for all x in a dense subset of R n .For more details, we refer to Section 7. Let Exotic-UETR denote the decision problem whether a sentence of the form is true, where ϕ ∈ QFF.Then the complexity class ∀ * ∃R contains all problems that many-one reduce to Exotic-UETR.Based on our techniques and developed tools, we can show that the two complexity classes ∀ * ∃R and ∀∃ < R are the same.

Related Work
This subsection reviews previous work concerning two directions.First, we discuss the complexity of computing the Hausdorff distance for special sets.Afterwards, we investigate previous work on the complexity class ∀∃R.

Computing the Hausdorff Distance
The notion of the Hausdorff distance was introduced by Felix Hausdorff in 1914 [33].Many early works focused on the Hausdorff distance for finite point sets.For a set of a points and a set of b points in any fixed dimension, the Hausdorff distance can be computed by checking all pairs, i.e., in time O(ab).In the plane, the runtime can be improved to O((a + b) log(a + b)) by using Voronoi diagrams [7].In fact, this method can be extended to sets consisting of pairwise non-crossing line segments in the plane, e.g., simple polygons and polygonal chains fulfill this property.If the polygons are additionally convex, their Hausdorff distance can even be computed in linear time [10].
More generally, the Hausdorff distance can be computed in polynomial time whenever the two sets can be described by a simplicial complex of fixed dimension.Based on the PhD thesis of Godau [31], Alt et al. [8,Theorem 3.3] show how to compute the directed Hausdorff distance between two sets in R n consisting of a and b k-dimensional simplices in time O(ab k+2 ) (assuming n is constant).Using a Las Vegas algorithm for computing the vertices of the lower envelope, similar ideas yield an approach with randomized expected time in O(ab k+ε ) for k > 1 and every ε > 0 [8, Theorem 3.4].They additionally present algorithms with better randomized expected running times for sets of triangles in R 3 and point sets in R n .
Given two semi-algebraic sets A, B ⊆ R n and a threshold value t ∈ N, the Hausdorff decision problem can be encoded as a UETR sentence Φ as already done for the directed Hausdorff distance in sentence (1) above.Such a sentence can be decided in time (sd) O(n 2 ) , where d denotes the maximum degree of any polynomial of Φ and s denotes the number of atoms [11,Theorem 14.14].
In other contexts the two sets are allowed to undergo certain transformations (e.g.translations) such that the Hausdorff distance is minimized [19].See Alt [9] for a survey.

The (Universal) Existential Theory of the Reals
As mentioned above, the complexity class ∀∃R was first studied by Bürgisser and Cucker who prove complexity results for many decision problems involving circuits [20].Dobbins, Kleist, Miltzow, and Rzążewski [29,28] consider ∀∃R in the context of area-universality of graphs.A plane graph is area-universal if for every assignment of non-negative reals to the inner faces of a plane graph, there exists a straight-line drawing such that the area of each inner face equals the assigned number.Dobbins et al. conjecture that the decision problem whether a given plane graph is area-universal is complete for ∀∃R.They support this conjecture by proving hardness for several related notions [28].Additionally, for future research directions, they present a number of candidates for potentially ∀∃R-hard problems.Among them, they asked whether the Hausdorff problem is ∀∃R-complete.The other candidates exhibit intrinsic connections to the notions of imprecision, robustness and extendability.
We point out that the computational complexity may also become easier when asking universal-type questions.For example, it is ∃R-complete to decide whether a graph is a unit distance graph, i.e., whether it has a straight-line drawing in the plane in which all edges have the same length [47].On the other hand, the decision problem whether for all reasonable assignments of weights to the edges, a graph has straight-line drawing in which the edge lengths correspond to the assigned weight lies in P [13].Similarly, it is ∃R-complete to decide for a given planar graph for which some vertices are fixed to the boundary of a polygon (with holes) whether there exists a planar straight-line drawing inside the polygon [34].The case of simple polygons is open.In contrast, there is a polynomial time algorithm to test if a given graph G and a contained cycle C admit for every simple polygon P , representing C, a straight-line drawing of G inside P [40].
The complement class ∃∀R was recently investigated by D'Costa et al. [26].They show that it is ∃∀ ≤ R-complete (where ∃∀ ≤ R = co∀∃ < R) to decide for a given rational matrix A and a compact semi-algebraic set K ⊆ R n , whether there exists a starting point x ∈ K such that x n := A n x is contained in K for all n ∈ N .This and similar problems are generally referred to as escape problems.Another subclass of ∃∀R, called ∃ D •∀R (here the ∃ D restricts the existentially quantified variables to Boolean instead of real values), was introduced by Blanc and Hansen [16].They show that computing evolutionary stable strategies in certain multi-player games is ∃ D •∀R-complete.
We understand the complexity class ∀∃R as a natural extension of the complexity class ∃R (pronounced as 'exists R' or 'ER'), which is defined similarly to ∀∃R, but without universally quantified variables.The complexity class ∃R has gained a lot of interest in recent years, specifically in the computational geometry community.It gains its significance because numerous well-studied problems from diverse areas of theoretical computer science and mathematics have been shown to be complete for this class.Famous examples from discrete geometry are the recognition of geometric structures, such as unit disk graphs [36], segment intersection graphs [35], visibility graphs [23], stretchability of pseudoline arrangements [39,50] and order type realizability [35].Other ∃R-complete problems are related to graph drawing [34], Nash-Equilibria [15,30], geometric packing [6], the art gallery problem [3], convex covers [2], non-negative matrix factorization [49], polytopes [27,44], geometric embeddings of simplicial complexes [4], geometric linkage constructions [1], training neural networks [5,14], and continuous constraint satisfaction problems [37].We refer the reader to the lecture notes by Matoušek [35] and surveys by Schaefer [46] and Cardinal [22] for more information on the complexity class ∃R.

Techniques and Proof Overview
In this subsection, we present the general idea behind the hardness reduction for the Hausdorff problem.The goal is to convey the intuition and to motivate the technical intermediate steps needed.The sketched reduction is oversimplified and thus neither in polynomial time nor fully correct.We point out both of these issues and give first ideas on how to solve them.
Let Φ := ∀X ∈ R n .∃Y ∈ R m : ϕ(X, Y ) be a Strict-UETR instance.We define two sets and ask whether d H (A, B) = 0.If Φ is true, then A = R n and we have d H (A, B) = 0 because both sets are equal.Otherwise, if Φ is false, then there exists some x ∈ R n for which there is no y ∈ R m satisfying ϕ(x, y) and we conclude that A R n .In general, we call the set of all x ∈ R n for which there is no y ∈ R m satisfying ϕ(x, y) the counterexamples ⊥(Φ) of Φ.One might hope that ⊥(Φ) = ∅ is enough to obtain d H (A, B) > 0. However, this is not the case.To this end, consider the formula Ψ := ∀X ∈ R .∃Y ∈ R : XY > 1, which is false.The set ⊥(Ψ) = {0} contains only a single element, so we have A = R \ {0} and B = R.However, their Hausdorff distance also evaluates to d H (A, B) = 0. We conclude that above reduction does not (yet) work, because it may also map no-instances of Strict-UETR to yes-instances of Hausdorff.
We solve this issue by a preprocessing step that expands the set of counterexamples.Specifically, Theorem 15 establishes a polynomial-time algorithm to transform a Strict-UETR instance Φ into an equivalent formula Φ such that the set of counterexamples is either empty (if Φ is true) or contains an open ball of positive radius (if Φ is false).The radius of the ball serves as a lower bound on the Hausdorff distance d H (A, B).Thus a reduction starting with Φ is correct.A key tool for this step is that we can restrict the variable ranges from R n and R m to small and compact intervals.Figure 5 presents an example on how such a range restriction may enlarge the set of counterexamples from a single point to an interval.We emphasize that it is not known whether such a restriction of the variable ranges is possible for general UETR formulas.However, we exploit the fact that Strict-UETR formulas have a special property that we call ∀-strict; a negation-and implication-free formula is ∀-strict if each atom involving universally quantified variables is a strict inequality.Being ∀-strict is a key property of many of the formulas considered throughout the paper and our proofs crucially rely on it.
A further challenge is given by the definition of the sets A and B. While the description complexity of B depends only on n, the definition of A contains an existential quantifier.This is troublesome because our definition of the Hausdorff problem requires quantifierfree formulas as its input, and in general there is no equivalent quantifier-free formula of polynomial length which describes the set A [25].We overcome this issue by taking the existentially quantified variables as additional dimensions into account.We scale them to a range much smaller than the range of the universally quantified variables, so that their influence on the Hausdorff distance becomes negligible.Therefore instead of the above, we work (in Section 5) with sets similar to for some value C that is doubly exponentially large in |Φ|.This definition of A and B introduces the new issue that even if Φ is true, the Hausdorff distance d H (A, B) might be strictly positive.However, we manage to identify a threshold t ∈ N, such that d H (A, B) ≤ t if and only if Φ is true.This completes the proof of ∀∃ < R-hardness.In Section 7.1 we also establish ∀∃ < R-hardness for t = 0.

Organization
The remainder of the paper is organized as follows.We introduce preliminaries concerning the first-order theory of the reals in Section 2 and essential tools from real algebraic geometry in Section 3. Section 4 presents the result for expanding the set of counterexamples for ∀-strict formulas.Finally, Section 5 contains the ∀∃ < R-hardness proof, followed by the ∀∃ < R-membership in Section 6.In Section 7, we apply our findings to so-called exotic quantifiers and relate them to ∀∃ < R. We conclude with a list of interesting open problems in Section 8.

Preliminaries
In this section, we first introduce the necessary notation and definitions.Afterwards, we consider the relation between all complexity classes that are relevant for the paper.

First-Order Theory of the Reals
We mostly introduce standard terminology following the book by Cox, Little and O'Shea [24].
An atom is an expression of the form P • 0 for some polynomial P ∈ Z[X 1 , . . ., X n ] and • ∈ {<, ≤, =, =, ≥, >}.We always assume that a polynomial is written as a sum of monomials.Its total degree is the maximum number of occurrences of variables involved in any monomial.For example P (X, Y, Z) = X 2 Y 2 + XY Z has total degree four.A variable is called free if it is not bound by a quantifier.A formula is either an atom, or if ϕ 1 , ϕ 2 are formulas, then their conjunction ϕ 1 ∧ ϕ 2 , their disjunction ϕ 1 ∨ ϕ 2 , and the negation ¬ϕ 1 are formulas, or if ϕ(X) is a formula with a free variable X, then ∃X ∈ R : ϕ(X) and ∀X ∈ R : ϕ(X) are formulas in which X is bound.Note that the implication ϕ 1 =⇒ ϕ 2 can be formulated as ¬ϕ 1 ∨ ϕ 2 .
In order to determine the length |ϕ| of a formula ϕ, we count 1 for each fixed symbol, we encode integer coefficients in binary, exponents in unary, and we count log k (to encode the variable name) for each occurrence of a variable, where k denotes the number of variables.We denote by QFF the family of quantifier free formulas.Furthermore, QFF < and QFF ≤ are the families in QFF that do not contain any negations and have only atoms involving < and ≤, respectively.
A sentence is a formula without free variables and thus either equivalent to true or to false.As a convention, we use upper case Greek letters for sentences and use lower case Greek letter for formulas.We write Ψ ≡ Ψ if the two sentences have the same truth value.The first-order theory of the reals is the family of all true sentences.If all quantifiers of a formula appear at its beginning, we say it is in prenex normal form.We usually write blocks of variables, i.e., ∀X ∈ R n : ϕ(X).Here X is a shorthand notation for X = (X 1 , . . ., X n ).We say n is the length of X in this case.
We use upper case Latin letters for variables in formulas and lower case Latin letters for specific values, i.e., symbol X denotes a vector of variables, while x ∈ R n is a point.We sometimes write ϕ(X, Y ) to emphasize that X and Y are (blocks of) free variables in ϕ.Often we omit the free variables in ϕ though.
Consider a formula Φ :≡ ∀X ∈ R n .∃Y ∈ R m : ϕ(X, Y ), where ϕ ∈ QFF.Each atom of ϕ is of the form P • 0, where • ∈ {<, ≤, =, =, ≥, >} and P ∈ Z[X, Y ] is a polynomial in the variables X and Y .Without loss of generality we can restrict our attention to the case of • ∈ {<, ≤}, because the following transformations show that the other relations can be expressed by < or ≤ such that the length of the formula is at most doubled: Furthermore, we can assume that ϕ contains only the logical connectives ∧ and ∨, because De Morgan's law allows to push all negations (and therefore also implications) down to the atoms transforming ϕ into negation normal form.This justifies, why QFF • for • ∈ {<, ≤} only contains negation-free formulas by our definition.With the following equivalences we obtain a formula without negations: The complexity of a semi-algebraic set S is the length of a shortest quantifier-free formula ϕ, such that S = S(ϕ) (recall that integer coefficients are encoded in binary).We write ϕ ≡ ϕ if S(ϕ) = S(ϕ ).

Complexity Classes
Several complexity classes appear in this paper.Here we discuss their relations among one another.We make use of a helpful lemma from the literature.It allows us to replace a quantifier-free formula ϕ by a simpler one (at the cost of adding additional variables).Here and throughout the rest of the paper the notation x ≤ poly(y 1 , . . ., y k ) means that there is a polynomial Lemma 5 ([48, Lemma 3.2]).Let ϕ(X) ∈ QFF be a formula with n free variables X.Then we can construct either of the following in polynomial time: (i) Integers , m ≤ poly(|ϕ|) and for i ∈ {1, . . ., m} a polynomial (ii) An integer k ≤ poly(|ϕ|) and a polynomial F : R n+k → R of degree at most 4 such that For any fixed • ∈ {<, ≤}, we denote by ∀∃ • R the subset of ∀∃R containing all decision problems that polynomial-time many-one reduce to a UETR-instance whose quantifier-free parts are contained in QFF • .Similarly, for • ∈ {<, ≤}, we denote the corresponding subsets of ∃R and ∀R by ∃ • R and ∀ • R, respectively.The following lemma summarizes what we know about the relation between the complexity classes ∀∃ < R, ∀∃ ≤ R and ∀∃R as well as their relation to the well-studied classes NP, coNP, ∃R, ∀R, and PSPACE.Lemma 6.The following inclusions hold: Proof.The inclusion NP ⊆ ∃R was first presented by Shor [50].This directly implies coNP ⊆ ∀R (because ∀R = co∃R).For • ∈ {<, ≤} the inclusion ∀∃ • R ⊆ ∀∃R follows by definition because the left hand side is just a special case of the right hand side.Using that ∃ < R = ∃R [48, Theorem 4.1], the same argument can be used for ∃R ⊆ ∀∃ < R. Canny first established ∀∃R ⊆ PSPACE in his seminal paper [21].
To show that ∀∃R ⊆ ∀∃ ≤ R, consider a UETR instance We apply Lemma 5 to ϕ and obtain in polynomial time an integer k ≤ poly(|ϕ|) and a polynomial F : R n+m+k → R, such that is equivalent to Φ.Note that both atoms use ≤.
Lastly, let us consider the inclusion ∀R ⊆ ∀∃ < R. Note that ∀R = ∀ < R (because two complexity classes are equal whenever their complement classes are equal and ∃R = ∃ ≤ R is known [48]).Now ∀ < R ⊆ ∀∃ < R again follows by definition.

Toolbox for Semi-Algebraic Sets
In this section, we first introduce tools from real algebraic geometry, and then show how the ranges of quantifiers can be bounded.

Tools Borrowed from Real Algebraic Geometry
We review two sophisticated results from algebraic geometry, namely singly exponential quantifier elimination and the so called Ball Theorem.While quantifier elimination provides equivalent quantifier-free formulas of bounded length, the Ball Theorem guarantees that every non-empty semi-algebraic set contains an element not too far from the origin.
We start with a result on quantifier-elimination which originates from a series of articles by Renegar [41,42,43].Let us stress that the time complexity of this algorithm is singly exponential and not doubly exponential for every fixed number of quantifier alternations.
Theorem 7 ([11,Theorem 14.16]).Let X 1 , . . ., X k , Y be blocks of real variables where X i has length n i , Y has length m, formula ϕ(X 1 , . . ., X k , Y ) ∈ QFF has s atoms and Q i ∈ {∃, ∀} is a quantifier for all i = 1, . . ., k. Further, let d be the maximum total degree of any polynomial of ϕ(X 1 , . . ., X k , Y ).Then for any formula there is an equivalent quantifier-free formula of size at most Throughout the paper we use the following corollary of Theorem 7. It is weaker but easier to work with.Corollary 8. Let Φ(Y ) be as in Theorem 7 of length L = |ϕ(X 1 , . . ., X k , Y )|.Then for some constant α ∈ R independent of Φ, there exists an equivalent quantifier-free formula of size at most Proof.Let Ψ be the quantifier-free formula equivalent to Φ obtained by Theorem 7. By observing that d, s ≤ L, we get where α := max{α 1 , . . ., α k , α m }.
The Ball Theorem was first discovered by Vorob'ev [52] and Grigor'ev and Vorobjov [32].(Vorob'ev and Vorobjov are two different transcriptions of the same name from the Cyrillic to the Latin alphabet.)Explicit bounds on the distance are given by Basu and Roy [12].We use a formulation from Schaefer and Štefankovič [48].Recall that for any quantifier-free formula ϕ(X) with free variables X ∈ R n , the set . This is how we are going to use Theorem 9 throughout this paper.
Below we use Corollary 8 and Theorem 9, proving a lemma that was stated already by D'Costa, Lefaucheux, Neumann, Ouaknine and Worrel [26, Lemma 14] for two quantifiers.We are interested in a generalization to more quantifiers.The proof for the k quantifiers goes along the same lines as the proof for two quantifiers.Lemma 10.Let X 1 , . . ., X k be blocks of variables where X i has length n i ≥ 1 and let ϕ(ε, X 1 , . . ., X k ) ∈ QFF with L := |ϕ|.For Q i ∈ {∃, ∀} consider the set If S is non-empty, then there is an ε * ∈ S such that for some constant β ∈ R we have Let d be the maximum degree of any polynomial in φ and δ be a new variable.We replace each atom P (ε) • 0 (where • ∈ {<, ≤}) of φ by δ d P (1/δ) • 0 and denote the new formula by ψ(δ).Then for ε > 0 it follows that φ(ε) is true if and only if for δ = 1/ε the sentence ψ(δ) is true.It follows that ∃ε > 0 : φ(ε) ≡ ∃δ > 0 : ψ(δ).
The next lemma will be used frequently to scale (some dimensions of) semi-algebraic sets.For some N ∈ N and N + 1 variables U = (U 0 , . . ., U N ) it considers the following formula: Proof.The if-part is trivial.The only-if-part follows from a simple induction.

Bounding the Ranges of the Quantifiers
In the following, we show how to restrict the ranges of the variables.This was first done by D'Costa et al. [26] in the context of their ∃∀ ≤ R-complete escape problem.Lemmas 12 and 13 below are stated in our setting, but their proofs directly follow the ideas in [26].
As a first step, we restrict the universally quantified variables.This works for general UETR instances without any further requirements on the formula.
Then there exists an integer N ≤ poly(n, m, |ϕ|), such that for C := 2 2 N the sentence Proof.We rewrite Φ via a double negation to get and let L := |¬ϕ| denote the length of the quantifier-free part.By Corollary 8 there is a constant α ∈ R and a quantfier-free formula ψ(X) such that Φ is equivalent to ¬ ∃X ∈ R n : ψ(X) , where Assuming that {x ∈ R n : ψ(x)} is non-empty, Theorem 9 yields that it contains a point of distance at most and therefore Φ ≡ Ψ.
In a second step, we additionally restrict the existentially quantified variables.Before we do so, we show that this may be impossible in general (without changing its true/false value).To this end, consider the following example: This sentence is clearly true as either X = 0 or if X = 0 we may define Y := 1/X.This remains true if we restrict the range of X, e.g., to [−10, 10].However, note that 1/X with X ∈ [−10, 10] may be arbitrarily large (or small).Consequently, we cannot restrict the range of Y to any interval.In the following, we show how the ranges can be restricted in case of ∀-strict formulas.Requiring the formula to be ∀-strict is a slight generalization of the corresponding statement shown in [26] (where the formula is required to be strict).This more general case is crucial for our proofs in Sections 6 and 7.
there is an integer M ≤ poly(n, m, N, |ϕ|) such that for D := 2 2 M the sentence x, y).Thus, Ψ is also false.
In the remainder of the proof we assume that Φ is true.The proof consists of two steps.First we show that an upper bound D for the existentially quantified variables indeed exists.In a second step, we use the Ball Theorem to compute an upper bound for D.
For the first step, let S = [−C, C] n .Sentence Φ being true implies that for each x ∈ S there is a y(x) ∈ R m such that ϕ(x, y(x)) is true.Even stronger, as ϕ is ∀-strict, we even find an ε(x) > 0, such that for all x ∈ S with x − x < ε(x) we get that ϕ( x, y(x)) is true.Recall that we denote by r} the open ball with center x and radius r in R n .Then {B n (x, ε(x)) | x ∈ S} is an open cover of S. As S is compact, it has a finite subcover B n (x 1 , ε(x 1 )), . . ., B n (x s , ε(x s )).Now, given some x ∈ S, there is an i ∈ {1, . . ., s}, such that ϕ(x, y(x i )) is true.We define y max := max{ y(x 1 ) ∞ , . . ., y(x s ) ∞ }.Then, for all D ≥ y max formula Φ implies proving the existence of an upper bound D for the existentially quantified variables.
The second step is to obtain a bound on D. We first need to construct C = 2 2 N inside the formula.For this, let U = (U 0 , . . ., U N ) be N + 1 new variables and χ(U ) be the formula (2).Recall that by Lemma 11, χ(u) is true if and only if u i = 2 −2 i .Further, each U i can be trivially restricted to be in [−1, 1].Using χ(U ), we can rewrite above sentence as From here on, bounding D is a straightforward application of the Ball Theorem: Let L be the length of the subformula behind the existential quantification of D. By Corollary 8 there is a constant α ∈ R and a quantifier-free formula ψ(D), such that above sentence is equivalent to ∃D > 0 : ψ(D) where |ψ| ≤ L α 3 (n+N +1)m .Then Theorem 9 yields the following upper bound for D: Lastly, we choose M = 8α 3 log(L)n(n + N + 1)m to be the smallest integer such that D ≤ 2 2 M .Note that M ≤ poly(n, m, N, log L) ≤ poly(n, m, N, |ϕ|) as required.

Counterexamples of Strict-UETR
Let us recall the definition of counterexamples here that was already motivated in Section 1.8.Given a sentence Φ :≡ ∀X ∈ R n .∃Y ∈ R m : ϕ(X, Y ) we call its counterexamples.The counterexamples of Φ are exactly the values x ∈ R n for which there is no y ∈ R m such that ϕ(x, y) is true.The main result of this section, Theorem 15, is that we can transform a Strict-UETR instance Φ into an equivalent formula Ψ for which ⊥(Ψ) is either empty or contains an open ball.The main tools for this are the range restrictions from Section 3.2 and the following lemma from calculus.
Lemma 14.Let S and T be compact sets and f : S × T → R be a continuous function.
Proof.We first observe that by compactness of S and T , their Cartesian product S × T is compact as well.Thus, because f is continuous on S × T , it is even uniformly continuous, i.e., for every ε > 0 there is a δ > 0, such that |f (x, y) − f ( x, y)| < ε whenever (x, y) − ( x, y) < δ for every two points (x, y), ( x, y) ∈ S × T .Now consider x, x ∈ S with x − x < δ.We have By exchanging the role of x and x, we get g(x) − g( x) < ε.Combined, we obtain that |g(x) − g( x)| < ε for all x, x ∈ S with x − x < δ.It follows that g is continuous on S.
With these tools at hand, we are able to tackle the main result of this section.
Theorem 15.Given a Strict-UETR instance Φ, we can construct in polynomial time an equivalent UETR instance Ψ of the form

such that ⊥(Ψ) is either empty or contains an n-dimensional open ball.
Proof.The proof is split into two parts.First, we construct Ψ from Φ. Afterwards, we show that ⊥(Ψ) has the desired properties.

Construction of Ψ. Without loss of generality, each atom of the sentence
with ϕ < ∈ QFF < is of the form P < 0, where P ∈ Z[X, Y ] is a polynomial.We replace P < 0 by the equivalent formula ∃Z ∈ R : Z 2 P + 1 < 0. Here, Z is a new variable that is exclusive to this atom.While this replacement may look innocent, it is very powerful.The key insight is as follows: Once we bound the range of Z to some compact interval [−D, D], this requires P < −1/D 2 in order to satisfy the atom.This is stronger than just requiring P < 0 and expands the set of counterexamples as we show below.Moving the new existential quantifiers to the front yields a sentence in prenex normal form.Here, k is the number of atoms in Φ and ϕ < is obtained from ϕ < by above transformation.Note that in particular, ϕ < and ϕ < have exactly the same logical structure (their only difference lies in the transformed atoms).The length increases only by a constant amount per atom, so |Φ 1 | is linear in |Φ|.Further, we have ⊥(Φ 1 ) = ⊥(Φ) by construction.
We can apply Lemma 12 to restrict the ranges of the universally quantified variables and obtain an integer N ≤ poly(|Φ 1 |) such that for C := 2 2 N the sentence Φ 1 is equivalent to Each atom in Φ 2 is a strict inequality.Thus, we can use Lemma 13 to also restrict the ranges of the existentially quantified variables.We obtain another integer M ≤ poly(N, |Φ 2 |) such that for D := 2 2 M above sentence Φ 2 is equivalent to Regarding the counterexamples, we have ⊥(Φ 3 ) ⊇ ⊥(Φ 2 ).
The last step is to scale the ranges over which the variables are quantified to the interval [−1, 1].To this end, define K := max{N, M }, let U := (U 0 , . . ., U K ) be K + 1 new variables and let χ(U ) be formula (2).Recall that by Lemma 11, for u ∈ [−1, 1] K+1 we have χ(u) if and only if u i = 2 −2 i .Let d be the maximum degree of any polynomial in ϕ < .We define where X/U N means that every X i is replaced by X i /U N (likewise for Y /U M and Z/U M ).
The multiplication of ϕ < with U d K denotes that both sides of each atom are multiplied by U d K .This restores the requirement that each atom is a polynomial inequality.(Strictly speaking, the obtained formula contains the divisions by U N and U M .However, because K ≥ N , we can replace any U K • (X i /U N ) by U K−N X i , which does not contain divisions.Likewise, we handle Y /U M and Z/U M .)As this last step just scaled variables, we conclude that Ψ is equivalent to Φ 3 and therefore also to Φ. Also, sentence Ψ has the form required by the statement of the theorem.

Properties of ⊥(Ψ). It remains to show that ⊥(Ψ) is either empty (if Ψ is true) or contains an n-dimensional open ball (if Ψ is false)
. Note that scaling variables (as done to get from Φ 3 to Ψ) also scales the counterexamples; thus, an open ball in ⊥(Φ 3 ) maps to an open ball in ⊥(Ψ).It therefore suffices to prove that ⊥(Φ 3 ) contains an open ball.As Φ 3 is the simpler formula, we analyze ⊥(Φ 3 ) below.
We proof below that for some r > 0, all To simplify the following argument, we further assume that ϕ < (in Φ) is in disjunctive normal form (DNF), i.e., a disjunction of conjunctions of atoms.By construction, ϕ < is then also in DNF and has exactly the same logical structure.This is justified as the set of counterexamples is invariant under applications of the distributive law on the quantifier-free part.Thus, ϕ < and ϕ < have exactly the same counterexamples as their DNFs.
Let C(X, Y ) := s i=1 P i (X, Y ) < 0 be one of the conjunctive clauses of (the DNF of) ϕ < (X, Y ).For our fixed counterexample x * ∈ ⊥(Φ 2 ), every conjunctive clause of ϕ < (x * , Y ) evaluates to false independently of Y .We get that for all y ∈ R m and thus in particular for all y ∈ [−D, D] m that C(x * , y) is false and that is true.Let us point out that for different choices of y ∈ [−D, D] m , different subsets of the polynomials P i (x * , y) may evaluate to non-negative values.We only know that for every y at least one of the polynomials is non-negative (here it is important that ϕ < (X, Y ) is in DNF).
To overcome this we combine the polynomials into a single function.Each of the P i ∈ Z[X, Y ], i ∈ {1, . . ., s}, is a polynomial and thus continuous.The maximum over a finite number of continuous functions is again continuous, so is continuous.It follows from (3) that for our fixed counterexample x * and all y ∈ [−D, D] m it holds that We want to argue about the value of P max at points x in a small neighborhood around x * .
To this end, we consider the function which eliminates the dependency on y.The sets [−C, C] n and [−D, D] m are compact, so by Lemma 14 function P * is again continuous.From (4), we get for our fixed counterexample x * that By the continuity of P * , for every ε > 0 there exists a δ > 0 such that for all x ∈ [−C, C] n with x * − x < δ we have |P * (x) − P * (x * )| < ε.We choose ε < 1/D 2 and conclude that for a sufficiently small δ > 0 and all x ∈ [−C, C] n with x * − x < δ it holds that Fix one such x.Going backwards through our chain of defined functions, it follows for all y ∈ [−D, D] m that P max (x, y) > −1/D 2 and moreover that Now also fix an arbitrary y ∈ [−D, D] m and choose j ∈ {1, . . ., s} such that P j (x, y) > −1/D 2 .Because A := (P j (X, Y ) < 0) is an atom in the DNF of ϕ < (X, Y ), there is a corresponding atom A := (Z 2 j P j (X, Y )+1 < 0) in the DNF of ϕ < (X, Y, Z).Recall that Z j is an existentially quantified variable that only appears in A .Note that A can never be true for Z j = 0.For Z j = 0, the atom A can be rewritten as we get that Z 2 j ≤ D 2 and therefore our considered atom A can only ever be satisfied, if However, by the choice of j and (5), we know that P j (x, y) > −1/D 2 .Thus, because y was fixed arbitrarily, x must be a counterexample of Φ 3 .Additionally, because x ∈ R n with x * − x < δ was arbitrary, we conclude that all such x are counterexamples of Φ 3 forming an n-dimensional open ball.

∀∃ < R-Hardness of Hausdorff
We are now able to show ∀∃ < R-hardness.Proof.Let Φ be an instance of Strict-UETR.We give a polynomial-time many-one reduction to an equivalent Hausdorff instance.The proof is split into two parts: In the first part, we transform Φ into an equivalent UETR instance Ψ whose counterexamples ⊥(Ψ) contain an open ball (if there are any).Sentence Ψ is then used to construct a Hausdorff instance (A, B, t).The second part then proves that Φ and (A, B, t) are indeed equivalent.
Constructing Hausdorff instance (A, B, t).The first step is to apply Theorem 15 to Φ and to obtain in polynomial time an equivalent UETR instance where ψ ∈ QFF.We know that either Note that Ψ and Ψ are equivalent: If Ψ is true, then obviously Ψ is also true because the new condition is added using a logical 'or'.If Ψ is false, then Since ⊥(Ψ ) contained an open ball, it follows that ⊥(Ψ) also contains an open ball.The key idea behind the definition of Ψ is that ⊥(Ψ) is guaranteed to be a strict subset of R n .This will be important below to make sure that set A (of the Hausdorff instance we define below) is non-empty.If Ψ is false, then there is an for some r > 0. Expressed as a sentence in the first-order theory of the reals we get Let us denote by L the length of the quantifier-free part of this sentence.We see that L is clearly polynomial in |Ψ| which by construction is polynomial in |Φ|.Above sentence has the form required by Lemma 10, and we get a constant β ∈ R such that the following lower bound for r can be assumed: Let N = β 4 n(n + m) be the smallest integer, such that By Equation ( 6), it holds that N ≤ poly(n, m, log(L)) ≤ poly(|Φ|).Define C := 2 2 N .The idea now is to scale the universally quantified variables by a factor of C (so that they are from the interval [−C, C]).This then also scales the set of counterexamples ⊥(Ψ) by C and in particular the radius of the open ball in ⊥(Ψ).Let U = (U 0 , . . ., U N ) ∈ [−1, 1] be N + 1 new variables and χ(U ) be formula (2).Recall that by Lemma 11, where U N X means that every occurrence of X i in ψ is replaced by U N X i .Finally we are ready to define our desired Hausdorff instance: Note that this is well-defined, because both sets A and B are non-empty.While this is trivial for B, it holds for A by our construction of φ from Φ: It always holds that Equivalence of Φ and (A, B, t).To see that Φ and (A, B, t) are equivalent, assume first that Φ is true.For every point a := (x, y, u) ∈ A it must hold that u i = 2 −2 i as this is necessary to satisfy χ(u).Consider the point b := (x, {0} n , u) ∈ B. We get As a was chosen arbitrarily, we get an upper bound for the directed Hausdorff distance d H (A, B) ≤ t.On the other hand, consider an arbitrary point b : Because Φ (and therefore Ψ) is true, there is some y ∈ [−1, 1] m such that there is a point a := (x, y, u) ∈ A. By the same calculation as above, we get d H (B, A) ≤ t and thus Now assume that Φ and Ψ are false.Then there is some x ∈ [−1, 1] n such that there is an n-dimensional open ball B n (x, r) ⊆ ⊥(Ψ) (the r here is the one from ( 6

)). By the construction of A, this corresponds to an open ball of radius
Equations ( 8) and ( 9) prove that d H (A, B) ≤ t (and also d H (B, A) ≤ t) if and only if Φ is true.
In the proof of Theorem 16, we could choose N := N + 1 instead of N in Equation (7).Then in the case that Φ is false, the Hausdorff distance d H (A, B) is at least Note that the number of free variables in the formulas describing the resulting sets A and B equals n + m + N + 1 = Θ(N ).We created a gap of size 2 2 Θ(N ) .This implies the following inapproximability result.

Corollary 2.
Let A and B be two semi-algebraic sets in R n and f (n Another interesting observation is that we can restrict the sets A and B to be described by (relatively) simple formulas: Corollary 3. The Hausdorff problem remains ∀∃ < R-complete, even if the two sets A and B are both described either by (i) a conjunction of quadratic polynomial equations, or (ii) a single polynomial equation of degree at most four.
Proof.Taking the formula ψ in the proof of Theorem 16, we apply Lemma 5i to obtain an equivalent new formula ψ (with additional existentially quantified variables) which is a conjunction of quadratic polynomial equations.Then set A can be defined using ψ instead of ψ.Set B can be trivially described in the desired form.This shows statement i.
For ii, we modify the above procedure by applying Lemma 5ii to ψ to obtain an equivalent formula which is a single polynomial of degree at most four.

∀∃ < R-Membership of Hausdorff
This section is devoted to show the following theorem.
Theorem 17. Hausdorff and Directed Hausdorff are contained in ∀∃ < R.
Note that ∀∃R-membership is already shown by Dobbins et al. [28].The remainder of this section deals with reformulating a given Hausdorff instance into a Strict-UETR instance, thereby proving ∀∃ < R-membership.
Let (A, B, t) be a Hausdorff instance, where Let us remark that introducing the real variable ε is necessary to also consider the points in the closure of B.Moreover, we work with the squared distance between a and b, because a − b is the square root of a polynomial.Below we transform formula (10) in multiple technical steps into a form that allows us to apply a recent theorem by D'Costa et al. [26] such that ∀∃ < R-membership follows.Before we do so, we state a few helpful lemmas.These allow us to consider some of the intermediate steps in isolation, thereby simplifying the needed notation.Also, Lemma 20 below is used again in Section 7.
The first lemma allows us to transform a UETR instance of special structure into an equivalent Strict-UETR instance: Lemma 18.Given a UETR instance Proof.We first prove that there exists an integer N ≤ poly(|Φ|), such that the Strict-UETR instance is equivalent to Φ.In a second step, we construct 2 −2 N inside the formula.
The direction Φ =⇒ Ψ is trivially true for any N ∈ N. To prove the other direction, we show its contraposition ¬Φ =⇒ ¬Ψ.Assume that is true.Let L be the length of the quantifier-free part in (11).By Lemma 10 there is a constant β ∈ R such that ∃ε > 0 in (11) can be strengthened to ∃ε ≥ 2 −L β 4 nm .Now choose N = β 4 nm to be the smallest integer satisfying 2 −2 N < 2 −L β 4 nm .Note that N ≤ poly(n, m, log L), so it is polynomial in the input size.Plugging in the lower bound on ε, we get that ¬Φ is equivalent to which is exactly ¬Ψ.We conclude that Φ ≡ Ψ as claimed.
To construct a Strict-UETR instance from Ψ, we need to express 2 −2 N inside the formula.To this end, introduce N + 1 new variables U = (U 0 , . . ., U N ) ∈ [−1, 1] N +1 and let χ(U ) be formula (2).Recall that by Lemma 11,χ(u) is true if and only if u i = 2 −2 i .Including χ(U ) into our formula, we conclude that is equivalent to Φ.We arrived at a sentence where all variables are restricted to [−1, 1] and in which all atoms are strict.At this point we use a recent result by D'Costa et al. [26].They show that it is ∃∀ ≤ R-complete to decide a sentence of the form with ϕ ≤ ∈ QFF ≤ .Because ∃∀ ≤ R = co∀∃ < R, deciding the complements of these sentences, i.e., sentences of the form 12) is of this form.Thus there is a polynomialtime reduction to an equivalent Strict-UETR instance.
The next lemma establishes an upper bound on the value of a polynomial over a compact domain.To obtain an upper bound on E, we first need to encode C inside the formula.We introduce N + 1 new variables U = {U 0 , . . ., U N } and let χ(U ) be formula (2).Recall that by Lemma 11,χ(u) is true if and only if u i = 2 −2 i .Now we can rewrite the above formula equivalently as Let ϕ(E) be the subformula following the quantification of E (starting from ∀) and L := |ϕ(E)|.Applying quantifier elimination (Corollary 8) to ϕ(E), we obtain a constant α ∈ R and an equivalent, quantifier-free formula ψ(E) of length The ball theorem (Theorem 9) applied to ∃E ∈ R : ψ(E) now yields an upper bound for E: Choose K = 8 log(|ψ|)α 3 n(N + 1) .Obviously, K ≤ poly(log|ψ|, N, n).Since |ψ| ≤ poly(|P |, n, N ), the claim follows.
Above lemma is used to prove the following lemma that allows us to transform some more general UETR instances into equivalent Strict-UETR instances.
where F : R n → R, G : R m → R and P : R n+m → R are polynomials.Then we can compute in polynomial time an equivalent Strict-UETR instance.
Proof.Via a series of manipulations, we transform the given sentence into an equivalent UETR instance that has the form required by Lemma 18.The first step is to move the condition that ε > 0 into the formula.We obtain an equivalent sentence Rewriting the implication A =⇒ B as ¬A ∨ B turns the existential quantifier in front of δ into a universal quantifier.Furthermore, we replace ¬(δ 2 ε − 1 = 0) by the equivalent (δ 2 ε − 1) 2 > 0. We get an equivalent sentence Moving all quantifiers to the front, turns this into an equivalent prenex normal form This sentence is ∀-strict, so Lemmas 12 and 13 are applicable.Thus, there are two integers N, M bounded by a polynomial in the length of the sentence, such that for C := 2 2 N and D := 2 2 M all universally quantified variables can be restricted to [−C, C] and all existentially quantified variables can be restricted to [−D, D].We obtain another equivalent sentence In the next step, we replace the strict inequality P (X, Y ) < ε by the non-strict inequality P (X, Y ) ≤ ε.For this step, we exploit the fact that a continuous function over a compact domain attains its minimum and maximum.Consequently, ∀ε > 0 Going one step further, we now want to express P (X, Y ) ≤ ε as a polynomial equation.To this end, we replace it by the equivalent formula ∃B ∈ R : P (X, Y ) − ε + B 2 = 0.By Lemma 19, we can also bound the range over which B is quantified: We can compute in polynomial time an integer At this point we define Note that ϕ < ∈ QFF < .We use these to get the equivalent sentence The last step is to scale all variables to be in the interval [−1, 1].For this, let S := max{N, M, K} and introduce S + 1 new variables U = {U 0 , . . ., U S }.Furthermore, let χ(U ) be formula (2).Recall that by Lemma 11, χ(u) is true if and only if u i = 2 −2 i .We can rewrite our sentence to the equivalent sentence Here d is the maximum degree of any polynomial in ϕ < and H.By X/U S we denote that every variable X i is replaced by X i /U S .Multiplying by U d S makes sure that each atom remains a polynomial.What we obtained is a UETR instance that has the form required by Lemma 18 (note that ¬χ(U ) is strict).Therefore, we can transform this into an equivalent Strict-UETR instance in polynomial time.Now we finally have all the needed tools to prove Theorem 17 which states that the Hausdorff problem is contained in ∀∃ < R. We do this by transforming formula (10) into the form required by Lemma 20.This then yields an equivalent Strict-UETR instance, thus proving ∀∃ < R-membership.
Proof of Theorem 17. Recall that d H (A, B) ≤ t is equivalent to (10), which is In a first step, we resolve the shorthand notations a ∈ A and b ∈ B and we obtain Next, we consider the (quantifier-free) formulas ϕ A (a) and ϕ B (b).Using Lemma 5, we obtain in polynomial time two integers k, and two polynomials F A : R n+k → R and Rewriting the implication X =⇒ Y as ¬X ∨ Y changes the existential quantifier in front of U a into a universal quantifier, which we can move to the front.Also, the equation gets negated.Substituting ¬(F (a, U a ) = 0) by F (a, U a ) 2 > 0, we get the equivalent sentence Lastly, we move the existential quantifier after the universal one and get an equivalent sentence in prenex normal form.This sentence has the form required by Lemma 18, concluding the proof.

Exotic Quantifiers
In this section, we show an interesting connection of the complexity class ∀∃ < R to a complexity class introduced by Bürgisser and Cucker when studying the computational complexity of many basic problems regarding semi-algebraic sets [20].While they mainly work in the BSS-model, they also consider some problems in the bit-model of computation (which we use throughout this paper).There, among others, the complexity classes ∃R, ∀R and ∀∃R appear under the names BP 0 (∃), BP 0 (∀), and BP 0 (∀∃), respectively.(Here the BP stands for 'binary part' and the superscript 0 denotes that there are no machine constants in the BSS machine.)They notice that the computational complexity of some natural problems defies to be classified into this hierarchy of complexity classes.In this paper, we have a similar situation because we prove that the Hausdorff problem is complete for a the class ∀∃ < R, supposedly between ∃R/∀R and ∀∃R.See also the paper by D'Costa et al. [26], where they show that their escape problem is ∃∀ ≤ R-complete, though supposedly between ∃R/∀R and ∃∀R.
The approach in this paper and in [26] is to make syntactic restrictions to the quantifierfree parts of the sentences (i.e., allowing only strict inequalities as in Strict-UETR).This defines new decision problems that in turn are used to define new complexity classes like ∀∃ < R. Bürgisser and Cucker take a different approach.They define new quantifiers, called exotic quantifiers, that make a topological restriction on the sentences [20].Two of them are highly related to our work: Intuitively, ∀ * X ∈ R n : ϕ(X) means that ϕ(x) does not need to be true for all x ∈ R n but just for all x ∈ D, where D is some dense subset of R n .Conversely, ∃ * X ∈ R n : ϕ(X) means that there must be an x ∈ R n and some radius r > 0, such that for all x ∈ B n (x, r) it holds that ϕ( x), where B n (x, r) denotes the n-dimensional open ball of radius r centered at x.
Theorem 4, the main theorem of this section, establishes a relation between the two approaches described above.As it turns out, the topological restrictions on the formulas by Bürgisser and Cucker are equivalent to the syntactical restrictions done for example in this paper.For this purpose, let Exotic-UETR denote the decision problem whether a sentence of the form ∀ * X ∈ R n .∃Y ∈ R m : ϕ(X, Y ) with quantifier-free ϕ is true.Further, we define the complexity class ∀ * ∃R to contain all problems that polynomial-time many-one reduce to Exotic-UETR.We show that the complexity classes ∀ * ∃R and ∀∃ < R coincide.Consequently, Exotic-UETR is ∀∃ < R-hard.
To prove that Exotic-UETR is contained in ∀∃ < R, we transform ∀ * X ∈ R n .∃Y ∈ R m : ϕ(X, Y ) in polynomial time into an equivalent sentence of the form required by Lemma 20.This lemma allows us to construct an equivalent Strict-UETR instance in polynomial time, thereby proving ∀∃ < R-membership.We start by expressing the exotic quantifier ∀ * in terms of classical quantifiers ∀ and ∃, obtaining an equivalent sentence By Lemma 5 we can compute in polynomial time an integer k and a polynomial G : R n+m+k → R such that ϕ(X 0 , Y ) is equivalent to ∃U ∈ R k : G(X 0 , Y, U ) = 0. Plugging this into above sentence, we get another equivalent sentence This has the form required by Lemma 20.Hence, ∀∃ < R-membership follows.

Applications to the Hausdorff Problem
We now use our insights to establish the exact computational complexity of Euclidean Relative Denseness (ERD) which was left as an open problem by Bürgisser and Cucker [20].
In ERD, we are given two semi-algebraic sets A and B and wonder whether A is contained in the closure of B, which is denoted by B. Note that ERD is equivalent to deciding whether d H (A, B) = 0. Bürgisser and Cucker show: Theorem 21 ([20, Corollary 5.6]).ERD is in ∀∃R and ∀ * ∃R-hard.
They prove this in the BSS-model, but the same proof also works in the bit-model.Building upon our insights, we are able to determine the exact computational complexity of ERD (in the bit-model).

Open Problems
We showed that the Hausdorff problem is ∀∃ < R complete.We conclude the paper with a list of interesting open questions: While ∃R = ∃ ≤ R = ∃ < R and ∀R = ∀ ≤ R = ∀ < R are known [48], similar results are unknown for higher levels of the hierarchy.In this context, we are particularly interested in the following question: Open Problem 1. Are the two complexity classes ∀∃ < R and ∀∃R actually the same?

The Complexity of the Hausdorff Distance
Regarding Open Problem 1, we are not aware of any algorithms that are more efficient if the atoms are restricted to strict polynomial inequalities only.An answer to this question is interesting in its own right.If the two classes are indeed different, this would imply NP = PSPACE, so we do not expect such a proof any time soon.
Open Problem 2. What is the computational complexity of deciding ∀-strict UETR instances?
By definition, deciding ∀-strict UETR instances is ∀∃ < R-hard and in ∀∃R.The most important tools for showing ∀∃ < R-membership in this paper and also in [26] are the range restrictions for the quantified variables (Lemmas 12 and 13).These are still applicable to ∀-strict formulas.However, this seems not enough to transform an arbitrary ∀-strict UETR instance efficiently into an equivalent Strict-UETR instance, in which all atoms are not negated and are strict inequalities.If this can be done, then this would significantly simplify the proof of Lemma 20 (and therefore Theorem 17 proving that Hausdorff is in ∀∃ < R).
Our third open problem concerns even more restricted versions of the Hausdorff problem that remain hard.As already noted in Corollary 3, Hausdorff remains ∀∃ < R-hard if all atoms in the formulas describing A and B are quadratic equations.

Open Problem 3. What is the most restricted version of the Hausdorff problem that is still ∀∃ < R-hard?
There are several directions to explore on Open Problem 3. Identifying meaningful restrictions on the sets A and B might lead to an easier problem.For example, it is ∀Rcomplete to decide if closed semi-algebraic sets A, B have Hausdorff distance exactly zero (they do if and only if A = B): Theorem 23.Deciding if two semi-algebraic sets are equal is ∀R-complete.
Proof.Given quantifier-free formulas ϕ A (X) and ϕ B (X), it holds that A = B if and only if ∀X ∈ R n : ϕ A (X) ⇐⇒ ϕ B (X).This shows ∀R-membership.
To prove ∀R-hardness, note that the sentence ∀X ∈ R n : ϕ(X) is equivalent to deciding

Figure 2
Figure 2 The Hausdorff distance in different branches of science.

( a )
Two sets of white and black points in R 2 .(b) Two sets of blue and red disks in R 2 .

Figure 3
Figure 3 The Hausdorff distance in simple and more complicated settings.

1 BFigure 4
Figure 4The Hausdorff distance between the compact semi-algebraic sets (in blue and green) is attained at points (a2, b2) such that the segment a2b2 is orthogonal to the tangents at a2 and b2.While the segment a1b1 is longer than a2b2, the pair (a1, b1) does not realize the Hausdorff distance because the segment a1b1 crosses both A and B.
Each point (x, y) ∈ R 2 in the green open region satisfies xy > 1.Only for x = 0 (in red) no suitable y ∈ R exists.x y (b) If we restrict the range of Y to [−1, 1], then for no x ∈ [−1, 1] (in red) a suitable y with xy > 1 exists.

Theorem 9 (
Ball Theorem[48, Corollary 3.1]).Every non-empty semi-algebraic set in R n of complexity at most L ≥ 4 contains a point of distance at most 2 L 8n from the origin.

Lemma 12 .
Let X and Y be blocks of variables with n := |X| and m := |Y |, let ϕ(X, Y ) ∈ QFF and let

Lemma 13 .
Let X and Y be blocks of variables with n := |X| and m := |Y | and ϕ(X, Y ) ∈ QFF.Further, let N be an integer and C := 2 2 N .Then for a ∀-strict sentence x ∈ [−C, C] n with x * − x < r are counterexamples of Φ 3 as well.If B n (x * , r) ⊆ [−C, C] n , then x * is the center of our desired open ball of counterexamples.If B n (x * , r) is not completely contained in [−C, C] n , then any x ∈ B n (x * , r) ∩ (−C, C) n can be used instead as the center of a smaller (but still open) ball of counterexamples.
is true.Hence for at least one fixed x ∈ [−1, 1] n we obtain a polynomial H(x, Y ) 2 that is positive everywhere on [−1, 1] m (the fixed x values are real coefficients for the variables Y ).Because [−1, 1] m is compact and because polynomials are continuous, H(x, Y ) 2 attains its minimum over [−1, 1] m and it follows that

Lemma 19 .
Let P : R n → R be a polynomial, N be an integer and C := 2 2 N .Then we can compute in polynomial time an integerK ≤ poly(|P |, N, n) such that for E := 2 2 K and all x ∈ [−C, C] n it holds that |P (x)| ≤ E.Proof.Because P is a polynomial, |P | is continuous and therefore |P | attains its maximum over any compact domain.We conclude that∃E ∈ R .∀X ∈ [−C, C] n : |P (X)| ≤ Eis true.Note that, strictly speaking, we may not use |•| inside the formula.However, |P (X)| ≤ E is equivalent to P (X) ≤ E ∧ −P (X) ≤ E.
It is an intriguing open problem if those two classes coincide or are different, see Section 8 for a short discussion.
are described by quantifier-free formulas ϕ A and ϕ B with n free variables each.For simplicity, we only consider the directed Hausdorff distance here, namely the question whether So if we can formulate the decision problem for the directed Hausdorff distance as a Strict-UETR instance, their conjunction is a formula for the general Hausdorff problem.Assuming that no variable name appears in both operands of this conjunction, this formula can be converted into prenex normal form by just moving the quantifiers to the front.From the definition we get that d H ? ≤ t.It is obvious, that d H (A, B) ≤ t if and only if d H (A, B) ≤ t and d H (B, A) ≤ t.