A new face iterator for polyhedra and more general finite locally branched lattices

We discuss a new memory-efficient depth-first algorithm and its implementation that iterates over all elements of a finite locally branched lattice. This algorithm can be applied to face lattices of polyhedra and to various generalizations such as finite polyhedral complexes and subdivisions of manifolds, extended tight spans and closed sets of matroids. Its practical implementation is very fast compared to state-of-the-art implementations of previously considered algorithms. Based on recent work of Bruns, Garc\'ia-S\'anchez, O'Neill and Wilburne, we apply this algorithm to prove Wilf's conjecture for all numerical semigroups of multiplicity 19 by iterating through the faces of the Kunz cone and identifying the possible bad faces and then checking that these do not yield counterexamples to Wilf's conjecture.


Introduction
We call a finite lattice (P, ≤) locally branched if all intervals of length two contain at least four elements. We show that such lattices are atomic and coatomic and refer to Section 2 for details.
This paper describes a depth-first algorithm to iterate through the elements in a finite locally branched lattice given its coatoms, see Section 3. It moreover describes variants of this algorithm allowing the iteration over slightly more general posets. Most importantly, examples of such locally branched lattices (or its mild generalizations) include face posets of • polytopes and unbounded polyhedra, • finite polytopal or polyhedral complexes, • finite polyhedral subdivisions of manifolds, • extended tight spans, and • closed sets of matroids. One may in addition compute all cover relations as discussed in Subsection 4.1. The provided theoretical runtime (without variants) is the same as of the algorithm discussed by V. Kaibel and M. E. Pfetsch in [7], see Section 4. In the sligthly generalized situations, the theoretical runtime might be better as for extended tight spans (without chords) with many facets (using the opposite lattice), or might be worse as for extended tight spans with many vertices.
In practice it appears that the chosen data structures and implementation details make the implementation 1 very fast for the iteration and still fast for cover relations in the graded case compared to state-of-the-art implementations of previously considered algorithms, see Section 5. In Section 6, we apply the presented algorithm to affirmatively settle Wilf 's conjecture for all numerical semigroups of multiplicity 19 by iterating, up to a certain symmetry of order 18, through all faces of the Kunz cone (which is a certain unbounded polyhedron), identifing the bad faces which possibly yield counterexamples to Wilf's conjecture, and then checking that these do indeed not yield such counterexamples. This is based on recent work of W. Bruns, P. García-Sánchez, C. O'Neill and D. Wilburne [3] who developed this approach to the conjecture and were able to settle it up to multiplicity 18.
In Appendix A, we finally collect detailed runtime comparisions between the implementation of the presented algorithm with the state-of-the-art implementations in polymake and in normaliz.
Acknowledgements. We thank Michael Joswig and Winfried Bruns for valuable discussions and for providing multiple relevant references. We further thank Jean-Philippe Labbé for pointing us to [3] and all participants of the trac ticket in SageMath 1 for stimulating discussions.

Formal framework
Let (P, ≤) be a finite poset and denote by ≺ its cover relations. We usually write P for (P, ≤) and write P op for the opposite poset (P op , If P has a lower bound0, its atoms are the upper covers of the lower bound, Atoms(P) = {p ∈ P |0 ≺ p} and, for p ∈ P, we write Atoms(p) = {a ∈ Atoms(P) | p ≥ a} for the atoms below p. Analogously, if P has an upper bound1, its coatoms are the lower covers of the upper bound, coAtoms(P) = {p ∈ P | p ≺1}. P is called graded if it admits a rank function r : P → Z with p ≺ q ⇒ r(p) + 1 = r(q). Definition 2.1. P is locally branched if for every saturated chain a ≺ b ≺ c there exists an element d = b with a < d < c. If this element is unique, then P is said to have the diamond property.
The diamond property is a well-known property of face lattices of polytopes, see [9, Theorem 2.7(iii)]. The property of being locally branched has also appeared in the literature in contexts different from the present under the name 2-thick lattices, see for example [1] and the references therein.
An obvious example of a locally branched lattice is the boolean lattice B n given by all subsets of {1, . . . , n} ordered by containment. We will later see that all locally branched lattices are meet semi-sublattices of B n .
In the following, we assume P to be a finite lattice with meet operation ∧, join operation ∨, lower bound0 and upper bound1. We say that • P is atomic if all elements are joins of atoms, • P is coatomic if all elements are meets of coatoms, • p ∈ P is join-irreducible if p has a unique lower cover q ≺ p, • p ∈ P is meet-irreducible if p has a unique upper cover p ≺ q. Atoms are join-irreducible and coatoms are meet-irreducible. The following classification of atomic and coatomic lattices is well-known. Proof. First observe that for all p, q ∈ P we have p ≥ q ⇒ Atoms(p) ⊇ Atoms(q) and p ≥ Atoms(p). Moreover, P is atomic if and only if p = Atoms(p) for all p ∈ P. Assume that P is atomic and let q ∈ P join-irreducible and p ≺ q. Because we have Atoms(p) = Atoms(q) it follows that p =0. Next assume that P is not atomic and let p ∈ P minimal such that p > Atoms(p). If q < p then by minimality q = Atoms(q). It follows that q ≤ Atoms(p) and p is join-irreducible.
The second equivalence is the first applied to P op .
Examples 2.3. The face lattice of a polytope has the diamond property, it is atomic and coatomic, and every interval is again the face lattice of a polytope. The face lattice of an (unbounded) polyhedron might neither be atomic nor coatomic as witnessed by the face lattice of the positive orthant in R 2 with five faces.
The reason to introduce locally branched posets is the following relation to atomic and coatomic lattices, which has, to the best of our knowledge, not appeared in the literature. Example 2.5. On the left an example of a non-graded locally branched lattice. On the right an example of an atomic, coatomic lattice, which is not locally branched as the interval between the two larger red elements contains only three elements.
Let P be a finite locally branched poset with atoms {1, . . . , n}. As we have seen that P is atomic and thus p = Atoms(p) for all p ∈ P. The following proposition underlines the importance of subset checks and of computing intersections to understanding finite locally branched lattices.
Proposition 2.6. In a finite locally branched lattice it holds that (i) p ≤ q ⇔ Atoms(p) ⊆ Atoms(q).

Proof.
(i) If p ≤ q then clearly Atoms(p) ⊆ Atoms(q). On the other hand, if Atoms(p) ⊆ Atoms(q), then p = Atoms(p) ≤ Atoms(q) = q, as Atoms(q) is in particular an upper bound for Atoms(p). (ii) By (i) it holds that (Atoms(p) ∩ Atoms(q)) is a lower bound of p and q. Also, Atoms(p ∧ q) ⊆ Atoms(p), Atoms(q) and we obtain This proposition provides the following meet semi-lattice embedding of any finite locally branched lattice into a boolean lattice. Example 2.8. The above embedding does not need to be a join semi-sublattice embedding as witnessed by the face lattice of a square in R 2 .
Remark 2.9. Proposition 2.6 shows that checking whether the relation p ≤ q holds in P is algorithmically a subset check Atoms(p) ⊆ Atoms(q), while computing the meet is given by computing the intersection Atoms(p) ∩ Atoms(q).
Justified by Corollary 2.7, we restrict our attention in this paper to meet semi-sublattices of the boolean lattice.

Variants of this framework and examples.
Before presenting in Section 3 the algorithm to iterate over the elements of a finite locally branched lattice together with variants to avoid any element above certain atoms and to avoid any element below certain coatoms (or other elements of B n ), we give the the following main use cases for such an iterator. Example 2.10 (Polytope). The face lattice of a polytope P has the diamond property and is thus locally branched.
Example 2.11 (Polyhedron). The face lattice of a polyhedron P is isomorphic to the one obtained from quotiening out the affine space P contains. Thus, we can assume that P does not contain an affine line. It is well known (see e.g. [9, Exercise 2.19]) that we may add an extra facet F to obtain a polytope P . The faces of P are exactly the faces of P not contained in F (together with the empty face). Thus, the iterator visits all non-empty faces of P by visiting all faces of P not contained in F . Example 2.13 (Extended tight spans). We consider extended tight spans as defined in [6, Section 3] as follows: Let P ⊂ R d be a finite point configuration, and let Σ be a polytopal complex with vertices P , which covers the convex hull of P . We call the maximal cells of Σ facets. We can embedd Σ into a closed d-manifold M : In any case, we can add a vertex at infinity and for each face F on the boundary of Σ a face F ∪ {∞}. In many cases, just adding one facet containing all vertices on the boundary will work as well.
Given a collection Γ of boundary faces of Σ. We can iterate over all elements of Σ, which have empty intersection with Γ: Iterate over all faces of M , which do not contain a vertex of Γ and are not contained in a facet in M \ Σ. Example 2.15 (Locally branched lattices with non-trivial intersection). Let P 1 , . . . , P k be finite locally branched meet semi-sublattices of B n . Then the iterator may iterate through all elements of their union by first iterating through P 1 , then through all elements in P 2 not contained in P 1 and so on.
Example 2.16 (Polyhedral complexes). Using the iteration as in the previous example allows to iterate through polytopal or polyhedral complexes, or through complexes of tight spans.

The algorithm
Let P be a finite locally branched lattice given as a meet semi-sublattice of the boolean lattice B n . This is, Atoms P = {1, . . . , n} and p = Atoms(p) ∈ P. The following algorithm is a recursively defined depth-first iterator through the elements of P. Given c ∈ P and its lower covers x 1 , . . . , x k , the iterator yields c and then computes, one after the other, the lower covers of x 1 , . . . , x k , taking into account those to be ignored, and then recursively proceeds. Being an iterator means that the algorithm starts with only assigning the input to the respective variables and then waits in its current state. Whenever an output is requested, it starts from its current state and runs to the point ITERATOR OUTPUT, outputs the given output, and again waits. Iterators are regularly used in modern programming languages 2 . .
For polyhedra, a slightly more sophisticated version of this algorithm is implemented in SageMath 1 . Before proving the correctness of the algorithm, we provide several detailed examples. If not mentioned otherwise, we do not ignore any atoms and always set ignored_atoms = {} in the examples. We also assume the lists to be ordered lexicographically for iteration. One may assume that the algorithm additionally visits the upper bound given by the union of the coatoms, whenever this is suitable.
Example 3.1 (Square). We apply the algorithm to visit faces of a square.
•  •  3.1. Correctness of the algorithm. As assumed, let P be a locally branched meet semisublattice of the boolean lattice B n . In the following properties and their proofs, we indeed see that if P is any meet semi-sublattice of B n , the algorithm visits exactly once each element p ∈ P not contained in any of ignored_sets and not containing any of ignored_atoms if the interval [p,1] is locally branched. (ii) The call of FaceIterator in line 24 applies the algorithm to P with a ∪ ignored_atoms appended to ignored_sets and all coatoms contained in a ∪ ignored_atoms removed.
Proof. The proof of (ii) is obvious. To prove (i), we have to show that the construction of new_coatoms in lines 15-17 is correct. First, observe that all elements in new_coatoms are strictly below the element a. Next, let x ≺ a ≺1 in P. Since P is locally branched there is . If x is not contained in any element in ignored_sets, then the same holds for b and thus, b ∈ coatoms and x ∈ new_coatoms. This implies that new_coatoms are exactly the lower covers of a not contained in an element of ignored_sets, as desired.

3.2.
Variants of the algorithm. We finish this section with a dualization property followed by explicitly stating the result when applying the algorithm for the variants discussed in Subsection 2.1.

Corollary 3.7. If ignored_sets is a list of coatoms, then the algorithm can also be applied to P op with the roles of atoms and coatoms interchanged.
We later see in Theorem 4.1 that considering P op instead of P might be faster as the runtime depends on the number of coatoms. For example, in Example 3.2 one could apply the algorithm to P op to improve runtime as there are 10 facets but only 6 vertices.
Corollary 3.8. Let P be a polytope. Provided the vertex-facet incidences of P, the above algorithm visits exactly once all faces of P . Corollary 3.9. Let P be an unbounded polyhedron and let P be a projectively equivalent polytope with marked face. Provided the vertex-facet incidences of P , the above algorithm visits exactly once all non-empty faces of P .
Actually, a non-empty intersection of two faces of P is not contained in the marked facet at infinity. Hence, one could even use the algorithm without providing the marked facet at infinity. This might or might not visit the empty face.

Data structures, memory usage, and theoretical runtime
The operations used in the algorithm are intersetions, subset checks and unions. It will turn out that the crucial operation for the runtime is the subset check.
For the theoretical runtime we consider representation as (sparse) sorted-lists-of-atoms. However, in the implementation we use (dense) atom-incidence-bit-vectors. This is theoretically slighly slower, but the crucial operations can all be done using bitwise operations.
Observe that a sorted-lists-of-atoms needs as much memory as there are incidences. Consider two sets A and B (of integers) of lengths a and b, respectively, and a (possibly unsorted) list C of m sets of total length α. Using standard implementations, we assume in the runtime analysis that • finding (and possibly deleting) a given element • to check whether A is subset of any element in C has runtime O(α). Let r + 1 be the number of elements in a longest chain in P, let m = |coatoms|, n = |atoms|, and let α = a∈coatoms∪ignored_sets |a ∪ ignored_atoms|.
(In the case that ignored_sets and ignored_atoms are both empty, α is the total number of atom-coatom incidences.) Moreover, let ϕ be the number of recursive calls of the algorithm. (In the case that ignored_atoms is empty, ϕ is the cardinality of P. Otherwise, it is bounded by this cardinality.) Theorem 4.1. The algorithm has memory consumption O(α · r) and runtime O(α · m · ϕ).
Proof. Note first that at each recursive call of FaceIterator the number of coatoms is bounded by m and the total length of coatoms, ignored_sets and ignored_atoms is bounded each by α.
With above assumptions, FaceIterator has runtime O(α · m) not considering recursive calls. A single call of FaceIterator has memory usage at most c · α for a global constant c, not taking into account the recursive calls. The call in line 24 does not need extra memory as all old variables can be discarded. The longest chain of the lattice [0, a] is at most of length r − 1. By induction the call of FaceIterator in line 18 has total memory consumption at most (r − 1) · c · α. The claimed bounds follow.

4.1.
Computing all cover relations. Applying the algorithm to a graded locally branched meet semi-sublattice of B n while keeping track of the recursion depth allows an a posteriori sorting of the output by the level sets of the grading. The recursion depth is the number of iterative calls using line 18. We obtain the same bound for generating all cover relations as V. Kaibel and M. E. Pfetsch [7]. For this we additionally assume that • a list of ϕ sets each of length at most n can be sorted in time O(n · ϕ · log ϕ) and • a set with a elements can be looked up in a sorted list of ϕ sets in time O(a · log ϕ).
Proposition 4.2. Let P be a graded meet sublattice of B n . Assume each level set of P to be given as sorted-lists-of-atoms, one can generate all cover relations in time O(α · min(m, n) · ϕ) with quantities as defined above using the above algorithm.
Observe that in the situation of this proposition, ignored_sets and ignored_atoms are both empty and in particular α is the total length of the coatoms.
Proof. First, we sort all level-sets. Then, we intersect each element with each coatom, obtaining its lower covers and possibly other elements. We look up each intersection to determine the lower covers.
Sorting the level sets is done in time O(n · ϕ · log ϕ). All such intersection are obtained in time O(ϕ · m · n). For a fixed element the total length of its intersections with all coatoms is bounded by α. Hence, all lookups are done in time O(ϕ · α · log ϕ).
Finally, we note that m, n ≤ α and that log ϕ ≤ min(m, n).
In the ungraded case, one first sorts all elements in P, and then intersects each element p with all coatoms. The inclusion maximal elements among those strictly below p are lower covers of p. They can be looked up in the list of sorted elements to obtain an index. Observe that all this is done time O(α · m · ϕ).

Performance of the algorithm implemented in SageMath
We present running times for the several computations. These are performed on an Intel ® Core™ i7-7700 CPU @ 3.60GHz x86_64-processor with 4 cores and 30 GB of RAM. The computations are done either using • polymake 3.3 [5], or • normaliz 3.7.2 [2], or • the presented algorithm in sage-8.9, or • the presented algorithm in sage-8.9 with additional parallelization, intrinsics, and subsequent improvements 3 The default algorithms in SageMath before version sage-8.9 performs much worse than either of these and is not considered here. Given the vertex-facet incidences, we computed (1) cover relations and f -vector in polymake,  Figure 1. Comparision of the runtimes. Every dot represents one best-of-five computation, and every shifted diagonal is a factor-10 faster runtime. Dots at the boundary represent memory overflows.
• polymake also provides a different algorithm to compute the f -vector from the h-vector for simplicial/simple polytopes (providing this additional information sometimes improves the performance in polymake), and • normaliz does not provide an algorithm to compute the cover relations. For every algorithm we record the best-of-five computation on • the simplex of dimension n, • several instances of the cyclic polyhedron of dimension 10 and 20, • the associahedron of dimension n, • the permutahedron of dimension n embedded in dimension n + 1, • a 20-dimensional counterexample to the Hirsch-conjecture, • the cross-polytope of dimension n, • the Birkhoff-polytope of dimension (n − 1) 2 , • joins of such polytopes with their duals, • Lawrence polytopes of such polytopes, and refer to Appendix A for the detailed runtimes.
6. Application of the algorithm to Wilf's conjecture W. Bruns, P. García-Sánchez, C. O'Neill and D. Wilburne provided an algorithm that verifies Wilf's conjecture for a given fixed multiplicity [3]. We give a brief overview of their approach: Definition 6.1. A numerical semigroup is a set S ⊂ Z ≥0 containing 0 that is closed under addition and has finite complement.
• Its conductor c(S) is the smallest integer c such that c + Z ≥0 ⊆ S.
• Its sporadic elements are the elements a ∈ S with a < c(S) and let n(S) be the number of sporadic elements.
• The embedding dimension e(S) = |S \ (S + S)| is the number of elements that cannot be written as sum of two elements. • The multiplicity m(S) is the minimal nonzero element in S. For fixed mulitplicity m one can analyse certain polyhedra to verify this conjecture.
The Kunz cone is the set C m of points (x 1 , . . . , x m−1 ) ∈ R m−1 satisfying Checking Wilf's conjecture for fixed multiplicity m can be done as follows: (1) For each face F in C m check if Proposition 6.6 holds.
(2) If Proposition 6.6 does not hold, check with Proposition 6.5 if the translated face in P ′ m contains a point corresponding to a counterexample of the Wilf's conjecture.
We say that a face F of C m is bad if Proposition 6.6 does not hold. The group of units (Z/mZ) × acts on R m−1 by multiplying indices. The advantage of the Kunz cone over the (relaxed) Kunz polyhedron is that it is symmetric with respect to this action. Even more, e(F ) and t(F ) are invariant under this action. Thus in order to determine the bad faces, it suffices to determine for one representative of its orbit, if it is bad. We say that an orbit is bad, if all its faces are bad.
While [3] uses a modified algorithm of normaliz to determine all bad orbits, we replace this by the presented algorithm. To use the symmetry of C m , after visiting a facet F , we mark all facets in the orbit of F as visited.
We visit of each orbit at least one face. By sorting the facets by orbits and some lexicographic ordering of the facet-indices, we can even guarantee that we will visit the first element of each orbit. Now, we are in a situation to apply the presented algorithm to Wilf's conjecture. The concrete implementation is available in SageMath 4 .In the following While testing all bad faces takes a significant amount of time, recent work by S. Eliahou has simplified this task. Checking the remaining orbits can be done quickly (we used an Intel ® Core™ i7-7700 CPU @ 3.60GHz x86_64-processor with 4 cores). For each of the orbits with 3e < m, we have checked whether the corresponding region is empty analogously to the computation in [3]: (2) Compute f -vector with normaliz sage : P = polytopes . simplex (2 , backend = ' normaliz ') sage : P. _nmz_result (P . _normaliz_cone , ' FVector ') .  For displaying the runtimes, we use the following notations: • ∆ d for the d-dimensional simplex, • C d,n for the d-dimensional cyclic polytope with n vertices, • A d for the d-dimensional associahedron, • P d for the d-dimensional permutahedron, • H for the 20-dimensional counterexample to the Hirsch conjecture, • d for the d-cube, • B n for the (n − 1) 2 -dimensional Birkhoff polytope, • P op for the polar dual of a polytope P , • L(P ) for the Lawrence polytope of P .
The runtimes of the five best-of-five computations on the various examples are as given in the following table. "MOF" indicates that the process was killed due to memory overflow, and a dash indicates a runtime of less than a second.