## 1 Introduction

Denote the *n*-dimensional cube by $Q^n = [0,1]^n$ and the set of vertices of the *n*-dimensional cube by $Q^n_0$. In other words, $Q^n_0 = \{0,1\}^n$, which is the set of all *n*-tuples with binary entries. More generally, let $Q^n_k$ denote the *k*-dimensional skeleton of $Q^n$. For example, $Q^n_1$ is the graph with vertex set $Q^n_0$ and an edge (i.e., a $1$-dimensional face) between two vertices if and only if they differ by exactly one coordinate. Define the random $2$-dimensional cubical complex $Q_2(n,p)$ as having $1$-skeleton equal to $Q^n_1$, and where each $2$-dimensional face of $Q^n$ is included with probability *p*, independently.

The random complex $Q_2(n,p)$ is a cubical analogue of the random simplicial complex $Y_2(n,p)$ introduced by Linial and Meshulam in [Reference Linial and Meshulam22], whose theory is well developed. The random complex $Y_2(n,p)$ is defined by taking the complete $1$-skeleton of the *n*-dimensional simplex $\Delta ^n$ and including each $2$-face independently and with probability *p*. In this way, $Q_2(n,p)$ is constructed in exactly the same way as $Y_2(n,p)$, except that the underlying polytope $\Delta ^n$ is replaced by $Q^n$.

The random complex $Q_2(n,p)$ is also the $2$-dimensional analogue of the random cubical graph; see [Reference Kostochka, Sapozhenko and Weber21] for a 1992 survey. To make the connection precise and review some of the history, let $Q(n,p)$ denote the random subgraph of the *n*-cube defined by including all vertices of $Q^n$, and including each edge in $Q_1^n$ independently with probability *p*.

Burtin [Reference Burtin6] and later Erdoős and Spencer [Reference Erdős and Spencer14] studied the threshold for connectivity in the random cubical graph:

### Theorem 1.1 Burtin [Reference Burtin6], Erdoős and Spencer [Reference Erdős and Spencer14]

For $Q \sim Q(n,p)$ and for any fixed $p \in [0,1]$,

Let $f_n(p)=\mathbb {P}[Q \sim Q(n,p) \text { is connected}]$. It is easy to see that if $p < 1/2$, then $\lim _{n \to \infty }f_n(p) =0$. Burtin showed that this is sharp; if $p> 1/2$, then $\lim _{n \to \infty }f_n(p) =1$.

Erdoős and Spencer refined this argument to show what happens at $p=1/2$ exactly. They also showed that near $p=1/2$, the only connected components of $Q(n,p)$ are isolated vertices and a giant component. Then it is straightforward to show that the number of isolated vertices has a limiting Poisson distribution with mean $1$, and as a consequence

for every integer $k \ge 0$, where ${\beta }_0$ denotes the number of connected components.

This picture strongly parallels what is seen in Erdoős–Rényi graphs $G \sim G(n,p)$. Let $p = (\log n + c)/n$ with $c \in \mathbb {R}$ fixed. Then

(see [Reference Erdős and Rényi13] or [Reference Bollobás5]). Letting $c \to \pm \infty $, the probability tends to $0$ or $1$.

The proofs share a strong similarity, in that the method is to enumerate potential cut sets and show that they are rare by making a first moment estimate of the number of cut sets.

It is therefore perhaps reasonable to speculate that the topological phenomenology of the higher-dimensional process $Q_2(n,p)$ mirrors that of $Y_2(n,p)$ after appropriately adjusting how *p* is chosen as a function of *n*. We shall show, however, that there are major differences between $Q_2(n,p)$ and $Y_2(n,p)$.

Before discussing our results and illustrating these differences, we introduce some standard terminology. Our focus is on typical behaviour of random objects for large values of *n*. So we will say that a sequence of statements $\mathcal {P}_n$ holds *with high probability* (abbreviated ‘w.h.p.’) if

We will make use of the Landau notations $O, o, \omega , \Omega , \Theta $ in the asymptotic sense, so that $f = O(g)$ means $f/g$ is eventually bounded above as $n \to \infty $ and $f = o(g)$ means $f/g \to 0$ as $n \to \infty $. Also, $f = \omega (g)$ means $g = o(f)$ and $f = \Omega (g)$ means $g = O(f)$. Finally, we will use $f = \Theta (g)$ to mean $f = O(g)$ and $f = \Omega (g)$. We occasionally display parameters like $O_{a,b,c}(\cdot )$, emphasising that the implied constants depend on $a,b,c$.

We will also make use of the notion of thresholds. A function $f = f(n)$ is said to be a *threshold* for a property *P* of a sequence of random objects $G=G_{n,p}$ if $p=\omega (f)$ implies $G \in P$ w.h.p. and $p=o(f)$ implies $G \not \in P$ w.h.p. Such a threshold is defined only up to *n*-independent scalar multiples. If there is a function $g = o(f)$ such that $p \geq f + g$ implies $G \in P$ w.h.p. and $p \leq f - g$ implies $G \not \in P$ w.h.p., the threshold is said to be *sharp.*

In this paper we study the *fundamental group* $\pi _1(Q)$ for $Q \sim Q_2(n,p)$. The fundamental group can be given a purely combinatorial representation for a space such as $Q_2(n,p)$, which we discuss in Section 2.1. Our first result establishes the threshold for $\pi _1(Q)=0$ – that is, for $Q\sim Q_2(n,p)$ to be simply connected. Here we formulate the theorem for *p* fixed independently of *n*.

The $2$-dimensional analogues of isolated vertices are maximal $1$-faces. It is not hard to see that the threshold for maximal $1$-faces is $p=1/2$, and that for any fixed $p \leq 1/2$, there are maximal $1$-dimensional faces w.h.p. If there are any maximal $1$-faces, then any loop passing through such an edge is not contractible, so $\pi _1(Q) \neq 0$. Most of our work is to prove the following:

Theorem 1.2. If $Q \sim Q_2(n,p)$ and $p>1/2$, then w.h.p., $\pi _1 (Q)= 0$.

This theorem marks a substantial difference between the behaviours of the random cubical complex $Q \sim Q_2(n,p)$ and the random simplicial complex $Y \sim Y_2(n,p)$. The threshold for $\pi _1(Y) = 0$ is roughly $p = n^{-1/2}$ [Reference Babson, Billera and Chan4]. The threshold is sharpened by Luria and Peled in [Reference Luria and Peled25]. There is a sharp threshold for $H_1(Y) = 0$ vanishing at $p=2\log n / n$. This is due to Linial and Meshulam [Reference Linial and Meshulam22], for the statement with $\mathbb {Z} / 2\mathbb {Z}$ coefficients. This was extended by Meshulam and Wallach [Reference Meshulam and Wallach26] to all finite coefficient rings, and finally to $\mathbb {Z}$ coefficients by Łuczak and Peled [Reference Łuczak and Peled24]; see also [Reference Newman and Paquette28] for the extension of the $\mathbb {Z}$-coefficients result to higher dimensions. In summary, there is a big gap between the thresholds for $\pi _1(Y)=0$ and $H_1(Y)=0$, but Theorem 1.2 implies that the thresholds for $\pi _1(Q)=0$ and $H_1(Q)=0$ (with any coefficients) coincide.

For $p> 1-(1/2)^{1/2}$, we characterise the structure of the fundamental group $\pi _1(Q)$ for $Q \sim Q_2(n,p))$. For the following statement, recall that in a simplicial complex, a *maximal* $1$*-face* is a $1$-face which is not contained in any $2$-face.

Theorem 1.3. For $p> 1-\left (\tfrac 12\right )^{1/2}$, with high probability, for $Q \sim Q_2(n,p)$,

where $F_N$ denotes a free group on *N* generators and *N* denotes the number of maximal $1$-dimensional faces in *Q*.

Hence, just below the $p = 1/2$ threshold, only maximal $1$-faces contribute to the fundamental group. Again, this is in contrast with the corresponding story for $\pi _1(Y)$. The fundamental group of the random $2$-dimensional simplicial complex $\pi _1(Y)$ is known to have property (T) with high probability once $p \ge (2 + \epsilon ) \log n / n$ [Reference Hoffman, Kahle and Paquette19], and this precludes it being a nontrivial free group or even having any nontrivial free quotients.

Theorem 1.3 has the following corollary, a limiting Poisson distribution for the Betti number $\beta _1$:

Corollary 1.4. If $c \in \mathbb {R}$ is fixed and

then

Here $\beta _1$ represents the dimension of homology $H_1(Q, \mathbb {R})$. It is also the number of generators of the free group $\pi _1(Q)$. This all follows from Theorem 1.3, together with showing that the number of maximal $1$-faces is Poisson distributed with mean $e^{-c}$.

It is also possible to formulate a *process version* of this statement. Here one couples all $Q_2(n,p)$ together for all $p \in [0,1]$ in a monotone fashion, so the $2$-faces of $Q_2(n,p_1)$ are a subset of $Q_2(n,p_2)$ whenever $p_1 \leq p_2$. Let $\left (Q_p : p \in [0,1]\right )$ have this distribution, and let $N_p$ be the number of maximal $1$-faces in $Q_p$. Then we can formulate the *stopping times* $T_{sc}$ and $T_{2d}$ as

We have the following:

Corollary 1.5. $T_{sc} = T_{2d}$ w.h.p.

Theorem 1.3 characterises the structure of $\pi _1(Q)$ for $Q \sim Q_2(n,p)$ and

For smaller *p*, we are not able to completely describe the structure of the fundamental group, but we give a partial characterisation in terms of its free factorisation.

For a finitely presented group *H*, we say that *H* is *indecomposable* if whenever *H* is written as a free product of two groups $H \cong H_1 * H_2$, either $H_1$ or $H_2$ is a trivial group. It is well known that a finitely presented group *G* be may be written as a free product

where every $G_i$ is indecomposable. Moreover, this free-product factorisation is unique, up to isomorphism types of the factors and reordering.

Definition 1.6. For a cubical subcomplex *T* of $Q^n$, let $e(T)$ denote the number of edges in *T*. Let $\mathscr {T}_p$ be the set of pure $2$-dimensional strongly connected cubical complexes *T* that are subcomplexes of (the $2$-dimensional skeleton of) $Q^n$ for some *n* and such that $1-(1/2)^{1/e(T)}> p$.

While we do not characterise all the free factors, we are able to characterise some of them. Essentially, we show that everything that can happen will happen, somewhere, with high probability.

Theorem 1.7. For $p \in (0,1)$ fixed and $Q \sim Q_2(n,p)$, let the free-product factorisation of $G = \pi _1(Q)$ be given by

With high probability, for every $T \in \mathscr {T}_p$ with nontrivial fundamental group, $\pi _1(T)$ appears as a free factor – that is, we have $\pi _1(T) \cong G_j $ for some $1 \le j \le \ell $.

Indeed, every finitely presented group *G* can appear as a free factor (see Section 5 for details). One can also ask the extremal topological combinatorial question: For given homotopy classes of $2$-dimensional complexes *T*, what is the smallest $e(T)$ attainable? Furthermore, one can ask what is the threshold for specific groups to appear as a free factor in *G*. In Section5, we give some examples of specific complexes which we believe to be minimal – the torus, the projective plane and the Klein bottle.

Using the case of the projective plane, when $0 < p < 1 - \left (\tfrac 12\right )^{1/40} \approx 0.017179$ and $Q \sim Q_2(n,p)$, we show that $\pi _1(Q)$ has a $\mathbb {Z}/2\mathbb {Z}$ free factor with high probability (see Corollary 5.4). This shows in particular that $H_1(Q;\mathbb {Z})$ has torsion elements for small enough fixed $p>0$. The question of whether torsion ever appears in $H_1(Y; \mathbb {Z})$ is an open one, although it appears that there is almost always a short burst of enormous torsion [Reference Kahle, Lutz, Newman and Parsons20].

Conjecture 1.8. For $p> 1 - \left (\tfrac 12\right )^{1/40}$ and $Q \sim Q_2(n,p)$, $\pi _1(Q)$ is torsion free with high probability.

We further believe it is possible that for *p* above this threshold, $\pi _1(Q)$ is free with high probability. For the case of $\pi _1(Y)$ with $Y\sim Y_2(n,p)$, the sharp threshold is found by Newman in [Reference Newman27], improving on previous work of [Reference Cohen, Costa, Farber and Kappeler7].

### 1.1 Discussion

We have not addressed many results about the fundamental group of $\pi _1(Y)$ for $Y\sim Y_2(n,p)$, which may have interesting analogues in $Q_2(n,p)$ that could further elucidate what appear to be deep differences between simplicial and random cubical complexes. As the body of literature on $Y_2(n,p)$, is substantial, we discuss possible directions of interest for questions about $Q_2(n,p)$.

Many interesting topological phases of $\pi _1(Q)$ are likely to exist when $p \to 0$ at an appropriate rate as $n \to \infty $. For $Y_2(n,p)$, a particularly rich regime of *p* is when the mean degree of an edge $np$ tends to a constant. We would expect this regime to be similarly rich for $Q_2(n,p)$ and to name a few transitions that should appear in this regime: the collapsibility threshold [Reference Aronshtam, Linial, Ł uczak and Meshulam2], the threshold for a giant shadow [Reference Linial and Peled23] and the threshold for $\pi _1(Q)$ to have an irreducible factor in its free-product factorisation with growing rank.

A natural direction is to consider higher-dimensional complexes $Q_d(n,p)$ built in an analogous way to $Y_d(n,p)$. For $Q_d(n,p)$, it may be possible to analyse the higher homotopy groups in a similar fashion to what is done here.

In a different direction, we mention that all of the results we present are about the $n\to \infty $ limit, but also have some content for some large *n*. These could provide useful results for understanding $2$-dimensional percolation on a sufficiently high-dimensional lattice $\mathbb {Z}^n$. There are some recent related results for such higher-dimensional cubical percolation [Reference Dowling and Lundberg12, Reference Hiraoka and Tsunoda18, Reference Hiraoka and Shirai17].

#### 1.1.1 Multiparameter generalisations

In the literature on random cubical graphs, there is a $2$-parameter model $Q(n; p_0, p_1)$ (see [Reference Kostochka, Sapozhenko and Weber21] for a survey of some results). First we take a random induced subgraph of the *n*-cube, where every vertex has probability $p_0$ independently. Then we include each of the remaining edges with probability $p_1$ independently. Bond percolation on the hypercube is the random cubical graph where $p_0=1$ and $p_1$ varies, and site percolation is where $p_1 = 1$ and $p_0$ varies.

It seems natural to form a higher-dimensional generalisation of this model $Q_2(n; p_0, p_1, p_2)$. Indeed, Costa and Farber [Reference Costa and Farber8, Reference Costa and Farber9, Reference Costa and Farber10] have made a detailed study of the analogous model $Y_2(n; p_0, p_1, p_2)$, including many interesting results on the fundamental group. (See also [Reference Farber and Nowik15], wherein new questions about the fundamental group are discussed for this multiparameter model.) Our discussion has been about the special case where $p_0=p_1=1$ and $p_2$ varies.

For $Q_2(n; p_0, p_1, p_2)$, it is natural to ask if there is a critical surface for homology $H_1$ vanishing in the unit cube. The case of setting $p_1 = p_2 =1$ and letting $p_0$ vary looks particularly interesting, analogous to the site-percolation model. Higher homology is no longer monotone, as in, for example, a random clique complex or a Vietoris–Rips complex. Are there separate thresholds for $H_0$ vanishing, $H_1$ appearing, $H_1$ vanishing and $H_2$ appearing?

### 1.2 Overview and organisation

We begin with Section 2, where we define some key notions for working with $Q_2(n,p)$, and make some elementary estimates about it. In Section 2.1 we give a combinatorial definition of $\pi _1$. In Section 2.2 we introduce notation to work with subcomplexes of $Q^n$ and we introduce the notions of the random cubical complex $Q_2(n,p)$ and the random graph $Q\left (n,p^4\right )$. In Section 2.3 we summarise some estimates from [Reference Erdős and Spencer14] that we need about the random graph $Q(n,p)$. In Section 2.4 we make estimates for the existence of maximal $1$-faces and use these to deduce Theorem 1.2 from Theorem 1.3.

In Section 3 we introduce an algorithm for identifying contractible $4$-cycles in $\pi _1$. This algorithm reduces the analysis of $\pi _1$ to determining the topology of small subcomplexes. We also finish the proof of Theorem 1.2 and give a proof of Theorem 1.3.

In Section 4 we show a general structure theorem that describes the free-product factorisation of $\pi _1(Q_2(n,p))$, and we then prove Theorem 1.7. In Section 5 we construct specific complexes which show that certain interesting free factors appear.

## 2 Preliminaries

### 2.1 The edge-path group

For subcomplexes *Q* of $Q^n$, the fundamental group $\pi _1(Q)$ has a nice combinatorial definition as the *edge-path group*, which we now define.

Say that two edges ($1$-faces) of $Q^n$ are adjacent if they intersect at a vertex. An *edge path* in $Q^n$ is defined to be a sequence of edges in which every consecutive pair are adjacent.

In $Q^n$, any $2$-face has a $4$-cycle as its boundary. Conversely, every $4$-cycle in $Q^n$ is the boundary of a $2$-face. Hence, any two adjacent edges are contained in a unique $2$-face and therefore in a unique $4$-cycle in $Q^n$.

Two edge paths in *Q* are said to be *edge-equivalent* if one can be obtained from the other by successively doing one of the following moves:

1) Replacing two consecutive adjacent edges by the two opposite edges of the $4$-cycle

*x*that contains them,*if*the $2$-face that bounds*x*is in*Q*2) Replacing one edge contained in a $4$-cycle

*x*with the other three consecutive edges in*x*,*if*the $2$-face that bounds*x*is in*Q*3) Replacing three consecutive edges in a $4$-cycle

*x*with the complementary edge in*x*,*if*the $2$-face that bounds*x*is in*Q*4) Removing an edge that appears twice consecutively or adding an edge that appears twice consecutively

Define $\overline {0}$ to be the vector with only zero entries in $Q^n_0$. An edge loop at $\overline {0}$ is an edge path starting and ending at $\overline {0}$. The edge-path group $\pi _1(Q)$ of a complex $Q \subset Q^n$ (for any $n\geq 1$) is defined as the set of edge-equivalence classes of edge loops at $\overline {0}$ (with product and inverse defined by concatenation and reversal of edge loops).

For random cubical complexes $Q \sim Q_2(n,p)$, we explore first the extremal cases. If $p=0$, then any $Q \sim Q_2(n,p)$ is equal to $Q^n_1$ – that is, with a probability of $1$, the complex *Q* has not a single $2$-face included. Observing that in any graph *G* the number of independent generators in $\pi _1(G)$ is equal to $E(G)-V(G)+1$, in the case of an element $Q \sim Q_2(n,p)$ we get

which implies that the number of independent generators in $\pi _1(Q)$ will be at most $2^{n-1}(n-2)+1$. Thus, when $p=0$ we have that $\pi _1(Q)$ is a free group with $2^{n-1}(n-2)+1$ independent generators, and this is the maximum number of independent generators that the edge-path group of a random $2$-cubical complex can attain. This number of independent generators is less than the total number of $4$-cycles in $Q^n$, which is $2^{n-3}n(n-1)$. If $p=1$, then any $Q \sim Q_2(n,p)$ will have all the $2$-faces included, which implies that $\pi _1(Q)=0$ with a probability of $1$.

### 2.2 Star notation and the parallel relation

In $Q^n$, the four vertices belonging to a $4$-cycle have $n-2$ equal entries and two coordinate entries that are not equal in all of them. Denote these nonequal coordinate entries as *i* and *j*; then we can uniquely represent a $4$-cycle using an *n*-tuple with $n-2$ fixed binary values and two $*$s. One $*$ will be located on coordinate *i* and the other will be located on coordinate *j*. As an example, the $4$-cycles of $Q^3$ are $\{(0,*,*), (*,1,*), (*,*,1), (*,0,*), (1,*,*), (*,*,0)\}$, with, for instance, $(*,*,0)=\{(1,1,0), (1,0,0), (0,1,0), (0,0,0)\}$.

For dice, physical realisations of the cube $Q^3$, we have a physical intuitive notion of parallel faces; there are three pairs of parallel faces, and if the die is fair, each pair should add up to $7$. Using the $*$ notation of $4$-cycles just introduced, we extend this notion of parallel faces to $Q^n$:

Definition 2.1. Two $4$-cycles in $Q^n$ are *parallel* if they have the two $*$s in the same entries, and if their Hamming distance is $1$.

Thus, in $Q^3$ (the cube), there are three pairs of parallel $4$-cycles: $(0,*,*)$ and $(1,*,*)$, the $4$-cycles $(0,*,*)$ and $(1,*,*)$, and the $4$-cycles $(0,*,*)$ and $(1,*,*)$. With this parallel notion, we are able to define a binary relation in the set of $4$-cycles of a random $2$-cubical complex.

We represent a $3$-dimensional cube in $Q^n$ with a vector with *n* entries, three of which have a fixed $*$ and the rest of which are binary numbers. If we have two parallel faces *x* and *y* that have $*$ in the *i* and *j* coordinates and differ (only) in the binary value of the *k* coordinate, then the cube that contains them is represented by a vector with the three fixed $*$s in entries $i, j, k$ and with the rest of the $n-3$ entries equal to the entries of *x* (which are also equal to the entries of *y*).

Observe that the other four $4$-cycles of the cube will have all the entries that are not *i*, *j*, or *k* equal to the entries of *x*, two $*$s in positions either $\{i,k\}$ or $\{j,k\}$ and a binary number in the remaining coordinate. Also, given two parallel $2$-faces in $Q^n$, there is a unique $3$-dimensional cube in $Q^n$ that contains them.

Definition 2.2. Given a subcomplex *Q* of $Q^n$, two parallel $4$-cycles $x, y \in Q$ are related if the (unique) $3$-dimensional *cube* that contains them has a $2$-face attached to each one of the other four $4$-cycles in the cube. We represent this by $x \parallel y$.

Lemma 2.3. If two $4$-cycles *x* and *y* are related ($x \parallel y$), then they are edge-equivalent.

#### Definition 2.4 Graph of parallel related $4$-cycles

Given a subcomplex *Q* of $Q^n$, we define its graph of parallel cycles, which we represent by $G[Q]$, as the graph with set of vertices $V^n$ whose elements are all the the $4$-cycles in $Q^n$ (there are $2^{n-3}n(n-1)\, 4$-cycles), and an edge between two of them if they are related by $\parallel $.

Observe that $\parallel $ is reflexive but not transitive. This implies, for instance, that $G\left [Q^n_2\right ]$ (remember that $Q^n_2$ is the $2$-skeleton of $Q^n$) is not the complete graph. We can completely characterise $G\left [Q^n_2\right ]$.

Lemma 2.5. The graph $G\left [Q^n_2\right ]$ has $\binom {n}{2}$ components, and each one of these components is isomorphic to a $Q^{n-2}_1$ graph.

Proof. Fix an $n>0$. By definition of the relation $\parallel $, a necessary condition for two $4$-cycles to be related is to have their two $*$s in the same position. There are $\binom {n}{2}$ ways of choosing the positions of two $*$s in a vector of size *n*, which implies that there are at most $\binom {n}{2}$ components in $G\left [Q^n_2\right ]$. This gives us a partition of the set of vertices, which we represent by

Set $1\leq i\leq {\binom {n}{2}}$; in what follows we prove that the induced subgraph of $V^n_i$ in $G\left [Q^n_2\right ]$ is isomorphic to $Q^{n-2}_1$. Any element in $V^n_i$ has the two $*$s in the same position, and the rest of the $n-2$ entries have all possible binary entries. This implies that $\left \lvert V^n_{i}\right \rvert = \left \lvert Q_0^{n-2}\right \rvert $. Let $\phi : V^n_{i} \to Q_0^{n-2}$ be the natural bijection between these two sets of vertices. It is clear from Definition 2.3 that two $4$-cycles *x* and *y* in $V^n_{i}$ are connected in $G\!\left [Q^n_2\right ]$ if and only if the Hamming distance of $\phi (x)$ and $\phi (y)$ is $1$. This implies that $G\left [V_i^{n}\right ] \equiv Q^{n-2}_1$.

In this paper we restrict ourselves to complexes $Q \sim Q_2(n,p)$, and thus the graphs $G[Q]$ that we analyse are always subgraphs of $G\left [Q^n_2\right ]$. We say that a vertex in $V^n$ is coloured if the $4$-cycle that it represents has its $2$-face present in *Q*, and we say that it is not coloured otherwise. We use the previous established partition of $V^n$ in $\binom {n}{2}$ sets to denote accordingly the induced subgraphs $G_1, \dotsc , G_{\binom {n}{2}}$ of the graph $G\left [Q^n_2\right ]$. For a $Q \sim Q_2(n,p)$, this partition defines $\binom {n}{2}$ random subgraphs, which we represent by $G_1[Q], \dotsc , G_{\binom {n}{2}}[Q]$. Then the edges that are included in $G_i[Q]$, for $1 \leq i\leq {\binom {n}{2}}$, depend on the $2$-faces included in *Q*. The next lemma characterises the probability distribution of each $G_i[Q]$:

Lemma 2.6. Set $p \in (0,1)$ and let $Q \sim Q_2(n,p)$. Then for $1 \leq i\leq {\binom {n}{2}}$, each random graph $G_i[Q]$ is a random graph on $Q^{n-2}_1$, with each edge included independently with probability $p^4$ and each vertex coloured independently with probability *p*. Moreover, the vertex colourings are independent of the edge set. Using the notation established in the Introduction, the uncoloured graph $G_i[Q]$ has the same distribution as $Q\left (n-2,p^4\right )$ for all $1 \leq i\leq {\binom {n}{2}}$.

Proof. Set $Q \sim Q_2(n,p)$. From Lemma 2.5, we know that each $G_i[Q]$ is a random graph on $Q^{n-2}_1$. Let *x* and *y* be two vertices in $G_i[Q]$ that are connected in $G[Q^n_2]$, and represent this edge by $\overline {xy}$. This implies in particular that *x* and *y* are $4$-cycles that have, with the previously defined star notation, the $*$ in the same entries and Hamming distance equal to $1$. Let $c_{\overline {xy}} \in Q^n$ be the unique $3$-dimensional cube that contains *x* and *y*.

The probability of $\overline {xy}$ being an edge in $G_i[Q]$ is equal to the probability of the other $4$-cycles in $c_{\overline {xy}}$ being covered by $2$-faces in *Q*. This event happens with probability $p^4$ because in $Q_2(n,p)$ each $2$-face is added independently with probability *p*.

Moreover, observe that any of these $4$-cycles in $c_{\overline {xy}}$ are not vertices in $G_i[Q]$, because they do not have the two $*$s in the same location as *x* (or *y*). This implies the independence between the colouring of the vertices and the inclusion of the edges in $G_i[Q]$.

Let $\mathcal {C}$ be the set of all $3$-dimensional cubes $c_{\overline {xy}}$ with *x* and *y* varying among all unordered pairs of vertices in $G_i[Q]$ that are connected in $G\left [Q^n_2\right ]$. Then, by the uniqueness of the cube $c_{\overline {xy}} \in Q^n$, we have that $\lvert \mathcal {C} \rvert $ is equal to the number of edges in $G_i[Q]$. Finally, edges in $G_i[Q]$ are added independently with probability $p^4$ because each $4$-face in a cube in $\mathcal {C}$ appears in only one $3$-dimensional cube in $\mathcal {C}$.

Remark. Even if the edges within each subgraph $G_i[Q]$ of the graph $G[Q]$ are included independently with probability $p^4$, this independence does not extend to events related to edges selected from two or more of the subgraphs $G_i[Q]$. An illustrative example of this dependence can be easily seen in the $3$-dimensional cube where there is only one cube containing all the $4$-cycles.

### 2.3 The sizes of the components of $Q(n,p)$

For a given $p \in (0,1)$, we want to understand the sizes of the components of $Q(n,p)$. We will require an argument from [Reference Erdős and Spencer14] that rules out components of small sizes. Because we slightly adapt those lemmas, we include proofs.

Denote by $\mathscr {Q}_s$ the set of all subsets of vertices in $Q^n$ which are connected and have cardinality *s*. Given a subset *S* of vertices in $Q^n$ that are connected, define

Let

Then from a union bound, $g(s)$ is an upper bound for the probability of the existence of a connected component on *s* vertices appearing in $Q(n,p)$.

Lemma 2.7. We have

Proof. Set $s \geq 1$; then for any $S \in \mathscr {Q}_s$ we have (from [Reference Hart16])

Also, using the fact that the degree of each vertex of $Q^n$ is at most *n*,

Hence,

Lemma 2.8. For any $p \in (0,1)$, there is a number $T_p \in \mathbb {N}$ and there exist $\delta $, $\epsilon>0$ such that

with the sum over all *s* such that $T_p\leq s\leq 2^{\epsilon n}$.

Proof. Let $T_p$ be defined by

Then for $s \leq 2^{\epsilon n}$, by Lemma 2.7,

for all *n* sufficiently large. Then

provided $\epsilon $ is chosen so that $2^\epsilon (1-p) <1$ and *n* is taken large. Taking $\epsilon $ sufficiently small,

Hence, in terms of $\alpha $,

for some $\delta> 0$ sufficiently small and all *n* sufficiently large.

### 2.4 The threshold for maximal $1$-faces

Any element $Q \sim Q_2(n,p)$ has $2^{n-1}n$ edges, which we represent by

with each one of these edges being in $n-1$ different $4$-cycles. We represent by $I_{i}$ the indicator function of the event that the edge $e_i$ is maximal – that is, that none of the $(n-1)\, 4$-cycles that contain $e_i$ has an attached $2$-face. Then

Let $\mathcal {I}(Q)$ be the random variable that counts the number of maximal edges in *Q*:

Then

Observe that if $p=1/2$, then $\mathbb {E}[\mathcal {I}]=n$.

We now prove that Theorem 1.2 follows from Theorem 1.3:

Proof of Theorem 1.2. We first establish that for $p> \tfrac 12$, $\mathcal {I} = 0$ w.h.p., and for $p \leq \tfrac 12$, $\mathcal {I} \geq 2$ w.h.p. For the first claim, the expectation (10) tends to $0$. For the second, again from equation (10), if $(1-p) \geq 1/2$ for a random $2$-cubical complex, $Q \sim Q_2(n,p)$, then

Thus $\mathbb {E}[\mathcal {I}] \to \infty $ as $n \to \infty $. Now, we use a second moment argument (see [Reference Alon and Spencer1, Corollary 4.3.5]) to prove that $\mathbb {P}[\mathcal {I} \geq 2]\to 1$ as $n\to \infty $.

Fix an edge $e_i$. Any other edge $e_j$ such that $I_j$ is not independent from $I_i$ – we represent this nonindependent relation between edges $e_i$ and $e_j$ by $j \sim i$ – will be an edge of one and only one of the $(n-1)\, 4$-cycles that contain $e_i$. There are $3(n-1)$ such edges and $\mathbb {P}\left [I_j \mid I_i\right ] = (1-p)^{n-2}$. If we define $\Delta ^*_i=\sum _{j\sim i} \mathbb {P}\left [I_j \mid I_i\right ]$, then

Thus $\Delta ^*_i=o(\mathbb {E}[I_n])$, which implies that $\mathbb {P}[\mathcal {I}>n/2] \to 1$ as $n \to \infty $.

Hence from Theorem 1.3, we have that for $p> \tfrac 12$, $\pi _1(Q_2(n,p))=0$ with high probability, and for any $p<\tfrac 12$, $\pi _1(Q_2(n,p)) = G * \mathbb {Z} * \mathbb {Z}$ for some group *G* with high probability. The event that $Q_2(n,p)$ has such a free factorisation is a *decreasing* event, in that for any complex *Q* that satisfies $\pi _1(Q) = G * \mathbb {Z} * \mathbb {Z}$ for some group *G*, removing any $2$-face (i.e., removing relations from $\pi _1(Q)$) yields a complex $Q'$ so that $\pi _1(Q') = G' * \mathbb {Z} * \mathbb {Z}$ for some other group $G'$. It follows that for any $p \leq \tfrac 12$,

as $n \to \infty $, which completes the proof.

## 3 Parallel homotopy algorithm

In this section, we introduce a simple iterative algorithm for finding contractible $4$-cycles. For $Q_2(n,p)$ with $p> 0$, this algorithm rapidly and dramatically simplifies the fundamental group to its nontrivial parts.

We begin by introducing the algorithm. We have defined $V^n$ as the set of all $4$-cycles in $Q^n_1$. For any subset $V \subset V^n$, we define the *graph of parallel related* $4$*-cycles* denoted by $G(V)$ in a similar fashion to Definition 2.4: the vertex set of $G(V)$ is given by the $V^n$, and two $4$-cycles *x* and *y* are connected if they have $*$s in the same positions and are contained in a $3$-cube *c* and all other $4$-cycles in *c* are in *V*. That is, two $4$-cycles *x* and *y* are connected in $G(V)$ if they are connected in $G[Q]$, with *Q* being the cubical complex $Q \subset Q^n_{2}$ such that the $2$-faces included in *Q* are exactly those corresponding to the $4$-cycles that are in *V*.

Given a $Q \sim Q_2(n,p)$, we denote by $V^n_1$ the subset of $V^n$ which contains the boundaries of $2$-faces in *Q*. We then iteratively run the following procedure, with $t \in \mathbb {N}$:

**Stage t:** Build the graph of parallel related $4$-cycles $G\left (V^n_t\right )$. Define the set of $4$-cycles $V^n_{t+1}$ as the set of $4$-cycles that are in a component in $G\left (V^n_t\right )$ that contains a $4$-cycle in $V^n_t$.

The algorithm stops at the first *t* for which $V^n_{t+1}=V^n_t$. This will happen, in particular, if there exists a *t* such that $V^n_t=V^n$, in which case all $4$-cycles of $Q^n$ are in a component of $G\left (V^n_t\right )$ that contains a $4$-cycle in $V^n_t$. Thus, Theorem 1.2 follows from the following result:

Theorem 3.1. For $p>1/2$,

### 3.1 Stage 1: Explosive growth

For any set of $4$-cycles $V \subset V^n$, say that a set of vertices *S* in $G(V)$ is a *quasicomponent* if *S* is connected in $G(V^n)$ and *S* is disconnected from its complement in $G(V)$.

Theorem 3.2. Set $Q \sim Q_2(n,p)$. For any $p \in (0,1)$, there exists an integer $T_p$ so that w.h.p. there is no quasicomponent of $G\left (V_1^n\right )$ bigger than $T_p$ that is disjoint from $V_1^n$.

Proof. The proof will follow from two key steps. Let $A_s$ be the event that a quasicomponent of size *s* in $G\left (V^n_1\right )$ exists.

(Step i) For any $p \in (0,1)$, there exist an integer $T_p$ and $\epsilon ,\delta>0$ such that for all

*n*sufficiently large,(11)$$ \begin{align} \mathbb{P}\left[ \cup_{s=T_p}^{2^{\epsilon n}}A_s \right]<2^{-\delta n}. \end{align} $$(Step ii) For any $\epsilon> 0$, the probability that there exists a component of $G\left (V_1^n\right )$ bigger than $2^{\epsilon n}$ with no vertex in $V^n_1$ tends to zero with

*n*.

We show first how to complete the proof from this point. We now suppose that there is no quasicomponent of $G\left (V_1^n\right )$ of size between $T_p$ and $2^{\epsilon n}$ for some integer $T_p$ and some $\epsilon>0$, and we further suppose that there is no component of $G\left (V_1^n\right )$ of size $2^{\left (\epsilon /2\right )n}$ with no vertex in $V_1^n$.

Let *X* be a minimal quasicomponent of $G\left (V_1^n\right )$ which is bigger than $T_p$ and which is disjoint from $V_1^n$, if it exists. Then the size of *X* must be at least $2^{\epsilon n}$. As it is so large (in particular larger than $2^{\left (\epsilon /2\right )n}$), it cannot be that *X* is connected. So we must be able to remove a connected component (say by building a spanning tree in $G(V)$ of *X* by connecting spanning trees of its components and removing a component which contains a leaf) to form a smaller quasicomponent $X'$. The component we remove must be smaller than $2^{\left (\epsilon /2\right )n}$, and so for all *n* sufficiently large, we conclude that $X'$ is a strictly smaller quasicomponent of $G\left (V_1^n\right )$ which is bigger than $T_p$ and which is disjoint from $V_1^n$ – a contradiction.

We turn to proving Step (i). For any *s*, we have $\mathbb {P}[A_s]\leq g(s)$ (recalling *g* from equation (4)), as $g(s)$ is the expected number of quasicomponents of size *s* in $Q_2(n,p)$, and hence from a union bound,

with the sum over all $T_p \leq s \leq 2^{\epsilon n}$. The existence of $\epsilon ,\delta ,T_p$ such that formula (11) holds is then a direct consequence of Lemma 2.8.

We turn to showing Step (ii). Let *W* be the event that there exists a component in $G\left (V_1^n\right )$ of size greater than or equal than $2^{\epsilon n}$ that does not intersect $V_1^n$. We show in what follows that $\mathbb {P}[W]\to 0$ as $n \to \infty $. First, we observe that $G\left (V_1^n\right )=G[Q]$ and that the vertices in $V_1^n$ are precisely the coloured vertices in $G[Q]$, which by Lemma 2.6 are coloured independently with probability equal to *p*. For $1 \leq i \leq {\binom {n}{2}}$, define $W_i$ as the event that there exists in $G_i[Q]$ a component of size greater than or equal to $2^{\epsilon n}$ that has all its vertices uncoloured. Thus, by Lemma 2.6,

Set $1 \leq i \leq {\binom {n}{2}}$. Conditioned on knowing $G_i[Q]$ – in particular on knowing that there are exactly *l* components with uncoloured vertices and with sizes $s_1, s_2, \dotsc , s_l$ greater than $2^{\epsilon n}$ in $G_i[Q]$ – we get

Observing that $s_1 + s_2 + \dotsb + s_l \leq 2^{n-2}$, it has to be the case that $l\leq 2^{n-2}$, and because $(1-p)< 1$, we have $(1-p)^{s_{k}} \leq (1-p)^{2^{\epsilon n}}$ for all $1\leq k \leq l$. Thus from formula (13) we get

This implies that $ \mathbb {E}[\mathbb {P}[W_i \mid G_i]] \leq 2^{n-2}(1-p)^{2^{\epsilon n}}$, and thus

for all $1 \leq i \leq {\binom {n}{2}}$. Finally, by a union bound argument on equation (12) and inequality (15), we have that

with

### 3.2 Stage 2: Only local defects remain

Let $\mathcal {F}$ be the event that there is no quasicomponent of $G\left (V_1^n\right )$ bigger than $T_p$ that is disjoint from $V_1^n$. This event was shown to hold w.h.p. by Theorem 3.2.

Lemma 3.3. In the event $\mathcal {F}$, any $4$-cycle *v* with at least $T_p$ neighbors in $G\left (V_2^n\right )$ is in $V_3^n$. Likewise, any $4$-cycle *v* with at least $T_p$ neighbors in $G\left (V_1^n\right )$ is in $V_2^n$.

Proof. Suppose $\mathcal {F}$ holds, and let *v* be any $4$-cycle. Suppose that *v* has at least $T_p$ neighbors in $G\left (V_1^n\right )$. Then the connected component of *v* in $G(V_1^n)$ has at least $T_p$ neighbors, and therefore this connected component intersects $V_1^n$. It follows by the definition of $V_2^n$ that $v \in V_2^n$.

Suppose now that *v* has at least $T_p$ neighbors in $G\left (V_2^n\right )$. We would like to show that at least one of these neighbors is also in $V_2^n$, for then in the next step of the parallel transport algorithm, we would have $v \in V_3^n$. We may also suppose that *v* is not in a component of $G\left (V_1^n\right )$ that intersects $V_1^n$, for if it is, then $v \in V_2^n$ and we are done.

Suppose by way of a contradiction that none of the neighbors of *v* is in $V_2^n$, which implies that each is in a component of $G\left (V_1^n\right )$ disjoint from $V_1^n$. Hence the union of these components and the component of $G\left (V_1^n\right )$ containing *v* is a quasicomponent of $G\left (V_1^n\right )$ that is disjoint from $V_1^n$. Moreover, it is a quasicomponent which is larger than $T_p$, which is disjoint from $V_1^n$. This does not exist in $\mathcal {F}$, and therefore *v* has a neighbor in $V_2^n$. Hence $v \in V_3^n$.

We will show that as a consequence of Lemma 3.3, in Stage 2 all those $4$-cycles whose every constituent edge has a high enough degree will be collapsed. For any *p*, define

For any $1$-face *f* in $Q^n$, define $\deg (f)$ as the number of $2$-faces in *Q* containing *f*. Call a $1$-face of $Q \sim Q_2(n,p)$ *light* if its degree is less than or equal to $M_p$; otherwise, call it *heavy*. We show that $4$-cycles made from heavy edges are contracted in the second stage of the algorithm:

Lemma 3.4. For any $p \in (0,1)$, with probability tending to $1$ as $n\to \infty $, every $4$-cycle whose every $1$-face is heavy is contained in $V_3^n$.

We will introduce some additional notation for working with faces of *Q*. For two disjoint sets $U, W \subset [n]$, let $\left (U^*, W^1\right )$ denote the $\lvert U\rvert $-dimensional face of *Q* with $*$s in the positions given by *U* and $1$s exactly in the positions given by *W*.

Using symmetry, it will be enough to analyse the $4$-cycle $\left (\{1,2\}^*, \emptyset ^1\right )$. With $M_p$ from equation (18), define $\mathcal {E}$ as the event that all the $1$-faces in the $4$-cycle $\left (\{1,2\}^*, \emptyset ^1\right )$ are heavy – that is,

To prove Lemma 3.4, it suffices to show the following:

Lemma 3.5. For any $p \in (0,1)$, there is an $\epsilon> 0$ such that

Proof. The possible neighbors of $\left ( \{1,2\}^*,\emptyset ^1\right )$ in $G(V^n)$ all have the form $\left ( \{1,2\}^*,\{j\}^1\right )$ for some $3 \leq j \leq n$. To have an edge between these $4$-cycles in $G\left (V^n_2\right )$, we must have

In the event $\mathcal {F}$, we must only lower-bound the degree of these $4$-cycles in $G\left (V^n_1\right )$ to ensure that they are in $V^n_2$. Hence, define

Here, ‘$\deg $’ refers to the degree of the $4$-cycle in $G\left (V^n_1\right )$. We would like to show that there are at least $T_p$ choices *j* for which all $Y_{\ell j}$, $\ell \in \{1,2,3,4\}$, are $1$.

In the event $\mathcal {E}$, there are four disjoint sets $R_\ell \subset \{3,4, \dotsc , d\}$ for $\ell \in \{1,2,3,4\}$ of size $\left \lfloor M_p/4 \right \rfloor $ such that

Observe that the possible neighbors of $\left (\{1,j\}^*, \emptyset ^1\right )$, $j \in \{3,4, \dotsc , n\}$, are given by $\left (\{1,j\}^*, \{k\}^1\right )$ for $k \not \in \{1,j\}$. For simplicity, we will also discard the case $k=2$. To have this edge in $G\left (V^n_1\right )$, we would need

In particular, for $k \in R_1$ the first of these requirements is guaranteed. Hence we can define

and define

Then $Z_{1j}$ is a lower bound for $\deg \left ( \left (\{1,j\}^*, \emptyset ^1\right ) \right )$, and so if $Z_{1j}$ is at least $T_p$, then $Y_{1j}=1$.

We do a similar construction for $\ell \in \{2,3,4\}$, making appropriate modifications. We list them for clarity:

In terms of these, we set $Z_{\ell j} = \sum _{k \in R_\ell } Z_{\ell jk}$.

Let $J = \{3,4, \dotsc , d\} \setminus \left (\cup _1^4 R_\ell \right )$. Then the family

is independent random variables. Moreover, for any $\ell \in \{1,2,3,4\}$ and $j \in J$, from equation (18) we have

It follows that with

and with $q = \mathbb {P}\left (Z_{\ell j} \geq T_p\right )^4> \tfrac 12$, we have

which completes the proof.

### 3.3 Stage 3: The final squeeze

In this section, we draw conclusions on what remains noncontracted in the complex in the third stage.

#### 3.3.1 The simply connected regime, $p> \tfrac 12$

We begin by showing that for $p> 1/2$, there are simply no light $1$-faces. Hence in fact for $p> \tfrac 12$, $V_3^n=V_n$ with high probability (proving Theorem 3.1).

Lemma 3.6. For any $p> 1/2$, there is an $M_p> 0$ such that with probability tending to $1$ with *n*, for every $1$-face *f* of $Q \sim Q_2(n,p)$, $\deg (f)>M_p$.

Proof. The degree of a $1$-face is distributed as $\text {Binomial}(n-2,p)$. For $p> \tfrac 12$, the probability that this is less than any fixed constant *M* is $n^{O(1)}(1-p)^{n}$. Hence by a union bound, the lemma follows.

#### 3.3.2 Completely shielded $1$-faces

Call a $1$-face $f \in Q \sim Q_2(n,p)$ *completely shielded* if every $3$-face $c \in Q^n$ that contains *f* contains only heavy $1$-faces of *Q*, besides possibly *f*. Completely shielded $1$-faces modify the fundamental group of *Q* in a simple way, contributing a free factor of $\mathbb {Z}$ if *f* is maximal.

To see this we begin with the following definition:

Definition 3.7. Let *f* be any $1$-face of $Q^n$. Define the *n-bubble around f* to be the subcubical complex of $Q^n$ given by the union of the complete $1$-skeletons of all $3$-faces containing *f* and every $2$-face on this skeleton which does *not* contain *f*.

An *n*-bubble has fundamental group $\mathbb {Z}$.

Lemma 3.8. For any $n \geq 3$ and any *n*-bubble *X* around *f*,

Furthermore, the complex $X \setminus \{f\}$ and the complex $X \cup \{e\}$, where *e* is any $2$-face containing *f*, are simply connected.

Proof. Without loss of generality, suppose that *f* is the face $\left (\{1\}^*,\emptyset ^1\right )$. The $3$-faces containing *f* all have the form $\left (\{1,i,j\}^*, \emptyset ^1\right )$, and so the $1$-skeleton of *X* is

We claim that all the $4$-cycles containing *f* are homotopic. As all other $4$-cycles are contractible from the definition of *X*, the statements in the lemma follow.

The $4$-cycles that contain *f* are boundaries of the $2$-faces of $Q^n$ of the form

For any $2 \leq i < j \leq n$, the $3$-face $c=(\{1,i,j\}^*, \emptyset )$ intersected with *X* contains four $2$-faces. Moreover, the $2$-faces $(\{1,i\}^*, \emptyset )$ and $(\{1,j\}^*, \emptyset )$ are adjacent in this cube. Hence, these cycles can be deformed through *c* to one another. As this holds for any such *i* and *j*, the proof follows.

Lemma 3.9. For any $p \in (0,1)$, let $\hat Q$ be the cubical complex that results from deleting from $Q \sim Q_2(n,p)$ every completely shielded $1$-face *f* and any $2$-face of *Q* containing *f*. Then with high probability,

where *N* denotes the number of completely shielded $1$-faces in *Q* that are isolated.

Proof. From Lemma 3.4, all $4$-cycles whose every $1$-face is heavy are contractible. In particular, we do not modify the fundamental group of *Q* if we include all those $2$-faces into *Q* whose boundary is in $V_3^n$. Let $\hat Q$ be this cubical complex.

We now remove completely shielded $1$-faces from $\hat Q$ one at a time, tracking the changes to the fundamental group. We will show what happens after removing the first. It will be clear that by using induction, a similar analysis would give the claim in the lemma.

Let *f* be a completely shielded $1$-face of $\hat Q$. Let $Q_1$ be the complex that results after removing *f* from $\hat Q$ and any $2$-face containing *f*, and let $Q_2$ be the union of all the complete $2$-skeletons of all $3$-faces that contain *f*. Then $Q_2$ contains an *n*-bubble, and it is exactly an *n*-bubble if *f* is isolated.

As $Q_2 \cup Q_1 = \hat Q$ and $Q_1 \cap Q_2$ is open and path-connected (compare Lemma 3.8, as this complex is an *n*-bubble with its central $1$-face deleted). Moreover, every $4$-cycle in