> application "tropical";
The simplest non-trivial example builds a polyhedral line from a tropical line. So let's first create a tropical line:
> $h1 = new Hypersurface(POLYNOMIAL=>toTropicalPolynomial("min(x,y,z)"));
> print $h1->MONOMIALS;
(3) (2 1)
(3) (1 1)
(3) (0 1)
The line consists of 3 rays eminating from the point (0,0,0). This gives us one vertex. The points where the rays intersect the plane at infinity are also considered vertices.
> print $h1->PROJECTIVE_VERTICES;
0 1 0 0
0 0 1 0
0 0 0 1
1 0 0 0
> print $h1->MAXIMAL_POLYTOPES; # the facets of the (original) tropical hypersurface
{0 3}
{1 3}
{2 3}
The property ''%%MAXIMAL_POLYTOPES%%'' is an ''%%IncidenceMatrix%%''. An entry $k$ in the $i$-th row of ''%%MAXIMAL_POLYTOPES%%'' indicates the vertex (represented by the $k$-th row in ''%%PROJECTIVE_VERTICES%%'') contained in the $i$-th facet of the tropical line.
We can now add a sign distribution on its monomials in the following way:
> $h1_pw1 = $h1->PATCHWORK(SIGNS=>[0,0,1]); # a real structure on $h1
> $h1_pw2 = $h1->PATCHWORK(SIGNS=>[1,0,1]); # another one, why not?
The property ''%%PATCHWORK%%'' represents a multiple subobject to a ''%%Hypersurface%%'' object (whether we deal with a ''%%Min%%'' or ''%%Max%%'' tropical hypersurface is irrelevant for the patchworking), parametrized by the property ''%%SIGNS%%'' with type ''%%Array
> print dense($h1_pw1->REAL_PHASE);
0 1 1 0
1 1 0 0
1 0 1 0
The property ''%%REAL_PHASE%%'' is an ''%%IncidenceMatrix%%'', representing the real phase structure of the real tropical hypersurface, with the following semantics:
Each orthant $o\subset\mathbb R^n$ corresponds to a subset $o\cap{-e_1,\ldots,-e_n}\subset{-e_1,\ldots,-e_n}$, whose characteristic vector is the binary representation of a unique natural number $0\leq N_o< 2^n$. E.g. in the plane, the positive orthant has binary representation $(00)_2 = 0$, and the negative $(11)_2 = 3$.
The $j$-th entry in the $i$-th row of ''%%REAL_PHASE%%'' is now $1$ iff the $i$-th facet of the tropical hypersurface (represented by the $i$-th row of ''%%MAXIMAL_POLYTOPES%%''; see above) is remembered in the orthant with binary representation $j$.
==== Realization as a PolyhedralComplex ====
We can produce a realization of the patchworked hypersurface as a ''%%PolyhedralComplex%%'' with the user method ''%%...->realize()%%'':
> $h1_pw_r = $h1_pw1->realize();
> print $h1_pw_r->COMBINATORIAL_DIM;
> svg($h1_pw_r->VISUAL);
1
Undefined subroutine &Polymake::User::svg called
Note that the realization is only unique up to combinatorial equivalence.
==== Some classic curves ====
There are convenience functions to produce some classic algebraic curves:
> $harnack = harnack_curve(6); # harnack curve of degree 6
> $ragsdale = ragsdale_counterexample(); # a counterexample to the ragsdale conjecture
> $gudkov = gudkov_curve(); # gudkov curve (degree 6)
These return a ''%%Hypersurface%%'' object with a unique ''%%PATCHWORK%%'' property attached, to access it simply use ''%%...->PATCHWORK%%''.
> print $ragsdale->PATCHWORK->SIGNS;
> svg($ragsdale->PATCHWORK->realize("uniform")->VISUAL);
1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1
Undefined subroutine &Polymake::User::svg called
===== The $\mathbb Z/2\mathbb Z$ cellular homology of a patchworked hypersurface =====
Naive computation of the homology of a patchworked hypersurface is computationally expensive, since its size depends exponentially on the dimension (we glue together $2^n$ copies of the tropical hypersurface).
Shaw & Renaudineau describe a way to exploit the symmetry of a patchworked hypersurface to compute its $\mathbb Z/2\mathbb Z$ homology directly from the triangulation + sign distribution, without needing to construct a polyhedral complex realization; cf. [[https://arxiv.org/abs/1805.02030|arXiv:1805.02030]] or the published version [[https://smf.emath.fr/publications/bornes-sur-les-nombres-de-betti-des-hypersurfaces-algebriques-reelles-proches-de-la|here]].
This leads to a straight forward algorithm, which is implemented in Polymake, and accessible in the following way:
> print $h1_pw1->CHAIN_COMPLEX_Z2;
<0 1 1
1 1 0
1 0 1
>
> print $h1_pw1->BETTI_NUMBERS_Z2;
1 1
===== Non-regular patchworking =====
It is possible to use this implementation starting with a (possibly non-regular) subdivision $\tau$ (i.e., without the data of a tropical hypersurface).
The usage is similar, you just have to define the hypersurface via the ''%%DUAL_SUBDIVISION%%'' property (even if mathematically no such hypersurface exists, i.e. in the non-regular case), instead the tropical ''%%POLYNOMIAL%%''.
Here is such a non-regular subdivision of $4\Delta_2$, the "mother of all examples":
> $moae = new fan::SubdivisionOfPoints(POINTS=>[[1,4,0,0],[1,0,4,0],[1,0,0,4],[1,2,1,1],[1,1,2,1],[1,1,1,2]],
> MAXIMAL_CELLS=>[[0,1,3],[0,2,5],[0,3,5],[1,2,4],[1,3,4],[2,4,5],[3,4,5]]);
> $moae->VISUAL;
> $h2 = new Hypersurface(DUAL_SUBDIVISION=>$moae);
> $h2_pw = $h2->PATCHWORK(SIGNS=>[0,0,0,1,1,0]);
> print $h2_pw->BETTI_NUMBERS_Z2;
3 3