Keywords

1 Introduction

Hilbert’s 16th problem asks about topological constraints for real algebraic hypersurfaces in projective space. In the 1980s Viro developed patchworking as a combinatorial method to construct real algebraic hypersurfaces with unusually large \(\mathbb {Z}_2\)-Betti numbers [14,15,16,17]. A major breakthrough of this idea was Itenberg’s refutation of Ragsdale’s Conjecture [9]. Today patchworking is most naturally interpreted within the larger framework of tropical geometry [12]. In this way patchworking is a combinatorial avenue to real tropical hypersurfaces.

Here we report on a recent implementation of patchworking and real tropical hypersurfaces in polymake [1], version 4.1 of June 2020. The first software for patchworking that we are aware of is the “Combinatorial Patchworking Tool” [4], which works web-based and is restricted to the planar case. A second implementation is Viro.sage [18] which is capable of patchworking in arbitrary dimension and degree. Our implementation has the same scope as Viro.sage but it is superior in two ways. First, it naturally ties in with a comprehensive hierarchy of polyhedral objects in polymake; e.g., this allows for a rich choice of constructions of real tropical hypersurfaces. Second, our implementation is more efficient. This is demonstrated by several experiments with curves and surfaces of various degrees. As a new mathematical contribution we provide a census of Betti numbers of real tropical surfaces.

1.1 Tropical Hypersurfaces in \(\mathbb {TP}^{n-1}\)

Let \(f = \bigoplus _{v\in V} c_v \odot x^v \in \mathbb T[x_1,\dots ,x_n]\) be a tropical polynomial where V is a finite subset of \(\mathbb {Z}^n\). We use the multi-index notation \(x^v=x_1^{v_1}\cdots x_n^{v_n}\), and \(\mathbb T=\mathbb R\cup \{\infty \}\), \(\oplus {=}\min \) and \(\odot {=}+\). The tropical hypersurface \(\mathcal T(f)\) is the tropical vanishing locus of f, i.e., the set of points in \(\mathbb R^n\), where the minimum of the evaluation function \(x\mapsto f(x)\) is attained at least twice. Throughout we will assume that f is homogeneous of degree d, i.e., for each \(v\in V\) we have \(v_1+\dots +v_n=d\). In that case \(\mathcal T(f)\) descends to the tropical projective torus \(\mathbb R^n/\mathbb R{\mathbf 1}\), where \({\mathbf 1}=(1,\dots ,1)\). The Newton polytope of f is \(\mathcal N(f)=\mathrm {conv} \, V\), and the coefficients of f induce a regular subdivision, \(\mathcal S(f)\). The latter is dual to \(\mathcal T(f)\). We refer to [12] and [3] for further details.

The tropical projective space \(\mathbb {TP}^{n-1}=(\mathbb T^n{-}\{\infty {\mathbf 1}\})/\mathbb R{\mathbf 1}\) compactifies \(\mathbb R^n/\mathbb R{\mathbf 1}\). It is naturally stratified into lower dimensional tropical projective tori, marked by those coordinates which are finite. In this way the pair \((\mathbb {TP}^{n-1},\mathbb R^n/\mathbb R{\mathbf 1})\) is naturally homeomorphic with an \((n{-}1)\)-simplex and its interior. Often we will identify the tropical hypersurface \(\mathcal T(f)\) with its compactification in \(\mathbb {TP}^{n-1}\).

1.2 Viro’s Patchworking

The following is essentially a condensed version of [13, §3.1], with minor variations. A sign distribution \(\epsilon \in \mathbb {Z}_2^V\) can be symmetrized to the function

$$\begin{aligned} s_\epsilon : \mathbb {Z}_2^n\rightarrow \mathbb {Z}_2^V \,,\ s_\epsilon (z)(v) := \epsilon (v) + \langle z,v\rangle \bmod 2. \end{aligned}$$

As in [6] we choose our signs in \(\mathbb {Z}_2=\{0,1\}\), which corresponds to \(\pm 1\) via \(z\mapsto (-1)^z\). Further, the elements \(z\in \mathbb {Z}_2^n\) are in bijection with the \(2^n\) orthants of \(\mathbb R^n\) via \(z \mapsto \mathrm {pos}\{(-1)^{z_1}e_1,\ldots ,(-1)^{z_n}e_n\}\), where \(e_1,\dots , e_n\) are the standard basis vectors of \(\mathbb R^n\), and \(\mathrm {pos}(\cdot )\) denotes the nonnegative hull. We will use this identification throughout and, consequently, we call z itself an orthant.

The tropical hypersurface \(\mathcal T(f)\) is a polyhedral complex in \(\mathbb {TP}^{n-1}\), and its k-dimensional cells are dual to the \((n{-}1{-}k)\)-cells of \(\mathcal S(f)\). In particular, each maximal cell F of \(\mathcal T(f)\) corresponds to an edge, \(V(F)\subset V\), of \(\mathcal S(f)\). We write \(\mathcal T_{n-2}\) for the set of maximal cells (which are \((n{-}2)\)-dimensional polyhedra) and denote powersets as \(\mathcal P(\cdot )\).

Note that there are no \((n{-}2)\)-cells of \(\mathcal T(f)\) in the boundary \(\mathbb {TP}^{n-1}-\mathbb R^n/\mathbb R{\mathbf 1}\). The real phase structure on \(\mathcal T(f)\) induced by \(\epsilon \) is the map

That is, for each maximal cell F of \(\mathcal T(f)\) this describes the set of orthants, in which the symmetrized sign distribution takes distinct values on the two vertices of the dual edge V(F) in \(\mathcal S(f)\). This extends to all cells G of \(\mathcal T(f)\) by setting \(\phi _\epsilon (G) := \bigcup \phi _\epsilon (F)\), where the union is taken over all maximal cells \(F\in \mathcal T_{n-2}\) containing G. The pair \(\mathcal T_\epsilon (f)=(\mathcal T(f),\epsilon )\) is a real tropical hypersurface.

Fig. 1.
figure 1

Real tropical elliptic curve (left) and its real part (right)

Let \(\overline{z}\), defined by \(\overline{z}_i=1-z_i\), be the antipode of \(z\in \mathbb {Z}_2^n\). We define an equivalence relation \(\sim \) on \(\mathbb {Z}_2^n\times \mathbb {TP}^{n-1}\), which identifies copies of \(\mathbb {TP}^{n-1}\) along common strata, by letting

$$\begin{aligned} (z, x) \sim (z', y) \ :\iff \ x=y \text { and } \bigl ( \overline{z} = z' \text { or } ( x_i=\infty =y_i \Leftrightarrow z_i = 1 = z_i' ) \bigr ). \end{aligned}$$

This identifies \(\{z\}\times \mathbb {TP}^{n-1}\) and \(\{\overline{z}\}\times \mathbb {TP}^{n-1}\) one to one for each z. It follows that the quotient \((\mathbb {Z}_2^n\times \mathbb {TP}^{n-1})/{\sim }\) is homeomorphic to the real projective space \(\mathbb {RP}^{n-1}\). Combinatorially that construction can be seen as follows: the union of the \(2^{n}\) simplices \(\mathrm {conv}\{(-1)^{z_1}e_1,\ldots ,(-1)^{z_{n}}e_{n}\}\), where z ranges over all orthants, gives the boundary of the regular cross polytope \(\mathrm {conv}\{\pm e_1,\dots ,\pm e_{n}\}\) in \(\mathbb R^{n}\). Taking the quotient modulo antipodes yields \(\mathbb {RP}^{n-1}\).

The real part of the real tropical hypersurface \(\mathcal T_\epsilon (f)=(\mathcal T(f),\epsilon )\), denoted \(\mathbb R\mathcal T_\epsilon (f)\), is now defined as the collection of polyhedral complexes in \(\mathbb {Z}_2^n\times \mathbb {TP}^{n-1}\) consisting of the polyhedra

$$\begin{aligned} \bigl \{ \{z\}\times F \mid F\in \mathcal T_{n-2} \text { and } z \in \phi _\epsilon (F) \bigr \} \end{aligned}$$

and their faces. Note that \(\{z\}\times F \in \mathbb R\mathcal T_\epsilon (f)\) if and only if \(\{\overline{z}\}\times F \in \mathbb R\mathcal T_\epsilon (f)\), and hence we may restrict to the part of \(\mathbb R\mathcal T_\epsilon (f)\) in \((\{0\}\times \mathbb {Z}_2^{n-1})\times \mathbb {TP}^{n-1}\).

To avoid cumbersome notation and language we call the quotient of \(\mathbb R\mathcal T_\epsilon (f)\) by \(\sim \) also the real part of \(\mathcal T_\epsilon (f)\) and use the same symbol, \(\mathbb R\mathcal T_\epsilon (f)\). In this way \(\mathbb R\mathcal T_\epsilon (f)\) becomes a piecewise linear hypersurface in \(\mathbb {RP}^{n-1}\approx \mathbb {Z}_2^n\times \mathbb {TP}^{n-1}/{\sim }\).

The above construction is relevant for its connection with real algebraic geometry. To simplify the exposition we now consider a special case: Setting \(\varDelta _{n-1}=\mathrm {conv}\{e_1,\dots ,e_n\}\), we assume that the set \(V=d\cdot \varDelta _{n-1}\cap \mathbb {Z}^n\) is the set of lattice points in the dilated unit simplex. This entails that the projective toric variety generated from V is the (complex) projective space \(\mathbb {CP}^{n-1}\). The following result comes in various guises; this version occurs in [15] and [8, Proposition 2.6].

Theorem 1 (Viro’s combinatorial patchworking theorem)

Let f be a homogeneous tropical polynomial of degree d with support \(V=d\cdot \varDelta _{n-1}\cap \mathbb {Z}^n\). Then, for each sign distribution \(\epsilon \in \mathbb {Z}_2^n\), there exists a nonsingular real algebraic hypersurface X in \(\mathbb {CP}^{n-1}\), also with Newton polytope \(\mathcal N(f)=d\cdot \varDelta _{n-1}\), such that

$$\begin{aligned} (\mathbb {Z}_2^n\times \mathbb {TP}^{n-1}/{\sim },\, \mathbb R\mathcal T_\epsilon (f)) \ \textit{is} \, \mathbb {Z}_2 \textit{-homologous to} \, (\mathbb {RP}^{n-1},\, \mathbb RX). \end{aligned}$$

If additionally \(\mathcal S(f)\) is unimodular, i.e., each simplex has normalized volume one, this is “primitive patchworking". In the primitive case stronger conclusions hold [13, 16]. The notion “combinatorial patchworking" refers to the condition \(\mathcal N(f)=d\cdot \varDelta _{n-1}\). This is what our implementation supports, for arbitrary degrees and dimensions. More general results require to carefully take into account the toric geometry of \(\mathcal N(f)\).

Example 2

With \(n=d=3\) we consider the tropical polynomial

$$\begin{aligned} f \ = \ x^3 \oplus 1x^2y \oplus 1x^2z \oplus 4xy^2 \oplus 3xyz \oplus 4xz^2 \oplus 9y^3 \oplus 7y^2z \oplus 7yz^2 \oplus 9z^3 \end{aligned}$$

in \(\mathbb T[x,y,z]\), where we omit ‘\(\odot \)’ for improved readability. The tropical hypersurface \(\mathcal T(f)\) is the tropical elliptic curve in \(\mathbb R^3/\mathbb R{\mathbf 1}\) in Fig. 1 (left). The sign distribution \(\epsilon =(0, 1, 0, 1, 1, 1, 1, 0, 1, 1)\) yields a real tropical curve with real part in \(\mathbb {Z}_2^3\times \mathbb {TP}^2/{\sim }\) which has two components; cf. Fig. 1 (right). This primitive patchwork corresponds to a classical Harnack curve of degree 3; cf. [9, Sec. 5].

2 Betti Numbers from Combinatorial Patchworking

Our goal is to exhibit a census of Betti numbers of real tropical surfaces in \(\mathbb {Z}_2^4\times \mathbb {TP}^3/{\sim }\). Throughout the following let f be a tropical polynomial of degree d in \(n=4\) homogeneous variables; we will assume that \(\mathcal S(f)\) is a regular and full triangulation of \(V=d\cdot \varDelta _3\cap \mathbb {Z}^4\). That is, we focus on combinatorial patchworks. A triangulation of V is full if it uses all points in V; a unimodular triangulation is necessarily full. While the converse holds in the plane, there are many more full triangulations of \(d\cdot \varDelta _3\) than unimodular ones if \(d\ge 3\). Further, with

$$\begin{aligned} k \ := \ \frac{1}{6} d^3 + d^2 + \frac{11}{6} d + 1, \end{aligned}$$
(1)

which is the cardinality of V, we pick a sign vector \(\epsilon \in \mathbb {Z}_2^k\). This gives rise to a real algebraic surface X in \(\mathbb {CP}^3\) whose real part \(\mathbb RX\) is “near the tropical limit” \(\mathbb R\mathcal T_\epsilon (f)\) in the sense of [13]. Itenberg [6, Theorems 3.2/3.3] showed that the Euler characteristic satisfies

$$\begin{aligned} \chi (\mathbb RX) \ \ge \ \frac{4d-d^3}{3}, \end{aligned}$$
(2)

with equality attained in the primitive/unimodular case. Moreover, by [6, Theorem 4.2],

$$\begin{aligned} b_1(\mathbb RX) \ \le \ \frac{2d^3 - 6d^2 + 7d}{3}, \end{aligned}$$
(3)

where \(b_q(\cdot )\) are \(\mathbb {Z}_2\)-Betti numbers; see also [7] for bounds without the fullness assumption. However, if \(\mathcal S(f)\) is even unimodular then, by [6, Theorem 4.1],

$$\begin{aligned} b_0(\mathbb RX) \ \le \ \left( {\begin{array}{c}d - 1\\ 3\end{array}}\right) +1. \end{aligned}$$
(4)

See Table 1 for explicit numbers in the range which is relevant for our experiments. The main result of [13] furnishes a vast generalization of (4) to arbitrary dimensions.

Table 1. Bounds for Euler characteristic and Betti numbers, depending on the degree d. The values k, \(\chi '\), \(b_0'\) and \(b_1'\) are the right hand sides of (1), (2), (4) and (3), respectively.
Fig. 2.
figure 2

The real part of a cubic surface with Betti vector (2, 1, 2). There are three affine sheets, of which the outer two account for one connected component in \(\mathbb {RP}^3\), which is homeomorphic to \(\mathbb S^2\); the middle sheet forms a component homeomorphic to \(\mathbb {RP}^2\).

Example 3

The subdivision \(\mathcal S(f)\) induced by the tropical polynomial

$$\begin{aligned} \begin{aligned} f \ =&\ 5x^3 \oplus 1x^2y \oplus 1xy^2 \oplus 5y^3 \oplus 2x^2z \oplus 0xyz \oplus 2y^2z \\&\oplus \,0xz^2 \oplus 0yz^2 \oplus 1z^3 \oplus 2x^2w \oplus 0xyw \oplus 2y^2w \oplus 1xzw \\&\oplus \,1yzw \oplus 1z^2w \oplus 3xw^2 \oplus 3yw^2 \oplus 4zw^2 \oplus 8w^3 \end{aligned} \end{aligned}$$

is a full triangulation of \(3\cdot \varDelta _3\) which is not unimodular. Its f-vector reads (20, 60, 64, 23), and its automorphism group is of order 6. The sign distribution

$$\begin{aligned} \epsilon \ = \ (0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0) \end{aligned}$$

yields a real tropical surface \(\mathbb R\mathcal T_\epsilon (f)\) whose real part has Betti vector (2, 1, 2) (Fig. 2).

Fig. 3.
figure 3

Distribution of Betti vectors for surfaces of degrees 3 and 4. The colors indicate values for \(b_0=b_2\), the values on the x-axis indicate values for \(b_1\). For \(d=3\) the most frequent vector is (1, 7, 1) with 67.52%. For \(d=4\) it is (1, 10, 1) with 19.86%.

2.1 Combinatorial Description of the Homology

The polyhedral description of \(\mathbb R\mathcal T_\epsilon (f)\) directly gives a combinatorial description of the homology; see also [13, Proposition 3.17]. The cellular chain modules read

$$\begin{aligned} C_q(\mathbb R\mathcal T_\epsilon (f);\mathbb {Z}_2) \ = \ \bigoplus _{\sigma \text { cell of }\mathcal T_\epsilon (f), \dim \sigma = q}\;\left( \bigoplus _{z\in \phi _\epsilon (\sigma )}\mathbb {Z}_2^{\{\sigma \times \{z\}\}}\right) \end{aligned}$$
(5)

and \(\partial (\sigma \times \{z\})=\partial (\sigma )\times \{z\}\) defines the boundary maps. In fact this construction is a special case of a cellular (co-)sheaf [11]. Algorithmically it is beneficial that this does not require the geometric construction of \(\mathbb R\mathcal T_\epsilon (f)\).

2.2 A Census of Betti Numbers of Real Tropical Surfaces

We used mptopcom [10] to compute regular and full triangulations of \(d\cdot \varDelta _3\) for \(3\le d\le 6\), which are not necessarily unimodular. For \(d=3\) the total number of such triangulations is known to be \(21\,125\,102\) [10, Table 3], up to the natural action of the symmetric group \(S_4\). For higher degrees the corresponding numbers are unknown and probably out of reach for current hard- and software. Still we can compute some of those triangulations, for each degree.

Fig. 4.
figure 4

Distribution of Betti vectors for surfaces of degrees 5 and 6. The colors indicate values for \(b_0=b_2\), the values on the x-axis indicate values for \(b_1\). For \(d=5\) the most frequent vector is (1, 35, 1) with 21.9%. For \(d=6\) it is (1, 52, 1) with 18.97%.

Our experiments suggest that, in order to see many different Betti vectors \((b_0,b_1,b_0)\), it is preferable to look at many different triangulations. This is feasible for degrees 3 and 4, where we created \(1\,000\,000\) and \(100\,000\) orbits of triangulations, respectively. Each of them was equipped with 20 sign distributions which were picked uniformly at random; cf. Fig. 3. For \(d=3\) we obtain all values for \(b_1\) which are allowed by (3) if the surface is connected (i.e., \(b_0=1\)). Additionally, 965 times we saw the Betti vector (2, 1, 2); cf. Example 3. In view of (4) this occurs for non-unimodular triangulations only; all our examples of this kind share the same f-vector (20, 60, 64, 23). For \(d=4\) all the possible Betti vectors occur; cf. (2) and (3).

The case of \(d=5\) turned out to be surprisingly difficult. In our standard setup mptopcom quickly produced about a hundred full and regular triangulations before it stalled. mptopcom ’s algorithm employs a very special search through the flip graph of the point configuration, and it finds all regular triangulations plus some non-regular ones connected by a sequence of flips. Apparently, most neighbors to our first 100 triangulations of \(5\cdot \varDelta _3\) are not regular or not full. As we were interested in exploring many different Betti vectors, we created a second sample of triangulations; to this end we employed a random walk on the flip graph of \(5\cdot \varDelta _3\). After eliminating multiples, this gave an additional \(13\,000\) regular and full triangulations. On each of the resulting \(13\,100\) triangulations we tried 500 random sign distributions; cf. Fig. 4 (left) for the combined statistic. For \(d=6\) we checked \(1\,500\) triangulations with 500 sign distributions each; cf. Fig. 4 (right).

No matter how hard we try we will only see a tiny fraction of all possible real tropical surfaces of higher degrees. So the distributions for \(d=5\) and \(d=6\) may not even be close to the “truth”. Yet for \(d=5\) we observed \(b_1 = 43\), whereas \(b_1'=45\); cf. Table 1. We found 61 triangulations of \(5\cdot \varDelta _3\) with five components, none of which were unimodular. The maximal number of components in the unimodular case was four. For \(d=6\) our census is way off the theoretical bounds.

3 Implementation in polymake

polymake is a comprehensive software system for polyhedral geometry and related areas of mathematics [1]. Mathematical objects like tropical hypersurfaces are determined by their properties. Upon a user query the system directly returns a property (e.g., a tropical polynomial or the dual polyhedral subdivision) if it is known, or it computes it by applying a sequence of rules. Subsequently, the property asked for becomes known, along with any intermediate results. Throughout the life of such a big object the number of properties grows; objects, with their properties, can be saved and loaded again. The latter is useful, e.g., for processing data on a cluster and examining them on a laptop later.

The computation which is relevant here takes a tropical polynomial f (such that the Newton polytope \(\mathcal N(f)\) is a dilated simplex) and a sign distribution \(\epsilon \) as input and computes the \(\mathbb {Z}_2\)-Betti numbers of the real part \(\mathbb R\mathcal T_\epsilon (f)\) of the real tropical hypersurface \(\mathcal T_\epsilon (f)\). The individual steps are: (i) find the maximal cells of \(\mathcal T(f)\) via a dual convex hull computation; (ii) compute the Hasse diagram of the entire face lattice of \(\mathcal T(f)\); (iii) construct the chain complex (5) from that Hasse diagram; (iv) compute ranks of the boundary matrices mod 2. Each step is implemented as a separate rule, which makes the code highly modular and reusable. In particular, the only nontrivial implementation which is really new is step (iii).

We wish to give some details about the first two steps. Often the dual convex hull computation is the most expensive part. For this polymake has interfaces to several algorithms and implementations, the default being PPL [2] which is also used here. In general, it is difficult to predict which algorithm performs best; see [1] for extensive convex hull experiments. The computation of the Hasse diagram uses a combinatorial procedure whose complexity is linear in the size of the output, i.e., the total number of cells of the tropical hypersurface; cf. [5].

3.1 Running Times

To compare the running times of Viro.sage and polymake for computing the Betti numbers of patchworked hypersurfaces we conducted two experiments, one for Harnack curves and one for surfaces. All computations were carried out on an AMD Phenom II X6 1090T (3.2 GHz, 38528 bmips).

For the Harnack curves, where we have just one curve per degree (the cubic case is Example 2), we repeated the same computation ten times each. Figure 5 (left) shows the mean running time depending on the degree. The Viro.sage code showed a rather wide variety, while the polymake computations gave almost identical running times for each test.

Fig. 5.
figure 5

Time taken to compute Betti numbers (in seconds). Left: Harnack curves, average time by degree. Right: various surfaces, boxplots for each degree.

The experiment for the surfaces is slightly different in that both the tropical polynomials (and triangulations) and the sign distributions were varied. For degrees 3, 4, 5, and 6 we took the first 2000, 1000, 100, and 75 triangulations (as enumerated by mptopcom), respectively, and measured the running time for 10 random sign distributions each. Figure 5 (right) shows a box plot for each degree. The boxes indicate the 2nd and 3rd quartiles, the whiskers mark the minimum and maximum time measurements, excluding outliers (i.e., measurements whose ratio to the median is either bigger than 4, or smaller than 0.25), which are marked separately. Again Viro.sage exhibits a much greater variety of running times than polymake.

4 Conclusion

We have shown that our new implementation is capable of determining the \(\mathbb {Z}_2\)-Betti numbers of a patchworked surface of moderate degree within a few seconds. This allows for providing a rich census.

One major reason for polymake being faster than Viro.sage [18] is that we avoid the explicit construction of a simplicial complex model of \(\mathbb R\mathcal T_\epsilon (f)\). Moreover, polymake computes \(\mathbb {Z}_2\) Betti numbers directly, while Viro.sage goes through a standard homology computation with integer coefficients. polymake provides geometric realizations (and integral homology), too, but this is unnecessary here.