1 Introduction

A (convex) polytope \(P \subseteq \mathbb {R}^d\) is said to be 2-level if every hyperplane H that is facet-defining for P has a parallel hyperplane \(H'\) that contains all the vertices of P which are not contained in H. The 3-dimensional 2-level polytopes are illustrated in Fig. 1 below.

Two-level polytopes appear in different areas of mathematics, in contexts related to discrete optimization. These polytopes have beautiful properties. For instance, a polytope is 2-level if and only if it is affinely equivalent to the convex hull of the columns of its facet-vertex incidence matrixFootnote 1 (see Lemma 4 or [18, Corollary 4.5] for a proof).

Therefore, every 2-level polytope is affinely equivalent to a 0 / 1-polytope. Hence, optimizing a linear function over a 2-level polytope amounts to solving an instance of a certain combinatorial optimization problem. Moreover, as is explained below, every linear program over a d-dimensional 2-level polytope can be reformulated in a very succinct way as a semidefinite program over \((d+1) \times (d+1)\) matrices. Roughly speaking, this means that the combinatorial optimization problem behind every family of 2-level polytopes can be solved efficiently.

Since no characterization of 2-level polytopes is in sight, we do not know precisely which combinatorial optimization problem can be modeled by 2-level polytopes. Nevertheless, some interesting families of polytopes studied in the literature turn out to be 2-level. For instance, cubes and cross-polytopes (more generally, Hanner polytopes [26]), Birkhoff polytopes [4] and order polytopes [40] (more generally, polytopes of the form \(P = \{x \in [0,1]^d \mid Ax = b\}\) where \(A \in \mathbb {Z}^{m \times d}\) is totally unimodular and \(b \in \mathbb {Z}^m\)), stable set polytopes of perfect graphs [8] and their twisted prisms, the Hansen polytopes [27], and spanning tree polytopes of series-parallel graphs [23] all are 2-level polytopes. See [2] for more examples. Outside this list, not many 2-level polytopes are known.

The goal of this paper is to design an algorithm that enumerates small-dimensional 2-level polytopes. Using this algorithm, we built a database of d-dimensional 2-level polytopes for \(d \leqslant 7\). Before explaining in more detail why 2-level polytopes are interesting objects and the contexts in which they appear, we give two reasons why we think that enumerating 2-level polytopes is relevant. First, having a database of small-dimensional 2-level polytopes provides a systematic way to find new 2-level polytopes, which could then be hopefully generalized to whole families. Second, it gives a way to challenge existing conjectures about 2-level polytopes and can also inspire new conjectures. In particular, any potential structural characterization of 2-level polytopes should at least explain what we observe for small dimensions. Conversely, the small-dimensional data can serve as a basis for guessing what the characterization could be.

Fig. 1
figure 1

a Representation of all combinatorially inequivalent 2-level polytopes in dimension 3. b Non 2-level 3-dimensional 0/1 polytopes. The highlighted facet violates the 2-level property

1.1 Relevance of 2-level polytopes

Let \(V \subseteq \mathbb {R}^d\) be a finite set and k be a positive integer. We write \(\mathbb {R}_{\leqslant k}[x]\) to denote the set of all polynomials of degree at most k over the field \(\mathbb {R}\) in the variable x. A polynomial \(f(x) \in \mathbb {R}_{\leqslant 1}[x]\) is said to be (1, k)-SOS on V if there exist polynomials \(g_1(x), \ldots , g_n(x) \in \mathbb {R}_{\leqslant k}[x]\) such that

$$\begin{aligned} f(x) = \sum _{i=1}^n g^2_i(x) \quad \text {for every } x \in V\,. \end{aligned}$$

The k-th theta body of V is the convex relaxation of V defined by the linear inequalities \(f(x) \geqslant 0\) where f(x) is (1, k)-SOS on V. The theta rank of V is defined as the smallest k such that this relaxation is exact, that is, the smallest k such that for every valid linear inequality \(f(x) \geqslant 0\), the affine form f(x) is (1, k)-SOS on V. These notions were introduced by Gouveia, Parrilo and Thomas [18]. Answering a question of Lovász [31], they proved that a finite set has theta rank 1 if and only if it is the vertex set of a 2-level polytope.

By virtue of this result and of the connection between sum-of-squares and semidefinite programming (see, e.g., [5] for more details), 2-level polytopes are particularly well behaved from the point of view of optimization: any linear optimization problem over a 2-level polytope in \(\mathbb {R}^d\) can be reformulated as a semidefinite programming problem over \((d+1) \times (d+1)\) symmetric matrices. More precisely, it is known that 2-level polytopes have minimum positive semidefinite rank (or positive semidefinite extension complexity) among all polytopes of the same dimension. In other words, 2-level d-polytopesFootnote 2 have positive semidefinite rank equal to \(d+1\) [17]. For example, stable set polytopes of perfect graphs are one of the most prominent examples of 2-level polytopes. To our knowledge, the fact that these polytopes have small positive semidefinite rank is the only known reason why one can efficiently find a maximum stable set in a perfect graph [24].

Moreover, 2-level polytopes are also of interest in communication complexity since they provide interesting instances to test the log-rank conjecture [32], one of the fundamental open problems in the area. This conjecture asserts that every 0 / 1-matrix M can be computed by a deterministic communication protocol of complexity at most \(\mathrm {polylog}(\mathrm {rk}(M))\), which implies that the nonnegative rank of every 0 / 1-matrix M is at most \(2^{\mathrm {polylog}(\mathrm {rk}(M))}\). By results of Yannakakis [43], the log-rank conjecture implies that every 2-level d-polytope has nonnegative rank (or linear extension complexity) at most \(2^{\mathrm {polylog}(d)}\). This is known for stable set polytopes of perfect graphs [43], but appears to be open for general 2-level polytopes.

There are more reasons to study 2-level polytopes beyond those given above, in particular, in the context of Ehrhart theory in which 2-level polytopes originally appeared. Stanley [39] introduced 2-level polytopes, under the name compressed polytopes, because the Ehrhart polynomial of a 2-level polytope has a simple combinatorial interpretation in terms of the f-vector of any pulling triangulation of P.Footnote 3 Sullivant [41] studied 2-level polytopes in the context of algebraic statistics.

1.2 Contribution and outline

In this paper we study the problem of enumerating all combinatorial types of 2-level polytopes of a fixed dimension d. This is equivalent to enumerating all 2-level polytopes up to affine equivalence because for 2-level polytopes the notions of combinatorial and affine equivalence coincide, see Lemma 5. We simply say that two 2-level polytopes are isomorphic if they are combinatorially (or affinely) equivalent. (For a definition of affine and combinatorial equivalence, see [44, Chapter 0].)

Since every 2-level polytope is affinely equivalent to a 0/1-polytope, one might think to compute all 2-level polytopes of a given dimension simply by enumerating all 0/1-polytopes of that dimension and discarding the polytopes which are not 2-level. However, the complete enumeration of d-dimensional 0/1-polytopes has been implemented only for \(d\leqslant 5\) [1]. The author of the same paper has enumerated all 6-dimensional 0/1-polytopes having up to 12 vertices, but the complete enumeration even for this low dimension is not expected to be feasible: the output of the combinatorial types alone is so huge that it is not currently possible to store it or search it efficiently [45]. Thus for all but the lowest dimensions, there is no hope of working with a pre-existing list of 0/1-polytopes, and it is desirable to find an algorithm that computes 2-level polytopes from scratch.

We present the first algorithm to enumerate all combinatorial types of 2-level polytopes of a given dimension d. The algorithm uses new structural results on 2-level polytopes which we develop here.

Our starting point is a pair of full-dimensional embeddings of a given 2-level d-polytope defined in Sect. 2. In one embedding, which we refer to as the \({\mathcal {H}}\)-embedding, the facets have 0 / 1-coefficients. In the other —the \({\mathcal {V}}\)-embedding— the vertices have 0 / 1-coordinates. The \({\mathcal {H}}\)- and \({\mathcal {V}}\)-embeddings are determined and linked by a structure, which we call a simplicial core (see Sect. 2.2).

Our enumeration algorithm computes a complete list \(L_d\) of non-isomorphic 2-level d-polytopes using the list \(L_{d-1}\) of 2-level \((d-1)\)-polytopes. The algorithm is based on the fact that \(L_d\) is the union of \(L_d(P_0)\) for \(P_0\in L_{d-1}\), where \(L_d(P_0)\) is the collection of all 2-level d-polytopes that have a facet isomorphic to \(P_0\). Indeed, every facet of a 2-level polytope is 2-level (see Lemma 6 below) and thus the above union equals \(L_d\). Our enumeration strategy is inspired by Fig. 2.

Fig. 2
figure 2

(Rotated) Hasse diagram of the poset of combinatorial types of 2-level polytopes with respect to inclusion. In the figure, an edge between the combinatorial types of the polytopes P and F indicates that P has a facet that is isomorphic to F. Combinatorial types of a fixed dimension are sorted top to bottom lexicographically by their f-vector. Thus the first type is always that of the simplex. Labels on the nodes of the diagram are the number of times a given combinatorial type appears as a facet of another type

For every polytope \(P_0 \in L_{d-1}\), we perform the following steps. First, we embed \(P_0\) in the hyperplane \(\{x \in \mathbb {R}^d \,|\, x_1 = 0\} \simeq \mathbb {R}^{d-1}\) (using an \(\mathcal {H}\)-embedding). Then, we compute a collection \(\mathcal {A}\) of point sets \(A\subseteq \{x \in \mathbb {R}^d \,|\, x_1=1\}\) such that for each 2-level polytope \(P \in L_d(P_0)\), there exists \(A \in \mathcal {A}\) with P isomorphic to \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\). For each \(A \in \mathcal {A}\), we add the polytope \(P' :=\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) to the list \(L_d\), provided that it is 2-level and not isomorphic to any of the polytopes already generated by the algorithm.

The efficiency of this approach depends greatly on how the collection \(\mathcal {A}\) is chosen. Our basic strategy is to exploit properties of the \({\mathcal {H}}\)- and \({\mathcal {V}}\)-embeddings of 2-level polytopes to define: (i) a finite ground set \(\mathcal {X} \subseteq \{x \in \mathbb {R}^d \,|\, x_1 = 1\}\), (ii) an appropriate family \(\mathcal {A}\) of subsets of \(\mathcal {X}\) that reflects some properties of the 2-level d-polytopes in \(L_d(P_0)\). For various choices of \(\mathcal {X}\) and \(\mathcal {A}\), we prove that this suffices to recover all polytopes in \(L_d(P_0)\).

We describe the enumeration algorithm in Sect. 3, as well as a first ground set \(\mathcal {X}\) and family \(\mathcal {A}\). Then in Sect. 4, we explain how to make both \(\mathcal {X}\) and \(\mathcal {A}\) smaller by a finer analysis. In Sect. 5, we explain in more detail how the members of \(\mathcal {A}\) are enumerated.

Section 6 discusses the implementation in detail. In particular, we develop tools to compute convex hulls of 2-level polytopes combinatorially and avoid resorting to standard convex hull algorithms, providing a considerable speedup in the computations.

We implemented the algorithm and ran it to obtain \(L_d\) for \(d \leqslant 7\). The outcome of our experiments is discussed in Sect. 7. In particular, our results show that the number of combinatorial types of 2-level d-polytopes is surprisingly small for low dimensions d.

We conclude the paper by discussing research questions inspired by our experiments, see Sect. 8.

1.3 Previous related work

The enumeration of all combinatorial types of point configurations and polytopes is a fundamental problem in discrete and computational geometry. Latest results in [12] report complete enumeration of polytopes for dimension \(d=3,4\) with up to 8 vertices and \(d=5,6,7\) with up to 9 vertices. For 0 / 1-polytopes this is done completely for \(d \leqslant 5\) and \(d=6\) with up to 12 vertices [1]. In our approach, we use techniques from formal concept analysis, in particular we use a previously existing algorithm to enumerate all concepts of a relation, see [14, 30].

Regarding 2-level polytopes, Grande and Sanyal [23] give an excluded minor characterization of 2-level matroid base polytopes. Grande and Rué [22] give a \(O(c^d)\) lower bound on the number of 2-level matroid d-polytopes for some constant \(c > 0\). Finally, Gouveia et al. [19] give a complete classification of polytopes with minimum positive semidefinite rank, which generalize 2-level polytopes, in dimension \(d=4\).

1.4 Conference versions

A first version of the enumeration algorithm together with the experimental results for \(d \leqslant 6\) appeared in [6]. An improvement of the algorithm that yielded enumeration results in \(d=7\) appeared as part of [11]. We point out that this paper is missing one 2-level polytope for \(d = 7\), see [11, Table 2]. The correct number of 2-level 7-polytopes is provided here, see Table 3 below. Besides this correction, the present paper contains a full correctness proof for the enumeration algorithm. Moreover, compared to [11], the algorithm was further optimized. The two main differences are: the more drastic reductions we perform on the ground set, and the fact that we bypass convex hull computations completely. These are replaced by a combinatorial polytope verification procedure. More details can be found in Sect. 6.

2 Embeddings

In this section, after fixing some notation, we discuss the notion of simplicial core. This is then used to define the two types of embeddings that we use for 2-level polytopes. Finally, we establish important properties of these embeddings that are used later in the enumeration algorithm.

2.1 Notations

For basic notions on polytopes that do not appear here, we refer the reader to [44]. We use \(\mathrm {vert}(P)\) to denote the vertex set of a polytope P. Let d denote a positive integer, which we use most of the time to denote the dimension of the ambient space. We let \([d] :=\{1,\dots ,d\}\). For \(x \in \mathbb {R}^d\) and \(E \subseteq [d]\), we let \(x(E):=\sum _{i \in E} x_i\).

2.2 Simplicial cores

We introduce the structural notion of simplicial core of a polytope, which will be used in the enumeration algorithm to ease the counting of combinatorial types of 2-level polytopes.

Definition 1

(Simplicial core) A simplicial core for a d-polytope P is a \((2d+2)\)-tuple \((F_1,\ldots ,F_{d+1};\)\(v_1,\ldots ,v_{d+1})\) of facets and vertices of P such that each facet \(F_i\) does not contain vertex \(v_i\) but contains vertices \(v_{i+1}\), ..., \(v_{d+1}\).

The concept of simplicial core appeared in relation with 2-level polytopes already in [39] and with polytopes of minimum nonnegative rank in [20].

The following lemma proves the existence of simplicial cores. Although this is known (see [20, Proposition 3.2]), we provide a proof for completeness. See Fig. 3 for an example of simplicial core.

Fig. 3
figure 3

An example of a simplicial core \((F_1,F_2,F_3,F_4;v_1,v_2,v_3,v_4)\) for the 3-dimensional cube

Lemma 2

For every d-polytope P, there exist facets \(F_1\), ..., \(F_{d+1}\) and vertices \(v_1\), ..., \(v_{d+1}\) of P such that \((F_1,\ldots ,F_{d+1};v_1,\ldots ,v_{d+1})\) is a simplicial core for P.

Proof

The proof is by induction on the dimension. For a 1-polytope \(P:=\mathrm {conv}(\{v_1,v_2\})\) we can take \(F_1 :=\{v_2\}\) and \(F_2 :=\{v_1\}\). For the induction step, let \(P'\) be a facet of P. Thus \(P'\) is a \((d-1)\)-polytope. By the induction hypothesis, there are facets \(F'_2, \ldots , F'_{d+1}\) and vertices \(v_2,\ldots , v_{d+1}\) of \(P'\) such that \((F'_2, \ldots , F'_{d+1};v_2,\ldots ,v_{d+1})\) is a simplicial core for \(P'\). Now let \(F_1 :=P'\) and, for i, \(2 \leqslant i \leqslant d+1\), let \(F_i\) be the unique facet of P that contains \(F'_i\) and is distinct from \(F_1\). Let \(v_1\) be any vertex of P which does not belong to the facet \(F_1\).

By construction, each \(F_i\) contains \(v_{i+1}, \ldots , v_{d+1}\). Moreover, \(F_1\) does not contain \(v_1\) and, for \(i \geqslant 2\), facet \(F_i\) does not contain \(v_i\) because otherwise \(F'_i = F_1 \cap F_i\) would contain \(v_i\), contradicting our hypothesis. \(\square \)

We point out that the proof of Lemma 2 gives us more than the existence of simplicial cores: for every polytope P, every facet \(F_1\) of P and every simplicial core \(\varGamma ' :=(F'_2, \ldots , F'_{d+1};v'_2,\ldots ,v'_{d+1})\) of \(F_1\), there exists a simplicial core \(\varGamma :=(F_1,F_2,\ldots ,F_{d+1};v_1,v_2,\ldots ,v_{d+1})\) of Pextending\(\varGamma '\) in the sense that \(F'_i = F_1 \cap F_i\) and \(v'_i = v_i\) for \(i \geqslant 2\).

Finally, we make the following observation. Let \((F_1,\ldots ,F_{d+1};v_1,\ldots ,v_{d+1})\) be a simplicial core of some polytope P. For each i, the affine hull of \(F_i\) contains \(v_j\) for \(j > i\), but does not contain \(v_i\). Therefore, the vertices of a simplicial core are affinely independent. That is, \(v_1\), ..., \(v_{d+1}\) form the vertex set of a d-simplex contained in P.

2.3 Slack matrices and slack embeddings

Definition 3

(Slack matrix [43]) The slack matrix of a polytope \(P \subseteq \mathbb {R}^{d}\) with m facets \(F_1\), ..., \(F_m\) and n vertices \(v_1\), ..., \(v_n\) is the \(m \times n\) nonnegative matrix \(S = S(P)\) such that \(S_{ij}\) is the slack of the vertex \(v_j\) with respect to the facet \(F_i\), that is, \(S_{ij} = g_i(v_j)\) where \(g_i : \mathbb {R}^{d} \rightarrow \mathbb {R}\) is the affine form such that \(\min \{g_i(x) \mid x \in P\} = 0\), \(\max \{g_i(x) \mid x \in P\} = 1\) and \(F_i = \{x \in P \mid g_i(x) = 0\}\).

The slack matrix of a polytope is unique up to permuting its rows and columns. Notice that simplicial cores for P correspond to \((d+1) \times (d+1)\) submatrices of S(P) that are invertible and lower-triangular, for some ordering of rows and columns.

The slack matrix provides a canonical way to embed any polytope, which we call the slack embedding. This embedding maps every vertex \(v_j\) to the corresponding column \(S^j \in \mathbb {R}_+^m\) of the slack matrix \(S = S(P)\). The next lemma shows that every polytope is affinely isomorphic to the convex hull of the columns of its slack matrix.

Lemma 4

Let P be a d-polytope having facet-defining inequalities \(g_1(x) \geqslant 0\), ..., \(g_m(x) \geqslant 0\), and vertices \(v_1\), ..., \(v_n\). If \(\sigma \) denotes a map from the affine hull \(\mathrm {aff}(P)\) of P to \(\mathbb {R}^m\) defined by \(\sigma (x)_i :=g_i(x)\) for all \(x \in \mathrm {aff}(P)\), then the polytopes P and \(\sigma (P)\) are affinely equivalent.

Proof

The map \(\sigma : \mathrm {aff}(P) \rightarrow \mathbb {R}^m\) is affine, and injective because it maps the vertices of any simplicial core for P to affinely independent points. The result follows. \(\square \)

By definition, a polytope P is 2-level if and only if S(P) is a 0 / 1-matrix. Notice that the slack matrix of a 2-level polytope is also its (facet-vertex) non-incidence matrix, where 0 indicates incidence and 1 indicates non-incidence. As a consequence, we have the following result:

Lemma 5

Two 2-level polytopes are affinely equivalent if and only if they have the same combinatorial type.

Proof

The result follows directly from Lemma 4 and the fact that, since the slack matrix of a 2-level polytope P is the non-incidence matrix of P, it depends only on the combinatorial type of P. (We remark that this implies that P is also affinely equivalent to the convex hull of the columns of its incidence matrix, as mentioned in the introduction.) \(\square \)

For the sake of completeness, we state the following basic result about 2-level polytopes, which easily follows from our discussion of slack matrices (see also [18, Corollary 4.5 (2)]).

Lemma 6

Each face of a 2-level polytope is a 2-level polytope.

Proof

Let \(S = S(P) \in \{0,1\}^{m \times n}\) be the slack matrix of some 2-level polytope P, and let F be any face of P. If F is empty or a point, then F is 2-level by definition. Otherwise, the slack matrix of F is a submatrix of S obtained by selecting one row per facet of F and one column per vertex of F, which implies that F is 2-level. \(\square \)

2.4 \({\mathcal {H}}\)- and \({\mathcal {V}}\)-embeddings

Although canonical, the slack embedding is never full-dimensional, which can be a disadvantage. To remedy this, we use simplicial cores to define two types of embeddings that are full-dimensional. Let P be a 2-level d-polytope with m facets and n vertices, and let \(\varGamma :=(F_1,\ldots ,F_{d+1};v_1,\ldots ,v_{d+1})\) be a simplicial core for P. Since \(v_1\),..., \(v_{d+1}\) are affinely independent, the images of \(v_1\),..., \(v_{d+1}\) uniquely define an affine embedding of P.

The slack matrix S(P) is a 0 / 1-matrix. Moreover, we assume that the rows and columns of the slack matrix S(P) are ordered compatibly with the simplicial core \(\varGamma \), so that the i-th row of S(P) corresponds to facet \(F_i\) for \(i \in [d+1]\) and the j-th column of S(P) corresponds to vertex \(v_j\) for \(j \in [d+1]\).

Definition 7

(\(\mathcal {H}\)-embedding) The \(\mathcal {H}\)-embedding of P with respect to the simplicial core \(\varGamma :=(F_1,\ldots ,F_{d+1};v_1,\ldots ,v_{d+1})\) is defined by mapping \(v_j\), \(1 \leqslant j \leqslant d\) to the unit vector \(e_j\) of \(\mathbb {R}^d\) and mapping \(v_{d+1}\) to the origin.

Definition 8

(\(\mathcal {V}\)-embedding) Let \(S :=S(P)\) be the slack matrix of P. The \({\mathcal {V}}\)-embedding of P with respect to the simplicial core \(\varGamma :=(F_1,\ldots ,F_{d+1};v_1,\ldots ,\)\(v_{d+1})\) is defined by mapping \(v_j\), \(j \in [d+1]\) to the point of \(\mathbb {R}^d\) whose i-th coordinate is \(S_{ij}\) for \(i \in [d]\).

Notice that every \(\mathcal {V}\)-embedding can be obtained from the slack embedding by dropping all but d coordinates.

Definition 9

We call embedding transformation matrix with respect to \(\varGamma \) the submatrix of the slack matrix of P induced by the first d rows and columns, and denote it by \(M(P,\varGamma )\).

Note that every embedding transformation matrix \(M = M(P,\varGamma )\) is unimodular. Indeed, M is an invertible, lower-triangular, 0 / 1-matrix. Thus we have \(\det (M)=1\).

Note also that the \({\mathcal {V}}\)-embedding can be equivalently defined by the mapping \( x \mapsto Mx\, \) where \(M = M(P,\varGamma )\) and \(x \in \mathbb {R}^d\) is a point in the \({\mathcal {H}}\)-embedding with respect to \(\varGamma \). In fact, for every \(i \in [d+1]\), the matrix M maps the \(i\)-th vertex of the simplicial core to the first d coordinates of the \(i\)-th column of the slack matrix of P, that are precisely the vertices of P in the \({\mathcal {V}}\)-embedding.

The next lemma provides the main properties of the \({\mathcal {H}}\)- and \({\mathcal {V}}\)-embeddings.

Lemma 10

Let P be a 2-level d-polytope and \(\varGamma :=(F_1,\ldots ,F_{d+1};v_1,\ldots ,v_{d+1})\) be some simplicial core for P. Then the following properties hold:

  • in the \({\mathcal {H}}\)-embedding of P with respect to \(\varGamma \), all the facets are of the form \(x(E) \leqslant 1\) or \(x(E) \geqslant 0\) for some nonempty \(E \subseteq [d]\).

  • in the \({\mathcal {V}}\)-embedding of P with respect to \(\varGamma \), the i-th coordinate of a vertex is the slack with respect to facet \(F_i\) of the corresponding vertex in P. In particular, in the \({\mathcal {V}}\)-embedding all the vertices have 0 / 1-coordinates.

Proof

Let \(g(x) :=a_0 + \sum _{i=1}^d a_i x_i \geqslant 0\) be a facet-defining inequality in the \({\mathcal {H}}\)-embedding. Since P is 2-level, we may assume that g(x) takes 0 / 1-values on the vertices of the \({\mathcal {H}}\)-embedding. That is, on the unit vectors \(e_j\) (for \(j \in [d]\)) and the origin. Thus, g(x) has either the form \(\sum _{i \in E} x_i\) or the form \(1 - \sum _{i \in E} x_i\) for some nonempty \(E \subseteq [d]\).

Consider the \({\mathcal {V}}\)-embedding with respect to \(\varGamma \) and fix \(i \in [d]\) arbitrarily. The i-th coordinate of a point in the \({\mathcal {V}}\)-embedding and the map computing the slack with respect to the facet \(F_i\) are two affine forms on \(\mathrm {aff}(P)\), and their value coincide on the vertices \(v_1, \ldots , v_{d+1}\in P\). The statement follows, since the affine hull of \(v_1, \ldots , v_{d+1}\) equals \(\mathrm {aff}(P)\). \(\square \)

Below, we use the shorthand \(M \cdot X\) for the set \(\{Mx \mid x \in X\}\) where M is a \(d \times d\) matrix and X is a subset of \(\mathbb {R}^d\).

Corollary 11

Let P be the \({\mathcal {H}}\)-embedding of a 2-level d-polytope with respect to a simplicial core \(\varGamma \). Then \(\mathrm {vert}(P)=P \cap (M^{-1} \cdot \{0,1\}^d)=P \cap \mathbb {Z}^d\subseteq \mathbb {Z}^d\), where \(M = M(P,\varGamma )\) is the embedding transformation matrix of P with respect to \(\varGamma \).

Proof

First, \(\mathrm {vert}(P)=M^{-1}\cdot (\mathrm {vert}(M\cdot P))=M^{-1}\cdot \big ((M\cdot P)\cap \{0,1\}^d\big )\), where the last equality is due to the fact that \(M\cdot P\) is a 0 / 1-polytope. Thus, \(\mathrm {vert}(P)=M^{-1}\cdot \big (M\cdot P\big )\cap \big (M^{-1}\cdot \{0,1\}^d\big )=P\cap \big (M^{-1}\cdot \{0,1\}^d\big )\).

Using the exact same reasoning while replacing \(\{0,1\}^d\) by \(\mathbb {Z}^d\), we obtain \(\mathrm {vert}(P)=P\cap \big (M^{-1}\cdot \mathbb {Z}^d\big )=P\cap \mathbb {Z}^d\), where the last equality is due to the unimodularity of M.

\(\square \)

It follows from Lemma 10 that any \({\mathcal {H}}\)-embedding of a 2-level d-polytope is of the form \(P(H) :=\{x \in \mathbb {R}^d\mid 0 \leqslant x(E) \leqslant 1 \text { for each } E \in \mathcal {E} \} \), for some hypergraph \(H = (V,\mathcal {E})\), with \(V=[d]\). Observe that P(H) is 2-level if and only if it is integral. For every hyperedge \(E\in \mathcal {E}\), we refer to a pair of inequalities \(0 \leqslant x(E) \leqslant 1\) as a pair of hyperedge constraints.

Finally, we prove a surprising structural result for 2-level polytopes: the local information of having a simple vertex has a huge impact on the entire structure of the polytope since it forces the polytope to be isomorphic to the stable set polytope of a perfect graph. We recall that a vertex of a d-polytope is said to be simple if it is contained in exactly d facets. We use this later in Sect. 7 to recognize stable set polytopes of perfect graphs among 2-level polytopes.

Lemma 12

A 2-level d-polytope P has a simple vertex if and only if it is isomorphic to the stable set polytope of a perfect graph on d vertices.

Proof

The “if” direction follows from the fact that, in a stable set polytope, the origin is always a simple vertex. We now prove the “only if” direction. Let v be some simple vertex of P. Since P is a d-polytope, v is contained in exactly d edges of P, see e.g. [44, Proposition 2.16]. We denote by \([v,v_i]\), \(i \in [d]\), the d edges containing v. There exist facets \(F_1\), ..., \(F_{d+1}\) of P such that \(\varGamma :=(F_1,\ldots ,F_{d+1}; v_1,\ldots ,v_d,v_{d+1})\) is a simplicial core, where \(v_{d+1} :=v\). The first d facets are determined by the choice of v since they are all the facets of P containing v, while \(F_{d+1}\) is any facet not containing v. By construction, \(M(P, \varGamma )\) is the \(d \times d\) identity matrix.

Consider the \(\mathcal {H}\)-embedding of P with respect to \(\varGamma \), which has the form \(P(H) = \{x \in \mathbb {R}^d\mid 0 \leqslant x(E) \leqslant 1 \text { for each } E \in \mathcal {E} \} \), for some hypergraph \(H = (V,\mathcal {E})\) with \(V=[d]\). Since \(M(P,\varGamma ) = I_d\), the \(\mathcal {H}\)- and \(\mathcal {V}\)-embeddings with respect to \(\varGamma \) coincide. For this reason, \(P(H) = P_+(H)\), where \(P_+(H) :=P(H) \cap \mathbb {R}^d_+\).

Since P is 2-level, \(P(H) = P_+(H)\) is integral. By [9, Theorem 3.4], we conclude that \(P_+(H)\) is the stable set polytope of some perfect graph. The result follows. \(\square \)

3 The enumeration algorithm

As explained above, our enumeration algorithm for 2-level polytopes relies on the basic fact that every facet of a 2-level d-polytope is a 2-level \((d-1)\)-polytope (Lemma 6).

This section establishes three specific structural properties that 2-level d-polytopes P with a prescribed facet \(P_0\) possess. First, we prove that when \(P_0\) is embedded in \(\{0\} \times \mathbb {R}^{d-1} \simeq \mathbb {R}^{d-1}\) with a \(\mathcal {H}\)-embedding, it suffices to consider all subsets A of some finite ground set in \(\{1\} \times \mathbb {R}^{d-1}\) in order to generate all such d-polytopes P, by taking the convex hull of \(\mathrm {vert}(P_0) \cup A\). Then, we give two properties that the sets A have to satisfy in order to produce a 2-level polytope. Indeed, every set A such that the convex hull of \(\mathrm {vert}(P_0) \cup A\) is 2-level:

  • is discretely convex, in the sense that it is a maximal subset of points of our finite ground set that verify all 2-valued inequalities satisfied by \(\mathrm {vert}(P_0) \cup A\), see Sect. 3.2.

  • does not contain any incompatible triple of points. We call a triple of points in Aincompatible if there is a facet of \(P_0\) whose affine hull and whose translates containing the three points cannot be covered by any two parallel hyperplanes (other than \(\{0\}\times \mathbb {R}^{d-1}\) and \(\{1\}\times \mathbb {R}^{d-1}\)), see Sect. 3.3.

Both these properties turn out to be closed under intersection, hence yield Moore families. Their intersection is a complete family of sets for the given embedding of \(P_0\) (Definition 18), in the sense that all 2-level d-polytopes P with a facet isomorphic to \(P_0\) are affinely equivalent to the convex hull of \(\mathrm {vert}(P_0) \cup A\) for some A in such family. The enumeration algorithm parses sets in this complete family. We conclude the section by stating the enumeration algorithm, see Algorithm 1.

3.1 Combining embeddings

The first property allows us to confine the vertex set of the 2-level polytopes that the algorithm has to enumerate in a finite point set.

Lemma 13

Let \(P_0\) be a 2-level \((d-1)\)-polytope \(\mathcal {H}\)-embedded in \(\{x \in \mathbb {R}^{d} \mid x_1 = 0\} \simeq \mathbb {R}^{d-1}\) with respect to some simplicial core \(\varGamma _0\), and let \(M_{d-1} :=M(P_0,\varGamma _0)\). Every 2-level d-polytope P with a facet isomorphic to \(P_0\) admits an embedding transformation matrix of the form

(1)

where \(c \in \{0,1\}^{d-1}\), and thus P is isomorphic to \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) for some A included in

$$\begin{aligned} \mathcal {X}_{\mathrm {full}}= \mathcal {X}_{\mathrm {full}}(P_0,\varGamma _0) :=\bigcup _{c \in \{0,1\}^{d-1}} M_d(c)^{-1} \cdot (\{1\} \times \{0,1\}^{d-1})\,. \end{aligned}$$
(2)

Proof

It is useful to think of \(P_0\) and P as being represented by their slack matrices \(S(P_0)\) and S(P), respectively. Thus, S(P) contains \(S(P_0)\) as a submatrix.

As in Definition 3, we order rows and columns of the slack matrices in such a way that the i-th facet and j-th vertex of the chosen simplicial core index the i-th row and j-th column respectively. Thus, the top left \(d \times d\) submatrix of \(S(P_0)\) gives the non-incidences between the facets and vertices of simplicial core \(\varGamma _0\).

Now let \(F_1\) denote any facet of P that is isomorphic to \(P_0\). Through the isomorphism between \(F_1\) and \(P_0\), the simplicial core \(\varGamma _0\) of \(P_0\) determines a simplicial core of \(F_1\). Consider any simplicial core \(\varGamma = (F_1,F_2,\ldots ,F_{d+1};v_1,v_2,\ldots ,\)\(v_{d+1})\) of P extending the simplicial core of \(F_1\). Here, \(v_1\) is some vertex of P that is not in \(F_1\), while the vertices \(v_2\),..., \(v_{d+1}\) are in \(F_1\).

All incidences between the facets and vertices of \(\varGamma \) are prescribed, except the incidences between \(v_1\) and \(F_2\), ..., \(F_{d+1}\). In particular, the embedding transformation matrix \(M_d = M(P,\varGamma )\) is as in (1).

A priori, we do not know the vector \(c \in \{0,1\}^{d-1}\). Suppose for now that we fix \(c \in \{0,1\}^{d-1}\), so that \(M_d\) is completely defined. Let \(P'\) denote the \(\mathcal {H}\)-embedding of P with respect to \(\varGamma \). Thus \(P'\) is a 2-level d-polytope isomorphic to P. From Corollary 11, we have \(\mathrm {vert}(P') \subseteq M_d^{-1} \cdot \{0,1\}^d\).

By construction, \(F_1 \simeq P_0\) is the first facet of \(\varGamma \). Moreover, \(P_0\) is the facet of \(P'\) defined by \(x_1 \geqslant 0\). Since \(P'\) is 2-level, we can decompose its vertex set as \(\mathrm {vert}(P') = \mathrm {vert}(P_0) \cup A\) where A is the vertex set of the face of \(P'\) opposite to \(P_0\), defined by \(x_1 \leqslant 1\). Notice that \(A \subseteq M_d^{-1} \cdot (\{1\} \times \{0,1\}^{d-1})\). The result follows. \(\square \)

We point out that \(\mathcal {X}_{\mathrm {full}}\) has size \(3^{d-1}\), as we prove later in Lemma 23. Moreover, in the proof above, we have \(e_1 \in A\), since we are considering an \(\mathcal {H}\)-embedding of P.

Example 14

Let \(d = 3\), let \(P_0\) be the 2-simplex, and let \(\varGamma _0\) be any of its simplicial cores (there is just one, up to symmetry). Using (2), it is easy to compute that

$$\begin{aligned} \mathcal {X}_{\mathrm {full}}&= \bigcup _{c \in \{0,1\}^2} {\begin{pmatrix} 1 &{} 0 &{} 0 \\ c_1 &{} 1 &{} 0 \\ c_2 &{} 0 &{} 1 \end{pmatrix}^{-1}}\cdot (\{1\} \times \{0,1\}^2) \\&= \left\{ {\begin{pmatrix}1\\ -1\\ -1\end{pmatrix}, \begin{pmatrix}1\\ -1\\ 0\end{pmatrix}, \begin{pmatrix}1\\ -1\\ 1\end{pmatrix}, \begin{pmatrix}1\\ 0\\ -1\end{pmatrix}, \begin{pmatrix}1\\ 0\\ 0\end{pmatrix}, \begin{pmatrix}1\\ 0\\ 1\end{pmatrix}, \begin{pmatrix}1\\ 1\\ -1\end{pmatrix}, \begin{pmatrix}1\\ 1\\ 0\end{pmatrix}, \begin{pmatrix}1\\ 1\\ 1\end{pmatrix} }\right\} . \end{aligned}$$

Notice that in this case \(\mathcal {X}_{\mathrm {full}}\) can be more compactly expressed as \(\{1\} \times \{-1,0,1\}^2\). This leads to an alternative way to describe \(\mathcal {X}_{\mathrm {full}}\) in general, which is discussed in detail in Sect. 4.2. In Fig. 4, we represent the \({\mathcal {H}}\)-embedding of \(P_0\) in \(\{0\} \times \mathbb {R}^2\) with respect to \(\varGamma _0\) and the set \(\mathcal {X}_{\mathrm {full}}\).

Fig. 4
figure 4

\({\mathcal {H}}\)-embedding of \(P_0\) in \(\{0\} \times \mathbb {R}^2\) with respect to its simplicial core \(\varGamma _0\). The black points in \(\{1\} \times \mathbb {R}^2\) form the corresponding set \(\mathcal {X}_{\mathrm {full}}\)

3.2 Discrete convexity

The sets \(A \subseteq \mathcal {X}_{\mathrm {full}}\) of Lemma 13 such that \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is 2-level satisfy stringent properties. First, we focus on a “discrete convexity” property that is motivated by Lemma 10.

Lemma 15

Let \(P_0\) be a 2-level \((d-1)\)-polytope \(\mathcal {H}\)-embedded in \(\{x \in \mathbb {R}^{d} \mid x_1 = 0\} \simeq \mathbb {R}^{d-1}\) with respect to some simplicial core \(\varGamma _0\), and let \(M_{d-1} :=M(P_0,\varGamma _0)\). Let \(M_d(c)\) and \(\mathcal {X}_{\mathrm {full}}\) be defined as in (1) and (2), respectively. For \(B \subseteq \mathrm {vert}(P_0) \cup \mathcal {X}_{\mathrm {full}}\), let \(\mathcal {E}(B)\) be the set of all hyperedges \(E \subseteq [d]\), \(E \ne \varnothing \), whose corresponding slab\(S(E) :=\{x \in \mathbb {R}^d \mid 0 \leqslant x(E) \leqslant 1\}\) contains all the points of B. That is,

$$\begin{aligned} \mathcal {E}(B) :=\{ E \subseteq [d],\,E \ne \varnothing \mid \,0 \leqslant x(E)\leqslant 1 \text { for every }x \in B\}\,. \end{aligned}$$
(3)

Let \(A \subseteq \mathcal {X}_{\mathrm {full}}\) be such that \(e_1 \in A\). If \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is an \(\mathcal {H}\)-embedded 2-level polytope, then

$$\begin{aligned} A = \{x \in \mathcal {X}_{\mathrm {full}}\mid 0 \leqslant x(E) \leqslant 1 \text { for every } E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\}\,. \end{aligned}$$
(4)

Moreover, if \(A, B \subseteq \mathcal {X}_{\mathrm {full}}\) both satisfy (4), then so does \(A \cap B\).

Proof

Assume that \(P := \mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is an \(\mathcal {H}\)-embedded 2-level polytope. By Lemma 10, there exists a collection \(\mathcal {E}\) of nonempty subsets \(E \subseteq [d]\) such that P is defined by the hyperedge inequalities \(0 \leqslant x(E) \leqslant 1\) for \(E \in \mathcal {E}\). Since the hyperedge inequalities for \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\) are all those that are valid for P, we get

$$\begin{aligned} P = \{x \in \mathbb {R}^d \mid 0 \leqslant x(E) \leqslant 1 \text { for every } E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\}\,. \end{aligned}$$

Let \(A'\) denote the right hand side of (4). Then A is contained in \(A'\). As \(\mathcal {X}_{\mathrm {full}}\subseteq \mathbb {Z}^d\), we have \(A' \subseteq P \cap \mathbb {Z}^d = \mathrm {vert}(P) \subseteq \mathrm {vert}(P_0) \cup A\), where the equality holds by Lemma 11. Since \(A' \subseteq \mathcal {X}_{\mathrm {full}}\subseteq \{x \in \mathbb {R}^d \mid x_1 = 1\}\) and \(\mathrm {vert}(P_0) \subseteq \{x \in \mathbb {R}^d \mid x_1 = 0\}\), we actually have \(A' \subseteq A\). Thus \(A' = A\).

Next, assume that \(A, B \subseteq \mathcal {X}_{\mathrm {full}}\) satisfy (4). For \(X \subseteq \mathcal {X}_{\mathrm {full}}\), let \(X' :=\{x \in \mathcal {X}_{\mathrm {full}}\mid 0 \leqslant x(E) \leqslant 1 \text { for every } E \in \mathcal {E}(\mathrm {vert}(P_0) \cup X)\}\). Thus \(A = A'\) and \(B = B'\). Also, \(X \subseteq X'\) for all \(X \subseteq \mathcal {X}_{\mathrm {full}}\), thus in particular \(A \cap B \subseteq (A \cap B)'\).

Let \(x \in (A \cap B)'\). We have \(0 \leqslant x(E) \leqslant 1\) for every \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup (A \cap B))\), and thus for every \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\) and every \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup B)\). Hence, \(x \in A' \cap B'\). Using \(A' = A\) and \(B' = B\), we get \((A \cap B)' \subseteq A' \cap B' = A \cap B\). It follows that \((A \cap B)' = A \cap B\), that is, \(A \cap B\) satisfies (4). This concludes the proof. \(\square \)

A property that we will use often is that the point \(e_1\) always satisfies all inequalities in (4), therefore all sets \(A \subseteq \mathcal {X}_{\mathrm {full}}\) satisfying (4) contain \(e_1\).

3.3 Incompatibilities from the base

This section discusses a second property that sets \(A \subseteq \mathcal {X}_{\mathrm {full}}\) have to satisfy in order for the polytope \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) to be 2-level. For simplicity, we let P denote this 2-level d-polytope. Every facet \(F_0\) of \(P_0\) can be uniquely extended to a facet F of P distinct from \(P_0\), see e.g. [44, Theorem 2.7]. Since P is 2-level, we see that the vertices of P are covered by at most two translates of \(\mathrm {aff}(F)\), the affine hull of F.

In order to model this fact, we declare three points \(u, v, w \in \mathrm {vert}(P_0) \cup \mathcal {X}_{\mathrm {full}}\) to be incompatible whenever there exists a facet \(F_0\) of \(P_0\) such that \(\mathrm {aff}(F_0)\) and its three translates containing u, v and w respectively cannot be covered by any two parallel hyperplanes other than \(\{0\}\times \mathbb {R}^{d-1}\) and \(\{1\}\times \mathbb {R}^{d-1}\) (see Fig. 5 for an illustration).

Fig. 5
figure 5

An example of incompatible triple of points. As in Example 14, \(P_0\) is the 2-simplex. The facet \(F_0\) of \(P_0\) depicted in the figure certifies that the displayed triple \(\{a,d,e_1\}\) is incompatible. Notice that \(\{0,a,e_1\}\) is also incompatible

Lemma 16

Let \(P_0\) be a 2-level \((d-1)\)-polytope \(\mathcal {H}\)-embedded in \(\{x \in \mathbb {R}^{d} \mid x_1 = 0\} \simeq \mathbb {R}^{d-1}\) with respect to some simplicial core \(\varGamma _0\), and let \(M_{d-1} :=M(P_0,\varGamma _0)\). As before, let \(M_d(c)\) and \(\mathcal {X}_{\mathrm {full}}\) be defined as in (1) and (2), respectively. Let A be a subset of \(\mathcal {X}_{\mathrm {full}}\). If \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is 2-level, then

$$\begin{aligned} \mathrm {vert}(P_0) \cup A \text { has no incompatible triple.} \end{aligned}$$
(5)

Moreover, if A satisfies (5) then every \(A' \subseteq A\) satisfies (5).

Proof

By contradiction, assume that \(P := \mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is 2-level and u, v and w form an incompatible triple in \(\mathrm {vert}(P) = \mathrm {vert}(P_0) \cup A\). Let \(F_0\) be a facet of \(P_0\) that witnesses this in the sense that no pair of parallel hyperplanes other than \(\{0\}\times \mathbb {R}^{d-1}\) and \(\{1\}\times \mathbb {R}^{d-1}\) cover \(F_0\), u, v and w.

Since \(P_0\) is a facet of P, there is unique facet F of P distinct from \(P_0\) that extends \(F_0\). Let \(H := \mathrm {aff}(F)\). Because P is 2-level, there exists a hyperplane \(H'\) parallel to H that contains all the vertices of P that are not in F. Then H and \(H'\) are two parallel hyperplanes distinct from \(\{0\}\times \mathbb {R}^{d-1}\) and \(\{1\}\times \mathbb {R}^{d-1}\) that cover \(F_0\), u, v and w, a contradiction. Hence, A satisfies (5).

The fact that (5) is monotone for inclusion is straightforward. \(\square \)

3.4 Moore families

In the literature, every collection of subsets of some set \(\mathcal {X}\) that is closed under intersection and contains \(\mathcal {X}\) itself is called Moore family on \(\mathcal {X}\). The members of a Moore family are usually called closed sets. The notion of Moore family was introduced by Birkhoff in [3], referring to Moore’s book [34], that dates back to the beginning of the last century.

Definition 17

Let \(P_0\) be a 2-level \((d-1)\)-polytope \(\mathcal {H}\)-embedded in \(\{0\} \times \mathbb {R}^{d-1}\) with respect to some simplicial core \(\varGamma _0\), and let \(\mathcal {X}_{\mathrm {full}}\) be defined as in (2). Let \(\mathcal {A}_{\mathrm {dc}}= \mathcal {A}_{\mathrm {dc}}(P_0,\varGamma _0)\) denote the family of subsets A of \(\mathcal {X}_{\mathrm {full}}\) satisfying (4). Let \(\mathcal {A}_{\mathrm {comp}}= \mathcal {A}_{\mathrm {comp}}(P_0,\varGamma _0)\) denote the family of subsets A of \(\mathcal {X}_{\mathrm {full}}\) satisfying (5), to which \(\mathcal {X}_{\mathrm {full}}\) is added.

By Lemmas 15 and 16, both families are in fact Moore families, as well as their intersection \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\).

Each one of these families is “sufficient” in the sense that enumerating its members allows to recover all 2-level d-polytopes P with a facet isomorphic to the fixed 2-level \((d-1)\)-polytope \(P_0\). The next definition formalizes this. Notice that \(e_1 \in A\) for all \(A \in \mathcal {A}_{\mathrm {dc}}\), and thus for all \(A \in \mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\).

Definition 18

Let \(P_0\) be a 2-level \((d-1)\)-polytope \(\mathcal {H}\)-embedded in \(\{0\} \times \mathbb {R}^{d-1}\) with respect to some simplicial core \(\varGamma _0\), and let \(\mathcal {X}_{\mathrm {full}}\) be defined as in (2). A family \(\mathcal {A}\) of subsets of \(\mathcal {X}_{\mathrm {full}}\) is called complete with respect to \(P_0\), \(\varGamma _0\) every 2-level d-polytope having a facet isomorphic to \(P_0\) is affinely equivalent (and thus isomorphic) to \(\mathrm {conv}(\mathrm {vert}{(P_0)} \cup A)\) for some \(A \in \mathcal {A}\).

We get the following result.

Lemma 19

Using the notation of Definition 17, \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) is a complete family.

Proof

The result follows directly from Lemmas 1315 and 16. \(\square \)

3.5 Pseudocode

To conclude this section, we provide a sketch of the pseudocode of the enumeration algorithm.

As before, let \(P_0\) be a fixed 2-level \((d-1)\)-polytope and let \(\varGamma _0\) be a simplicial core for \(P_0\). The algorithm enumerates all candidate sets\(A \in \mathcal {A}\) for some complete family \(\mathcal {A} = \mathcal {A}(P_0,\varGamma _0)\) and checks, for each of them, if it yields a 2-level polytope \(P = \mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) that we did not previously find. In case the latter holds, the algorithm adds P to the list \(L_d\) of d-dimensional 2-level polytopes.

Clearly, the strength of the algorithm relies on how accurate is our choice of \(\mathcal {A}\), and how efficiently we can enumerate the sets \(A \in \mathcal {A}\). By Lemma 19, we can define \(\mathcal {A}\) to be \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) for now. In Sect. 4, we will introduce two extra ideas that will allow us to replace the ground set \(\mathcal {X}_{\mathrm {full}}\) by a smaller ground set and reduce the complete family \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\).

The pseudocode of the enumeration algorithm is presented below, see Algorithm 1. The correctness of the algorithm is a direct consequence of the fact that, for each \(P_0 \in L_{d-1}\) with simplicial core \(\varGamma _0\), \(\mathcal {A} = \mathcal {A}(P_0,\varGamma _0)\) is a complete family. We remark that for \(\mathcal {A} = \mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) we can always take the first vertex \(v_1\) of the simplicial core of the output polytope P to be \(e_1\).

figure a

4 Reductions of the ground set and complete family

In the previous section, we divided the task of enumerating all 2-level d-polytopes into the subtasks of enumerating all 2-level d-polytopes P with a prescribed facet \(P_0\), where \(P_0\) is a fixed 2-level \((d-1)\)-polytope. Prescribing \(P_0\) as a facet (sometimes referred to as the base) yields constraints that were exploited to define a first ground set and complete family to be used by our enumeration algorithm. In this section, we discuss more properties that allow us to reduce both ground set and complete family.

First, we observe that some points of the ground set \(\mathcal {X}_{\mathrm {full}}\) are never part of any proper closed set in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) (Lemma 20). Here, we call proper every closed set in \(\mathcal {X}_{\mathrm {full}}\) that is distinct from the whole ground set \(\mathcal {X}_{\mathrm {full}}\).

Next, we introduce a covering of \(\mathcal {X}_{\mathrm {full}}\) by tiles, see (8). We prove that every proper closed set in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) is contained in some tile, and that there exists a collection of translations that move proper candidate sets across tiles (Lemma 23) and preserve membership in both \(\mathcal {A}_{\mathrm {dc}}\) (Lemma 27) and \(\mathcal {A}_{\mathrm {comp}}\) (Lemma 28), thus in their intersection.

Both these arguments lead to the construction of a reduced ground set \(\mathcal {X}_{\mathrm {final}}\subseteq \mathcal {X}_{\mathrm {full}}\), defined in (10). As we prove towards the end of the section, the collection of all sets in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) that are contained in \(\mathcal {X}_{\mathrm {final}}\) is a complete family. This crucially improves the efficiency of the enumeration algorithm, see Sect. 7.1.

4.1 Removing points that always cause incompatibilities

Lemma 20

Let \(P_0\) be a 2-level \((d-1)\)-polytope \(\mathcal {H}\)-embedded in \(\{0\} \times \mathbb {R}^{d-1}\) with respect to some simplicial core \(\varGamma _0\), and let \(\mathcal {X}_{\mathrm {full}}\) be defined as in (2). Let \(\mathcal {F} = \mathcal {F}(P_0,\varGamma _0)\) denote the collection of nonempty subsets \(E \subseteq \{2,\ldots ,d\}\) such that \(x(E) \geqslant 0\) or \(x(E) \leqslant 1\) defines a facet of \(P_0\).Footnote 4 Finally, let

$$\begin{aligned} \mathcal {X}_{\mathrm {comp}}= \mathcal {X}_{\mathrm {comp}}(P_0,\varGamma _0) :=\left\{ u \in \mathcal {X}_{\mathrm {full}}\mid u(E) \in \{-1,0,1\} \text { for every } E \in \mathcal {F} \right\} \,. \end{aligned}$$
(6)

Every proper closed set \(A \in \mathcal {A}_{\mathrm {comp}}\) that contains \(e_1\) is contained in \(\mathcal {X}_{\mathrm {comp}}\).

Proof

By contradiction, suppose that there exists a point \(u \in A{\setminus }\mathcal {X}_{\mathrm {comp}}\). Let \(E \in \mathcal {F}\) be a hyperedge such that \(u(E) \notin \{-1,0,1\}\), and let \(F_0\) denote a corresponding facet of \(P_0\). Let v be any vertex of \(P_0\) not in \(F_0\).

The four affine spaces \(\{x \in \mathbb {R}^d \mid x(E) = 0,\ x_1 = 0\}\), \(\{x \in \mathbb {R}^d \mid x(E) = 1,\ x_1 = 0\}\), \(\{x \in \mathbb {R}^d \mid x(E) = 0,\ x_1 = 1\}\) and \(\{x \in \mathbb {R}^d \mid x(E) = u(E),\ x_1 = 1\}\) cannot be covered by two parallel hyperplanes other than \(\{0\} \times \mathbb {R}^{d-1}\) and \(\{1\} \times \mathbb {R}^{d-1}\). This implies that \(\{u,v,e_1\}\) is an incompatible triple in \(\mathrm {vert}(P_0) \cup A\), and thus \(A \notin \mathcal {A}_{\mathrm {comp}}\), a contradiction. (Here we used \(A \ne \mathcal {X}_{\mathrm {full}}\). Notice that the “full” closed set \(A = \mathcal {X}_{\mathrm {full}}\) does not yield a 2-level polytope.) \(\square \)

Example 21

Let \(d = 3\), let \(P_0\) be the 2-simplex, see Example 14. Using (6), we deduce that

$$\begin{aligned} \mathcal {X}_{\mathrm {comp}}= \left\{ {\begin{pmatrix}1\\ -1\\ 0\end{pmatrix}, \begin{pmatrix}1\\ -1\\ 1\end{pmatrix}, \begin{pmatrix}1\\ 0\\ -1\end{pmatrix}, \begin{pmatrix}1\\ 0\\ 0\end{pmatrix}, \begin{pmatrix}1\\ 0\\ 1\end{pmatrix}, \begin{pmatrix}1\\ 1\\ -1\end{pmatrix}, \begin{pmatrix}1\\ 1\\ 0\end{pmatrix} }\right\} . \end{aligned}$$

Indeed, the facet \(x_2 +x_3 \leqslant 1\) of \(P_0\) is such that \(x_2 +x_3 = 2\) and \(x_2 +x_3 = -2\) for the points \({\begin{pmatrix}1\\ 1\\ 1\end{pmatrix},\begin{pmatrix}1\\ -1\\ -1\end{pmatrix} } \in \mathcal {X}_{\mathrm {full}}\) respectively, hence these points do not figure in \(\mathcal {X}_{\mathrm {comp}}\). See Fig. 6 for an illustration.

Fig. 6
figure 6

The black points in the hyperplane \(\{1 \} \times \mathbb {R}^2\) represent \(\mathcal {X}_{\mathrm {comp}}\) when \(P_0\) is the 2-simplex

Lemma 20 directly gives a first way to reduce the ground set \(\mathcal {X}_{\mathrm {full}}\) and complete family \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\). Along with this first reduction of the ground set, we are able to simplify the description of the Moore family \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\). (Recall that \(e_1 \in A\) for all \(A \in \mathcal {A}_{\mathrm {dc}}\).)

Lemma 22

Assume the same notations as in Lemma 20. A proper subset A of \(\mathcal {X}_{\mathrm {full}}\) containing \(e_1\) belongs to \(\mathcal {A}_{\mathrm {comp}}\) if and only if \(A \subseteq \mathcal {X}_{\mathrm {comp}}\) and

$$\begin{aligned} u(E) \cdot v(E) \in \{0,1\} \text { for every } u, v \in A \text { and every } E \in \mathcal {F}\,. \end{aligned}$$
(7)

Proof

First, consider a closed set \(A \in \mathcal {A}_{\mathrm {comp}}\) containing \(e_1\) and distinct from \(\mathcal {X}_{\mathrm {full}}\). By Lemma 20, \(A \subseteq \mathcal {X}_{\mathrm {comp}}\). That is, \(x(E) \in \{-1,0,1\}\) for all \(x \in A\) and \(E \in \mathcal {F}\). So that \(u(E) \cdot v(E) \in \{-1,0,1\}\) for all \(u, v \in A\) and \(E \in \mathcal {F}\).

By contradiction, suppose that there exist \(E \in \mathcal {F}\) and \(u, v \in A\) such that \(u(E) \cdot v(E) = -1\). Up to renaming u and v, we may assume \(u(E) = 1\) and \(v(E) = -1\). From the definition of \(\mathcal {F}\), we have \(x(E) \in \{0,1\}\) for every \(x \in \mathrm {vert}(P_0)\). Therefore \(\mathrm {vert}(P_0) \cup A\) contains the triple of incompatible points \(\{u,v,e_1\}\), a contradiction.

Next, let A be a subset of \(\mathcal {X}_{\mathrm {comp}}\) containing \(e_1\) and satisfying (7). Then for every \(E \in \mathcal {F}\), either \(x(E) \in \{0,1\}\) for all \(x \in A\), or \(x(E) \in \{-1,0\}\) for all \(x \in A\), or both. This implies that \(\mathrm {vert}(P_0) \cup A\) contains no incompatible triple. Thus \(A \in \mathcal {A}_{\mathrm {comp}}\). \(\square \)

4.2 Removing points that can be avoided by translating the candidate set

We now establish useful properties of \(\mathcal {X}_{\mathrm {full}}\) that will lead to a second reduction of the ground set. (Recall that \(\mathcal {X}_{\mathrm {full}}\) is defined in (2) and \(M_d(c)\) is defined in (1).)

For each fixed \(c \in \{0,1\}^{d-1}\), we define a corresponding tileFootnote 5

$$\begin{aligned} T(c) :=M_d(0)^{-1} \cdot \left( \{1\} \times \prod _{i = 1}^{d-1} \{0-c_i,1-c_i\}\right) \,. \end{aligned}$$
(8)

Thus each tile is the vertex set of a \((d-1)\)-parallelepiped in \(\{1\} \times \mathbb {R}^{d-1}\).

Lemma 23

Consider the set \(\mathcal {X}_{\mathrm {full}}\) defined as in (2) and, for some \(c \in \{0,1\}^{d-1}\) let the matrix \(M_d(c)\) be defined as in (1) and T(c) as in (8). Then \(T(c) = M_d(c)^{-1} \cdot (\{1\} \times \{0,1\}^{d-1})\). Thus \(\mathcal {X}_{\mathrm {full}}\) is the union of the \(2^{d-1}\) tiles T(c) for \(c \in \{0,1\}^{d-1}\). Moreover, \(\mathcal {X}_{\mathrm {full}}= M_d(0)^{-1} \cdot (\{1\} \times \{-1,0,1\}^{d-1})\).

Proof

Letting \(c' :=- M_{d-1}^{-1}\cdot c\), we have

Hence, we have

$$\begin{aligned} M_d(0) \cdot M_d(c)^{-1} \cdot (\{1\} \times \{0,1\}^{d-1})&=\begin{pmatrix}1 \\ -c\end{pmatrix} + \{0\} \times \{0,1\}^{d-1}\\&=\{1\} \times \prod _{i = 1}^{d-1} \{0-c_i,1-c_i\}\,. \end{aligned}$$

By applying \(M_d(0)^{-1}\), this implies immediately that \(T(c) = M_d^{-1}(c) \cdot (\{1\} \times \{0,1\}^{d-1})\). Moreover, taking the union over all \(c \in \{0,1\}^{d-1}\), we get \(\mathcal {X}_{\mathrm {full}}= M_d(0)^{-1} \cdot (\{1\} \times \{-1,0,1\}^{d-1})\). \(\square \)

As established in the next lemma, the closed sets of \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) either are included in a tile or equal to the full ground set \(\mathcal {X}_{\mathrm {full}}\).

Lemma 24

Assume the notations of Definition 17. Consider \(A \subsetneq \mathcal {X}_{\mathrm {full}}\) be an element of the family \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\). Then A is contained in some tile.

Proof

By contradiction, assume that A is not contained in a tile. Then, A contains two points u and v such that \((M_d(0) \cdot u)_i \cdot (M_d(0) \cdot v)_i = -1\) for some index \(i > 1\). But then the set \(E \in \mathcal {F}\) corresponding to the \((i-1)\)-th facet of the simplicial core \(\varGamma _0\) has \(u(E) \cdot v(E) = -1\). Since A belongs to \(\mathcal {A}_{\mathrm {dc}}\), we have \(e_1 \in A\). Lemma 22 gives the desired contradiction. \(\square \)

In the following lemma, we introduce certain translations that when applied to a tile produce another tile.

Lemma 25

Consider the tile T(c) for some \(c \in \{0,1\}^{d-1}\), see (8). Then for every \(a \in T(c)\), there exists \(c' \in \{0,1\}^{d-1}\) such that \(T(c)+e_1-a = T(c')\).

Proof

Let \(T=T(c)\) for some \(c \in \{0,1\}^{d-1}\) and fix \(a \in T\). We want to prove that there exists \(c'\) such that, for each \(x \in T\) we have \(x+e_1 - a \in T(c')\). The statement then follows from the fact that each tile has the same number of points and the translation is an invertible map. Fix \(x \in T\) and let \(b :=M_d(0) \cdot a\) and \(y :=M_d(0) \cdot x\). We can write \(b_{i+1} = \overline{b}_i - c_{i}\) and \(y_{i+1} = \overline{y}_i - c_{i}\) for \(i \in [d-1]\), where \(\overline{b}\) and \(\overline{y}\) are some vectors in \(\{0,1\}^{d-1}\). Then we have

$$\begin{aligned} y_{i+1} - b_{i+1} = (\overline{y}_i - c_{i}) - (\overline{b}_i - c_{i}) = \overline{y}_i - \overline{b}_i \end{aligned}$$

for \(i \in [d-1]\). It follows that \(y + e_1 - b \in \{1\} \times \prod _{i=1}^{d-1} \{0-\overline{b}_i,1-\overline{b}_i\}\), and thus \(x + e_1 - a \in T(\overline{b})\). Since \(\overline{b}\) only depends on a, the thesis follows by setting \(c'=\overline{b}\). \(\square \)

Let \(\preccurlyeq \) denote the usual lexicographic order on \(\mathbb {R}^d\): \(a \preccurlyeq b\) whenever \(a = b\) or there is an index \(j \in [d]\) with \(a_j < b_j\) and \(a_i = b_i\) for all \(i < j\). Notice that \(\preccurlyeq \) is invariant under translation: \(a \preccurlyeq b\) iff \(a + c \preccurlyeq b + c\), for every \(a, b, c \in \mathbb {R}^d\). Below, we will use the linear ordering \(\mathop {{\preccurlyeq }_0}\) on \(\mathbb {R}^d\) defined through the linear isomorphism \(x \mapsto M_d(0) \cdot x\) by

$$\begin{aligned} a \mathop {{\preccurlyeq }_0}b \iff M_d(0) \cdot a \preccurlyeq M_d(0) \cdot b\,. \end{aligned}$$
(9)

This linear ordering is also invariant under translation.

Consider a subset A of some tile T. By Lemma 25, for every \(a \in A\), the translate \(A' :=A+e_1-a\) is contained in some tile \(T'\), and thus in particular contained in \(\mathcal {X}_{\mathrm {full}}\). Moreover, the d-polytopes \(\mathrm {conv}(\mathrm {vert}{(P_0)} \cup A)\) and \(\mathrm {conv}(\mathrm {vert}{(P_0)} \cup A')\) are affinely equivalent since \(A'\) is a translated copy of A in the hyperplane \(\{1\} \times \mathbb {R}^{d-1}\). In order to eliminate some redundancies, we wish to choose a such that \(A'\) is contained in a smaller portion of the ground set \(\mathcal {X}_{\mathrm {full}}\). Lemma 26 proves that this can be achieved.

Lemma 26

Let \(\mathcal {X}_{\mathrm {full}}\) and \(\mathop {{\preccurlyeq }_0}\) be defined as above, see (2) and (9) respectively. Let A be a subset of \(\mathcal {X}_{\mathrm {full}}\) that is contained in some tile. Then there exists \(a^* \in A\) such that \(A + e_1 - a^*\) is contained in \(\{x \in \mathcal {X}_{\mathrm {full}}\mid e_1 \mathop {{\preccurlyeq }_0}x\}\).

Proof

Let \(a^*\) be the minimum of A for \(\mathop {{\preccurlyeq }_0}\). By Lemma 25, \(A + e_1 - a^*\) is contained in \(\mathcal {X}_{\mathrm {full}}\). By contradiction, assume that there exists \(a \in A\) such that \(a + e_1 - a^* \mathop {{\prec }_0}e_1\). Since \(\mathop {{\preccurlyeq }_0}\) is invariant under translation, we get \(a \mathop {{\prec }_0}a^*\), a contradiction. The lemma follows. \(\square \)

Lemma 26 motivates the following definition of our final ground set, that we use in our actual implementation of Algorithm 1 (see Fig. 7 for an illustration):

$$\begin{aligned} \mathcal {X}_{\mathrm {final}}= \mathcal {X}_{\mathrm {final}}(P_0,\varGamma _0) :=\{x \in \mathcal {X}_{\mathrm {comp}}\mid e_1 \mathop {{\preccurlyeq }_0}x\}. \end{aligned}$$
(10)
Fig. 7
figure 7

\({\mathcal {H}}\)-embedding of \(P_0\) in \(\{0\} \times \mathbb {R}^2\) with respect to its simplicial core \(\varGamma _0\), together with the corresponding ground set \(\mathcal {X}_{\mathrm {final}}= \mathcal {X}_{\mathrm {final}}(P_0,\varGamma _0)\) in \(\{1\} \times \mathbb {R}^2\) (indicated by black points). a\(\mathcal {X}_{\mathrm {final}}\) if \(P_0\) is a 2-simplex. b\(\mathcal {X}_{\mathrm {final}}\) if \(P_0\) is a 2-cube

We establish an invariance property for closed sets of \(\mathcal {A}_{\mathrm {dc}}\) and then \(\mathcal {A}_{\mathrm {comp}}\) under translations, that will be useful to prove that the closed sets of the restriction of \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) forms a complete family.

Lemma 27

Let \(\mathcal {A}_{\mathrm {dc}}\) be as in Definition 17. Consider a set \(A \in \mathcal {A}_{\mathrm {dc}}\) that is contained in some tile. Then \(A+e_1-a \in \mathcal {A}_{\mathrm {dc}}\) for every \(a \in A\).

Proof

For convenience, define \(A' :=A + e_1 - a\). By Lemma 25, \(A'\) is also contained in some tile. In particular, \(A' \subseteq \mathcal {X}_{\mathrm {full}}\).

First, we establish a bijection between \(\mathcal {E}(\mathrm {vert}(P_0) \cup A)\) and \(\mathcal {E}(\mathrm {vert}(P_0) \cup A')\) (see (3) for the definition of the collection \(\mathcal {E}(\,\cdot \,)\)). Notice that for every \(E \in {\mathcal {E}}(\mathrm {vert}(P_0) \cup A)\), we have \((e_1-a)(E) \in \{-1,0,1\}\), hence \(a(E) \in \{0,1\}\).

For \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\), we let \(E' :=E\) if \((e_1-a)(E) = 0\) and \(E' :=E \vartriangle \{1\}\) if \((e_1-a)(E) \ne 0\), where \(\vartriangle \) denotes symmetric difference. Observe that we always have \((e_1-a)(E) = (e_1-a)(E')\), since \(E\cap \{2,\ldots ,d\}=E'\cap \{2,\ldots ,d\}\) and \(e_1, a\in \{1\}\times \mathbb {R}^{d-1}\).

Take \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\). For all \(x \in \mathcal {X}_{\mathrm {full}}\), we find

$$\begin{aligned} (x+e_1-a)(E') = x(E') + (e_1-a) (E') = x(E') + (e_1-a)(E) = x(E) \in \{0,1\}\,. \end{aligned}$$
(11)

Indeed, if \((e_1-a)(E) = 0\) then \(E' = E\). Second, if \((e_1-a)(E) = -1\) then \(1 \notin E\), \(E' = E \cup \{1\}\) and \(x(E') = x(E)+1\). Finally, if \((e_1-a)(E)= 1\) then \(1 \in E\), \(E' = E \setminus \{1\}\) and \(x(E') = x(E)-1\).

Moreover, for all \(x \in \mathrm {vert}(P_0)\), we have

$$\begin{aligned} x(E') = x(E) \in \{0,1\} \end{aligned}$$

since \(x \in \mathrm {vert}(P_0)\) implies \(x_1 = 0\). Therefore, \(E' \in \mathcal {E}(\mathrm {vert}(P_0) \cup A')\).

So far, we obtained a map \(\psi : \mathcal {E}(\mathrm {vert}(P_0) \cup A) \rightarrow \mathcal {E}(\mathrm {vert}(P_0) \cup A')\) defined as \(E \mapsto \psi (E) :=E'\). This map is injective since if \(E, F \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\) have \(\psi (E) = \psi (F)\) then \(E \cap \{2,\ldots ,d\} = F \cap \{2,\ldots ,d\}\) so that \((e_1 - a)(E) = (e_1 - a)(F)\). It follows that \(E = F\).

Since \(A \in \mathcal {A}_{\mathrm {dc}}\), we have \(e_1 \in A\) and hence \(2e_1 - a \in A'\). Let \(a' :=2e_1 - a\). By applying the reasoning above to \(A'\) and \(A = A' + e_1 - a'\), we know that there exists an injective map from \(\mathcal {E}(\mathrm {vert}(P_0) \cup A')\) to \(\mathcal {E}(\mathrm {vert}(P_0) \cup A)\). This implies that \(\psi \) is in fact a bijection.

Let \(A''\) be the set of points \(y \in \mathcal {X}_{\mathrm {full}}\) such that \(0 \leqslant y(E') \leqslant 1\) for every \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A')\). Notice that \(A' \subseteq A''\). Now take \(x' \in A''\). Then letting \(x :=x' - e_1 + a = x' + e_1 - a'\) and using (11), we find that \(x(E) = x'(E')\) for all \(E\in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\), and thus \(x(E) \in \{0,1\}\) for all \(E\in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\). Hence \(x = x'-e_1+a \in A\). We deduce that \(A''-e_1+a \subseteq A\), or equivalently, \(A'' \subseteq A+e_1-a = A'\). Using this, we conclude that \(A'\) verifies (4), or equivalently \(A' \in \mathcal {A}_{\mathrm {dc}}\), as desired. \(\square \)

A similar property is satisfied by the sets in \(\mathcal {A}_{\mathrm {comp}}\). The proof directly follows from the definition of incompatible triple, since \(\mathrm {vert}(P_0) \cup A\) contains no incompatible triple if and only if \(\mathrm {vert}(P_0) \cup (A + e_1 - a)\) contains no incompatible triple.

Lemma 28

Let \(\mathcal {A}_{\mathrm {comp}}\) be as in Definition 17. Consider a set \(A \in \mathcal {A}_{\mathrm {comp}}\) that is contained in some tile. Then \(A+e_1-a \in \mathcal {A}_{\mathrm {comp}}\) for every \(a \in A\).

Lemmas 2427 and 28 imply that if a set \(A \ne \mathcal {X}_{\mathrm {full}}\) is in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\), then \(A + e_1 - a\) belongs to \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) for every \(a \in A\).

4.3 Final complete family

Consider some general Moore family \(\mathcal {A}\) on some ground set \(\mathcal {X}\) and \(\mathcal {Y} \subseteq \mathcal {X}\). There is a natural way to construct a new Moore family starting from \(\mathcal {A}\) and restricting to \(\mathcal {Y}\). In fact, as \(\mathcal {A}\) is a Moore family on \(\mathcal {X}\), the collection \(\mathcal {A}\big |_{\mathcal {Y}} :=\{ A \in \mathcal {A} \mid A \subseteq \mathcal {Y} \} \cup \{ \mathcal {Y} \}\) is a Moore family over \(\mathcal {Y}\). We call the Moore family \(\mathcal {A}\) the restriction of \(\mathcal {A}\) to \(\mathcal {Y}\).

Now consider \(\mathcal {X}_{\mathrm {full}}\) as in (2) and \(\mathcal {X}_{\mathrm {final}}\) as in (10). We have the inclusions \(\mathcal {X}_{\mathrm {final}}\subseteq \mathcal {X}_{\mathrm {comp}}\subseteq \mathcal {X}_{\mathrm {full}}\). In this section, we finally prove that the collection \((\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}})\big |_{\mathcal {X}_{\mathrm {final}}}\) constitutes a complete family. This is the family of sets that the enumeration algorithm constructs, parses and tests for 2-levelness.

Lemma 29

Assume the notations of Definition 17, and define \(\mathcal {X}_{\mathrm {final}}\) as in (10). Then \((\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}})\big |_{\mathcal {X}_{\mathrm {final}}}\) is a complete family with respect to \(P_0\), \(\varGamma _0\).

Proof

Let P be some 2-level d-polytope having a facet isomorphic to \(P_0\). By Lemma  19, there is a closed set A in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) such that P is isomorphic to \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\).

Lemma 24 implies that A is contained in some tile. By Lemma 26, there exists \(a^* \in A\) such that \(A^* :=A + e_1 - a^*\) is contained in \(\mathcal {X}_{\mathrm {final}}\). By Lemmas 27 and 28, the set \(A^*\) belongs to \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\). Since \(A^*\) is a translated copy of A in the hyperplane \(\{1\} \times \mathbb {R}^{d-1}\), \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) and \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A^*)\) are affinely equivalent. In particular, the latter polytope is 2-level.

We conclude that \(A^*\) is a closed set in \((\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}})\big |_{\mathcal {X}_{\mathrm {final}}}\) such that P is isomorphic to \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A^*)\). Since this holds for an arbitrary 2-level d-polytope P with a facet isomorphic to \(P_0\), the family \((\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}})\big |_{\mathcal {X}_{\mathrm {final}}}\) is complete. \(\square \)

Example 30

Figure 8a represents the collection of all closed sets in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) contained in \(\mathcal {X}_{\mathrm {final}}= \mathcal {X}_{\mathrm {final}}(P_0,\varGamma _0)\) when \(P_0\) is the 2-simplex. The six sets in Fig. 8a yield four nonisomorphic 2-level polytopes, namely: the simplex, the square based pyramid, the triangular prism and the octahedron.

Similarly, Fig. 8b represents the collection of all closed sets in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) contained in \(\mathcal {X}_{\mathrm {final}}\) when \(P_0\) is the 2-cube. The four sets depicted in Fig. 8b correspond to the square based pyramid, the triangular prism, the 3-cube. The latter is not a 2-level polytope, the remaining ones are.

Fig. 8
figure 8

Exploded view of the sets in \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) contained in \(\mathcal {X}_{\mathrm {final}}\), with respect to two different bases \(P_0\). In the upper part of the figure, all points joined by dotted lines are identified. a Complete family when \(P_0\) is the 2-simplex. b Complete family for when \(P_0\) is the 2-cube

5 Closure operators

When implementing the enumeration algorithm (see Algorithm 1 above), we take \(\mathcal {A}\) to be the Moore family from Lemma 29. We represent \(\mathcal {A}\) by its corresponding closure operator. The reason for doing this is that we use Ganter’s Next-Closure algorithm [13, 14] for enumerating the closed sets of \(\mathcal {A}\). This algorithm is one of the best known and most versatile algorithms for the enumeration of closed sets, initially originating from formal concept analysis [15]. Ganter’s algorithm takes as input the closure operator generating the Moore family. It was employed, e.g., in [28] for constructing face lattices of polytopes. More recently, the same algorithm was used for computations in tropical geometry, see [25].

The goal of this section is to give the closure operator corresponding to the Moore family \(\mathcal {A}\) used in the algorithm. In order to do this, we give the closure operators over \(\mathcal {X}_{\mathrm {full}}\) for the families \(\mathcal {A}_{\mathrm {dc}}\), \(\mathcal {A}_{\mathrm {comp}}\) and their intersection \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\). Then, we explain how to obtain the closure operator for the restriction of \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) to \(\mathcal {X}_{\mathrm {final}}\).

First, let us recall the definition of closure operator.

Definition 31

Let \(\mathcal {X}\) be an arbitrary ground set. A closure operator over \(\mathcal {X}\) is a function \(\mathrm {cl}: 2^{\mathcal {X}} \rightarrow 2^{\mathcal {X}}\) on the power set of \(\mathcal {X}\) that is

  1. (i)

    idempotent: \(\mathrm {cl}(\mathrm {cl}(A)) = \mathrm {cl}(A)\) for every \(A\subseteq \mathcal {X}\),

  2. (ii)

    extensive: \(A \subseteq \mathrm {cl}(A)\) for every \(A\subseteq \mathcal {X}\),

  3. (iii)

    monotone: \(A \subseteq B \Rightarrow \mathrm {cl}(A) \subseteq \mathrm {cl}(B)\) for every \(A, B \subseteq \mathcal {X}\).

A set \(A \subseteq \mathcal {X}\) is said to be closed with respect to \(\mathrm {cl}\) provided that A is a fixed point of \(\mathrm {cl}\), i.e., \(\mathrm {cl}(A) = A\).

If \(\mathrm {cl}\) is a closure operator over \(\mathcal {X}\), then \(\mathcal {A}_{\mathrm {cl}} := \{A \subseteq \mathcal {X} \mid \mathrm {cl}(A) = A\}\) is a Moore family on \(\mathcal {X}\). Conversely, let \(\mathcal {A}\) be a Moore family on \(\mathcal {X}\). The closure operator \(\mathrm {cl}_\mathcal {A}\) canonically associated to \(\mathcal {A}\) is defined as \( \mathrm {cl}_\mathcal {A}(A) :=\bigcap \{B \in \mathcal {A} \mid A \subseteq B \} \). It is known that the two correspondences \(\mathrm {cl}\mapsto \mathcal {A}_\mathrm {cl}\) and \(\mathcal {A} \mapsto \mathrm {cl}_{\mathcal {A}}\) defined above are bijective, and moreover each one is the inverse of the other. See for instance [7] for a survey.

5.1 Discrete convex hull operator

Lemma 32

Assume the notations of Definition 17. Let \(\mathrm {cl}_{\mathrm {dc}}: 2^{\mathcal {X}_{\mathrm {full}}} \rightarrow 2^{\mathcal {X}_{\mathrm {full}}}\) be the map defined as:

$$\begin{aligned} \mathrm {cl}_{\mathrm {dc}}(A) :=\{x \in \mathcal {X}_{\mathrm {full}}\mid 0 \leqslant x(E) \leqslant 1 \text { for every } E\in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\}\,. \end{aligned}$$
(12)

Then \(\mathrm {cl}_{\mathrm {dc}}\) is the closure operator associated to the Moore family \(\mathcal {A}_{\mathrm {dc}}\).

Proof

First, we prove that \(\mathrm {cl}_{\mathrm {dc}}\) is a closure operator.

  • \(\mathrm {cl}_{\mathrm {dc}}\) is extensive, since for every \(A \subseteq \mathcal {X}_{\mathrm {full}}\), every point of A belongs to all the slabs S(E) for \(E \in \mathcal {E}(A \cup \mathrm {vert}(P_0))\).

  • \(\mathrm {cl}_{\mathrm {dc}}\) is monotone. Let \(A \subseteq B \subseteq \mathcal {X}_{\mathrm {full}}\). Then, we have \(\mathcal {E}(\mathrm {vert}(P_0) \cup B) \subseteq \mathcal {E}(\mathrm {vert}(P_0) \cup A)\) and hence \(\mathrm {cl}_{\mathrm {dc}}(A) \subseteq \mathrm {cl}_{\mathrm {dc}}(B)\).

  • \(\mathrm {cl}_{\mathrm {dc}}\) is idempotent. Let \(A \subseteq \mathcal {X}_{\mathrm {full}}\). Notice that all slabs S(E) containing \(\mathrm {vert}(P_0) \cup A\) also contain \(\mathrm {vert}(P_0) \cup \mathrm {cl}_{\mathrm {dc}}(A)\). We get that \(\mathcal {E}(\mathrm {vert}(P_0) \cup A) \subseteq \mathcal {E}(\mathrm {vert}(P_0) \cup \mathrm {cl}_{\mathrm {dc}}(A))\), and the converse inclusion by extensitivity. Thus, \(\mathcal {E}(\mathrm {vert}(P_0) \cup A) = \mathcal {E}(\mathrm {vert}(P_0) \cup \mathrm {cl}_{\mathrm {dc}}(A))\). We conclude that \(\mathrm {cl}_{\mathrm {dc}}(A) = \mathrm {cl}_{\mathrm {dc}}(\mathrm {cl}_{\mathrm {dc}}(A))\).

By (4) and (12), it follows that \(\mathrm {cl}_{\mathrm {dc}}\) is the closure operator associated to \(\mathcal {A}_{\mathrm {dc}}\). \(\square \)

5.2 Incompatibility operator

Lemma 33

Assume the notations of Definition 17. For every \(A\subseteq \mathcal {X}_{\mathrm {full}}\), let

$$\begin{aligned} \mathrm {cl}_{\mathrm {comp}}(A) :={\left\{ \begin{array}{ll} A &{} \text {if } A \cup \mathrm {vert}(P_0) \text { does not contain any}\\ &{} \text {incompatible triple of points},\\ \mathcal {X}_{\mathrm {full}}&{}\text {otherwise.} \end{array}\right. } \end{aligned}$$
(13)

Then \(\mathrm {cl}_{\mathrm {comp}}\) is the closure operator associated to \(\mathcal {A}_{\mathrm {comp}}\).

Proof

Take \(A \subseteq \mathcal {X}_{\mathrm {full}}\). The claim follows by proving that \(\mathrm {cl}_{\mathrm {comp}}(A)\) is equal to the intersection of all closed sets in \(\mathcal {A}_{\mathrm {comp}}\) that contain A.

If A contains some incompatible triple of points, then the only closed set of \(\mathcal {A}_{\mathrm {comp}}\) that contains A is \(\mathcal {X}_{\mathrm {full}}\) itself and thus \(\mathrm {cl}_{\mathrm {comp}}(A) = \mathcal {X}_{\mathrm {full}}\).

Otherwise, A is a closed set in \(\mathcal {A}_{\mathrm {comp}}\) thus it coincides with the intersection of all closed sets in \(\mathcal {A}_{\mathrm {comp}}\) that contain it. Moreover, by (13), \(\mathrm {cl}_{\mathrm {comp}}(A) = A\). \(\square \)

5.3 Closure operator for the intersection

Lemma 34

Assume the notations of Definition 17, and let \(\mathrm {cl}_{\mathrm {dc}}\) and \(\mathrm {cl}_{\mathrm {comp}}\) be as in (12) and (13). The following two properties hold:

  1. (i)

    if \(A \in \mathcal {A}_{\mathrm {dc}}\), then \(\mathrm {cl}_{\mathrm {comp}}(A) \in \mathcal {A}_{\mathrm {dc}}\).

  2. (ii)

    if \(A \in \mathcal {A}_{\mathrm {comp}}\), then \(\mathrm {cl}_{\mathrm {dc}}(A) \in \mathcal {A}_{\mathrm {comp}}\).

Proof

Property (i) follows from (13).

We prove Property (ii). Let \(A \in \mathcal {A}_{\mathrm {comp}}\). We claim that, since \(A \cup \mathrm {vert}(P_0)\) does not contain any incompatible triple of points, neither does \(\mathrm {cl}_{\mathrm {dc}}(A) \cup \mathrm {vert}(P_0)\). From the notion of incompatibility in Sect. 3.3, since \(\mathrm {cl}_{\mathrm {comp}}(A) = A\), we deduce that for every \(E \in \mathcal {F}\), defined in Lemma 20, there exists some nonempty \(E' \subseteq [d]\) such that each point of \(A \cup \mathrm {vert}(P_0)\) is either on the hyperplane \(x(E') = 0\) or on \(x(E') = 1\) and \(E = E' \cap \{2, \dots ,d\}\). In other words, \(E' \in \mathcal {E}(A \cup \mathrm {vert}(P_0))\), see (3). By (12), the same holds for \(\mathrm {cl}_{\mathrm {dc}}(A) \cup \mathrm {vert}(P_0)\), thus \(\mathrm {cl}_{\mathrm {comp}}(\mathrm {cl}_{\mathrm {dc}}(A)) = \mathrm {cl}_{\mathrm {dc}}(A)\), the claim follows.

\(\square \)

Lemma 35

Assume the notations of Definition 17, and let \(\mathrm {cl}_{\mathrm {dc}}\) and \(\mathrm {cl}_{\mathrm {comp}}\) be as in (12) and (13). The operator \(\mathrm {cl}_{\mathrm {comp}}\circ \mathrm {cl}_{\mathrm {dc}}\) is the closure operator for the Moore family \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\).

Proof

For simplicity, let \(\mathrm {cl}:=\mathrm {cl}_{\mathrm {comp}}\circ \mathrm {cl}_{\mathrm {dc}}\) and \(\mathcal {A} :=\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\). First, we check that \(\mathrm {cl}\) is a closure operator. The extensivity and monotonicity of \(\mathrm {cl}\) directly follow from the analogous properties of \(\mathrm {cl}_{\mathrm {comp}}\) and \(\mathrm {cl}_{\mathrm {dc}}\). Moreover, the operator \(\mathrm {cl}\) is idempotent. In fact, by (i) in Lemma 34, \(\mathrm {cl}(A) \in \mathcal {A}_{\mathrm {dc}}\), hence \(\mathrm {cl}(\mathrm {cl}(A)) = \mathrm {cl}_{\mathrm {comp}}(\mathrm {cl}_{\mathrm {dc}}(\mathrm {cl}(A))) = \mathrm {cl}_{\mathrm {comp}}(\mathrm {cl}(A)) = \mathrm {cl}(A)\), where in the last identity we used the fact that \(\mathrm {cl}(A) =\mathrm {cl}_{\mathrm {comp}}(\mathrm {cl}_{\mathrm {dc}}(A)) \in \mathcal {A}_{\mathrm {comp}}\).

If \(A \in \mathcal {A}\) then \(\mathrm {cl}_{\mathrm {dc}}(A) = A\) and \(\mathrm {cl}_{\mathrm {comp}}(A) = A\), thus \(\mathrm {cl}(A) = A\). Now let \(A \subseteq \mathcal {X}_{\mathrm {full}}\) be such that \(\mathrm {cl}(A) = A\). By (i) in Lemma 34, we have \(\mathrm {cl}_{\mathrm {dc}}(A) = A\). Thus \(\mathrm {cl}_{\mathrm {comp}}(A) = \mathrm {cl}(A) = A\). This implies \(A \in \mathcal {A}\). We conclude that \(\mathcal {A} = \{A \subseteq \mathcal {X}_{\mathrm {full}}\mid \mathrm {cl}(A) = A\}\). \(\square \)

In the notations of Definition 17, we remark that the map obtained composing \(\mathrm {cl}_{\mathrm {dc}}\) and \(\mathrm {cl}_{\mathrm {comp}}\) in the inverse order with respect to the one in the previous lemma is a closure operator over \(\mathcal {X}_{\mathrm {full}}\) and thus the collection of all its closed sets is \(\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}}\) as well. The proof is analogous to the one of Lemma 35, and uses (ii) in Lemma 34.

In our enumeration algorithm we implement \(\mathrm {cl}_{\mathrm {comp}}\circ \mathrm {cl}_{\mathrm {dc}}\) because the number of closed sets produced by just \(\mathrm {cl}_{\mathrm {dc}}\) is considerably less than the number of closed sets produced by just \(\mathrm {cl}_{\mathrm {comp}}\), compare Table 2b and c.

5.4 Restricting to the final ground set

Our final lemma gives the closure operator for the complete family that we use in the implementation of the enumeration algorithm. The proof is almost identical to that of Lemma 35, and therefore not included.

Lemma 36

Assume the notations of Definition 17, and let \(\mathrm {cl}_{\mathrm {dc}}\) and \(\mathrm {cl}_{\mathrm {comp}}\) be as in (12) and (13). Finally, let \(\mathcal {X}_{\mathrm {final}}\) be as in (10). Consider the operator \(\mathrm {cl}: 2^{\mathcal {X}_{\mathrm {final}}} \rightarrow 2^{\mathcal {X}_{\mathrm {final}}}\) defined by \(\mathrm {cl}(A) := (\mathrm {cl}_{\mathrm {comp}}\circ \mathrm {cl}_{\mathrm {dc}})(A)\) if \((\mathrm {cl}_{\mathrm {comp}}\circ \mathrm {cl}_{\mathrm {dc}})(A) \subseteq \mathcal {X}_{\mathrm {final}}\) and \(\mathrm {cl}(A) := \mathcal {X}_{\mathrm {final}}\) otherwise. The operator \(\mathrm {cl}\) is the closure operator for the Moore family \((\mathcal {A}_{\mathrm {dc}}\cap \mathcal {A}_{\mathrm {comp}})\big |_{\mathcal {X}_{\mathrm {final}}}\).

6 Implementation

We implemented Algorithm 1 in C++, using the Boost Dynamic Bitset library [38] for set manipulations, and the Boost uBLAS library [42] for basic linear algebra computations. Besides this, our implementation heavily relies on the C library nauty [33]. We use nauty for rejecting every d-polytope \(P = \mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) that is isomorphic to some already computed 2-level d-polytope \(P' \in L_{d}\), and also to test whether a given d-polytope P is 2-level. We provide more detail about the implementation below.

6.1 Storing and comparing 2-level polytopes

Two-level polytopes P are stored via their 0/1 slack matrices S(P). We order the rows and columns of S(P) in such a way that the upper left corner of the matrix gives the non-incidences of the preferred simplicial core. Let us call two 0/1 matrices \(M_1\) and \(M_2\)isomorphic if the rows and columns of \(M_1\) can be permuted to give \(M_2\), that is, there exist permutation matrices L and R such that \(L M_1 R = M_2\). In order to detect isomorphism between two 2-level polytopes \(P_1\) and \(P_2\), we test whether their slack matrices \(S(P_1)\) and \(S(P_2)\) are isomorphic. Notice that if we have any 0/1 matrix M, we can check whether it is the slack matrix of a 2-level \((d-1)\)-polytope by comparing it to each \(S(P_0)\), for \(P_0 \in L_{d-1}\). Similarly, we can check whether M is the slack matrix of an already enumerated 2-level d-polytope by using \(L_d\) instead.

Isomorphism tests of two 0/1 matrices can be efficiently performed by nauty. We represent each 0/1 matrix \(M \in \{0,1\}^{m \times n}\) by a bipartite graph \(G = G(M)\) with \(m + n\) vertices, together with a 2-coloring of its vertex set, in the obvious way. For instance, we may let \(V(G) :=(\{0\} \times [m]) \cup (\{1\} \times [n])\) and \(E(G) :=\{ \{(0,i),(1,j)\} \mid M_{ij} = 1 \}\). The 2-coloring is then \(\phi : V(G) \rightarrow \{0,1\} : (c,k) \mapsto c\). Now, two 0/1 matrices \(M_1\) and \(M_2\) are isomorphic if and only if the colored graphs \(G(M_1)\) and \(G(M_2)\) are isomorphic, which can be tested by nauty.

6.2 Testing for 2-levelness

Now we describe how, for a given \(A \subseteq \mathcal {X}_{\mathrm {final}}\), we check whether the polytope \(P := \mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is 2-level or not. Roughly speaking, we build a 0/1 matrix M which is the slack matrix of P, provided that P is 2-level. For each row of this matrix M, we extract one submatrix of M, which is the slack matrix of the corresponding facet of P, provided that P is 2-level. Then we check that each one of these submatrices is the slack matrix of a 2-level \((d-1)\)-polytope, using \(L_{d-1}\). We now provide further details about this procedure.

First, we need to recall the general notion of slack matrix of a pair polytope-polyhedron, the first nested into the second. This definition first appeared in [16, 36].

Definition 37

(Reduced slack matrix of a pair) Let P be a polytope and Q be a polyhedron with \(P \subseteq Q \subseteq \mathbb {R}^d\). Consider an inner description \(P = \mathrm {conv}(\{v_1, \dots , v_n\})\) and an outer description \(Q = \{x \in \mathbb {R}^d \mid A x \leqslant b\}\), where the system \(Ax \leqslant b\) consists of the m inequalities \(A_1 x \leqslant b_1, \cdots , A_m x \leqslant b_m\). The slack matrix of the pair (PQ) with respect to these inner and outer descriptions is the \(m \times n\) matrix \(S = S(P,Q)\) with \(S_{ij} :=b_i - A_i v_j\).

The reduced slack matrix\(S_{\mathrm {red}}(P,Q)\) of the pair (PQ), is the matrix obtained from S by removing the rows, whose support properly contains the support of some other row or whose support is the same as the support of a row with a smaller index.

Given \(A \subseteq \mathcal {X}_{\mathrm {final}}\), let P be \(\mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) and let Q be the polyhedron defined by the inequalities \(x(E) \geqslant 0\) and \(x(E) \leqslant 1\) for \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\). Define

$$\begin{aligned} M :=S_{\mathrm {red}}(P,Q)\,. \end{aligned}$$
(14)

Observe that M is the slack matrix of a polytope if and only if \(P = Q\). By construction, M is a 0 / 1-matrix. By Lemma 10, P is 2-level if and only if M is the slack matrix of a polytope. Thus we can reduce testing for 2-levelness to testing whether a 0 / 1-matrix is a slack matrix. This is in fact a particular case of the problem of recognizing under what assumptions a matrix is the slack matrix of a polytope, see [17].

Take a polyhedral pair (PQ) and the corresponding reduced slack matrix \(M = S_{\mathrm {red}}(P,Q)\). As in Definition 37, let \(\mathrm {vert}(P) :=\{v_1,\dots ,v_n\}\) and let \(A_ix \leqslant b_i\), \(i \in [m']\) be the inequalities that index the rows of M. Moreover, let us assume that \(M \in \{0,1\}^{m' \times n}\). For every row index \(i \in [m']\), we construct the set of column indices corresponding to zeros in the i-th row, \(F_i :=\{j \in [n] \mid M_{ij} = 0\}\). We write \(i \sim j\) for distinct indices \(i, j \in [m']\) if there is no index \(k \in [m']\) distinct from i and j such that \(F_i \cap F_j \subseteq F_k\). We consider the polytope \(P_i\) and the polyhedron \(Q_i\) defined as:

$$\begin{aligned} P_i:= & {} \mathrm {conv}(\{v_j \mid j \in F_i\})\,, \end{aligned}$$
(15)
$$\begin{aligned} Q_i:= & {} \left\{ \begin{array}{ll} {x \in \mathbb {R}^d} &{} \Big |\begin{array}{l}{A_i x = b_i,}\\ {A_j x \leqslant b_j, \text {for all } j \in [m'],\ j \sim i}\end{array} \\ \end{array} \right\} . \end{aligned}$$
(16)

We remark that \(P_i \subseteq Q_i\) as all inequalities defining Q are valid for P. Moreover, the slack matrix of the pair \((P_i,Q_i)\) is reduced by the definition of \(\sim \).

figure b

Lemma 38

Let a pair (PQ) be as in Definition 37 and let \(M= S_{\mathrm {red}}(P,Q)\in \mathbb {R}^{m'\times n}\) be the reduced slack matrix of (PQ). Moreover, assume that M is a 0 / 1-matrix. Then Algorithm 2 correctly detects whether \(P = Q\) i.e., whether M is the slack matrix of a 2-level d-polytope.

Proof

It suffices to show that M is the slack matrix of the d-polytope P if and only if for every \(i \in [m']\), the matrix \(S_{\mathrm {red}}(P_i,Q_i)\) is the slack matrix of \(P_i\), where \(P_i\) is as in (15) and \(Q_i\) is as in (16).

The implication ‘\(\Rightarrow \)’ is trivial. In order to show ‘\(\Leftarrow \)’, we prove the contrapositive implication: suppose that M is not the slack matrix of P, then M is not the slack matrix of any d-polytope. Consider the set \(\tilde{Q} = \bigcup _{i \in [m']}\{x \in \mathbb {R}^d \mid A_i x = b_i,\, A_j x \leqslant b_j\)\(j \in [m']\}\). Note, that in general \(\tilde{Q}\) is not the boundary of Q, but it is the boundary of a polyhedron containing Q. Thus, there exists a point \(q \in \tilde{Q} \setminus P\). Indeed, if every point \(x \in \tilde{Q}\) lies in P, then Q is completely contained in P, contradicting the assumption. This point \(q \in \tilde{Q}\) lies in \(Q_i\) for some \(i \in [m']\). Since this point q is not in P, it is not in \(P_i\) either. For this reason, q is a witness to the fact that \(P_i \subsetneq Q_i\), thus \(S_{\mathrm {red}}(P_i,Q_i)\) is not a slack matrix. \(\square \)

We point out that this test only uses combinatorial information that can be found in the non-incidence matrix M. Therefore there is no need to explicitly compute the convex hull of \(P_0\) and A in order to determine whether \(P = \mathrm {conv}(\mathrm {vert}(P_0) \cup A)\) is 2-level. This improves over the algorithm presented in [6] and [11].

6.3 Generating the complete family

We implement Ganter’s Next-Closure algorithm (see, e.g., [15]), which we use to enumerate all closed sets of the closure operator \(\mathrm {cl}\), defined in Lemma 36. The Next-Closure algorithm generates all the closed sets one after the other in lexicographic order, starting with the closure of the empty set, which is \(\mathrm {cl}(\varnothing ) = \{e_1\}\) in our case, and ending with \(\mathcal {X}_{\mathrm {final}}\). To find the closed set that comes right after the current closed set A, the Next-Closure algorithm computes at most \(|\mathcal {X}_{\mathrm {final}}\setminus A|\) closures, see [13, 14]. Notice that each time we compute the discrete convex hull closure of a set \(B \subseteq \mathcal {X}_{\mathrm {final}}\), we may record the corresponding set \(\mathcal {E}(\mathrm {vert}(P_0) \cup B)\), since this is information that is useful for the 2-levelness test.

6.4 Further optimizations

We discard the candidate set A if the maximum number of zeros per row of \(M = S_{\mathrm {red}}(P,Q)\), as defined in (14), is greater than the number of vertices of the base \(P_0\). In this way we avoid adding multiple times different isomorphic copies of the same 2-level polytope to the list \(L_d\). If there exists a facet having more vertices than \(P_0\) and it is also 2-level, the polytope P will be constructed when that facet will be taken as base. In particular, if the base \(P_0\) is the simplex, only simplicial polytopes are tested for 2-levelness.

Example 39

In order to enumerate all the 3-dimensional 2-level polytopes, the enumeration algorithm considers all the polytopes constructed using the closed sets in Fig. 8a when \(P_0\) is the 2-simplex and Fig. 8b when \(P_0\) is the 2-cube. Obviously some polytopes are computed twice as the base changes, for instance the square-based pyramid and the triangular prism. With the optimization described above, we construct the square base pyramid, or the triangular prism only when we take the 2-cube as base.

A final optimization concerns the 2-levelness test: if some index i is found such that the number of indices j such that \(j \sim i\) is less than d, then we can safely reject the matrix \(M = S_{\mathrm {red}}(P,Q)\) in (14). Indeed, if M was the slack matrix of a d-polytope, then every facet \(F_i\) would have at least d adjacent facets \(F_j\).

7 Experimental results

As our main experimental result, we obtain a database of all 2-level polytopes of dimension \(d \leqslant 7\), up to isomorphism.Footnote 6 Table 1 summarizes these results regarding the number of 2-level polytopes and interesting subclasses.

We give the number of combinatorial types in the class of polar 2-level polytopes, those whose polar is 2-level. In fact, 2-levelness is in general not preserved under the operation of taking polars, and data show that the fraction of such polytopes rapidly decreases with the dimension.

A subset of polar 2-level polytopes is the class of centrally symmetric 2-level polytopes. From the analysis of the data we noticed that, among all 2-level polytopes, the centrally symmetric ones maximize the product of number of facets and number of vertices, see Fig. 10a.

Another well known class of 2-level polytopes are the stable set polytopes of perfect graphs. Lemma 12 provides an elementary way to recognize them: they are exactly 2-level polytopes with a simple vertex. Table 1 also shows the number of polytopes having a simplicial facet. This is a natural property to consider, being dual to the one of having a simple vertex.

Finally, we list the number of faces of Birkhoff polytopes, for which we refer to [35]. Birkhoff polytopes are a classical family of 2-level polytopes, and they correspond to the perfect matching polytopes of complete bipartite graphs.

Table 1 Comparison of numbers for combinatorially inequivalent 0 / 1-polytopes [1], 2-level polytopes and their sub-classes. polar: 2-level polytopes whose polar is 2-level, CS: centrally symmetric 2-level polytopes, \(\varDelta \)-f: 2-level polytopes with one simplicial facet, STAB: stable set polytopes of perfect graphs, Birk: faces of Birkhoff polytopes from [35]

7.1 Computational times

With our latest implementation, the databases for \(d \leqslant 6\) were computed in a total time of about 3 min on a computer cluster,Footnote 7 which improves the computational times of our previous implementations  [6, 11]. However, we remark that a direct comparison of the running times is not possible because the code presented here is not a secondary implementation of the same one used in [6, 11]. We were able to cut down the running time by rewriting it from scratch in C++ and using a reduced ground set, a new closure operator (Lemma 36 in Sect. 5 and (10) in Sect. 4) and a new, combinatorial 2-levelness test (Sect. 6).

The \(d = 7\) is the first challenging case for our code. We noticed that the time to compute all 2-level polytopes with a given base \(P_0\) is sharply decreasing as a function of the number of vertices of \(P_0\), see Fig. 9. When \(P_0\) is the simplex, the computational time is maximum and close to \(\frac{5}{6}\) of the total time for \(d = 7\).

Fig. 9
figure 9

Histogram representing the running time for the enumeration of all 2-level 7-polytopes with a base \(P_0\) as a function of the number of vertices of \(P_0\). Each bar represents the sum of the running times for bases corresponding to the same number of vertices

Recall that our code discards candidate sets that give polytopes having a facet with more vertices than the prescribed base \(P_0\). Thus the code enumerates all simplicial 2-level polytopes when \(P_0\) is a simplex. In fact, it is known that the simplicial 2-level d-polytopes are the free sums of d / k simplices of dimension k, for k a divisor of d [21]. For instance, for \(d=7\) there exist exactly two simplicial 2-level 7-polytopes: the simplex (obtained for \(k = 1\)) and the cross-polytope (obtained for \(k = 7\)). Thus, we could in fact have skipped the job that corresponds to taking a simplex as the base \(P_0\).

The current implementation provided a list of all combinatorial types of 2-level polytopes up to dimension 7 in about 53 h. There might still be ways to further improve it, for instance generalizing the closure operator and reducing the number of times isomorphic copies of the same 2-level polytope is constructed.

Profiling the code, we determined that 60-70% of the running time is dedicated to construction of incidences of points of \(\mathrm {vert}(P_0) \cup A\) and facet defining inequalities of the form \(x(E) \ge 0\) or \(x(E) \le 1\) for \(E \in \mathcal {E}(\mathrm {vert}(P_0) \cup A)\) while pushing the embedding transformation matrix it top-left position, 8-9% to the computation of \(\mathrm {cl}_{\mathrm {dc}}(A)\) and 5-8% to \(\mathrm {cl}_{\mathrm {comp}}(A)\) of subset A of the ground set.

Refer to Table 2a for more details about computational times. A comparison of the three sub-tables in Table 2 immediately shows the effect of using the composite closure operator \(\mathrm {cl}\) defined in Lemma 36 as opposed to the use of just \(\mathrm {cl}_{\mathrm {dc}}\) or \(\mathrm {cl}_{\mathrm {comp}}\). As expected, the number of closed sets and the running times corresponding to \(\mathrm {cl}\) are considerably reduced when compared to the ones corresponding to just \(\mathrm {cl}_{\mathrm {dc}}\) (compare Table 2a and b) or just \(\mathrm {cl}_{\mathrm {comp}}\) (compare Table 2a and c). Moreover, the computation for \(d = 6\) using just \(\mathrm {cl}_{\mathrm {comp}}\) did not finish after about ten days and it already produced \(10^9\) closed sets.

Table 2 (a) Computational results of enumeration algorithm, using \(\mathrm {cl}= \mathrm {cl}_{\mathrm {comp}}\circ \mathrm {cl}_{\mathrm {dc}}\) (sequential time), (b) Number of closed sets and 2-level tests using just \(\mathrm {cl}_{\mathrm {dc}}\), up to \(d = 6\), (c) Number of closed sets and 2-level tests using just \(\mathrm {cl}_{\mathrm {comp}}\), up to \(d = 6\)

7.2 Parallelization of the computation

We split the computation into several independent jobs, each corresponding to a certain set of bases \(P_0\). We created jobs testing all closed sets corresponding to only 1 base for the first 100 2-level 6-dimensional bases, corresponding to 5 bases for the bases between the 101st and the 500th, corresponding to 20 bases for the bases between the 501st and the 1000th and to 50 bases for the bases between the 1001st and the 1150th (bases are ordered by increasing number of vertices). In total we submitted 208 jobs to the cluster. All jobs but the one corresponding to the 6-simplex as base, finished in less than 3 h. Of these jobs, all but two finished in less than 20 min. Notice that we could use the characterization in [21] and skip the job that corresponds to taking a simplex as the base \(P_0\).

7.3 More statistics

Taking advantage of the data obtained, we computed a number of further statistics to understand the structure and properties of 2-level polytopes.

First, we considered the relation between the number of vertices and the number of facets in \(d=7\), see Fig. 10a. The results are discussed in the next section.

Second, we inspected the number of 2-level polytopes as a function of the number of vertices in dimension 7, see Fig. 10b. Interestingly, most of the polytopes, namely 94%, have 13 to 34 vertices.

Finally, our experiments show that all 2-level centrally symmetric polytopes, up to dimension 7, validate Kalai’s \(3^d\) conjecture [29]. Note that for general centrally symmetric polytopes, Kalai’s conjecture is known to be true only up to dimension 4 [37]. Dimension 5 is the lowest dimension in which we found centrally symmetric polytopes that are neither Hanner nor Hansen (for instance, one with f-vector (12, 60, 120, 90, 20)). In dimension 6 we found a 2-level centrally symmetric polytope with f-vector (20, 120, 290, 310, 144, 24), for which therefore \(f_0+f_4=44\). This is a stronger counterexample to conjecture B of [29] than the one presented in [37] having \(f_0+f_4=48\).

8 Discussion

The experimental evidence we gathered leads to interesting research questions. As a sample, we propose three conjectures.

Fig. 10
figure 10

a Relation between number of facets and number of vertices for 2-level 7-polytopes; b histogram of the number of 2-level 7-polytopes as a function of the number of vertices (in log scale)

The first conjecture concerns the asymptotic growth of the function \(\ell (d)\) that counts the number of (combinatorially distinct) 2-level polytopes in dimension d. All the known constructions of 2-level d-polytopes are ultimately based on graphs (sometimes directed) with O(d) vertices. As a matter of fact, the best lower bound we have on the number of 2-level polytopes is \(\ell (d) \geqslant 2^{\varOmega (d^2)}\). For instance, stable set polytopes of bipartite graphs give \(\ell (d) \geqslant 2^{d^2/4-o(1)}\).

Furthermore, Fig. 11a strongly suggests that \(\ell (d)\) might be \(2^{O(d^2)}\). This would have a big impact since, as mentioned above, every 2-level d-polytope gives rise to a 0 / 1-optimization problem in d variables that can be efficiently solved. If indeed \(\ell (d) = 2^{\varTheta (d^2)}\), then intuitively every such optimization problem is some problem on a graph with O(d) vertices. This motivates our first conjecture.

Conjecture 1

The number \(\ell (d)\) of combinatorially distinct 2-level d-polytopes satisfies \(\ell (d) \leqslant 2^{\mathrm {poly}(d)}\).

Fig. 11
figure 11

Bounds on number of 2-level polytopes, suspensions and faces. a Numbers of 2-level polytopes and 2-level suspensions. b Maximum number f(d) of faces of 2-level polytopes

A suspension of a polytope \(P_0 \subseteq \{x \in \mathbb {R}^d \mid x_1 = 0\}\) is any polytope P obtained as the convex hull of \(P_0\) and \(P_1\), where \(P_1 \subseteq \{x \in \mathbb {R}^d \mid x_1 = 1\}\) is the translate of some non-empty face of \(P_0\). For instance, the prism and the pyramid over a polytope \(P_0\) are examples of suspensions. Also, any stable set polytope is a suspension.

Analyzing our experimental data, we noticed that a majority of 2-level d-polytopes for \(d \leqslant 7\) are suspensions of \((d-1)\)-polytopes. Let s(d) denote the number of (combinatorially distinct) 2-level suspensions of dimension d. In Table 3, we give the values of the \(\ell (d)\) and s(d) coming from our experiments, for \(d \leqslant 7\), see also Fig. 11a.

Table 3 Number of 2-level suspensions s(d), 2-level polytopes \(\ell (d)\), ratio of number of 2-level suspensions to 2-level polytopes

In view of Table 3, it is natural to ask what is the fraction of 2-level d-polytopes that are suspensions. Excluding dimension 3, we observe that this fraction increases with the dimension. This motivates our second conjecture.

Conjecture 2

Letting \(\ell (d)\) and s(d) respectively denote the number of combinatorially distinct 2-level polytopes and 2-level suspensions in dimension d, we have \(\ell (d) = \varTheta (s(d))\).

Our last conjecture is motivated by Fig. 10a.

Conjecture 3

For every 2-level d-polytope P, we have \(f_0(P)f_{d-1}(P) \leqslant d2^{d+1}\)

Experiments show that this upper bound holds up to \(d=7\). A recent work subsequent to the conference version of the current paper established that this conjecture is true for several infinite classes of 2-level polytopes [2]. It is known that \(f_0(P) \leqslant 2^d\) is satisfied with equality if and only if P is a cube and \(f_{d-1}(P) \leqslant 2^d\) is satisfied with equality if and only if P is a cross-polytope  [18]. Notice that, in both of these cases, \(f_0(P)f_{d-1}(P) = d2^{d+1}\).

We conclude by proving some dependence between the above conjectures.

Proposition 40

Conjecture 2 implies Conjecture 1.

Proof

Let us prove by induction that Conjecture 2 implies \(\ell (d) \leqslant c^{d^3}\) for a sufficiently large constant \(c > 1\). Let \(c \geqslant 2\) be large enough so that \(\ell (d) \leqslant c \cdot s(d)\) for all dimensions d. Notice that the maximum number f(d) of faces of a 2-level d-polytope satisfies \(f(d) \leqslant (2^d)^d = 2^{d^2} \leqslant c^{d^2}\) since 2-level d-polytopes have at most \(2^d\) vertices. Now using the induction hypothesis \(\ell (d-1) \leqslant c^{(d-1)^3}\), we have

$$\begin{aligned} \ell (d) \leqslant c \cdot s(d) \leqslant c \cdot \ell (d-1) \cdot f(d-1) \leqslant c \cdot c^{(d-1)^3} \cdot c^{(d-1)^2} \leqslant c^{d^3}, \end{aligned}$$

which proves the claim. \(\square \)