Gray codes and symmetric chains

We consider the problem of constructing a cyclic listing of all bitstrings of length $2n+1$ with Hamming weights in the interval $[n+1-\ell,n+\ell]$, where $1\leq \ell\leq n+1$, by flipping a single bit in each step. This is a far-ranging generalization of the well-known middle two levels problem (the case $\ell=1$). We provide a solution for the case $\ell=2$, and we solve a relaxed version of the problem for general values of $\ell$, by constructing cycle factors for those instances. The proof of the first result uses the lexical matchings introduced by Kierstead and Trotter, which we generalize to arbitrary consecutive levels of the hypercube. The proof of the second result uses symmetric chain decompositions of the hypercube, a concept known from the theory of posets. We also present several new constructions of such decompositions based on lexical matchings. In particular, we construct four pairwise edge-disjoint symmetric chain decompositions of the $n$-dimensional hypercube for any $n\geq 12$.


3
The most general version of this problem is whether the subgraph of the n-cube induced by all levels in an arbitrary weight interval [a, b] has a Hamilton cycle. However, unless we are in the cases covered by Problem M (odd dimension and symmetric levels around the middle) or n is even and (a, b) = (0, n), the corresponding subgraph of the n-cube has two partition classes of different sizes, and thus cannot have a Hamilton cycle. Nonetheless, we may still ask for a cycle that visits all vertices in the smaller partition class, or for a cyclic listing of all vertices in which only few transitions flip two instead of one bit, where 'few' means the difference in size between the two partition classes. Both of these are natural generalizations of a Hamilton cycle, and we will refer to them as an 'almost' Hamilton cycle. This generalized problem was solved in [GM18] for several values of n ≥ 1 and 0 ≤ a ≤ b ≤ n, and it was shown that a solution to Problem M would imply this result for all possible values of n ≥ 1 and 0 ≤ a ≤ b ≤ n.
1.1. Our results. In this work we solve the case = 2 of Problem M, i.e., we construct a cyclic listing of all bitstrings of length 2n + 1 with Hamming weights in the interval [n − 1, n + 2].
Theorem 1. For any n ≥ 1, the subgraph of the (2n + 1)-cube induced by the middle four levels has a Hamilton cycle.
Combining Theorem 1 with the results from [GM18] shows more generally that the subgraph of the n-cube induced by any four consecutive levels has an 'almost' Hamilton cycle.
As another partial result towards Problem M, we show that the subgraph of the (2n + 1)-cube induced by the middle 2 levels has a cycle factor. A cycle factor is a collection of disjoint cycles which together visit all vertices of the graph. In particular, a Hamilton cycle is a cycle factor consisting only of a single cycle. Note here that the existence of a cycle factor for general values of is not an immediate consequence of Hall's theorem, which is applicable only for = 1 and = n + 1, as only in those cases all vertices of the underlying graph have the same degree.
Theorem 2. For any n ≥ 1 and 1 ≤ ≤ n + 1, the subgraph of the (2n + 1)-cube induced by the middle 2 levels has a cycle factor.
Our proof of Theorem 2 is concise and illustrative, and it motivates the subsequent discussion, so we present it right now. It uses a well-known concept from the theory of partially ordered sets (posets), a so-called symmetric chain decomposition. Here we define this term for the n-cube using graph-theoretic language. A symmetric chain in Q n is a path (x k , x k+1 , . . . , x n−k ) in the n-cube where x i is from level i for all k ≤ i ≤ n − k, and a symmetric chain decomposition, or SCD for short, is a partition of the vertices of Q n into symmetric chains. For illustration, an SCD of Q 5 is shown in Figure 1 (a). We say that two SCDs are edge-disjoint if the corresponding sets of paths are edge-disjoint, i.e., if there are no two consecutive vertices in a chain of the first SCD that are also contained in a chain of the second SCD. There is a well-known construction of two edge-disjoint SCDs in the n-cube for any n ≥ 1 [SK79], which we will discuss momentarily.
There is a well-known construction of an SCD for the n-cube that is best described by the following parenthesis matching approach pioneered by Greene and Kleitman [GK76]; see Figure 2. For any vertex x of the n-cube, we interpret the 0s in x as opening brackets and the 1s as closing brackets. By matching closest pairs of opening and closing brackets in the natural way, the chain containing x is obtained by flipping the leftmost unmatched 0 to move up the chain, or the rightmost unmatched 1 to move down the chain, until no more unmatched bits can be flipped. It is easy to see that this indeed yields an SCD of the n-cube for any n ≥ 1. We denote this standard SCD by D 0 ; it is shown in Figure 1 (a) for n = 5. There are several alternative ways to describe this SCD (see [dBvETK51,Aig73,WW77]).
By taking complements, we obtain another SCD, which we denote by D 0 . It is not hard to see that D 0 and D 0 are in fact edge-disjoint for any n ≥ 1 [SK79]. Figure 1 (b) shows both SCDs for n = 5, and how they are used for building a cycle factor. Our next result is a simple construction of another SCD in the n-cube for even values of n ≥ 2, which we call D 1 . It has the additional feature that D 0 , D 0 , D 1 and D 1 are pairwise edge-disjoint for n ≥ 6. Theorem 3. For any even n ≥ 6, the n-cube contains four pairwise edge-disjoint SCDs. Figure 3 shows the SCDs D 0 and D 1 in Q 6 . Their complements D 0 and D 1 are not shown for clarity. Note that four edge-disjoint SCDs are best possible for Q 6 , as they use up all edges incident with the middle level.
For odd values of n, we can still construct four edge-disjoint SCDs in the n-cube (except in a few small cases). However, the construction is not as direct and explicit as for even n.
Theorem 4. For n = 7 and any odd n ≥ 13, the n-cube contains four pairwise edge-disjoint SCDs.
For odd n, we can combine any two of the four edge-disjoint SCDs in the n-cube guaranteed by Theorem 4 to a cycle factor in the middle 2 levels, as explained before, yielding in total 4 2 = 6 distinct cycle factors. Our technique for proving Theorem 4 is the reason why the cases n = 9 5 Figure 3. The edge-disjoint SCDs D 0 (dashed vertical paths) and D 1 (solid paths; chains of the same length are drawn with the same color) in the 6-cube. The bitstrings are drawn with white squares representing 0s and black squares representing 1s. Table 1. Known pairwise edge-disjoint SCDs in the n-cube for n = 1, 2, . . . , 11. The definitions of X 5 , Y 5 , Z 5 and X 7 , Y 7 are given in Section 3.3, and the product operation × is described in Section 3.2. n 1 2 3 4 5 6 7 8 9 10 11 n/2 + 1 1 2 2 3 3 4 4 5 5 6 6 SCDs and n = 11 are excluded in the statement of the theorem. Specifically, we construct four edge-disjoint SCDs in the 7-cube in an ad hoc fashion and then apply the following product construction.
Theorem 5. If Q a and Q b each contain k pairwise edge-disjoint SCDs, then Q a+b contains k pairwise edge-disjoint SCDs.
Theorem 5 shows in particular that from k edge-disjoint SCDs in a hypercube of fixed dimension n, we obtain k edge-disjoint SCDs for infinitely many larger dimensions 2n, 3n, 4n, . . ..
We conjecture that the n-cube has n/2 + 1 pairwise edge-disjoint SCDs, but so far we only know that this holds for n ≤ 7. Clearly, finding this many edge-disjoint SCDs would be best possible, as they use up all middle edges of the cube. Maximum sets of pairwise edge-disjoint SCDs in the n-cube we found for n = 1, 2, . . . , 11 are shown in Table 1, together with the aforementioned upper bound.
1.2. Related work. Apart from building Gray codes, symmetric chain decompositions have many other interesting applications, e.g., to construct rotation-symmetric Venn diagrams for n sets when n is a prime number [GKS04,RSW06], and to solve the Littlewood-Offord problem on sums of vectors [Bol86]. It would be very interesting to investigate how the new SCDs of the n-cube presented in this paper can be exploited for those and other applications.
A notion that is closely related to edge-disjoint SCDs is that of orthogonal chain decompositions, which were first considered by Shearer and Kleitman [SK79]. Two chain decompositions are called orthogonal if every pair of chains has at most one vertex in common, where one also allows chains that are not symmetric around the middle or chains that skip some levels. Shearer and Kleitman showed that D 0 and D 0 are almost orthogonal (only the longest chains have two elements in common), and they conjectured that the n-cube has n/2 + 1 pairwise orthogonal chain decompositions where each decomposition consists of n n/2 many chains. Spink [Spi17] and Däubel et al. [DJMS19] recently made some progress towards this conjecture, establishing 4 as the best known lower bound.
Pikhurko [Pik99] showed via a parenthesis matching argument that all edges of the n-cube can be decomposed into symmetric chains. However, it is not clear whether these chains contain a subset that forms an SCD. An interesting construction relating Hamilton cycles and SCDs in the n-cube was presented by Streib and Trotter [ST14]. They inductively construct a Hamilton cycle in the n-cube for any n ≥ 2 that can be partitioned into symmetric chains forming an SCD. This Hamilton cycle has the minimal number of 'peaks' where the differences in the Hamming weight change sign (and thus also the minimal number of corresponding 'valleys').
1.3. Proof ideas and outlook. Our proofs of Theorem 1 and Theorem 3 are based on the so-called i-lexical matchings introduced by Kierstead and Trotter [KT88], which form a factorization of all edges between the middle two levels of the (2n + 1)-cube. We generalize these matchings to arbitrary consecutive levels of the cube of arbitrary dimension, and combine suitable subsets of those matching edges into a cycle factor and symmetric chain decompositions, respectively. In particular, the four SCDs in Theorem 3, referred to as D 0 , D 1 , D 0 and D 1 before the theorem, are the union of all 0-lexical and 1-lexical matching edges, and of their complements, respectively. For the proof of Theorem 1, the cycles of the factor obtained as the union of certain lexical matching edges are joined to a Hamilton cycle by local modifications. As mentioned before, Theorem 4 is derived from Theorem 5, which is proved by a straightforward adaptation of the arguments from [dBvETK51]. Subsequent to our work, Gregor, Mička, and Mütze [GMM20] solved Problem M in full generality. Their proof generalizes our construction for the case = 2, and also uses lexical matchings extensively. Furthermore, Däubel, Jäger, Mütze and Scheucher [DJMS19] showed that there are four edge-disjoint SCDs in the n-cube for all n ≥ 6, ruling out the two possible exceptions n = 9, 11. Moreover, they proved that there are five edge-disjoint SCDs for all n ≥ 90, and six edge-disjoint SCDs for all dimensions n = 11k, k ≥ 1.
1.4. Outline of this paper. In Section 2 we introduce several definitions that will be used throughout this paper. In Section 3 we present the proofs of Theorems 3-5, and we describe the construction of the SCD D 1 and of the SCDs in Q 5 and Q 7 referred to in Table 1. As it is somewhat technical, we defer the proof of Theorem 1 to Section 4. In Section 5 we present results from computer experiments on the cycle factors through the middle 2 levels of the (2n + 1)-cube constructed as in the proof of Theorem 2. We conclude in Section 6 with some open problems.

Preliminaries
We begin by introducing some terminology that is used throughout the following sections.
2.1. Bitstrings, lattice paths, and rooted trees. We use L n,k to denote the set of all bitstrings of length n with Hamming weight k, so this is exactly the kth level of Q n . For any bitstring x, we write x for its complement and rev(x) for the reversed bitstring.
We often interpret a bitstring x as a path in the integer lattice Z 2 starting at the origin (0, 0), where every 1-bit is interpreted as an -step that changes the current coordinate by (+1, +1) and every 0-bit is interpreted as a -step that changes the current coordinate by (+1, −1); see Figure 4. Let D n,k ⊆ L n,k denote the bitstrings that have the property that in every prefix, the number of 1s is at x = 11100100101100 ∈ D 14,7 Figure 4. The correspondence between bitstrings, lattice paths (left) and rooted trees (right).
least as large as the number of 0s. We partition the set D n,k further into D >0 n,k and D =0 n,k , according to whether this inequality is strict for all non-empty prefixes, or whether it holds with equality for at least one non-empty prefix, respectively. The empty bitstring () therefore belongs to D >0 0,0 and not to D =0 0,0 . We also define D >0 := n≥k≥0 D >0 n,k , D =0 := n≥k≥0 D =0 n,k and D := k≥0 D 2k,k . In terms of lattice paths, D corresponds to so-called Dyck paths that never move below the abscissa y = 0 and end at the abscissa. Similarly, D >0 are paths that always stay strictly above the abscissa except at the origin, and D =0 are paths that touch the abscissa at least once more. Any bitstring x ∈ D =0 can be written uniquely as x = (1, u, 0, v) with u ∈ D. We refer to this as the canonical decomposition of x. The set D − n,k is defined similarly as D n,k , but we require that in exactly one prefix, the number of 1s is strictly smaller than the number of 0s. That is, the lattice paths corresponding to D − n,k move below the abscissa exactly once.
Note that for any bitstring x, the inverted bitstring x corresponds to mirroring the lattice path at a horizontal line, and the inverted and reversed bitstring rev(x) corresponds to mirroring the lattice path at a vertical line. In particular, we have rev(x) ∈ D for every x ∈ D.
An (ordered) rooted tree is a tree with a specified root vertex, and the children of each vertex have a specified left-to-right ordering. We think of a rooted tree as a tree embedded in the plane with the root on top, with downward edges leading from any vertex to its children, and the children appear in the specified left-to-right ordering. Using a standard Catalan bijection, every Dyck path x ∈ D 2n,n can be interpreted as a rooted tree with n edges; see Figure 4 and [Sta15].
2.2. Lexical matchings. We now define the aforementioned i-lexical matchings of Kierstead and Trotter [KT88]. Originally, they were defined and analyzed for the graph between the middle two levels of the (2n + 1)-cube in an attempt to tackle the middle two levels problem, and we begin by generalizing them to the n-cube for arbitrary n and an arbitrary pair of consecutive levels k and k + 1. The parameter i is an integer i ∈ {0, 1, . . . , n − 1}, and these matchings are defined as follows; see Figure 5. Again we interpret a bitstring x as a lattice path, and we let x ↑ denote the lattice path that is obtained by appending -steps to x until the resulting path ends at height −1. If x ends at a height less than −1, then x ↑ := x. Similarly, we let x ↓ denote the lattice path obtained by appending -steps to x until the resulting path ends at height +1. If x ends at a height greater than +1, then x ↓ := x. We define the matching by two partial mappings M i,↑ n,k : L n,k → L n,k+1 and M i,↓ n,k : L n,k+1 → L n,k defined as follows: For any x ∈ L n,k we consider the lattice path x ↑ and scan it row-wise from top to bottom, and from right to left in each row. The partial mapping M i,↑ n,k (x) is obtained by flipping the ith -step encountered in this fashion, where counting starts with 0, 1, . . ., if this -step exists and is part of x; otherwise x is left unmatched. Similarly, for any x ∈ L n,k+1 we consider the lattice path x ↓ and scan it row-wise from top to bottom, and from left to right in each row. The partial mapping M i,↓ n,k (x) is obtained by flipping the ith -step encountered in this fashion if this -step exists and is part of x; otherwise x is left unmatched. It is straightforward to verify that these two partial mappings are inverse to each other, so they indeed define a matching between levels k and k + 1 of Q n , which we denote by M i n,k . Property (i) holds as in the smaller of the two levels k and k + 1, no steps are appended to the lattice paths and the required steps exist when computing the i-lexical matching between those levels. Property (ii) holds as the vertices in the smaller of the two levels k and k + 1 have degree l + 1 and the matchings M i n,k for i = 0, 1, . . . , l are pairwise disjoint. Property (iii) follows from the observation that complementing a bitstring corresponds to mirroring the lattice path at a horizontal line, and reverting a bitstring corresponds to mirroring the lattice path at a horizontal line and at a vertical line.

Pairwise edge-disjoint SCDs
We proceed to prove Theorems 3-5.   Figure 6. The labeling procedures that define the symmetric chains C 0 (x) (top) and C 1 (x) (bottom). The markers that define the upward and downward steps of the chains are drawn as a square and a diamond, respectively. The resulting chain C 0 (x) is the same as the one shown in Figure 2.
For even n ≥ 2, we consider a vertex x ∈ L n,n/2 in the middle level n/2 of Q n , and we define the sequence of vertices reached from x when moving up the corresponding chain, and the sequence of vertices reached when moving down the chain. For this we consider the lattice path corresponding to the bitstring x. This lattice path ends at the coordinate (n, 0) as the number of 0s equals the number of 1s. We now label a subsequence of -steps of this lattice path with integers j = 1, 2, . . . according to the following procedure; see the top part of Figure 6 for an illustration: (a0) We place a marker at the rightmost highest point of x and set j := 1. (b0) If the marker is at height h ≥ 1, we label the -step starting at the marker with j, and we move the marker to the starting point of the rightmost -step starting at height h − 1. We set j := j + 1 and repeat. (c0) If the marker is at height h = 0, we stop.
Flipping the -steps of x marked with 1, 2, . . . in this order yields the sequence of vertices reached from x when moving up the chain containing x. An analogous labeling procedure obtained by interchanging left and right, -steps and -steps, and starting with ending points yields the sequence of vertices reached from x when moving down this chain. We denote this chain by C 0 (x). Observe that C 0 (x) is a symmetric chain, as the height of the marker decreases by 1 in each step, so the number of edges we move up from x equals the number of edges we move down from x. It is easy to verify that the SCD D 0 defined before via the parenthesis matching approach satisfies Proof of Theorem 3. We first define a set D 1 of chains in Q n for even values of n ≥ 2 via a labeling rule similar to the rule for D 0 described before. From this definition it follows immediately that all chains in D 1 are symmetric. We then use an equivalent characterization of D 1 as the union of certain lexical matchings to show that the chains in D 1 form a partition of all vertices of Q n , proving that D 1 is an SCD, and that D 0 , D 0 , D 1 and D 1 are pairwise edge-disjoint.
For even n ≥ 2, we consider a vertex x ∈ L n,n/2 in the middle level n/2 of Q n . We interpret it as a lattice path, and label some of its -steps as follows; see the bottom part of  We consider all -steps starting at height h − 2 to the right of the labeled step and the -step starting at the marker, we label the second step from the right from this set with j + 1, and we move the marker to the starting point of the rightmost -step starting at height h − 2. We set j := j + 2 and repeat. (c1) If the marker is at height h = 1 or h = 0, we stop.
We let C 1 (x) denote the chain obtained by flipping bits according to this labeling rule and the corresponding symmetric rule obtained by interchanging left and right, -steps and -steps, and starting with ending points. Observe that C 1 (x) is a symmetric chain, as the height of the marker decreases by 2 in each iteration (and we label two steps in each iteration) and the conditional labeling with j = 1 in step (a1) occurs if and only if the highest point of x is not unique, so the number of edges we move up from x equals the number of edges we move down from x. At this point it is not at all clear yet that the chains C 1 (x), x ∈ L n,n/2 , are disjoint, nor that they cover all vertices of Q n . This is what we will argue about next, which will prove that is actually an SCD of Q n .
By property (i) from Lemma 6, for any sequence i : is a chain decomposition of Q n . The resulting chains are not necessarily symmetric, though. From the definitions in Section 2.2 it also follows that D 0 equals the union of the 0-lexical matchings, and that for even n ≥ 2, D 1 as defined in (1)   This completes the proof.
Clearly, D (0,0,...,0) as defined in (2) equals D 0 for every n ≥ 1, so the union of all 0-lexical matchings forms an SCD in any dimension. In contrast to that, the union of all 1-lexical matchings D (1,1,...,1) only forms an SCD for even n ≥ 2. Computer experiments show that for n ∈ {8, 10} there is no union of lexical matchings D i for any sequence i that forms an SCD that is edge-disjoint from D 0 , D 0 , D 1 and D 1 ; recall Table 1.
Furthermore, taking unions of the so-called modular matchings introduced by Duffus, Kierstead, and Snevily [DKS94] does not yield SCDs in Q n for n = 5 and n = 7, and only two edge-disjoint SCDs for n = 6.

Proof of Theorem 5.
Proof of Theorem 5. For the reader's convenience, this proof is illustrated in Figure 8. Assume that A 1 , A 2 , . . . , A k and B 1 , B 2 , . . . , B k denote k pairwise edge-disjoint SCDs of Q a and Q b , respectively. We will think of Q a+b as the Cartesian product Q a × Q b of Q a and Q b . We show how to construct is an edge from B i . From this it follows that the SCDs C 1 , C 2 , . . . , C k are pairwise edge-disjoint.
The SCD C i of Q a+b is defined as follows: The Cartesian products A×B of chains A ∈ A i and B ∈ B i partition the vertices of Q a+b into two-dimensional grids. As A and B are symmetric, we know that |x 1 | + |x α | = a and |y 1 | + |y β | = b, where |x| denotes the Hamming weight of the bitstring x. This implies that |(x 1 , y 1 )| + |(x α , y β )| = |x 1 | + |y 1 | + |x α | + |y β | = a + b, i.e., the bottom and top vertex of the grid A × B are on symmetric levels in Q a+b . We may therefore decompose A × B into disjoint symmetric chains C j , j = 1, 2, . . . , min{α, β}, by setting Note that in the proof of Theorem 5 we have some degrees of freedom in partitioning the twodimensional grids A×B into symmetric chains. If we perform this construction using Q n+1 = Q n ×Q 1 for n = 1, 2, . . . and always partition the grids according to (3), then the resulting SCD equals D 0 . If instead we partition always according to then we get the SCD D 0 . The difference between (3) and (4) is whether in building C j we first move along the first coordinates, or first along the last coordinates.
3.3. Proof of Theorem 4. We begin by constructing the SCDs in Q 5 and Q 7 mentioned in Table 1.
Lemma 7. Q 5 contains three pairwise edge-disjoint SCDs, Q 7 contains four pairwise edge-disjoint SCDs, and this is best possible.
Proof. For prime n, we consider the graph Q n with the two vertices in the outermost levels 0 and n removed, and we identify all bitstrings that differ only by rotation into so-called necklaces. The resulting graph N n is a multigraph version of the cover graph of the necklace poset. Specifically, the multiplicity of the edges in N n corresponds to the number of ways a bit from a necklace can be flipped to reach the corresponding adjacent necklace. Here we use that n is a prime number, so every necklace in N n corresponds to exactly n bitstrings in Q n . For example, in N 5 the necklace x := 10000 has two edges leading to y := 11000, as we can flip the second or the fifth bit in x to reach y. This way, every necklace on level k has n − k edges going up, and k edges going down, like the vertices in Q n . The multigraphs N 5 and N 7 are shown in Figure 9. Now observe that every SCD in N n corresponds to an SCD in Q n , by turning each chain from N n into n chains in Q n obtained by rotating a representative of each necklace in all possible ways. Moreover, one of the chains of length n − 2 needs to be extended by the all-zero and all-one bitstring to a chain of length n in Q n . Observe that in this way, k edge-disjoint SCDs in N n give rise to k edge-disjoint SCDs in Q n .  Figure 9. Illustration of the three edge-disjoint SCDs in N 5 (a) and four edgedisjoint SCDs in N 7 (b). The names of the SCDs correspond to the ones used in Table 1. In N 7 , two pairs of SCDs are complementary.

13
As n = 5 and n = 7 are prime, we thus obtain three edge-disjoint SCDs in Q 5 from the SCDs in N 5 shown in Figure 9 (a), and four edge-disjoint SCDs in Q 7 from the SCDs in N 7 shown in Figure 9 (b). These SCDs use up all middle edges, so this is best possible.
Proof of Theorem 4. For n = 7 the statement follows from Lemma 7. For odd n ≥ 13 we apply Theorem 5 to Q n−7 and Q 7 , using the four edge-disjoint SCDs in Q n−7 given by Theorem 3 (note that n − 7 ≥ 6), and the four edge-disjoint SCDs in Q 7 given by Lemma 7.

The middle four levels problem
In this section we prove Theorem 1. The proof proceeds similarly as the proof of the middle two levels problem [Müt16,GMN18]. First, we construct a cycle factor C 2n+1 in the middle four levels of Q 2n+1 , and we then modify the cycles in the factor locally to join them to a Hamilton cycle. Specifically, to join two cycles C and C from our cycle factor, we consider a suitable 6-cycle and take the symmetric difference between their edge sets, so that the result is a single cycle on the union of the vertex sets of C and C ; see Figure 15. This process is iterated until all cycles are joined to a single Hamilton cycle. This technique reduces the problem of proving that the middle four levels of Q 2n+1 have a Hamilton cycle to the problem of proving that a suitably defined auxiliary graph H n+1 has a spanning tree, which is much easier. This section is organized as follows: We first define the cycle factor C 2n+1 and analyze its structure. We then introduce the 6-cycles for the joining operations, and finally show that they can be used to join the cycles of the factor to a Hamilton cycle in the desired fashion.
4.1. Construction of the cycle factor C 2n+1 . As we are not able to analyze the cycle factor in the middle four levels of Q 2n+1 arising from the proof of Theorem 2 (see Table 2 in Section 5), we start with a different construction. To construct the cycle factor C 2n+1 in the middle four levels of Q 2n+1 , we use the i-lexical matchings defined in Section 2.2. Specifically, we take the union of all n-lexical and (n + 1)-lexical matching edges between the upper two levels n + 1 and n + 2 and between the lower two levels n − 1 and n, plus certain carefully chosen edges E from the (n − 2)-lexical, (n − 1)-lexical and n-lexical matching between the middle levels n and n + 1. Formally, we set where the set of edges E is defined in (8) below. By this definition and by Lemma 6 (i) and (ii), all vertices in the outer levels n − 1 and n + 2 have degree two in the subgraph C 2n+1 , and we will choose E so that all vertices in the inner levels n and n + 1 have degree two as well.
To define the set E, we consider the union of the matchings between the upper two levels In the following, for a set of bitstrings X and a bitstring x, we write X • x for the set obtained by concatenating each bitstring from X with x. The set P • 00 is a set of edges in the middle two levels of the (2n + 3)-cube, and from [GMN18, Proposition 2 (i)+(ii)+(iv)], which talks about a superset of the paths P • 0, we obtain the following properties.
The first vertices of the paths P, denoted by F (P), are the vertices from level n + 1 covered by the matching M n 2n+1,n+1 and not by M n+1 2n+1,n+1 . Similarly, the last vertices of the paths P, denoted 14 by L(P), are covered by the latter matching but not by the former. We let I(P) denote the set of vertices in level n + 1 covered by neither of the two matchings. We refer to those vertices as isolated.
We let f := rev denote the automorphism of Q 2n+1 that flips all bits and reverses them, i.e., f (x 1 , x 2 , . . . , x 2n+1 ) = (x 2n+1 , . . . , x 2 , x 1 ). Using the abbreviation (6) and Lemma 6 (iii), we may rewrite the definition (5) equivalently as For any set X of bitstrings and bitstrings a, b we let a X b denote the subset of the bitstrings from X that have the prefix a and the suffix b. Furthermore, let P 0 and P 1 be the collections of paths from P with fixed last bit equal to 0 or 1, respectively. Note that P = P 0 ∪ P 1 , as neither the n-lexical matching nor the (n + 1)-lexical matching between levels n + 1 and n + 2 uses any edges along which the last bit is flipped. We start with the following observations.
Lemma 9. For any n ≥ 1, the sets of first, last and isolated vertices of the paths P defined in (6) are given by Proof. The first two statements in part (i) are given by Lemma 8. The statement I(P) = D >0 2n+1,n+1 follows by considering for which x ∈ L 2n+1,n+1 the lattice path x ↑ (recall the definition from Section 2.2) has its nth and (n + 1)th -step (in the counting from top to bottom and from right to left in each row, starting from 0) in the two -steps that were added to x at positions 2n + 2 and 2n + 3. One can easily observe that this happens if and only if x ∈ D >0 2n+1,n+1 . Part (ii) follows immediately from the definitions and from part (i) by considering the lattice paths before the fixed last bit.
We define F (P) ⊆ F (P) as the set of vertices x ∈ F (P) = D =0 2n+1,n+1 such that x = (1, u, 0, v) with some u ∈ D and v ∈ D =0 (otherwise v ∈ D >0 ). Similarly, L (P) ⊆ L(P) is the set of all vertices y ∈ L(P) = D − 2n+1,n+1 such that y = (u, 0, 1, v) with some u ∈ D and v ∈ D =0 . Figure 10 illustrates the lattice paths corresponding to the different subsets of vertices given by Lemma 9, refined according to F (P) and L (P) and by fixing the first one or two bits, and which pairs of first and last vertices are joined along paths from P as given by Lemma 8.
We now define the set E of edges for the cycle factor C 2n+1 between levels n and n + 1 of Q 2n+1 so that each vertex of F (P) and L(P) will be incident with exactly one edge of E, each vertex of I(P ) will be incident with exactly two edges of E, and all other vertices in level n + 1 are not incident with any edges from E; see Figure 11. Effectively, adding the edges from E makes all degrees in the subgraph C 2n+1 in level n + 1 equal to two. We then show that adding the edges from E also makes all degrees in level n equal to two, so that C 2n+1 is indeed a cycle factor.
For a set of edges M and a set of vertices X, we let M [X] denote the set of edges from M incident with X. We then define To prove that C 2n+1 as defined in (7) is indeed a cycle factor, we now consider the sets of vertices in level n that are covered by the edges from E; see Figure 11. Proof. It suffices to show that in each of the cases, the edges from E join a vertex from one of the sets X in level n + 1 to a vertex from the corresponding set Y in level n (i.e., we show that these edges form an injection from X to Y ). The fact that they form a surjection follows by applying the same argument to f (C 2n+1 ), using that f is an involution and that f (M i 2n+1,n ) = M i 2n+1,n for i = n, n − 1, n − 2 by Lemma 6 (iii).
Lemma 10 allows us to conclude that C 2n+1 as defined in (7) with the edge set E defined in (8) is indeed a cycle factor in the subgraph of Q 2n+1 induced by the middle four levels, as every vertex in the four levels is covered by exactly two edges. 4.2. Structure of the cycle factor C 2n+1 . We now analyze the structure of the cycle factor C 2n+1 defined in (7). Observe from Figure 11 that on each cycle of C 2n+1 all paths from P are visited in the same orientation from the first vertices F (P) to the corresponding last vertices from L(P). The following lemma shows for a given path from P on a cycle C of C 2n+1 which path from P is encountered next on the cycle C. To state the lemma we introduce a bit of notation.
It is convenient here to identify the paths from P by their first vertices, so by Lemma 8 this is the set D =0 2n+1,n+1 . By appending an additional 0-bit to the bitstrings D =0 2n+1,n+1 , we obtain Dyck paths of length 2n + 2 with exactly n + 1 upsteps and n + 1 downsteps that touch the abscissa at least three times (in the origin (0, 0), at (2n + 2, 0) and at some intermediate point). It turns out that the structure of the cycle factor C 2n+1 can be described most conveniently by interpreting the Dyck paths D =0 2n+1,n+1 • 0 as rooted trees as described in Section 2.1 and illustrated in Figure 4. We introduce the abbreviation T n+1 := D =0 2n+1,n+1 • 0 for these trees. Note that they have exactly n + 1 edges and the root has degree at least two.
The following definitions are illustrated in Figure 12. We say that a tree from T n+1 is left-light if the leftmost child of the root is a leaf; otherwise, it is left-heavy. Analogously, we define right-light or right-heavy trees by considering the rightmost child of the root. A left-rotation of a tree moves the  1, v, 0). A right-rotation is the inverse operation of a left-rotation. Given a left-heavy tree x = (1, u, 0, s, 1, v 3 , 0), u, v 3 ∈ D, where s = () or s = (v 1 , 1, v 2 , 0) with v 1 , v 2 ∈ D, a heavy rotation is a left-rotation of the tree plus a right-rotation of the subtree s, i.e., the resulting tree y is given by y = (u, 1, 1, v 3 , 0, 0) if s = () and y = (u, 1, 1, v 1 , 0, v 2 , 1, v 3 , 0, 0) otherwise. Note that the resulting tree y is right-heavy. Given a left-light tree x = (1, 0, s, 1, v 3 , 0), v 3 ∈ D, where s = () or s = (v 1 , 1, v 2 , 0) with v 1 , v 2 ∈ D, a light rotation is a right-rotation of the tree plus a right-rotation of the (possibly empty) subtree s plus detaching the pending edge that leads to the leftmost child of the root of x and reattaching it as a rightmost child of the new root, i.e., the resulting tree y is given by y = (1, 0, v 3 , 1, 0) if s = () and y = (1, 1, v 1 , 0, v 2 , 0, v 3 , 1, 0) otherwise. Note that the resulting tree y is right-light. To any given tree from T n+1 , we can either apply a heavy or a light rotation, depending on whether the tree is left-heavy or left-light, respectively. We refer to this mapping on T n+1 as ρ. Analogously, ρ −1 applies either an inverse heavy or an inverse light rotation depending on whether the tree is right-heavy or right-light, respectively.
The following lemma asserts that the sequence of rooted trees corresponding to first vertices of paths from P that are encountered when following a cycle from our factor C 2n+1 corresponds to repeatedly applying ρ, i.e., either applying a heavy rotation or a light rotation. In other words, the cycles of C 2n+1 are in bijection with equivalence classes of rooted trees from T n+1 when iterating the mapping ρ.
Proof. We follow the cycle C in Figure 11 from some vertex x ∈ F (P) until we encounter the next vertex y ∈ F (P). The case when u = () is shown in Figure 13. In this case, following the path of P from x ∈ 11 F (P) leads to the vertex x := (u, 0, 1, v) ∈ 1 L(P) by Lemma 8. Then, depending on whether x ∈ L(P) \ L (P) or x ∈ L (P), we continue along the cycle via an edge from E n or E n−2 , respectively, from level n + 1 to level n. This corresponds to the two subcases distinguished by v and shown in the left and right column in Figure 13. By Lemma 10, we get to a vertex z ∈ f (L(P 0 )) that is last on some path of f (P 0 ). By following this path backwards using Lemma 8 we get to the corresponding first vertex z ∈ f (F (P 0 )). Using again Lemma 10, we then traverse an edge from E n to go from from level n to level n + 1 where we encounter the vertex y ∈ F (P 0 ). Observe in Figure 13 that y has exactly the claimed form. Figure 13. Proof of the first part of Lemma 11. The two columns represent the subpaths from x to y on a cycle from our factor for the two cases of v. Applying f = rev can be interpreted as reading the lattice path backwards, and this is indicated by the dotted coordinate systems. Figure 14. Proof of the second part of Lemma 11. The two columns represent the subpaths from x to y on a cycle from our factor for the two cases of v. Applying f = rev can be interpreted as reading the lattice path backwards, and this is indicated by the dotted coordinate systems.
The case when u = () is depicted in Figure 14 and can be verified analogously. Note that in this case we in addition visit a vertex from I(P) and from f (I(P)) before coming to y.
The number of cycles in the factor C 2n+1 is 1, 1, 1, 4, 6, 19, 49, 150, 442, 1424 for n = 1, 2, . . . , 11. This sequence matches the first entries of [OEI17], i.e., the number of plane trivalent trees with n internal vertices. A plane trivalent tree is a tree where every vertex has degree 1 or 3, and the neighbors 20 of each vertex have a specified cyclic ordering. We establish the correspondence between cycles from our factor and plane trivalent trees in the following proposition. This special family of trees appears only in this proposition and its proof. All subsequent arguments use again the set of rooted trees T n+1 introduced before.
Proposition 12. For any n ≥ 1, the cycles from the factor C 2n+1 defined in (7) are in bijection with the set of plane trivalent trees with n internal vertices.
Proof. We first define, for any x ∈ D, binary trees (x) and r(x). If x = (), then (x) and r(x) consist only of a single vertex. Otherwise we write x uniquely as x = (1, u, 0, v) = (u , 1, v , 0) with u, v, u , v ∈ D, and then (x) consists of a root with left child (u) and right child r(v), and r(x) consists of a root with left child (u ) and right child r(v ). Given any vertex x ∈ F (P) = D =0 2n+1,n+1 , we map the bitstring x := (x, 0) to a trivalent tree τ (x ) rooted at one of its n internal vertices as follows. We first write x uniquely in the form x = (1, u, 0, v, 1, w, 0) with u, v, w ∈ D, and we define τ (x ) as the tree that consists of a root with left child (u), middle child r(v) and right child r(w). One can show that under this bijection τ between D =0 2n+1,n+1 • 0 and trivalent trees rooted at one of their n internal vertices, the mapping ρ corresponds to rotating the root of the trivalent tree to the leftmost child until the root is again an internal vertex. Consequently, by Lemma 11 cycles from C 2n+1 correspond to equivalence classes of rooted trivalent trees whose root is one of their n internal vertices under this rotation operation. Obviously, these are exactly plane trivalent trees with n internal vertices. 4.3. Flippable pairs. In this section we define certain 6-cycles in the graph Q 2n+1 between levels n+ 1 and n + 2 that can be used to join pairs of cycles from our factor C 2n+1 as described in the beginning of this section (see Figure 15). Let us emphasize here that all modifications of the cycle factor happen only between the two upper levels n + 1 and n + 2.
We say that two vertices x, y ∈ F (P) = D =0 2n+1,n+1 form a flippable pair (x, y), if x and y have the form x = (1, u 1 , 1, u 2 , . . . , 1, u d , 1, 1, 0 with d ≥ 0 and u 1 , . . . , u d , v 1 , . . . , v d , w, (v 0 , 0) ∈ D. Recall that (x, 0) and (y, 0) can be viewed as rooted trees from T n+1 . If (x, y) is a flippable pair, then the tree (y, 0) is obtained from the tree (x, 0) by moving a pending edge from a vertex in the leftmost subtree to its parent. Specifically, the pending edge (q, r) must form the leftmost subtree of a vertex q in the leftmost subtree of (x, 0), and this edge is removed from q and reattached to the parent p of q to become the subtree directly left of the edge (p, q). We refer to this as a pull operation; see the right side of Figure 12. The inverse operation takes a pending edge (p, r) in the leftmost subtree of (y, 0), removes this edge from p, and reattaches it as the leftmost subtree of the vertex q that is the child of p directly to the right of r.
Any 6-cycle between levels n+1 and n+2 of Q 2n+1 can be uniquely encoded as a string of length 2n+1 over {0, 1, * } with n many 1s, n − 2 many 0s and three * s. The 6-cycle corresponding to this string is obtained by substituting the three * s by all six combinations of at least two different symbols from {0, 1}. We define a set of 6-cycles S 2n+1 between levels n + 1 and n + 2 of Q 2n+1 consisting of all 6-cycles C 6 (x, y) := (u 1 , 0, u 2 , 0, . . . , u d , 0, 1, * , * , w, for a flippable pair (x, y), x, y ∈ D =0 2n+1,n+1 , as in (9). Note that C 6 (x, y) • 00 is a 6-cycle in the middle two levels of the (2n + 3)-cube, and from [GMN18, Proposition 3] we obtain the following properties. For any x ∈ D =0 2n+1,n+1 , we write P (x) for the path from the set P defined in (6) that starts at the vertex x. 21 P (x) P (y) x y C 6 (x, y) C C Figure 15. Two cycles from our factor joined by taking the symmetric difference with a 6-cycle. The paths P (x) and P (y) from the set P (solid black) lying on the two cycles traverse the 6-cycle C 6 (x, y) (solid gray) as shown. The symmetric difference yields paths P (x) and P (y) that have flipped end vertices.
Lemma 13. For any n ≥ 1, the 6-cycles C 6 (x, y) ∈ S 2n+1 defined in (10) have the following properties: (i) Let (x, y) be a flippable pair. The 6-cycle C 6 (x, y) intersects P (x) in two non-incident edges and it intersects P (y) in a single edge. Moreover, the symmetric difference of the edge sets of the two paths P (x) ∈ P and P (y) ∈ P with the 6-cycle C 6 (x, y) gives two paths P (x) and P (y) on the union of the vertex sets of P (x) and P (y), interconnecting x with the last vertex of P (y), and y with the last vertex of P (x), respectively. (ii) For any flippable pairs (x, y) and (x , y ), the 6-cycles C 6 (x, y) and C 6 (x , y ) are edge-disjoint. (iii) For any flippable pairs (x, y) and (x, y ), the two pairs of edges that the two 6-cycles C 6 (x, y) and C 6 (x, y ) have in common with the path P (x) are not interleaved, but one pair appears before the other pair along the path.
4.4. Proof of Theorem 1. With Lemma 11 and 13 in hand, we are now ready to prove Theorem 1.
Proof of Theorem 1. Let C 2n+1 and S 2n+1 be the cycle factor and the set of 6-cycles defined in Section 4.1 and 4.3, respectively.
Consider two cycles C, C of C 2n+1 containing paths P, P ∈ P with first vertices x, y ∈ D =0 2n+1,n+1 , respectively, such that (x, y) is a flippable pair. By Lemma 13 (i), the symmetric difference of the edge sets C ∪ C and C 6 (x, y) forms a single cycle on the vertex set of C ∪ C , i.e., this joining operation reduces the number of cycles in the factor by one; see Figure 15. Recall that in terms of rooted trees, (y, 0) ∈ T n+1 is obtained from (x, 0) ∈ T n+1 by a pull operation; see Figure 12.
We repeat this joining operation until all cycles in the factor are joined to a single Hamilton cycle. For this purpose we define an auxiliary graph H n+1 whose nodes represent the cycles in the factor C 2n+1 and whose edges connect pairs of cycles that can be connected to a single cycle with such a joining operation that involves a 6-cycle from the set S 2n+1 . Formally, the node set of H n+1 is given by partitioning the set T n+1 into equivalence classes under the mapping ρ. By Lemma 11, the nodes of H n+1 therefore indeed correspond to the cycles in the factor C 2n+1 . Specifically, each rooted tree (x, 0) ∈ T n+1 = D =0 2n+1,n+1 • 0 belonging to some node of H n+1 corresponds to the first vertex x of some path P ∈ P such that P lies on the cycle corresponding to that node. For every flippable pair (x, y), x, y ∈ D =0 2n+1,n+1 , we add the edge to H n+1 that connects the node containing the tree (x, 0) to the node containing the tree (y, 0). By our initial argument, such a flippable pair yields a 6-cycle C 6 (x, y) that can be used to join the two corresponding cycles to a single cycle. As mentioned before, the 6-cycle lies entirely between levels n + 1 and n + 2.
To complete the proof of Theorem 1, it therefore suffices to prove that the auxiliary graph H n+1 is connected. Indeed, if H n+1 is connected, then we can pick a spanning tree in H n+1 , corresponding to a collection of 6-cycles S ⊆ S 2n+1 , such that the symmetric difference between the edge sets C 2n+1 S forms a Hamilton cycle in the middle four levels of Q 2n+1 . Of crucial importance here are properties (ii) and (iii) in Lemma 13, which ensure that whatever subset of 6-cycles we use in this joining process, they will not interfere with each other, guaranteeing that each 6-cycle indeed reduces the number of cycles by one, as desired.
At this point we reduced the problem of proving that the middle four levels of Q 2n+1 have a Hamilton cycle to showing that the auxiliary graph H n+1 is connected, which is much easier. Indeed, all we need to show is that any rooted tree from T n+1 can be transformed into any other tree from T n+1 by a sequence of heavy rotations, light rotations, pulls and their inverse operations; see Figure 12. It turns out that for our proof we only need light rotations and pulls.
Recall that heavy and light rotations correspond to following the same cycle from C 2n+1 (staying at the same node in H n+1 ), and a pull corresponds to a joining operation (traversing an edge in H n+1 to another node). For this we show that any rooted tree x ∈ T n+1 can be transformed into the special tree s := (1, 1, 0, 1, 0, . . . , 1, 0, 0, 1, 0) ∈ T n+1 , i.e., a right-light tree with a root of degree two and a star as its left subtree. To achieve this we distinguish three cases; see Figure 16.
(a) x is left-light and right-light. By a single light rotation we obtain a right-light tree with a root of degree two. We then repeatedly pull pending edges in the left subtree towards the left child of the root until we end up at the tree s. (b) x is left-light and right-heavy. The tree obtained after applying a single light rotation is right-light. If it is also left-light, then we continue as in case (a). Otherwise it is left-heavy, and then we consider the leftmost leaf of it, performing pull operations on this leaf until it becomes adjacent to the root. We thus obtain a tree that is left-light and right-light, and then we continue as in case (a). (c) x is left-heavy. We consider the leftmost leaf of x, and repeatedly perform pull operations on this leaf until it becomes adjacent to the root. We obtain a left-light tree, and then we continue as in cases (a) or (b).
This shows that H n+1 is connected, and thus completes the proof.

Computer experiments
The numbers of cycles in the factor through the middle 2 levels of the (2n + 1)-cube constructed as in the proof of Theorem 2 using the two edge-disjoint SCDs D := D 0 and D := D 0 are shown in Table 2 for n = 1, 2, . . . , 12. Note that the number of cycles in the middle two levels (the first column = 1) seems to grow faster than the number of cycles in the middle four levels (the second column = 2).
If instead we perform the proof of Theorem 2 with the two edge-disjoint SCDs constructed via our product construction, we obtain another set of cycle factors. Specifically, denoting by D 0 (a) the Table 2. Number of cycles of the factor in the middle 2 levels of the (2n + 1)-cube here is that we are missing a simple criterion like Hall's matching condition guaranteeing the existence of an SCD.