1 Introduction

The question of “how similar are two given objects” occurs in numerous settings. For three concrete examples, consider Fig. 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 Fig. 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 [36, 43], for example the quality of quadrangulations of complex 3D models [50]. In this paper, we study the computational complexity of the Hausdorff distance from a theoretical perspective.

1.1 Problem Definition

The directed Hausdorff distance between two non-empty sets \(A,B \subseteq \mathbb {R} ^n\) is defined as

$$\begin{aligned} \vec {d}_{H }(A,B) :=\sup _{a \in A} \inf _{b \in B} \Vert {a - b} \Vert . \end{aligned}$$

The directed Hausdorff distance between A and B can be interpreted as the smallest value \(t \geqslant 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 \(\vec {d}_{H }(A,B)\) and \(\vec {d}_{H }(B,A)\) may differ. For an example, consider Fig. 1(a); while \(A_1 \subseteq B_1\) and thus \(\vec {d}_{H }(A_1,B_1) = 0\), it holds that \(\vec {d}_{H }(B_1,A_1) > 0\). In contrast, the (undirected) Hausdorff distance is symmetric and defined as

$$\begin{aligned} d_{H }(A,B) := \max {\{\vec {d}_{H }(A,B),\vec {d}_{H }(B,A)\}}. \end{aligned}$$

In this paper, we investigate the computational complexity of deciding whether the Hausdorff distance of two sets is at most a given threshold.

1.2 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 Fig. 3.

Fig. 1
figure 1

How similar are these sets?

Fig. 2
figure 2

The Hausdorff distance in different branches of science

Fig. 3
figure 3

The Hausdorff distance in simple and more complicated settings

In this paper we consider semi-algebraic sets. 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 \(\mathcal {P}\) and \(\mathcal {Q}\) such that

$$\begin{aligned} S\hspace{0.55542pt}=\hspace{0.55542pt}\left\{ x \in \mathbb {R} ^n \;\Big \vert \;\bigwedge _{P \in \mathcal {P}} \!P(x) \leqslant 0 \,\wedge \!\bigwedge _{Q \in \mathcal {Q}}\! Q(x) <0\right\} . \end{aligned}$$

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.

In real algebraic geometry, one usually chooses \(\mathcal {P}, \mathcal {Q} \subseteq \mathbb {R} \hspace{0.55542pt}[X_1, \ldots , X_n]\), i.e., the polynomials have real valued coefficients. We are interested in determining the computational complexity of computing the Hausdorff distance in the standard bit-model of computation (you may think of a Turing machine or word RAM machine). Here, the polynomials describing the two sets A and B are part of the input and given with finite precision, usually in some binary encoding. Therefore, we cannot handle arbitrary real numbers as coefficients for the polynomials in \(\mathcal {P}\) and \(\mathcal {Q}\) as this would require unbounded precision. Throughout this paper, we always assume that the coefficients are integers (or equivalently rationals) and we describe their encoding in Sect. 2.1. Thus, we actually consider the problem of computing the Hausdorff distance between two semi-algebraic subsets of \(\mathbb {R} _{{alg }}^n\), where \(\mathbb {R} _{alg }\) is the real closed field of real algebraic numbers.

Having said that, assume that we are interested in \(d_{H }(A,B)\) for two sets

$$\begin{aligned} A:= \{x \in \mathbb {R} \mid \sqrt{2}\cdot x^2 = 1\} \quad \text {and} \quad B:= \{x \in \mathbb {R} \mid x = 1\}. \end{aligned}$$

The coefficient \(\sqrt{2}\) in the definition of A is obviously neither an integer nor a rational number and thus does not fulfill above restriction. However, it is possible to define two new sets

$$\begin{aligned}A'&:= \{(x,u) \in \mathbb {R}^2 \mid u> 0 \wedge u^2 = 2 \wedge u \hspace{1.33331pt}{\cdot }\hspace{1.33331pt}x^2 = 1\} \quad \text{ and } \\ B'&:= \{(x,u) \in \mathbb {R}^2 \mid u > 0 \wedge u^2 = 2 \wedge x = 1\} \end{aligned}$$

that circumnavigate this problem by adding a new variable u and additional constraints enforcing that \(u = \sqrt{2}\), while having integer coefficients only. It further holds that \(d_{H }(A,B) = d_{H }(A',B')\). Thus, modeling algebraic coefficients is indeed possible with a small overhead in the description complexity of the considered sets.

1.3 Concrete Example

In order to demonstrate how difficult it is in practice to compute the Hausdorff distance even between two curves in \(\mathbb {R} ^2\), let us consider the following example (given by Bernd Sturmfels at a workshop in Saarbrücken in 2019). The two polynomials

$$\begin{aligned} f(x,y)&:= x^4 + y^4 + 12\hspace{0.55542pt}x^3 + 2y^3 - 3xy + 11 \quad \text {and} \\ g(x,y)&:= 7x^4 + 8y^4 - 1 \end{aligned}$$

define sets \(A = \{(x,y) \in \mathbb {R} ^2 \mid f(x,y) = 0\}\) and \(B = \{(x,y) \in \mathbb {R} ^2 \mid g(x,y) = 0\}\). For an illustration of A and B, consider the blue and green curve in Fig. 4, respectively.

Fig. 4
figure 4

The Hausdorff distance between the compact semi-algebraic sets (in blue and green) is attained at points \((a_2, b_2)\) such that the segment \(a_2b_2\) is orthogonal to the tangents at \(a_2\) and \(b_2\). While the segment \(a_1b_1\) is longer than \(a_2b_2\), the pair \((a_1, b_1)\) does not realize the Hausdorff distance because the segment \(a_1b_1\) crosses both A and B

It can be argued using convexity and continuity that the Hausdorff distance is attained at points \(a \in A\) and \(b \in 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 (ab), the segment ab crosses A and B, for example \(a_1b_1\) as in Fig. 4. These solutions can be discarded. Among the remaining solutions the points \(a_2 \approx (-11.48362, -6.1760)\) and \(b_2 \approx (-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.

1.4 General Decision Algorithm

Consider a situation where we are given two semi-algebraic sets A and B as well as a threshold \(t \in \mathbb {N} \). The statement \(\vec {d}_{H }(A,B) \leqslant t\) can be encoded into a logical sentence of the form

$$\begin{aligned} \forall \, \varepsilon > 0,\, a \in A \hspace{1.111pt}\, . \,\hspace{1.111pt}\exists \, b \in B\hspace{1.111pt}:\hspace{1.111pt}\Vert {a-b} \Vert ^2 \leqslant t^2 + \varepsilon , \end{aligned}$$
(1)

where \(\varepsilon \) is needed to also consider points in the closure of B. (Instead of using an \(\varepsilon \) we would like to write \(b \in \overline{B}\) above to denote that b is from the closure \(\overline{B}\) of B. However, this is syntactically not allowed in these formulas). 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, Chap. 14]. These algorithms are so slow that they are impractical, 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.

1.5 Algorithmic Complexity

Let \(\varphi \) be a quantifier-free formula in the first-order theory of the reals with free variables \(X = (X_1, \ldots , X_n)\) and \(Y = (Y_1, \ldots , Y_m)\). See Sect. 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 a formula \(\varphi \) using the logical connectives \(\wedge \), \(\vee \), and \(\lnot \) (also, parenthesis are allowed). The Universal Existential Theory of the Reals (UETR) asks to decide whether a sentence of the form

$$\begin{aligned} \forall \, X \in \mathbb {R} ^n \hspace{1.111pt}\, . \,\hspace{1.111pt}\exists \, Y \in \mathbb {R} ^m\hspace{1.111pt}:\hspace{1.111pt}\varphi (X,Y) \end{aligned}$$

is true. We define the following restriction of UETR: If \(\varphi \) does not contain negations (no \(\lnot \)) and all atoms are strict inequalities (only <, >, or \(\ne \)), 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 \(\forall \exists _{}\mathbb {R} \) and \(\forall \exists _{<}\mathbb {R} \) to contain all decision problems that polynomial-time many-one reduce to UETR and Strict-UETR, respectively. Let us emphasize again 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, \(\forall \exists _{}\mathbb {R} \) was first introduced by Bürgisser and Cucker [20, Sect. 9] under the name \({\textsf {BP}}^0(\forall \exists )\) (in the constant-free Boolean part of the Blum–Shub–Smale model [17]). The notation \(\forall \exists _{}\mathbb {R} \) arised later in [27] extending the notation from Schaefer and Števankovič [46]. The class \(\mathsf{{co}\text {-}}{ \forall \exists _{<}\mathbb {R}} ={ \exists \forall _{\leqslant }\mathbb {R}} \) was first studied by D’Costa et al. [25].

Concerning the relation of these complexity classes, \(\forall \exists _{<}\mathbb {R} \) is contained in \(\forall \exists _{}\mathbb {R} \) because Strict-UETR is a special case of UETR. It is an intriguing open problem if those two classes coincide or are different. See Sect. 8 for a short discussion and a reference to a recent but still unpublished preprint claiming that \({ \forall \exists _{}\mathbb {R}} ={ \forall \exists _{<}\mathbb {R}} \)). We understand the complexity class \(\forall \exists _{}\mathbb {R} \) as a natural extension of the complexity class \(\exists \mathbb {R} \), which is defined similarly to \(\forall \exists _{}\mathbb {R} \), but contains only existentially and no universally quantified variables. The class \(\exists \mathbb {R} \) has gained increasing attention in recent years, see Sect. 1.7.2.

A word on notation. Below we adhere to the following convention: We use upper case letters like \(X,Y \in \mathbb {R} ^n\) for real variables and lower case letters like \(x,y\in \mathbb {R} ^n\) for real numbers. Thus, we write \(\varphi (X)\) to emphasize that \(\varphi \) is a formula with free variables X. If clear from the context, we often omit the free variables in \(\varphi \) though. On the other hand, \(\varphi (x)\) denotes a sentence in which concrete real numbers x were plugged in for the free variables X. In particular \(\varphi (x)\) has no free variables and is therefore either true or false.

1.6 Problem and Results

We now have all ingredients to state our problem and main results. Let \(\varphi _A(X)\) and \(\varphi _B(X)\) be quantifier-free formulas with free variables \(X = (X_1, \ldots , X_n)\). Further, let \(A := \{x \in \mathbb {R} ^n \mid \varphi _A(x)\}\), \(B := \{x \in \mathbb {R} ^n \mid \varphi _B(x)\}\), and let \(t \in \mathbb {N} \) be a natural number. The Hausdorff problem asks whether \(d_{H }(A,B) \leqslant 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 Sect. 1.7. Our main result determines the algorithmic complexity.

Theorem 1.1

The Hausdorff problem is \(\forall \exists _{<}\mathbb {R} \)-complete.

While we discuss the input encoding of \(\varphi _A\) and \(\varphi _B\) in Sect. 2.1, let us briefly note here that t is encoded in binary. A generalization to \(t \in \mathbb {Q} \) is straightforward, by representing t as a reduced fraction and encoding the numerator and denominator in binary. How to generalize further to \(t \in \mathbb {R} \) is not clear as, again, 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 \(\forall \exists _{<}\mathbb {R} \) contains the complexity classes NP, co-NP, \(\exists \mathbb {R} \), and \(\forall \mathbb {R} \), our result implies hardness for these classes. Theorem 1.1 answers an open question posed by Dobbins et al. [27].

One may wonder whether it is crucial for our results that the Hausdorff problem asks if the distance is \(\leqslant 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 \(\forall \exists _{<}\mathbb {R} \)-hardness for Theorem 1.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 , where n denotes the number of variables of \(\varphi _A\) and \(\varphi _B\). Thus, our result also yields the following inapproximability result:

Corollary 1.2

Let A and B be two semi-algebraic sets in \(\mathbb {R} ^n\) and . There is no polynomial-time f(n)-approximation algorithm to compute \(d_{H }(A,B)\), unless \(\mathsf{{P}} = { \forall \exists _{<}\mathbb {R}} \).

Second, our reduction can be modified slightly to obtain a Hausdorff instance in which A and B are described by syntactically simple formulas: First, all atoms are polynomial equations of bounded degree. Second, there are no disjunctions and negations. Of course, this comes at an expense, namely an increased number of variables. The following corollary states that this syntactic simplicity does not make the Hausdorff problem simpler, instead it remains equally difficult:

Corollary 1.3

The Hausdorff problem remains \(\forall \exists _{<}\mathbb {R} \)-complete, even if the two sets A and B are both described either by

  1. (i)

    a conjunction of quadratic polynomial equations, or

  2. (ii)

    a single polynomial equation of degree at most four.

Our last result concerns the complexity class \(\forall \exists _{<}\mathbb {R} \) itself. As shown in Theorem 1.1, the complexity class \(\forall \exists _{<}\mathbb {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 \(\exists \mathbb {R} \)/\(\forall \mathbb {R} \) and \(\forall \exists _{}\mathbb {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 introduce an exotic quantifier \(\forall ^*\). Intuitively, \(\forall ^*X\in \mathbb {R} ^n \,{:}\, \varphi (X)\) does not require that \(\varphi (x)\) holds for all \(x\in \mathbb {R} ^n\) but only for all x in a dense subset of \(\mathbb {R} ^n\). Formally, \(\forall ^*X \in \mathbb {R} ^n \, {:} \, \varphi (X)\) is defined as

$$\begin{aligned} \forall \,X \in \mathbb {R} ^n\!,\, \varepsilon > 0 \hspace{1.111pt}\, . \,\hspace{1.111pt}\exists \, \widetilde{X} \in \mathbb {R} ^n :\hspace{1.111pt}\Vert {X - \widetilde{X}} \Vert ^2 < \varepsilon ^2 \wedge \varphi (\widetilde{X}). \end{aligned}$$

For more details, we refer to Sect. 7. Let Exotic-UETR denote the decision problem whether a sentence of the form

$$\begin{aligned} \forall ^*X \in \mathbb {R} ^n \hspace{1.111pt}\, . \,\hspace{1.111pt}\exists \,Y \in \mathbb {R} ^m:\hspace{1.111pt}\varphi (X,Y) \end{aligned}$$

is true, where \(\varphi \) is quantifier-free. Then the complexity class \(\forall ^*\exists \mathbb {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 \(\forall ^*\exists \mathbb {R} \) and \({ \forall \exists _{<}\mathbb {R}} \) are the same.

Theorem 1.4

Exotic-UETR is \(\forall \exists _{<}\mathbb {R} \)-complete. Thus \(\forall ^*\exists \mathbb {R} = { \forall \exists _{<}\mathbb {R}} \).

1.7 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 \(\forall \exists \mathbb {R} \).

1.7.1 Computing the Hausdorff Distance

The notion of the Hausdorff distance was introduced by Felix Hausdorff in 1914 [31]. 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\hspace{0.33325pt}((a+b)\log \hspace{0.83328pt}(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. Alt et al. [8, Theorem 3.3] show how to compute the directed Hausdorff distance between two sets in \(\mathbb {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+\varepsilon })\) for \(k > 1\) and every \(\varepsilon > 0\) [8, Theorem 3.4]. They additionally present algorithms with better randomized expected running times for sets of triangles in \(\mathbb {R} ^3\) and point sets in \(\mathbb {R} ^n\).

Given two semi-algebraic sets \(A, B \subseteq \mathbb {R} ^n\) and a threshold value \(t \in \mathbb {N} \), the Hausdorff decision problem can be encoded as a UETR sentence \(\Phi \) as already done for the directed Hausdorff distance in sentence (1) above. Such a sentence can be decided in time  using an algorithm to decide general sentences from the first order theory of the reals [11, Theorem 14.14]. (Here d denotes the maximum degree of any polynomial of \(\Phi \) and s denotes the number of atoms. Further, use \(\omega = 2\) in the statement of [11, Theorem 14.14] as we have two blocks of quantifiers for the Hausdorff problem.)

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.

1.7.2 The (Universal) Existential Theory of the Reals

As mentioned above, the complexity class \(\forall \exists _{}\mathbb {R} \) was first studied by Bürgisser and Cucker who prove complexity results for many decision problems involving circuits [20]. Dobbins et al. [27, 28] consider \(\forall \exists _{}\mathbb {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 \(\forall \exists _{}\mathbb {R} \). They support this conjecture by proving hardness for several related notions [27]. Additionally, for future research directions, they present a number of candidates for potentially \(\forall \exists _{}\mathbb {R} \)-hard problems. Among them, they asked whether the Hausdorff problem is \(\forall \exists _{}\mathbb {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 \(\exists \mathbb {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 [45]. On the other hand, the decision problem whether for all reasonable assignments of weights to the edges, a graph has a straight-line drawing in which the edge lengths correspond to the assigned weight lies in P  [13]. Similarly, it is \(\exists \mathbb {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 [32]. 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 [38].

The complement class \(\exists \forall _{}\mathbb {R} \) was recently investigated by D’Costa et al. [25]. They show that it is \({ \exists \forall _{\leqslant }\mathbb {R}} \)-complete (where \({ \exists \forall _{\leqslant }\mathbb {R}} = \mathsf{{co}\text {-}}{ \forall \exists _{<}\mathbb {R}} \)) to decide for a given rational matrix A and a compact semi-algebraic set \(K\subseteq \mathbb {R} ^n\), whether there exists a starting point \(x\in K\) such that \(x_n:=A^nx\) is contained in K for all \(n\in \mathbb N\). This and similar problems are generally referred to as escape problems. Another subclass of \(\exists \forall _{}\mathbb {R} \), called \(\exists ^D\hspace{0.55542pt}{\cdot }\hspace{1.111pt}\forall \mathbb {R} \) (here the \(\exists ^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 \(\exists ^D\hspace{0.55542pt}{\cdot }\hspace{1.111pt}\forall \mathbb {R} \)-complete.

The complexity class \(\exists \mathbb {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 [34], segment intersection graphs [33], visibility graphs [23], stretchability of pseudoline arrangements [37, 49], and order type realizability [33]. Other \(\exists \mathbb {R} \)-complete problems are related to graph drawing [32], Nash equilibria [15, 29], geometric packing [6], the art gallery problem [3], convex covers [2], non-negative matrix factorization [48], polytopes [26, 42], geometric embeddings of simplicial complexes [5], geometric linkage constructions [1], training neural networks [4, 14], and continuous constraint satisfaction problems [35]. We refer the reader to the lecture notes by Matoušek [33] and surveys by Schaefer [44] and Cardinal [22] for more information on the complexity class \(\exists \mathbb {R} \).

1.8 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 \(\Phi := \forall X \in \mathbb {R} ^n \!\, . \,\exists \,Y \in \mathbb {R} ^m \hspace{-0.77774pt}: \varphi (X,Y)\) be a Strict-UETR instance. We define two sets

$$\begin{aligned} A:= \{x \in \mathbb {R} ^n \mid \exists \, Y \in \mathbb {R} ^m : \varphi (x,Y)\} \quad \text {and} \quad B:= \mathbb {R} ^n \end{aligned}$$

and ask whether \(d_{H }(A,B) = 0\). If \(\Phi \) is true, then \(A = \mathbb {R} ^n\) and we have \(d_{H }(A,B) = 0\) because both sets are equal. Otherwise, if \(\Phi \) is false, then there exists some \(x \in \mathbb {R} ^n\) for which there is no \(y \in \mathbb {R} ^m\) satisfying \(\varphi (x,y)\) and we conclude that \(A \subsetneq \mathbb {R} ^n\). In general, we call the set of all \(x \in \mathbb {R} ^n\) for which there is no \(y \in \mathbb {R} ^m\) satisfying \(\varphi (x,y)\) the counterexamples \(\bot (\Phi )\) of \(\Phi \). One might hope that \(\bot (\Phi ) \ne \emptyset \) is enough to obtain \(d_{H }(A,B) > 0\). However, this is not the case. To this end, consider the formula \(\Psi := \forall X \in \mathbb {R} \, . \,\exists \,Y \in \mathbb {R}: XY > 1\), which is false. The set \(\bot (\Psi ) = \{0\}\) contains only a single element, so we have \(A = \mathbb {R} \hspace{1.111pt}{\setminus }\hspace{1.111pt}\{0\}\) and \(B = \mathbb {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 4.2 establishes a polynomial-time algorithm to transform a Strict-UETR instance \(\Phi \) into an equivalent formula \(\Phi '\) such that the set of counterexamples is either empty (if \(\Phi '\) is true) or contains an open ball of positive radius (if \(\Phi '\) 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 \(\Phi '\) is correct. A key tool for this step is that we can restrict the variable ranges from \(\mathbb {R} ^n\) and \(\mathbb {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.

Fig. 5
figure 5

Expanding the set of counterexamples of \(\forall X \in \mathbb {R} \, . \,\exists \, Y \in \mathbb {R}: XY > 1\)

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 \(\forall \)-strict; a negation-free and implication-free formula is \(\forall \)-strict if each atom involving universally quantified variables is a strict inequality. Being \(\forall \)-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 quantifier-free formulas as its input, and in general there is no equivalent quantifier-free formula of polynomial length which describes the set A [24]. 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 Sect. 5) with sets similar to

$$\begin{aligned} A&:= \{(x,y) \mid x \in [-C,C]^n,\, y \in [-1,1]^m,\, \varphi (x,y)\}\ \ \quad \text {and} \\ B&:= [-C,C]^n \times \{0\}^m \end{aligned}$$

for some value C that is doubly exponentially large in \(|{\Phi } |\). This definition of A and B introduces the new issue that even if \(\Phi \) is true, the Hausdorff distance \(d_{H }(A,B)\) might be strictly positive. However, we manage to identify a threshold \(t \in \mathbb {N} \), such that \(d_{H }(A,B)\leqslant t\) if and only if \(\Phi \) is true. This completes the proof of \(\forall \exists _{<}\mathbb {R} \)-hardness. In Sect. 7.1 we also establish \({ \forall \exists _{<}\mathbb {R}} \)-hardness for \(t = 0\).

1.9 Organization

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

2 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.

2.1 First-Order Theory of the Reals

Let \(X_1, \ldots , X_n\) be variables. A variable is free if it is not bound by a quantifier. An atom is an expression of the form \(P \circ 0\) for some polynomial P in these variables and \(\circ \in \{{<},{\leqslant }\}\). Following [46] we restrict the signature over which P is defined to the symbols \(\{0, 1, +, \hspace{1.111pt}{\cdot }\hspace{1.111pt}, (\,,\,)\}\) as well as symbols for the variables. It is easy to see (and also shown in [33]) that arbitrary integer coefficients \(c \in \mathbb {N} \) can be encoded using the binary expansion of c using \(O(\log c)\) additional symbols. Note that this signature contains no symbols for exponents and we write \(X^k\) just as a shorthand notation for the k-fold product \(X \cdots X\) (see again [33] for why this is important).

For n being the number of variables, there are O(n) possible symbols in A. Together with the logical connectives \(\wedge \), \(\vee \), \(\lnot \), and the quantifiers \(\forall \) and \(\exists \) required later, each of these can be encoded by a unique sequence of \(O(\log n)\) bits. We define the length of an atom A, denoted by \(|{A} |\), the be the number of bits required to write it down using such an encoding.

The total degree of an atom (if written as a sum of monomials) is the maximum number of occurrences of variables in any monomial. Now that we have atoms, a formula is either

  • an atom A, or

  • if \(\varphi _1,\varphi _2\) are formulas, then their conjunction \((\varphi _1 \wedge \varphi _2)\), their disjunction \((\varphi _1 \vee \varphi _2)\), and the negation \(\lnot \hspace{0.55542pt}(\varphi _1)\) are formulas, or

  • if \(\varphi (X)\) is a formula with a free variable X, \((\exists \, X \in \mathbb {R} \,{:}\, \varphi (X))\) and \((\forall X \in \mathbb {R} \,{:}\, \varphi (X))\) are formulas in which X is bound.

If clear from the context, we usually omit the parenthesis. A sentence is a formula without free variables and thus either equivalent to true or to false. We denote by \(\mathrm {QFF_{}}\) the family of quantifier free formulas. Below we require two subfamilies of \(\mathrm {QFF_{}}\), namely \(\mathrm {QFF_{<}}\) and \(\mathrm {QFF_{\leqslant }}\) defined to be negation-free and having only atoms involving < and \(\leqslant \), respectively.

The length of a formula \(\varphi \) can also be defined inductively: If \(\varphi \) is an atom A, then \(|{\varphi } | := |{A} |\). Otherwise, if \(\varphi \) is constructed from shorter subformulas \(\varphi _1\) (and possibly \(\varphi _2\)), then \(|{\varphi } |\) is defined to be the length of the subformulas plus the \(O(\log n)\) bits required for each additional symbol (using above binary encoding).

For increased readability we freely use integer coefficients, the minus sign “−”, exponents, the other binary relations \(\{{=},{\ne },{>},{\geqslant }\}\), and the implication symbol “\(\Rightarrow \)” throughout the paper. All of these can be expressed with the basic symbols introduced above changing the length of the formula by a logarithmic factor at most, which we can safely ignore when talking about polynomial-time reductions. As a convention, we use upper case Greek letters for sentences and use lower case Greek letter for formulas. We write \(\Phi \equiv \Psi \) if the two sentences have the same truth value.

The first-order theory of the reals is the family of all true sentences. We usually write blocks of variables, i.e., \(\forall \,X \in \mathbb {R} ^n:\varphi (X)\). Here X is a shorthand notation for \(X = (X_1, \ldots , X_n)\). We say that n is the length of X in this case. If all quantifiers of a formula appear at its beginning, we say it is in prenex normal form. Furthermore, we can assume that \(\varphi \) contains only the logical connectives \(\wedge \) and \(\vee \), because De Morgan’s law allows to push all negations (and therefore also implications) down to the atoms transforming \(\varphi \) into negation normal form. Then, the negation can be absorbed by the atom, i.e., using the equivalence \(\lnot \,(P \,{<}\,0) \ \equiv \ -P\,{ \leqslant }\,0\). This justifies, why \(\mathrm {QFF_{\circ }}\) for \(\circ \in \{{<},{\leqslant }\}\) only contains negation-free formulas by our definition.

Given a formula \(\varphi (X)\) with n free variables X, the set \(S(\varphi ) = \{x \in \mathbb {R} ^n \mid \varphi (x)\}\) is semi-algebraic. The complexity of a semi-algebraic set S is the length of a shortest quantifier-free formula \(\varphi \), such that \(S = S(\varphi )\). We write \(\varphi \equiv \varphi '\) if \(S(\varphi ) = S(\varphi ')\).

2.2 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 \(\varphi \) by a simpler one (at the cost of adding additional variables). Here and throughout the rest of the paper the notation \(x \leqslant {{\,\textrm{poly}\,}}\hspace{0.99991pt}(y_1, \ldots , y_k)\) means that there is a polynomial \(p \in \mathbb {Z} \hspace{0.55542pt}[Y_1, \ldots , Y_k]\) such that \(x \leqslant p\hspace{0.33325pt}(y_1, \ldots , y_k)\).

Lemma 2.1

[46, Lem. 3.2] Let \(\varphi (X) \in { \mathrm {QFF_{}}} \) be a formula with n free variables X. Then we can construct either of the following in polynomial time:

  1. (i)

    Integers \(\ell , m \leqslant {{\,\textrm{poly}\,}}\hspace{0.44434pt}(|{\varphi } |)\) and for \(i \in \{1, \ldots , m\}\) a polynomial \(F_i :\mathbb {R} ^{n + \ell }\rightarrow \mathbb {R} \) with integer coefficients of degree at most 2 such that

    $$\begin{aligned} \{x \in \mathbb {R} ^n \mid \varphi (x)\} = \left\{ x \in \mathbb {R} ^n \mid \exists \, Y \in \mathbb {R} ^\ell : \bigwedge _{i = 1}^m F_i(x,Y) = 0 \right\} . \end{aligned}$$
  2. (ii)

    An integer \(k \leqslant {\text {poly}}\hspace{0.44434pt}(|{\varphi } |)\) and a polynomial \(F :\mathbb {R} ^{n + k} \rightarrow \mathbb {R} \) with integer coefficients of degree at most 4 such that

    $$\begin{aligned} \{x \in \mathbb {R} ^n \mid \varphi (x)\} =\{x \in \mathbb {R} ^n \mid \exists \, Y \in \mathbb {R} ^k: F(x,Y) = 0\}. \end{aligned}$$

For any fixed \(\circ \in \{{<},{ \leqslant }\}\), we denote by \({ \forall \exists _{\circ }\mathbb {R}} \) the subset of \({ \forall \exists _{}\mathbb {R}} \) containing all decision problems that polynomial-time many-one reduce to a UETR-instance whose quantifier-free parts are contained in \(\mathrm {QFF_{\circ }}\). Similarly, for \(\circ \in \{{<},{ \leqslant }\}\), we denote the corresponding subsets of \(\exists \mathbb {R} \) and \(\forall \mathbb {R} \) by \(\exists _{\circ }\mathbb {R} \) and \(\forall _{\circ }\mathbb {R} \), respectively. The following lemma summarizes what we know about the relation between the complexity classes \(\forall \exists _{<}\mathbb {R} \), \(\forall \exists _{\leqslant }\mathbb {R} \), and \(\forall \exists _{}\mathbb {R} \) as well as their relation to the well-studied classes NP, co-NP, \(\exists \mathbb {R} \), \(\forall \mathbb {R} \), and PSPACE.

Lemma 2.2

The following inclusions hold:

figure a

Proof

The inclusion \(\mathsf{{NP}} \subseteq \exists \mathbb {R} \) was first presented by Shor [49]. This directly implies \(\mathsf{{co}\text {-}}\mathsf{{NP}} \subseteq \forall \mathbb {R} \) (because \(\forall \mathbb {R} =\mathsf{{co}\text {-}}\exists \mathbb {R} )\). For \(\circ \in \{{<},{ \leqslant }\}\) the inclusion \({ \forall \exists _{\circ }\mathbb {R}} \subseteq { \forall \exists _{}\mathbb {R}} \) follows by definition because the left hand side is just a special case of the right hand side. Using that \(\exists _<\mathbb {R} =\exists \mathbb {R} \) [46, Theorem 4.1], the same argument can be used for \(\exists \mathbb {R} \subseteq { \forall \exists _{<}\mathbb {R}} \). Canny first established \({ \forall \exists _{}\mathbb {R}} \subseteq \mathsf{{PSPACE}} \) in his seminal paper [21]. To show that \({ \forall \exists _{}\mathbb {R}} \subseteq { \forall \exists _{\leqslant }\mathbb {R}} \), consider a UETR instance

$$\begin{aligned} \Phi \ :\equiv \ \forall X \in \mathbb {R} ^n\, . \,\exists \, Y \in \mathbb {R} ^m: \varphi (X,Y). \end{aligned}$$

We apply Lemma 2.1 to \(\varphi \) and obtain in polynomial time an integer \(k \leqslant {{\,\textrm{poly}\,}}\hspace{0.44434pt}(|{\varphi } |)\) and a polynomial \(F :\mathbb {R} ^{n+m+k}\rightarrow \mathbb {R} \), such that

$$\begin{aligned} \Psi \ :\equiv \ \forall X \in \mathbb {R} ^n\, . \,\exists \,Y \in \mathbb {R} ^{m+k}: F(X,Y) \leqslant 0 \wedge -F(X,Y) \leqslant 0, \end{aligned}$$

is equivalent to \(\Phi \). Note that both atoms use \(\leqslant \). Lastly, let us consider the inclusion \(\forall \mathbb {R} \subseteq { \forall \exists _{<}\mathbb {R}} \). Note that \(\forall \mathbb {R} = \forall _{<}\mathbb {R} \) (because two complexity classes are equal whenever their complement classes are equal and \(\exists \mathbb {R} = \exists _{\leqslant }\mathbb {R} \) is known [46]). Now \(\forall _{<}\mathbb {R} \subseteq { \forall \exists _{<}\mathbb {R}} \) again follows by definition. \(\square \)

3 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.

3.1 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 [39,40,41]. 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 3.1

[11, Thm. 14.16] Let \(X_1, \ldots , X_k, Y\) be blocks of real variables where \(X_i\) has length \(n_i\), Y has length m, formula \(\varphi (X_1, \ldots , X_k, Y)\in { \mathrm {QFF_{}}} \) has s atoms and \(Q_i\in \{\exists ,\forall \}\) is a quantifier for all \(i=1,\dots ,k\). Further, let d be the maximum total degree of any polynomial of \(\varphi (X_1, \ldots , X_k, Y)\). Then for any formula

$$\begin{aligned} \Phi (Y) \ :\equiv \ Q_1 X_1 \in \mathbb {R} ^{n_1} \!\ldots Q_k X_k \in \mathbb {R} ^{n_k}:\varphi (X_1, \ldots , X_k, Y) \end{aligned}$$

there is an equivalent quantifier-free formula of size at most

$$\begin{aligned} s^{(n_1 + 1) \cdots (n_k + 1) (m + 1)} d^{O(n_1) \cdots O(n_k) O(m)}. \end{aligned}$$

Throughout the paper we use the following corollary of Theorem 3.1 which is already stated by D’Costa et al. [25]. It is weaker but easier to work with.

Corollary 3.2

[25] Let \(\Phi (Y)\) be as in Theorem 3.1 of length \(L = |{\varphi (X_1, \ldots , X_k, Y)} |\). Then for some constant \(\alpha \in \mathbb {R} \) independent of \(\Phi \), there exists an equivalent quantifier-free formula of size at most

$$\begin{aligned} L^{\alpha ^{k+1} (n_1+1) \cdots (n_k+1) (m+1)}. \end{aligned}$$

The Ball Theorem was first discovered by Vorob’ev [51] and Grigor’ev and Vorobjov [30]. (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č [46].

Ball Theorem 3.3

[46, Cor. 3.1] Every non-empty semi-algebraic set in \(\mathbb {R} ^n\) of complexity at most \(L \geqslant 4\) contains a point of distance at most  from the origin.

Recall that for any quantifier-free formula \(\varphi (X)\) with free variables \(X \in \mathbb {R} ^n\), the set \(S := \{x \in \mathbb {R} ^n \mid \varphi (X)\}\) is semi-algebraic. It follows from Theorem 3.3 that \(\exists \, X \in \mathbb {R} ^n \,{:}\, \varphi (X)\) is equivalent to . This is how we are going to use the Ball Theorem 3.3 throughout this paper.

Below we use Corollary 3.2 and Theorem 3.3, proving a lemma that is stated in [25, 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 3.4

Let \(X_1, \ldots , X_k\) be blocks of variables where \(X_i\) has length \(n_i \geqslant 1\) and let \(\varphi (\varepsilon , X_1, \ldots , X_k) \in { \mathrm {QFF_{}}} \) with \(L := |{\varphi } |\). For \(Q_i \in \{\exists , \forall \}\) consider the set

$$\begin{aligned} S :=\{ \varepsilon > 0 \mid Q_1 X_1 \in \mathbb {R} ^{n_1}\! \ldots Q_k X_k \in \mathbb {R} ^{n_k}\! : \varphi (\varepsilon , X_1, \ldots , X_k)\}. \end{aligned}$$

If S is non-empty, then there is an \(\varepsilon ^*\in S\) such that for some constant \(\beta \in \mathbb {R} \) we have

$$\begin{aligned} \varepsilon ^* \geqslant 2^{-L^{\beta ^{k+2} (n_1+1) \cdots (n_k+1)}}. \end{aligned}$$

Proof

Let \(\Phi (\varepsilon )\) be the subformula \(Q_1 X_1 \in \mathbb {R} ^{n_1}\! \ldots Q_k X_k \in \mathbb {R} ^{n_k}\,{ : }\,\varphi (\varepsilon , X_1, \ldots , X_k)\). By Corollary 3.2, there is a constant \(\alpha \in \mathbb {R} \) and a quantifier-free formula \(\phi (\varepsilon )\) of length

$$\begin{aligned} |{\phi (\varepsilon )} | \leqslant L^{2\alpha ^{k+1} (n_1+1) \cdots (n_k+1)} \end{aligned}$$

such that \(S = \{\varepsilon > 0 \mid \phi (\varepsilon )\}\). Let d be the maximum degree of any polynomial in \(\phi \) and \(\delta \) be a new variable. We replace each atom \(P(\varepsilon ) \circ 0\) (where \(\circ \in \{{<},{ \leqslant }\}\)) of \(\phi \) by \(\delta ^d P(1/\delta ) \circ 0\) and denote the new formula by \(\psi (\delta )\). Then for \(\varepsilon > 0\) it follows that \(\phi (\varepsilon )\) is true if and only if for \(\delta = 1/\varepsilon \) the sentence \(\psi (\delta )\) is true. We get

$$\begin{aligned} \exists \, \varepsilon> 0 : \phi (\varepsilon )\ \equiv \ \exists \, \delta > 0 : \psi (\delta ). \end{aligned}$$

To obtain an upper bound on \(|{\psi (\delta )} |\), note that the length of each atom increases by a factor of at most d, which is obviously at most \(|{\phi (\varepsilon )} |\). We conclude that

$$\begin{aligned} |{\psi (\delta )} |\leqslant |{\phi (\varepsilon )} | \cdot d\leqslant |{\phi (\varepsilon )} |^2. \end{aligned}$$

If S is non-empty, then \(\exists \,\delta > 0 : \psi (\delta )\) is true. By Theorem 3.3, there is some \(\delta ^*\) such that \(\psi (\delta ^*)\) is true and . We get that

$$\begin{aligned} \delta ^*\leqslant 2^{|{\psi (\delta )} |^8}\!\leqslant 2^{|{\phi (\varepsilon )} |^{16}}\!\leqslant 2^{L^{32\alpha ^{k+1} (n_1+1) \cdots (n_k+1)}}\!\leqslant 2^{L^{\beta ^{k+2} (n_1+1) \cdots (n_k+1)}}, \end{aligned}$$

where \(\beta := \max \hspace{1.4444pt}\{32, \alpha \}\) is a real constant independent of the input. The result follows for \(\varepsilon ^* := 1/\delta ^*\). \(\square \)

The next lemma will be used frequently to scale (some dimensions of) semi-algebraic sets. For some \(N \in \mathbb {N} \) and \(N + 1\) variables \(U = (U_0, \ldots , U_N)\) it considers the following formula:

$$\begin{aligned} \chi (U) \ :\equiv \ (2 \hspace{1.38885pt}{\cdot }\hspace{1.4444pt}U_0 = 1) \wedge \bigwedge _{i = 1}^N (U_i = U_{i-1}^2). \end{aligned}$$
(2)

Lemma 3.5

For \(u \in [-1,1]^{N+1}\) formula \(\chi (u)\) is true if and only if .

Proof

The if-part is trivial. The only-if-part follows from a simple induction. \(\square \)

3.2 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. [25] in the context of their \({ \exists \forall _{\leqslant }\mathbb {R}} \)-complete escape problem. Lemmas 3.6 and 3.7 below are stated in our setting, but their proofs directly follow the ideas in [25].

As a first step, we restrict the universally quantified variables. This works for general UETR instances without any further requirements on the formula.

Lemma 3.6

Let X and Y be blocks of variables with \(n := |{X} |\) and \(m := |{Y} |\), let \(\varphi (X,Y) \in { \mathrm {QFF_{}}} \) and let

$$\begin{aligned} \Phi \ :\equiv \ \forall \, X \in \mathbb {R} ^n \!\, . \,\exists \, Y \in \mathbb {R} ^m\hspace{0.55542pt}:\hspace{1.111pt}\varphi (X,Y). \end{aligned}$$

Then there exists an integer \(N \leqslant {{\,\textrm{poly}\,}}\hspace{0.99991pt}(n, m, |{\varphi } |)\), such that for  the sentence

$$\begin{aligned} \Psi \ :\equiv \ \forall \, X \in [-C,C]^n\! \, . \,\exists \,Y \in \mathbb {R} ^m\hspace{0.55542pt}:\hspace{1.111pt}\varphi (X,Y) \end{aligned}$$

is equivalent to \(\Phi \).

Proof

We rewrite \(\Phi \) via a double negation to get

$$\begin{aligned} \Phi \ \equiv \ \lnot \,\bigl (\exists \, X \in \mathbb {R} ^n \!\, . \,\forall \, Y \in \mathbb {R} ^m \hspace{0.55542pt}:\hspace{1.111pt}\lnot \,\varphi (X,Y) \bigr ) \end{aligned}$$

and let \(L := |{\lnot \,\varphi } |\) denote the length of the quantifier-free part. By Corollary 3.2 there is a constant \(\alpha \in \mathbb {R} \) and a quantifier-free formula \(\psi (X)\) such that \(\Phi \) is equivalent to \(\lnot \,(\exists \, X \in \mathbb {R} ^n \hspace{0.55542pt}{:}\, \psi (X))\), where

$$\begin{aligned} |{\psi } |\leqslant L^{\alpha ^2 (n+1) (m+1)}= 2^{\alpha ^2(n+1) (m+1) \log L}. \end{aligned}$$

Assuming that \(\{x \in \mathbb {R} ^n \mid \psi (x)\}\) is non-empty, Theorem 3.3 yields that it contains a point of distance at most

$$\begin{aligned} D :=2^{|{\psi } |^{8n}}\!\leqslant 2^{(2^{\alpha ^2 (n+1) (m+1) \log L})^{8n}}\!= 2^{2^{8 \alpha ^2 n (n+1) (m+1) \log L}} \end{aligned}$$

from the origin. Let \(N = \lceil 8 \alpha ^2 n (n+1) (m+1)\log L \rceil \leqslant {{\,\textrm{poly}\,}}\hspace{1.04996pt}(n, m, \log L) \leqslant {{\,\textrm{poly}\,}}\hspace{1.05545pt}(n, m, |{\varphi } |)\). Then it holds that . It follows that

$$\begin{aligned} \lnot \,\Phi&\ \equiv \ \lnot \,(\exists \, X \in \mathbb {R} ^n:\hspace{0.55542pt}\psi (X)) \\&\ \equiv \ \lnot \,(\exists \, X \in [-C,C]^n:\hspace{0.55542pt}\psi (X)) \\&\ \equiv \ \lnot \,(\exists \, X \in [-C,C]^n \!\, . \,\forall \,Y \in \mathbb {R} ^m:\hspace{0.55542pt}\varphi (X,Y))\\&\ \equiv \ \lnot \, \Psi \end{aligned}$$

and therefore \(\Phi \equiv \Psi \). \(\square \)

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:

$$\begin{aligned} \forall \,X \in \mathbb {R} \hspace{1.111pt}\, . \,\hspace{1.111pt}\exists \, Y \in \mathbb {R} \hspace{1.111pt}:\hspace{1.111pt}X = 0 \vee XY = 1. \end{aligned}$$

This sentence is clearly true as either \(X = 0\) or if \(X \ne 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 \in [-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 \(\forall \)-strict formulas. Requiring the formula to be \(\forall \)-strict is a slight generalization of the corresponding statement shown in [25] (where the formula is required to be strict). This more general case is crucial for our proofs in Sects. 6 and 7.

Lemma 3.7

Let X and Y be blocks of variables with \(n := |{X} |\) and \(m := |{Y} |\), and \(\varphi (X,Y) \in { \mathrm {QFF_{}}} \). Further, let N be an integer and . Then for a \(\forall \)-strict sentence

$$\begin{aligned} \Phi \ :\equiv \ \forall \,X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m\! \hspace{0.55542pt}:\hspace{0.55542pt}\varphi (X,Y) \end{aligned}$$

there is an integer \(M \leqslant {{\,\textrm{poly}\,}}\hspace{1.111pt}(n, m, N, |{\varphi } |)\) such that for the sentence

$$\begin{aligned} \Psi \ :\equiv \ \forall \,X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D]^m:\hspace{0.55542pt}\varphi (X,Y) \end{aligned}$$

is equivalent to \(\Phi \).

Proof

If \(\Phi \) is false, then there exists an \(x \in [-C,C]^n\) such that no \(y \in \mathbb {R} ^m\) satisfies \(\varphi (x,y)\). In particular, no \(y \in [-D,D]^m \subseteq \mathbb {R} ^m\) satisfies \(\varphi (x,y)\). Thus, \(\Psi \) is also false. In the remainder of the proof we assume that \(\Phi \) 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 3.3 to compute an upper bound for D.

For the first step, let \(S = [-C,C]^n\). Sentence \(\Phi \) being true implies that for each \(x \in S\) there is a \(y(x)\in \mathbb {R} ^m\) such that \(\varphi (x,y(x))\) is true. Even stronger, as \(\varphi \) is \(\forall \)-strict, we even find an \(\varepsilon (x) > 0\), such that for all \(\widetilde{x}\in S\) with \(\Vert {x - \widetilde{x}} \Vert < \varepsilon (x)\) we get that \(\varphi (\widetilde{x},y(x))\) is true. Recall that we denote by \(B_n(x,r)=\{\widetilde{x} \in \mathbb {R} ^n\mid \Vert {\widetilde{x} - x} \Vert < r\}\) the open ball with center x and radius r in \(\mathbb {R} ^n\). Then \(\{B_n(x,\varepsilon (x)) \mid x \in S\}\) is an open cover of S. As S is compact, it has a finite subcover \(B_n(x_1,\varepsilon (x_1)), \ldots , B_n(x_s,\varepsilon (x_s))\). Now, given some \(x \in S\), there is an \(i\in \{1,\dots ,s\}\), such that \(\varphi (x, y(x_i))\) is true. We define \(y_{\max } := \max {\{\Vert {y(x_1)} \Vert _\infty , \ldots , \Vert {y(x_s)} \Vert _\infty \}}\). Then, for all \(D \geqslant y_{\max }\) formula \(\Phi \) implies

$$\begin{aligned} \exists \,D > 0 \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \,X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m \hspace{0.55542pt}:\hspace{0.55542pt}\bigwedge _{i=1}^m |{Y_i} | \leqslant D \wedge \varphi (X,Y), \end{aligned}$$

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 inside the formula. For this, let \(U = (U_0, \ldots ,U_N)\) be \(N + 1\) new variables and \(\chi (U)\) be the formula (2). Recall that by Lemma 3.5, \(\chi (u)\) is true if and only if . Further, each \(U_i\) can be trivially restricted to be in \([-1,1]\). Using \(\chi (U)\), we can rewrite the above sentence as

$$\begin{aligned} \exists \,D > 0 \hspace{0.55542pt}\, . \,\hspace{0.55542pt}&\forall \,X \in \mathbb {R} ^n,\,U \in [-1,1]^{N+1}\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m\hspace{0.55542pt}: \\&\left( \chi (U)\wedge \bigwedge _{i=1}^n |{X_i} |\hspace{0.55542pt}U_N \leqslant 1 \right) \ \Rightarrow \ \bigwedge _{i=1}^m |{Y_i} | \leqslant D\wedge \varphi (X,Y). \end{aligned}$$

From here on, bounding D is a straightforward application of the Ball Theorem 3.3: Let L be the length of the subformula behind the existential quantification of D. By Corollary 3.2 there is a constant \(\alpha \in \mathbb {R} \) and a quantifier-free formula \(\psi (D)\), such that above sentence is equivalent to \(\exists \, D > 0\hspace{0.55542pt}\,{:}\, \hspace{0.55542pt}\psi (D)\) where . Then Theorem 3.3 yields the following upper bound for D:

$$\begin{aligned} D\leqslant 2^{|{\psi (D)} |}\!\leqslant 2^{(L^{2 \alpha ^3 (n+N+2) (m+1)})^{8n}}\!= 2^{2^{16 \alpha ^3 n (n+N+2) (m+1)\log L}}. \end{aligned}$$

Lastly, we choose \(M \leqslant \lceil 16 \hspace{0.55542pt}\alpha ^3 n (n+N+2) (m+1)\log L \rceil \) to be the smallest integer such that . Note that \(M \leqslant {{\,\textrm{poly}\,}}\hspace{1.05545pt}(n, m, N, \log L) \leqslant {{\,\textrm{poly}\,}}\hspace{1.05545pt}(n, m, N, |{\varphi } |)\) as required. \(\square \)

4 Counterexamples of Strict-UETR

Let us recall the definition of counterexamples here that was already motivated in Sect. 1.8. Given a sentence \(\Phi \hspace{0.55542pt}:\equiv \hspace{0.55542pt}\forall \,X \in \mathbb {R} ^n\, . \,\exists \,Y \in \mathbb {R} ^m\hspace{-0.55542pt}:\hspace{-0.55542pt}\varphi (X,Y)\) we call

$$\begin{aligned} \bot (\Phi ) := \{x \in \mathbb {R} ^n \mid \forall \,Y \in \mathbb {R} ^m:\lnot \,\varphi (x,Y)\} \end{aligned}$$

its counterexamples. The counterexamples of \(\Phi \) are exactly the values \(x \in \mathbb {R} ^n\) for which there is no \(y \in \mathbb {R} ^m\) such that \(\varphi (x,y)\) is true. The main result of this section, Theorem 4.2, is that we can transform a Strict-UETR instance \(\Phi \) into an equivalent formula \(\Psi \) for which \(\bot (\Psi )\) is either empty or contains an open ball. The main tools for this are the range restrictions from Sect. 3.2 and the following lemma from calculus.

Lemma 4.1

Let S and T be compact sets and \(f :S \hspace{1.111pt}{\times }\hspace{1.111pt}T \rightarrow \mathbb {R} \) be a continuous function. Then \(g :S \rightarrow \mathbb {R} \), \(x \mapsto \min _{y \in T} \{f(x,y)\}\), is continuous over S.

Proof

We first observe that by compactness of S and T, their Cartesian product \(S \hspace{1.111pt}{\times }\hspace{1.111pt}T\) is compact as well. Thus, because f is continuous on \(S \hspace{1.111pt}{\times }\hspace{1.111pt}T\), it is even uniformly continuous, i.e., for every \(\varepsilon > 0\) there is a \(\delta > 0\), such that for every two points \((x,y),(\widetilde{x},\widetilde{y}) \in S \hspace{1.111pt}{\times }\hspace{1.111pt}T\) we have \(|f(x,y) - f(\widetilde{x},\widetilde{y}) |< \varepsilon \) whenever \(\Vert {(x,y) - (\widetilde{x},\widetilde{y})} \Vert < \delta \). Now consider \(x, \widetilde{x} \in S\) with \(\Vert {x - \widetilde{x}} \Vert < \delta \). We have

$$\begin{aligned} g(\widetilde{x}) - g(x)&= g(\widetilde{x}) - f(x, y)\qquad \quad \quad \,\ \ \quad \ \hbox {(for some }y \in T\mathrm{)}\\&< g(\widetilde{x}) - (f(\widetilde{x}, y) - \varepsilon )\qquad \quad \hbox {(by uniform continuity)} \\&\leqslant g(\widetilde{x}) - (g(\widetilde{x}) - \varepsilon ) \qquad \qquad \ \, \ \hbox {(by definition of }g\mathrm{)} \\&= \varepsilon . \end{aligned}$$

By exchanging the role of x and \(\widetilde{x}\), we get \(g(x)-g(\widetilde{x})<\varepsilon \). Combined, we obtain that \(|g(x)-g(\widetilde{x})|<\varepsilon \) for all \(x,\widetilde{x}\in S\) with \(\Vert {x - \widetilde{x}} \Vert < \delta \). It follows that g is continuous on S. \(\square \)

With these tools at hand, we are able to tackle the main result of this section.

Theorem 4.2

Given a Strict-UETR instance \(\Phi \), we can construct in polynomial time an equivalent UETR instance \(\Psi \) of the form

$$\begin{aligned} \forall \, X \in [-1,1]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-1,1]^\ell \hspace{1.111pt}:\hspace{1.111pt}\psi (X,Y), \end{aligned}$$

such that \({\bot (\Psi )}\) is either empty or contains an n-dimensional open ball.

Before proving Theorem 4.2 in full generality, let us illustrate the key idea with an example for a very simple Strict-UETR instance \(\Phi \) having only a single atom. This already shows how bounding the ranges of the quantifiers expands the set of counterexamples while not yet requiring the technical calculus arguments that are required to handle more than one atom.

In our example we consider the Strict-UETR instance

$$\begin{aligned} \Phi \ :\equiv \ \forall \, X \in \mathbb {R} \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \,Y \in \mathbb {R} \hspace{1.111pt}:\hspace{1.111pt}XY < 0. \end{aligned}$$

Note that \(\Phi \) is a no-instance with \(\bot (\Phi ) = \{0\}\), i.e., there is only a single counterexample. We start by introducing a new existentially quantified variable Z (in general we would add one variable per atom) and rewrite each atom \(P<0\) as \(\exists \, Z \in \mathbb {R} \hspace{0.55542pt}:\hspace{0.55542pt}Z^2P+1<0\). In our case we get

$$\begin{aligned} \Phi _1\ :\equiv \ \forall \, X \in \mathbb {R} \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R}, \,Z \in \mathbb {R} \hspace{1.111pt}:\hspace{1.111pt}Z^2\hspace{1.111pt}{\cdot }\hspace{1.111pt}XY+1 <0. \end{aligned}$$

It holds that \(\Phi \equiv \Phi _1\) and even stronger that \(\bot (\Phi ) = \bot (\Phi _1)=\{0\}\). While this transformation 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 \(XY < -{1}/{D^2}\) in order to satisfy the atom. This is stronger than just requiring \(XY < 0\) and expands the set of counterexamples. To see this in action, we apply Lemmas 3.6 and 3.7 and get integer constants C and D such that \(\Phi _1\) is equivalent to

$$\begin{aligned} \Phi _2 \ :\equiv \ \forall \, X \in [-C,C] \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D],\, Z \in [-D,D] \hspace{0.55542pt}:\hspace{0.55542pt}Z^2\hspace{1.111pt}{\cdot }\hspace{1.111pt}XY + 1 < 0 \end{aligned}$$

and further \(\bot (\Phi _2) \supseteq \bot (\Phi _1) \cap [-C,C]\). It remains to argue that \(\bot (\Phi _2)\) indeed contains an open ball.

Consider some \(x \in (0, C]\), for which \(y,z \in [-D,D]\) does \(z^2 \hspace{1.111pt}{\cdot }\hspace{1.111pt}xy + 1 < 0\) hold? Neither of yz may be zero and y must be negative (as \(z^2\) is always positive). Then \(z^2\hspace{1.111pt}{\cdot }\hspace{1.111pt}xy + 1 < 0\) is equivalent to \(xy < -{1}/{z^2}\). Further, we get

$$\begin{aligned} {-}\hspace{1.66656pt}xD \leqslant xy < -\frac{1}{z^2} \leqslant -\frac{1}{D^2}\hspace{0.55542pt}. \end{aligned}$$

It follows that \(-xD < -{1}/{D^2}\) and thus \(x > {1}/{D^3}\). This means that \((0, {1}/{D^3}] \subseteq \bot (\Phi _2)\) and this interval contains an open ball.

Proof of Theorem 4.2

The proof is split into two parts. First, we construct \(\Psi \) from \(\Phi \). Afterwards, we show that \(\bot (\Psi )\) has the desired properties.

Construction of \(\Psi \). Each atom of the sentence

$$\begin{aligned} \Phi \ :\equiv \ \forall \,X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m:\hspace{0.55542pt}\varphi _<(X,Y) \end{aligned}$$

with \(\varphi _< \in { \mathrm {QFF_{<}}} \) is of the form \(P < 0\), where \(P \in \mathbb {Z} [X,Y]\) is a polynomial. We replace \(P < 0\) by the equivalent formula \(\exists \,Z\in \mathbb {R}: Z^2P + 1 < 0\). Here, Z is a new variable that is exclusive to this atom. Moving the new existential quantifiers to the front yields a sentence

$$\begin{aligned} \Phi _1 \ :\equiv \ \forall \,X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \,Y \in \mathbb {R} ^m,\, Z \in \mathbb {R} ^k:\hspace{0.55542pt}\varphi _<'(X,Y,Z) \end{aligned}$$

in prenex normal form. Here, k is the number of atoms in \(\Phi \) and \(\varphi _<'\) is obtained from \(\varphi _<\) by above transformation. Note that in particular, \(\varphi _<\) and \(\varphi _<'\) 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 \(|{\Phi _1} |\) is linear in \(|{\Phi } |\). Further, we have \(\bot (\Phi _1) = \bot (\Phi )\) by construction.

We can apply Lemma 3.6 to restrict the ranges of the universally quantified variables and obtain an integer \(N\leqslant {{\,\textrm{poly}\,}}\hspace{0.44434pt}(|{\Phi _1} |)\) such that for  the sentence \(\Phi _1\) is equivalent to

$$\begin{aligned} \Phi _2 \ :\equiv \ \forall \, X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m,\, Z \in \mathbb {R} ^k:\hspace{0.55542pt}\varphi _<'(X,Y,Z). \end{aligned}$$

It holds that \(\bot (\Phi _2) \subseteq \bot (\Phi _1)\) and further that \(\bot (\Phi _2) = \bot (\Phi _1) \cap [-C,C]^n\). Each atom in \(\Phi _2\) is a strict inequality. Thus, we can use Lemma 3.7 to also restrict the ranges of the existentially quantified variables. We obtain another integer \(M \leqslant {{\,\textrm{poly}\,}}\hspace{0.88882pt}(N, |{\Phi _2} |)\) such that for above sentence \(\Phi _2\) is equivalent to

$$\begin{aligned} \Phi _3 \ :\equiv \ \forall \, X \in [-C,C]^n \, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D]^m,\, Z \in [-D,D]^k :\hspace{0.55542pt}\varphi _<'(X,Y,Z). \end{aligned}$$

Regarding the counterexamples, we have \(\bot (\Phi _3) \supseteq \bot (\Phi _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 \hspace{0.94437pt}\{N,M\}\), let \(U:=(U_0,\dots ,U_K)\) be \(K+1\) new variables and let \(\chi (U)\) be the formula (2). Recall that by Lemma 3.5, for \(u\in [-1,1]^{K+1}\) we have \(\chi (u)\) if and only if . Let d be the maximum degree of any polynomial in \(\varphi _<'\). We define

$$\begin{aligned} \Psi \ :\equiv \ ~&\forall X \in [-1,1]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-1,1]^m,\, Z \in [-1,1]^k,\, U \in [-1,1]^K \hspace{0.55542pt}: \\&\qquad \qquad \chi (U)\,\wedge \,U_K^d \cdot \varphi _<'\biggl (\frac{X}{U_N}\hspace{0.55542pt}, \frac{Y}{U_M}\hspace{0.55542pt}, \frac{Z}{U_M}\biggr ), \end{aligned}$$

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 \(\varphi _<'\) with \(U_K^d\) denotes that both sides of each atom are multiplied by \(U_K^d\). 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 \geqslant N\), we can replace any \(U_K \cdot (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 \(\Psi \) is equivalent to \(\Phi _3\) and therefore also to \(\Phi \). Further, \(\Psi \) has the form required by the statement of the theorem.

Properties of \(\bot (\Psi )\). It remains to show that \(\bot (\Psi )\) is either empty (if \(\Psi \) is true) or contains an n-dimensional open ball (if \(\Psi \) is false). Note that scaling variables (as done to get from \(\Phi _3\) to \(\Psi \)) also scales the counterexamples; thus, an open ball in \(\bot (\Phi _3)\) maps to an open ball in \(\bot (\Psi )\). It therefore suffices to prove that \(\bot (\Phi _3)\) contains an open ball. As \(\Phi _3\) is the simpler formula, we analyze \(\bot (\Phi _3)\) below.

By construction, \(\Phi \) and \(\Phi _3\) are equivalent. Thus, \(\Phi \) is true if and only \(\Phi _3\) is true. In particular, \(\bot (\Phi ) =\emptyset \) implies that \(\bot (\Phi _3) = \emptyset \). From now on, we assume that \(\Phi _3\) is false. Let \(x^*\in \bot (\Phi _2)\) be a counterexample of \(\Phi _2\), fixed until the end of the proof. We know that \(x^*\in [-C,C]^n\) (by Lemma 3.6) and also that \(x^*\in \bot (\Phi _3)\) (by construction of \(\Phi _3\)). We prove below that for some \(r > 0\), all \(x \in [-C,C]^n\) with \(\Vert {x^* - x} \Vert < r\) are counterexamples of \(\Phi _3\) as well. If \(B_n(x^*, r)\subseteq [-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' \in B_n(x^*, r) \cap (-C,C)^n\) can be used instead as the center of a smaller (but still open) ball of counterexamples.

To simplify the following argument, we further assume that \(\varphi _<\) (in \(\Phi \)) is in disjunctive normal form (DNF), i.e., a disjunction of conjunctions of atoms. By construction, \(\varphi _<'\) 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, \(\varphi _<\) and \(\varphi _<'\) have exactly the same counterexamples as their DNFs.

Let \(\mathcal {C}(X,Y) := \bigl (\hspace{0.55542pt}\bigwedge _{i=1}^s P_i(X,Y) < 0\bigr )\) be one of the conjunctive clauses of (the DNF of) \(\varphi _<(X,Y)\). For our fixed counterexample \(x^* \in \bot (\Phi _2)\), every conjunctive clause of \(\varphi _<(x^*, Y)\) evaluates to false independently of Y. We get that for all \(y \in \mathbb {R} ^m\) and thus in particular for all \(y \in [-D,D]^m\) that \(\mathcal {C}(x^*,y)\) is false and that

$$\begin{aligned} \bigvee _{i=1}^s \bigl (P_i(x^*,y) \geqslant 0\bigr ) \end{aligned}$$
(3)

is true. Let us point out that for different choices of \(y \in [-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 \(\varphi _<(X,Y)\) is in DNF). To overcome this we combine the polynomials into a single function.

Each of the \(P_i \in \mathbb {Z} [X,Y]\), \(i \in \{1, \ldots , s\}\), is a polynomial and thus continuous. The maximum over a finite number of continuous functions is again continuous, so

$$\begin{aligned} P_{\max } :[-C,C]^n \hspace{0.83328pt}{\times }\hspace{1.4444pt}[-D,D]^m\rightarrow \mathbb {R},\quad (x,y)\mapsto \max \limits _{i=1,\ldots ,s} \{P_i(x,y)\} \end{aligned}$$

is continuous. It follows from (3) that for our fixed counterexample \(x^*\) and all \(y \in [-D,D]^m\) it holds that

$$\begin{aligned} P_{\max }(x^*,y) \geqslant 0. \end{aligned}$$
(4)

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

$$\begin{aligned} P^* :[-C,C]^n\rightarrow \mathbb {R},\quad \ x\mapsto \min \limits _{y \in [-D,D]^m} P_{\max }(x,y), \end{aligned}$$

which eliminates the dependency on y. The sets \([-C,C]^n\) and \([-D,D]^m\) are compact, so by Lemma 4.1 function \(P^*\) is again continuous. From (4), we get for our fixed counterexample \(x^*\) that

$$\begin{aligned} P^*(x^*) \geqslant 0. \end{aligned}$$

By the continuity of \(P^*\), for every \(\varepsilon >0\) there exists a \(\delta > 0\) such that for all \(x\in [-C,C]^n\) with \(\Vert {x^*-x} \Vert <\delta \) we have \(|{P^*(x)-P^*(x^*)} | < \varepsilon \). We choose \(\varepsilon <1/D^2\) and conclude that for a sufficiently small \(\delta >0\) and all \(x \in [-C,C]^n\) with \(\Vert {x^*-x} \Vert < \delta \) it holds that

$$\begin{aligned} P^*(x) > -\frac{1}{D^2}\hspace{0.55542pt}. \end{aligned}$$

Fix one such x. Going backwards through our chain of defined functions, it follows for all \(y \in [-D,D]^m\) that \(P_{\max }(x,y) > -1/D^2\) and moreover that

$$\begin{aligned} \bigvee _{i = 1}^s P_i(x, y) > -\frac{1}{D^2}\hspace{0.55542pt}. \end{aligned}$$
(5)

Now also fix an arbitrary \(y \in [-D,D]^m\) and choose \(j \in \{1, \ldots , s\}\) such that \(P_j(x,y) > -1/D^2\). Because \(A := (P_j(X,Y) < 0)\) is an atom in the DNF of \(\varphi _<(X,Y)\), there is a corresponding atom \(A' := (Z_j^2P_j(X,Y) + 1 < 0)\) in the DNF of \(\varphi _<'(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 \ne 0\), the atom \(A'\) can be rewritten as \(P_j(X,Y) < -1/Z_j^2\). From \(Z_j \in [-D,D]\), we get that \(Z_j^2 \leqslant D^2\) and therefore our considered atom \(A'\) can only ever be satisfied, if \(P_j(X,Y) < -1/Z_j^2 \leqslant -1/D^2\). 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 \(\Phi _3\). Additionally, because \(x \in \mathbb {R} ^n\) with \(\Vert {x^* - x} \Vert < \delta \) was arbitrary, we conclude that all such x are counterexamples of \(\Phi _3\) forming an n-dimensional open ball. \(\square \)

5 \({ \forall \exists _{<}\mathbb {R}} \)-Hardness of Hausdorff

We are now able to show \({ \forall \exists _{<}\mathbb {R}} \)-hardness.

Theorem 5.1

Hausdorff and Directed Hausdorff are \(\forall \exists _{<}\mathbb {R} \)-hard.

Proof

Let \(\Phi \) 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 \(\Phi \) into an equivalent UETR instance \(\Psi \) whose counterexamples \(\bot (\Psi )\) contain an open ball (if there are any). Sentence \(\Psi \) is then used to construct a Hausdorff instance (ABt). The second part then proves that \(\Phi \) and (ABt) are indeed equivalent. \(\square \)

Constructing Hausdorff instance (ABt). The first step is to apply Theorem 4.2 to \(\Phi \) and to obtain in polynomial time an equivalent UETR instance

$$\begin{aligned} \Psi ' \ :\equiv \ \forall \, X \in [-1,1]^n\, . \,\hspace{0.55542pt}\exists \,Y \in [-1,1]^m:\hspace{0.55542pt}\psi '(X,Y), \end{aligned}$$

where \(\psi ' \in { \mathrm {QFF_{}}} \). We know that either \(\bot (\Psi ') = \emptyset \) (if \(\Psi '\) is true) or that \(\bot (\Psi ')\) contains an n-dimensional open ball (if \(\Psi '\) is false). Based on \(\Psi '\) we define

$$\begin{aligned} \psi (X,Y)&\ :\equiv \ \psi '(X,Y) \vee \bigwedge _{i=1}^n X_i = 0\ \quad \text {and} \\ \Psi&\ :\equiv \ \forall \, X \in [-1,1]^n \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, Y \in [-1,1]^m:\hspace{0.55542pt}\psi (X,Y). \end{aligned}$$

Note that \(\Psi '\) and \(\Psi \) are equivalent: If \(\Psi '\) is true, then obviously \(\Psi \) is also true because the new condition is added using a logical “or”. If \(\Psi '\) is false, then \(\bot (\Psi ) = \bot (\Psi ') \setminus \{\vec {0}\}\). Since \(\bot (\Psi ')\) contained an open ball, it follows that \(\bot (\Psi )\) also contains an open ball. The key idea behind the definition of \(\Psi \) is that \(\bot (\Psi )\) is guaranteed to be a strict subset of \(\mathbb {R} ^n\). This will be important below to make sure that set A (of the Hausdorff instance we define below) is non-empty.

If \(\Psi \) is false, then there is an \(x \in \bot (\Psi ) \subseteq [-1,1]^n\), such that \(B_n(x, r) \subseteq \bot (\Psi )\) for some \(r > 0\). Expressed as a sentence in the first-order theory of the reals we get

$$\begin{aligned}{} & {} \exists \, r > 0,\, X \in [-1,1]^n \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \, \widetilde{X} \in [-1,1]^n,\, Y \in [-1,1]^m:\\ {}{} & {} \hspace{0.55542pt}\Vert {X - \widetilde{X}} \Vert ^2\! < r^2\,{\Rightarrow }\,\lnot \,\psi (\widetilde{X},Y). \end{aligned}$$

Let us denote by L the length of the quantifier-free part of this sentence. We see that L is clearly polynomial in \(|{\Psi } |\) which by construction is polynomial in \(|{\Phi } |\). Above sentence has the form required by Lemma 3.4, and we get a constant \(\beta \in \mathbb {R} \) such that the following lower bound for r can be assumed:

$$\begin{aligned} r \geqslant 2^{-L^{\beta ^4 (n+1) (n+m+1)}} \end{aligned}$$
(6)

Let \(N \leqslant \lceil \beta ^4 (n+1) (n+m+1) \rceil \) be the smallest integer such that

$$\begin{aligned} r \hspace{1.111pt}{\cdot }\hspace{1.111pt}2^{2^N}\! > m. \end{aligned}$$
(7)

By (6), it holds that \(N \leqslant {{\,\textrm{poly}\,}}\hspace{0.99991pt}(n, m, \log L) \leqslant {{\,\textrm{poly}\,}}\hspace{0.44998pt}(|{\Phi } |)\). Define .

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 \(\bot (\Psi )\) by C and in particular the radius of the open ball in \(\bot (\Psi )\). Let \(U = (U_0, \ldots , U_N) \in [-1,1]\) be \(N+1\) new variables and \(\chi (U)\) be the formula (2). Recall that by Lemma 3.5, for \(u \in [-1,1]^{N+1}\) we have \(\chi (u)\) if and only if . With this, we define

$$\begin{aligned} \phi (X,Y,U) \ :\equiv \ \chi (U) \wedge \psi (U_N X, Y), \end{aligned}$$

where \(U_N X\) means that every occurrence of \(X_i\) in \(\psi \) is replaced by \(U_N X_i\). Finally we are ready to define our desired Hausdorff instance:

$$\begin{aligned} A&:=\bigl \{(x,y,u) \in [-C,C]^n \hspace{0.55542pt}{\times }\hspace{1.111pt}[-1,1]^{m} \hspace{0.55542pt}{\times }\hspace{1.111pt}\bigl \{2^{-2^0}\bigr \} \hspace{1.111pt}{\times }\hspace{1.111pt}\cdots \hspace{1.111pt}{ \times }\hspace{1.111pt}\bigl \{2^{-2^N}\bigr \} \mid \phi (x,y,u)\bigr \}, \\ B&:=[-C,C]^n \hspace{0.55542pt}{\times }\hspace{1.111pt}\{0\}^m \hspace{0.55542pt}{\times }\hspace{1.111pt}\bigl \{2^{-2^0}\bigr \} \hspace{1.111pt}{\times }\hspace{1.111pt}\cdots \hspace{1.111pt}{\times }\hspace{1.111pt}\bigl \{2^{-2^N}\bigr \}, \\ t&:=m. \end{aligned}$$

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 \(\phi \) from \(\Phi \): It always holds that

$$\begin{aligned} \emptyset \ne \{0\}^{n} \hspace{0.55542pt}{\times }\hspace{1.111pt}[-1,1]^m \hspace{0.55542pt}{\times }\hspace{1.111pt}\bigl \{2^{-2^0}\bigr \} \hspace{0.55542pt}{\times }\hspace{1.111pt}\cdots \hspace{1.111pt}{\times }\hspace{1.111pt}\bigl \{2^{-2^N}\bigr \}\subseteq A. \end{aligned}$$

Equivalence of \(\Phi \) and (ABt). To see that \(\Phi \) and (ABt) are equivalent, assume first that \(\Phi \) is true. For every point \(a := (x, y, u) \in A\) it must hold that as this is necessary to satisfy \(\chi (u)\). Consider the point \(b := (x,\{0\}^n, u) \in B\). We get

$$\begin{aligned} \Vert {a - b} \Vert = \Vert {(x,y,u) - (x,\{0\}^m,u)} \Vert = \Vert {y - \vec {0}} \Vert \leqslant {\sqrt{\sum _{i=1}^m 1}}= \sqrt{m}\leqslant m= t. \end{aligned}$$

As a was chosen arbitrarily, we get an upper bound for the directed Hausdorff distance \(\vec {d}_{H }(A,B) \leqslant t\). On the other hand, consider an arbitrary point \(b := (x, \{0\}^m, u) \in B\). Because \(\Phi \) (and therefore \(\Psi \)) is true, there is some \(y \in [-1,1]^m\) such that there is a point \(a := (x, y, u) \in A\). By the same calculation as above, we get \(\vec {d}_{H }(B,A) \leqslant t\) and thus

$$\begin{aligned} d_{H }(A,B) \leqslant t. \end{aligned}$$
(8)

Now assume that \(\Phi \) and \(\Psi \) are false. Then there is some \(x \in [-1,1]^n\) such that there is an n-dimensional open ball \(B_n(x, r) \subseteq \bot (\Psi )\) (the r here is the one from (6)). By the construction of A, this corresponds to an open ball of radius Cr in \(\mathbb {R} ^n\setminus A\). Let \(x^*\) be the center of this open ball in \(\mathbb {R} ^n\setminus A\). Then for \(b := (x^*,\{0\}^m,u) \in B\) all points \(a \in A\) have

$$\begin{aligned} \Vert {a - b} \Vert \geqslant Cr> m= t. \end{aligned}$$

It follows that

$$\begin{aligned} d_{H }(A,B)\geqslant \vec {d}_{H }(B,A)\geqslant \Vert {a - b} \Vert > t. \end{aligned}$$
(9)

Equations (8) and (9) prove that \(d_{H }(A,B) \leqslant t\) (and also \(\vec {d}_{H }(B,A) \leqslant t\)) if and only if \(\Phi \) is true. \(\square \)

In the proof of Theorem 5.1, we could choose \(N':=N+1\) instead of N in (7). Then in the case that \(\Phi \) is false, the Hausdorff distance \(d_{H }(A,B)\) is at least

$$\begin{aligned} 2^{2^{N+1}} r> 2^{2^{N+1}-2^N} m= 2^{2^N} m= 2^{2^N} t. \end{aligned}$$

Note that the number of free variables in the formulas describing the resulting sets A and B equals \(n + m + N' +1 = \Theta (N)\). We created a gap of size . This implies the following inapproximability result.

Corollary 1.2

Let A and B be two semi-algebraic sets in \(\mathbb {R} ^n\) and . There is no polynomial-time f(n)-approximation algorithm to compute \(d_{H }(A,B)\), unless \(\mathsf{{P}} = { \forall \exists _{<}\mathbb {R}} \).

Another interesting observation is that we can restrict the sets A and B to be described by syntactically simple formulas. We can express both formulas as a conjunction of (down to one) polynomial equation(s) with bounded degree at the expense of adding a polynomial number of new variables.

Corollary 1.3

The Hausdorff problem remains \(\forall \exists _{<}\mathbb {R} \)-complete, even if the two sets A and B are both described either by

  1. (i)

    a conjunction of quadratic polynomial equations, or

  2. (ii)

    a single polynomial equation of degree at most four.

Proof

Taking the formula \(\psi \) in the proof of Theorem 5.1, we apply Lemma 2.1 (i) to obtain an equivalent new formula \(\psi '\) (with additional existentially quantified variables) which is a conjunction of quadratic polynomial equations. Then set A can be defined using \(\psi '\) instead of \(\psi \). Set B can be trivially described in the desired form. This shows statement (i). For (ii), we modify the above procedure by applying Lemma 2.1 (ii) to \(\psi \) to obtain an equivalent formula which is a single polynomial of degree at most four.\(\square \)

6 \(\forall \exists _{<}\mathbb {R} \)-Membership of Hausdorff

This section is devoted to showing the following theorem.

Theorem 6.1

Hausdorff and Directed Hausdorff are contained in \({ \forall \exists _{<}\mathbb {R}} \).

Note that \(\forall \exists _{}\mathbb {R} \)-membership has been already shown by Dobbins et al. [27]. The remainder of this section deals with reformulating a given Hausdorff instance into a Strict-UETR instance, thereby proving \({ \forall \exists _{<}\mathbb {R}} \)-membership.

Let (ABt) be a Hausdorff instance, where \(A = \{x \in \mathbb {R} ^n \mid \varphi _A(x)\}\) and \(B = \{x \in \mathbb {R} ^n \mid \varphi _B(x)\}\) are described by quantifier-free formulas \(\varphi _A\) and \(\varphi _B\) with n free variables each. For simplicity, we only consider the directed Hausdorff distance here, namely the question whether

$$\begin{aligned} \vec {d}_{H }(A,B) :=\sup _{a \in A} \inf _{b \in B} \, \Vert {a - b} \Vert {\mathop {\leqslant }\limits ^{?}} t. \end{aligned}$$

It is obvious, that \(d_{H }(A,B) \leqslant t\) if and only if \(\vec {d}_{H }(A,B) \leqslant t\) and \(\vec {d}_{H }(B,A) \leqslant t\). 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 \(\vec {d}_{H }(A,B) \leqslant t\) is equivalent to

$$\begin{aligned} \forall \, \varepsilon > 0,\, a \in A \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, b \in B \hspace{0.55542pt}:\hspace{0.55542pt}\Vert {a - b} \Vert ^2 < t^2 + \varepsilon . \end{aligned}$$
(10)

Let us remark that introducing the real variable \(\varepsilon \) is necessary to also consider the points in the closure of B. Moreover, we work with the squared distance between a and b, because \(\Vert {a - b} \Vert \) 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. [25] such that \(\forall \exists _{<}\mathbb {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 6.4 below is used again in Sect. 7. The first lemma allows us to transform a UETR instance of special structure into an equivalent Strict-UETR instance:

Lemma 6.2

Given a UETR instance

$$\begin{aligned} \Phi \ :\equiv \ \forall \, X \in [-1,1]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-1,1]^m:\hspace{0.55542pt}\varphi _<(X,Y) \vee H(X,Y) = 0, \end{aligned}$$

where \(\varphi _<(X,Y) \in { \mathrm {QFF_{<}}} \) and \(H :[-1,1]^{n+m}\rightarrow \mathbb {R} \) is a polynomial. Then we can compute in polynomial time an equivalent Strict-UETR instance.

Proof

We first prove that there exists an integer \(N \leqslant {{\,\textrm{poly}\,}}\hspace{0.44434pt}(|{\Phi } |)\), such that the Strict-UETR instance

$$\begin{aligned} \Psi \ :\equiv \ \forall \, X \in [-1,1]^n\hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, Y \in [-1,1]^m:\hspace{0.55542pt}\varphi _<(X,Y) \vee H(X,Y)^2 < 2^{-2^N} \end{aligned}$$

is equivalent to \(\Phi \). In a second step, we construct inside the formula.

The direction \(\Phi \,{\Rightarrow }\, \Psi \) is trivially true for any \(N \in \mathbb {N} \). To prove the other direction, we show its contraposition \(\lnot \,\Phi \,{\Rightarrow }\, \lnot \,\Psi \). Assume that

$$\begin{aligned} \lnot \,\Phi \ \equiv \ \exists \, X \in [-1,1]^n\hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \, Y \in [-1,1]^m:\hspace{0.55542pt}\lnot \,\varphi _<(X,Y) \wedge H(X,Y)^2 > 0 \end{aligned}$$

is true. Hence for at least one fixed \(x \in [-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

$$\begin{aligned} \exists \,\varepsilon > 0 \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, X \in [-1,1]^n\hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \, Y \in [-1,1]^m:\hspace{0.55542pt}\lnot \,\varphi _<(X,Y) \wedge H(X,Y)^2 \geqslant \varepsilon \end{aligned}$$
(11)

is true. Let L be the length of the quantifier-free part in (11). By Lemma 3.4 there is a constant \(\beta \in \mathbb {R} \) such that \(\exists \,\varepsilon >0\) in (11) can be strengthened to . Now choose \(N \leqslant \lceil \beta ^{4}(n+1)(m+1) \rceil \) to be the smallest integer satisfying . Note that \(N \leqslant {{\,\textrm{poly}\,}}\hspace{1.05545pt}(n,m, \log L)\), so it is polynomial in the input size. Plugging in the lower bound on \(\varepsilon \), we get that \(\lnot \,\Phi \) is equivalent to

$$\begin{aligned} \exists \, X \in [-1,1]^n\hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \,Y \in [-1,1]^m:\hspace{0.55542pt}\lnot \,\varphi _<(X,Y) \wedge H(X,Y)^2 \geqslant 2^{-2^N}\!, \end{aligned}$$

which is exactly \(\lnot \,\Psi \). We conclude that \(\Phi \equiv \Psi \) as claimed.

To construct a Strict-UETR instance from \(\Psi \), we need to express  inside the formula. To this end, introduce \(N + 1\) new variables \(U = (U_0, \ldots , U_N) \in [-1,1]^{N+1}\) and let \(\chi (U)\) be the formula (2). Recall that by Lemma 3.5, \(\chi (u)\) is true if and only if . Including \(\chi (U)\) into our formula, we conclude that

$$\begin{aligned} {\begin{matrix} &{}\forall \, X, U \in [-1,1]^{n + N + 1}\, . \,\hspace{0.55542pt}\exists \,Y \in [-1,1]^m\, :\\ &{}\qquad \lnot \,\chi (U) \vee \lnot \,\varphi _<(X,Y) \vee H(X,Y)^2 < U_N \end{matrix}} \end{aligned}$$
(12)

is equivalent to \(\Phi \). 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. [25]. They show that it is \(\exists \forall _{\leqslant }\mathbb {R} \)-complete to decide a sentence of the form

$$\begin{aligned} \exists \, X \in [-1,1]^n\, . \,\hspace{0.55542pt}\forall \, Y \in [-1,1]^m:\hspace{0.55542pt}\varphi _\leqslant (X,Y) \end{aligned}$$

with \(\varphi _\leqslant \in { \mathrm {QFF_{\leqslant }}} \). Because \({ \exists \forall _{\leqslant }\mathbb {R}} = \mathsf{{co}\text {-}}{ \forall \exists _{<}\mathbb {R}} \), deciding the complements of these sentences, i.e., sentences of the form

$$\begin{aligned} \forall \,X \in [-1,1]^n \, . \,\hspace{0.55542pt}\exists \,Y \in [-1,1]^m:\hspace{0.55542pt}\varphi _<(X,Y) \end{aligned}$$

with \(\varphi _< \in { \mathrm {QFF_{<}}} \) is \(\forall \exists _{<}\mathbb {R} \)-complete. Sentence (12) is of this form. Thus there is a polynomial-time reduction to an equivalent Strict-UETR instance. \(\square \)

The next lemma establishes an upper bound on the value of a polynomial over a compact domain.

Lemma 6.3

Let \(P :\mathbb {R} ^n \rightarrow \mathbb {R} \) be a polynomial, N be an integer and . Then we can compute in polynomial time an integer \(K\leqslant {{\,\textrm{poly}\,}}\hspace{1.04431pt}(|{P} |, N, n)\) such that for and all \(x \in [-C,C]^n\) it holds that \(|{P(x)} | \leqslant E\).

Proof

Because P is a polynomial, \(|{P} |\) is continuous and therefore \(|{P} |\) attains its maximum over any compact domain. We conclude that

$$\begin{aligned} \exists \, E \in \mathbb {R} \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \, X \in [-C,C]^n:\hspace{0.55542pt}|{P(X)} | \leqslant E \end{aligned}$$

is true. Note that, strictly speaking, we may not use \(|{\,{\cdot }\,} |\) inside the formula. However, \(|{P(X)} | \leqslant E\) is equivalent to \(P(X) \leqslant E \wedge -P(X) \leqslant E\).

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, \ldots , U_N\}\) and let \(\chi (U)\) be the formula (2). Recall that by Lemma 3.5, \(\chi (u)\) is true if and only if . Now we can rewrite the above formula equivalently as

$$\begin{aligned} \exists \, E \in \mathbb {R} \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\forall \, X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, U \in \mathbb {R} ^{N+1} :\hspace{1.111pt}\bigwedge \limits _{i = 1}^n\hspace{0.55542pt}|{X_i U_N} | \leqslant 1\ \Rightarrow \ |{P(X)} | \leqslant E. \end{aligned}$$

Let \(\varphi (E)\) be the subformula following the quantification of E (starting from \(\forall \)) and \(L := |{\varphi (E)} |\). Applying quantifier elimination (Corollary 3.2) to \(\varphi (E)\), we obtain a constant \(\alpha \in \mathbb {R} \) and an equivalent, quantifier-free formula \(\psi (E)\) of length

$$\begin{aligned} |{\psi (E)} | \leqslant L^{2\alpha ^3(n+1)(N+2)}. \end{aligned}$$

The Ball Theorem 3.3 applied to \(\exists \, E \in \mathbb {R}: \psi (E)\) now yields an upper bound for E:

$$\begin{aligned} E \leqslant 2^{|{\psi } |^8}\! \leqslant 2^{L^{16 \alpha ^3 (n+1) (N+2)}}\! =2^{2^{16 \alpha ^3 (n+1) (N+2) \log (|{\psi } |)}}. \end{aligned}$$

Choose \(K = \lceil 16\hspace{0.66666pt}\alpha ^3 (n+1) (N+2) \log \hspace{0.7222pt}(|{\psi } |)\rceil \). Obviously, \(K \leqslant {{\,\textrm{poly}\,}}\hspace{0.99991pt}(\log |{\psi } |, N, n)\). Since \(|{\psi } | \leqslant {{\,\textrm{poly}\,}}\hspace{1.05545pt}(|{P} |, n, N)\), the claim follows. \(\square \)

The above lemma is used to prove the following lemma which allows us to transform some more general UETR instances into equivalent Strict-UETR instances.

Lemma 6.4

Given a UETR instance

$$\begin{aligned} \forall \, \varepsilon> 0,\, X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m:\hspace{0.55542pt}F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) < \varepsilon ), \end{aligned}$$

where \(F :\mathbb {R} ^n \rightarrow \mathbb {R} \), \(G :\mathbb {R} ^m \rightarrow \mathbb {R} \), and \(P :\mathbb {R} ^{n+m} \!\rightarrow \mathbb {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 6.2. The first step is to move the condition that \(\varepsilon > 0\) into the formula. We obtain an equivalent sentence

$$\begin{aligned}&\forall \, \varepsilon \in \mathbb {R},\,X \in \mathbb {R} ^n\, :\\&\qquad (\varepsilon> 0)\;{\Rightarrow }\;(\exists \, Y \in \mathbb {R} ^n:\hspace{0.55542pt}F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) < \varepsilon )). \end{aligned}$$

Now we observe that \(\varepsilon > 0\) is equivalent to \(\exists \, \delta \in \mathbb {R}: \delta ^2\varepsilon - 1 = 0\). Incorporating this yields an equivalent sentence

$$\begin{aligned} \forall \,\varepsilon \in \mathbb {R},\, X \in \mathbb {R} ^n\!&\,:\,(\exists \, \delta \in \mathbb {R}: \delta ^2\varepsilon - 1 = 0)\ \Rightarrow \\&\,\,(\exists \, Y \in \mathbb {R} ^m \hspace{0.55542pt}:\hspace{0.55542pt}F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) < \varepsilon )). \end{aligned}$$

Rewriting the implication \(A \,{\Rightarrow }\, B\) as \(\lnot \hspace{0.55542pt}A \vee B\) turns the existential quantifier in front of \(\delta \) into a universal quantifier. Furthermore, we replace \(\lnot \,(\delta ^2\varepsilon - 1 = 0)\) by the equivalent \((\delta ^2\varepsilon - 1)^2 > 0\). We get an equivalent sentence

$$\begin{aligned} \forall \,\varepsilon \in \mathbb {R},\, X \in \mathbb {R} ^n :\,&(\forall \, \delta \in \mathbb {R} \hspace{0.55542pt}:\hspace{0.55542pt}(\delta ^2\varepsilon - 1)^2> 0)\ \vee \\&(\exists \, Y \in \mathbb {R} ^m \hspace{0.55542pt}:\hspace{0.55542pt}F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) < \varepsilon )). \end{aligned}$$

Moving all quantifiers to the front, turns this into an equivalent prenex normal form

$$\begin{aligned}&\forall \,\varepsilon \in \mathbb {R}, \,\delta \in \mathbb {R}, \,X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m\,:\\&\quad (\delta ^2\varepsilon + 1)^2> 0 \vee F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) < \varepsilon ). \end{aligned}$$

This sentence is \(\forall \)-strict, so Lemmas 3.6 and 3.7 are applicable. Thus, there are two integers NM bounded by a polynomial in the length of the sentence, such that for and 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

$$\begin{aligned}&\forall \,\varepsilon \in [-C,C], \,\delta \in [-C,C], \,X \in [-C,C]^n \, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D]^m\,:\\&\quad (\delta ^2\varepsilon + 1)^2> 0 \vee F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) < \varepsilon ). \end{aligned}$$

In the next step, we replace the strict inequality \(P(X,Y) < \varepsilon \) by the non-strict inequality \(P(X,Y) \leqslant \varepsilon \). For this step, we exploit the fact that a continuous function over a compact domain attains its minimum and maximum. Consequently, the sentence \(\forall \, \varepsilon >0, \,X\in [-C,C] \hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, Y\in [-D,D]\hspace{0.55542pt}:\hspace{0.55542pt}P(X,Y)<\varepsilon \) is (true if and only if \(\max _{X\in [-C,C]}\min _{Y\in [-D,D]} P(X,Y)\leqslant 0\) and thus) equivalent to \(\forall \,\varepsilon >0, \,X\in [-C,C]\hspace{0.55542pt}\, . \,\hspace{0.55542pt}Y\in [-D,D] \hspace{0.55542pt}:\hspace{0.55542pt}P(X,Y) \leqslant \varepsilon \). We obtain the equivalent sentence

$$\begin{aligned}&\forall \, \varepsilon \in [-C,C],\, \delta \in [-C,C],\, X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D]^m\, :\\&\quad (\delta ^2\varepsilon + 1)^2> 0 \vee F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) \leqslant \varepsilon ). \end{aligned}$$

Going one step further, we now want to express \(P(X,Y) \leqslant \varepsilon \) as a polynomial equation. To this end, we replace it by the equivalent formula \(\exists \,B\in \mathbb {R}:P(X,Y)-\varepsilon + B^2 = 0\). By Lemma 6.3, we can also bound the range over which B is quantified: We can compute in polynomial time an integer \(K \leqslant {{\,\textrm{poly}\,}}\hspace{1.27777pt}(|{P} |, \max \hspace{1.05545pt}\{N,M\}, n + m + 1)\) such that . We get another equivalent sentence

$$\begin{aligned}&\forall \,\varepsilon \in [-C,C],\, \delta \in [-C,C], \,X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D]^m,\, B \in [E,E]\, :\\&\quad (\delta ^2\varepsilon + 1)^2> 0 \vee F(X)^2 > 0 \vee (G(Y) = 0 \wedge P(X,Y) - \varepsilon + B^2 = 0). \end{aligned}$$

At this point we define

$$\begin{aligned} \varphi _<(\varepsilon , \delta , X)> 0&\,:=\,(\delta ^2\varepsilon + 1)^2 \vee F(X)^2 > 0\ \quad \text {and} \\ H(X, Y, \varepsilon , B)&\,:=\, G(Y)^2 + (P(X,Y) - \varepsilon + B^2)^2. \end{aligned}$$

Note that \(\varphi _< \in { \mathrm {QFF_{<}}} \). We use these to get the equivalent sentence

$$\begin{aligned}&\forall \, \varepsilon \in [-C,C],\, \delta \in [-C,C],\, X \in [-C,C]^n\, . \,\hspace{0.55542pt}\exists \, Y \in [-D,D]^m,\, B \in [E,E]\, :\\&\qquad \qquad \varphi _<(\varepsilon , \delta , X) \vee H(X, Y, \varepsilon , B) = 0. \end{aligned}$$

The last step is to scale all variables to be in the interval \([-1,1]\). For this, let \(S :=\max \hspace{0.99991pt}\{N, M, K\}\) and introduce \(S + 1\) new variables \(U = \{U_0, \ldots , U_S\}\). Furthermore, let \(\chi (U)\) be the formula (2). Recall that by Lemma 3.5, \(\chi (u)\) is true if and only if . We can rewrite our sentence to the equivalent sentence

$$\begin{aligned}&\forall \, \varepsilon , \delta , X, U \in [-1,1]^{1 + 1 + n + S + 1} \, . \,\hspace{0.55542pt}\exists \, Y, B \in [-1,1]^{m + 1}\, :\\&\qquad \lnot \,\chi (U) \vee U_S^d\cdot \varphi _<\biggl (\frac{\varepsilon }{U_S}\hspace{0.55542pt}, \frac{\delta }{U_S}\hspace{0.55542pt}, \frac{X}{U_S}\biggr )\hspace{0.66666pt}\vee \hspace{0.66666pt}U_S^d \cdot H\biggl (\frac{X}{U_S}\hspace{0.55542pt}, \frac{Y}{U_S}\hspace{0.55542pt}, \frac{\varepsilon }{U_S}\hspace{0.55542pt}, \frac{B}{U_S}\biggr ) = 0. \end{aligned}$$

Here d is the maximum degree of any polynomial in \(\varphi _<\) and H. By \(X/U_S\) we denote that every variable \(X_i\) is replaced by \(X_i/U_S\). Multiplying by \(U_S^d\) makes sure that each atom remains a polynomial. What we obtained is a UETR instance that has the form required by Lemma 6.2 (note that \(\lnot \,\chi (U)\) is strict). Therefore, we can transform this into an equivalent Strict-UETR instance in polynomial time. \(\square \)

Now we finally have all the needed tools to prove Theorem 6.1 which states that the Hausdorff problem is contained in \({ \forall \exists _{<}\mathbb {R}} \). We do this by transforming formula (10) into the form required by Lemma 6.4. This then yields an equivalent Strict-UETR instance, thus proving \(\forall \exists _{<}\mathbb {R} \)-membership.

Proof of Theorem 6.1

Recall that \(\vec {d}_{H }(A,B) \leqslant t\) is equivalent to (10), which is

$$\begin{aligned} \forall \,\varepsilon > 0, \,a \in A\hspace{0.55542pt}\, . \,\hspace{0.55542pt}\exists \, b \in B \hspace{0.55542pt}:\hspace{0.55542pt}\Vert {a - b} \Vert ^2 < t^2 + \varepsilon . \end{aligned}$$

In a first step, we resolve the shorthand notations \(a \in A\) and \(b\in B\) and we obtain

$$\begin{aligned} \forall \, \varepsilon > 0,\, a \in \mathbb {R} ^n\,:\,\varphi _A(a)\;{\Rightarrow }\;(\exists \, b \in \mathbb {R} ^n:\varphi _B(b) \wedge \Vert {a - b} \Vert ^2 < t^2 + \varepsilon ). \end{aligned}$$

Next, we consider the (quantifier-free) formulas \(\varphi _A(a)\) and \(\varphi _B(b)\). Using Lemma 2.1, we obtain in polynomial time two integers \(k,\ell \) and two polynomials \(F_A :\mathbb {R} ^{n+k} \rightarrow \mathbb {R} \) and \(F_B :\mathbb {R} ^{n+\ell } \rightarrow \mathbb {R} \), such that \(\varphi _A(a)\) is equivalent to \(\exists \,U_a \in \mathbb {R} ^k:F_A(a,U_a) = 0\) and similarly \(\varphi _B(b)\) is equivalent to \(\exists \, U_b \in \mathbb {R} ^\ell : F_B(b,U_b) = 0\). This yields the equivalent sentence

$$\begin{aligned} \forall \, \varepsilon > 0, \,a \in \mathbb {R} ^n\, :&\,(\exists \, U_a \in \mathbb {R} ^k: F_A(a, U_a) = 0)\ \Rightarrow \\&(\exists \, b \in \mathbb {R} ^n, \,U_b \in \mathbb {R} ^\ell : F_B(b, U_b) = 0 \wedge \Vert {a - b} \Vert ^2 < t^2 + \varepsilon ). \end{aligned}$$

Rewriting the implication \(X\,{\Rightarrow }\,Y\) as \(\lnot \, X \vee 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 \(\lnot \,(F(a,U_a) = 0)\) by \(F(a,U_a)^2 > 0\), we get the equivalent sentence

$$\begin{aligned}&\forall \,\varepsilon> 0, \,a \in \mathbb {R} ^n,\, U_a \in \mathbb {R} ^k\,:\\&\qquad F_A(a, U_a)^2 > 0\;\vee \;(\exists \, b \in \mathbb {R} ^n,\, U_b \in \mathbb {R} ^\ell : F_B(b, U_b) = 0 \wedge \Vert {a - b} \Vert ^2 < t^2 + \varepsilon ). \end{aligned}$$

Lastly, we move the existential quantifier after the universal one and get an equivalent sentence

$$\begin{aligned}&\forall \,\varepsilon> 0, \,a \in \mathbb {R} ^n,\, U_a \in \mathbb {R} ^k\, . \,\hspace{0.55542pt}\exists \, b \in \mathbb {R} ^n,\, U_b \in \mathbb {R} ^\ell \, : \\&\quad F_A(a, U_a)^2 > 0 \vee (F_B(b, U_b) = 0 \wedge \Vert {a - b} \Vert ^2 < t^2 + \varepsilon ) \end{aligned}$$

in prenex normal form. This sentence has the form required by Lemma 6.2, concluding the proof. \(\square \)

7 Exotic Quantifiers

In this section, we show an interesting connection of the complexity class \({ \forall \exists _{<}\mathbb {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 \(\exists \mathbb {R} \), \(\forall \mathbb {R} \), and \(\forall \exists _{}\mathbb {R} \) appear under the names \({\textsf {BP}}^0(\exists )\), \({\textsf {BP}}^0(\forall )\), and \({\textsf {BP}}^0(\forall \exists )\), 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 the class \({ \forall \exists _{<}\mathbb {R}} \), supposedly between \(\exists \mathbb {R} \)/\(\forall \mathbb {R} \) and \(\forall \exists _{}\mathbb {R} \). See also the paper by D’Costa et al. [25], where they show that their escape problem is \({ \exists \forall _{\leqslant }\mathbb {R}} \)-complete, though supposedly between \(\exists \mathbb {R} \)/\(\forall \mathbb {R} \) and \(\exists \forall _{}\mathbb {R} \).

The approach in this paper and in [25] is to make syntactic restrictions to the quantifier-free 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 \(\forall \exists _{<}\mathbb {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:

$$\begin{aligned} \forall ^*X \in \mathbb {R} ^n\hspace{0.55542pt}:\hspace{0.55542pt}\varphi (X)&\ :\equiv \ \forall \, \varepsilon> 0, \,X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, \widetilde{X} \in \mathbb {R} ^n:\hspace{0.55542pt}\Vert {X - \widetilde{X}} \Vert ^2< \varepsilon \wedge \varphi (\widetilde{X}), \\ \exists ^*X \in \mathbb {R} ^n \hspace{0.55542pt}:\hspace{0.55542pt}\varphi (X)&\ :\equiv \ \exists \, \varepsilon > 0,\, X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\forall \, \widetilde{X} \in \mathbb {R} ^n:\hspace{0.55542pt}\Vert {X - \widetilde{X}} \Vert ^2 < \varepsilon \;{\Rightarrow }\;\varphi (\widetilde{X}). \end{aligned}$$

Intuitively, \(\forall ^*X \in \mathbb {R} ^n \,{:}\, \varphi (X)\) means that \(\varphi (x)\) does not need to be true for all \(x \in \mathbb {R} ^n\) but just for all \(x \in D\), where D is some dense subset of \(\mathbb {R} ^n\). Conversely, \(\exists ^*X \in \mathbb {R} ^n \,{:}\, \varphi (X)\) means that there must be an \(x \in \mathbb {R} ^n\) and some radius \(r > 0\), such that for all \(\widetilde{x} \in B_n(x, r)\) it holds that \(\varphi (\widetilde{x})\), where \(B_n(x, r)\) denotes the n-dimensional open ball of radius r centered at x. As one would expect, it holds that

$$\begin{aligned} \lnot \,\forall ^*X \in \mathbb {R} ^n:\hspace{0.55542pt}\varphi (X)&\ \equiv \ \exists ^*X \in \mathbb {R} ^n:\hspace{0.55542pt}\lnot \,\varphi (X)\quad \text {and} \\ \lnot \,\exists ^*X \in \mathbb {R} ^n:\hspace{0.55542pt}\varphi (X)&\ \equiv \ \forall ^*X \in \mathbb {R} ^n:\hspace{0.55542pt}\lnot \,\varphi (X). \end{aligned}$$

Theorem 1.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

$$\begin{aligned} \forall ^*X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m:\hspace{0.55542pt}\varphi (X,Y) \end{aligned}$$

with quantifier-free \(\varphi \) is true. Further, we define the complexity class \(\forall ^*\exists \mathbb {R} \) to contain all problems that polynomial-time many-one reduce to Exotic-UETR. We show that the complexity classes \(\forall ^*\exists \mathbb {R} \) and \({ \forall \exists _{<}\mathbb {R}} \) coincide.

Theorem 1.4

Exotic-UETR is \(\forall \exists _{<}\mathbb {R} \)-complete. Thus \(\forall ^*\exists \mathbb {R} = { \forall \exists _{<}\mathbb {R}} \).

Proof

The \(\forall \exists _{<}\mathbb {R} \)-hardness of Exotic-UETR follows directly from Theorem 4.2. For a given Strict-UETR instance

$$\begin{aligned} \Phi \ :\equiv \ \forall \, X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m:\hspace{0.55542pt}\varphi _<(X,Y) \end{aligned}$$

with \(\varphi _< \in { \mathrm {QFF_{<}}} \), Theorem 4.2 allows to compute in polynomial time an equivalent UETR instance

$$\begin{aligned} \Psi \ :\equiv \ \forall \, X \in \mathbb {R} ^k\, . \,\hspace{0.55542pt}\exists \,Y \in \mathbb {R} ^\ell :\hspace{0.55542pt}\psi (X,Y) \end{aligned}$$

with \(\psi \in { \mathrm {QFF_{}}} \). Recall that on the one hand, if \(\Psi \) is false, then the set of counterexamples \(\bot (\Psi )\) contains an open ball. On the other hand, if \(\Psi \) is true, then \(\bot (\Psi ) = \emptyset \). Therefore, \(\Psi \) is true if and only if it is true for a dense subset of \(\mathbb {R} ^k\). It follows that the \(\forall \)-quantifier can be replaced by the exotic \(\forall ^*\)-quantifier in \(\Psi \) and we get

$$\begin{aligned} \Phi \ \equiv \ \Psi \ \equiv \ \forall ^*X \in \mathbb {R} ^k\, . \,\hspace{0.55542pt}\exists \,Y \in \mathbb {R} ^\ell :\hspace{0.55542pt}\psi (X,Y). \end{aligned}$$

Consequently, Exotic-UETR is \(\forall \exists _{<}\mathbb {R} \)-hard.

To prove that Exotic-UETR is contained in \(\forall \exists _{<}\mathbb {R} \), we transform

$$\begin{aligned} \forall ^*X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, Y \in \mathbb {R} ^m:\hspace{0.55542pt}\varphi (X,Y) \end{aligned}$$

in polynomial time into an equivalent sentence of the form required by Lemma 6.4. This lemma allows us to construct an equivalent Strict-UETR instance in polynomial time, thereby proving \(\forall \exists _{<}\mathbb {R} \)-membership. We start by expressing the exotic quantifier \(\forall ^*\) in terms of classical quantifiers \(\forall \) and \(\exists \), obtaining an equivalent sentence

$$\begin{aligned} \forall \, \varepsilon > 0,\, X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, X_0 \in \mathbb {R} ^n,\, Y \in \mathbb {R} ^m:\hspace{0.55542pt}\Vert {X - X_0} \Vert ^2 < \varepsilon \hspace{0.55542pt}\wedge \hspace{0.55542pt}\varphi (X_0, Y). \end{aligned}$$

By Lemma 2.1 we can compute in polynomial time an integer k and a polynomial \(G :\mathbb {R} ^{n + m + k} \rightarrow \mathbb {R} \) such that \(\varphi (X_0,Y)\) is equivalent to \(\exists \, U \in \mathbb {R} ^k : G(X_0, Y, U) = 0\). Plugging this into above sentence, we get another equivalent sentence

$$\begin{aligned}{} & {} \forall \, \varepsilon > 0, \,X \in \mathbb {R} ^n\, . \,\hspace{0.55542pt}\exists \, X_0 \in \mathbb {R} ^n,\, Y \in \mathbb {R} ^m,\, U \in \mathbb {R} ^k: \\ {}{} & {} \hspace{0.55542pt}\Vert {X - X_0} \Vert ^2 < \varepsilon \wedge G(X_0, Y, U) = 0. \end{aligned}$$

This has the form required by Lemma 6.4. Hence, \(\forall \exists _{<}\mathbb {R} \)-membership follows. \(\square \)

7.1 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 \(\overline{B}\). Note that ERD is equivalent to deciding whether \(\vec {d}_{H }(A,B)= 0\). Bürgisser and Cucker show:

Theorem 7.1

[20, Cor. 5.6] ERD is in \(\forall \exists _{}\mathbb {R} \) and \(\forall ^*\exists \mathbb {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).

Theorem 7.2

ERD is \(\forall \exists _{<}\mathbb {R} \)-complete.

Proof

By Theorem 1.4 and \(\forall ^*\exists \mathbb {R} \)-hardness from Theorem 7.1, it follows that ERD is \(\forall \exists _{<}\mathbb {R} \)-hard. Further, Theorem 6.1 implies that ERD is contained in \(\forall \exists _{<}\mathbb {R} \). Consequently, ERD is \(\forall \exists _{<}\mathbb {R} \)-complete. \(\square \)

Moreover, we remark that \(\forall \exists _{<}\mathbb {R} \)-hardness of ERD implies \(\forall \exists _{<}\mathbb {R} \)-hardness of the general directed Hausdorff problem (for any distance \(t\geqslant 0\)): Given an instance \(A,B\subseteq \mathbb {R} ^n\) of ERD, we define \(A' := (A,0) \subseteq \mathbb {R} ^{n+1}\) and \(B' := (B,1) \subseteq \mathbb {R} ^{n+1}\). Then \(\vec {d}_{H }(A,B) = 0\) if and only if \(\vec {d}_{H }(A',B') \leqslant 1\).

8 Open Problems

We showed that the Hausdorff problem is \(\forall \exists _{<}\mathbb {R} \) complete. We conclude the paper with a list of interesting open questions:

While \(\exists \mathbb {R} = \exists _{\leqslant }\mathbb {R} = \exists _<\mathbb {R} \) and \(\forall \mathbb {R} = \forall _{\leqslant }\mathbb {R} = \forall _{<}\mathbb {R} \) are known [46], similar results are unknown for higher levels of the hierarchy. In this context, we are particularly interested in the following question:

Problem 1

Are the two complexity classes \(\forall \exists _{<}\mathbb {R} \) and \(\forall \exists _{}\mathbb {R} \) actually the same?

Regarding 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. In a recent and still unpublished preprint Schaefer and Štefankovič [47] claim that \({ \forall \exists _{}\mathbb {R}} = { \forall \exists _{<}\mathbb {R}} \). This would also answer our second open problem.

Problem 2

What is the computational complexity of deciding \(\forall \)-strict  UETR instances?

By definition, deciding \(\forall \)-strict  UETR instances is \(\forall \exists _{<}\mathbb {R} \)-hard and in \(\forall \exists _{}\mathbb {R} \). The most important tools for showing \(\forall \exists _{<}\mathbb {R} \)-membership in this paper and also in [25] are the range restrictions for the quantified variables (Lemmas 3.6 and 3.7). These are still applicable to \(\forall \)-strict formulas. However, this seems not enough to transform an arbitrary \(\forall \)-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 6.4 (and therefore Theorem 6.1 proving that Hausdorff is in \(\forall \exists _{<}\mathbb {R} \)).

Our third open problem concerns even more restricted versions of the Hausdorff problem that remain hard. As already noted in Corollary 1.3, Hausdorff remains \(\forall \exists _{<}\mathbb {R} \)-hard if all atoms in the formulas describing A and B are quadratic equations.

Problem 3

What is the most restricted version of the Hausdorff problem that is still \(\forall \exists _{<}\mathbb {R} \)-hard?

There are several directions to explore on Problem 3. Identifying meaningful restrictions on the sets A and B might lead to an easier problem. For example, it is \(\forall \mathbb {R} \)-complete to decide if closed semi-algebraic sets AB have Hausdorff distance exactly zero (they do if and only if \(A = B\)):

Theorem 8.1

Deciding if two semi-algebraic sets are equal is \(\forall \mathbb {R} \)-complete.

Proof

Given quantifier-free formulas \(\varphi _A(X)\) and \(\varphi _B(X)\), it holds that \(A = B\) if and only if \(\forall \, X \in \mathbb {R} ^n \,{:}\, \varphi _A(X)\,{\Leftrightarrow }\,\varphi _B(X)\). This shows \(\forall \mathbb {R} \)-membership. To prove \(\forall \mathbb {R} \)-hardness, note that the sentence \(\forall \,X \in \mathbb {R} ^n \,{:}\, \varphi (X)\) is equivalent to deciding whether \(\{x \in \mathbb {R} ^n \mid \varphi (x)\} {\mathop {=}\limits ^{?}} \mathbb {R} ^n\). \(\square \)