# Szemerédi regularity lemma

In extremal graph theory, Szemerédi’s regularity lemma states that a graph can be partitioned into a bounded number of parts so that the edges between parts are regular (in the sense defined below). The lemma shows that certain properties of random graphs can be applied to dense graphs like counting the copies of a given subgraph within graphs. Endre Szemerédi proved the lemma over bipartite graphs for his theorem on arithmetic progressions in 1975 and for general graphs in 1978. Variants of the lemma use different notions of regularity and apply to other mathematical objects like hypergraphs.

## Statement

To state Szemerédi's regularity lemma formally, we must formalize what the edge distribution between parts behaving 'almost randomly' really means. By 'almost random', we're referring to a notion called ε-regularity. To understand what this means, we first state some definitions. In what follows G is a graph with vertex set V.
   Definition 1. Let X, Y be disjoint subsets of V. The edge density of the pair (X, Y) is defined as:
       $d(X,Y):={\frac {\left|E(X,Y)\right|}{|X||Y|}}$
   where E(X, Y) denotes the set of edges having one end vertex in X and one in Y.
We call a pair of parts ε-regular if, whenever you take a large subset of each part, their edge density isn't too far off the edge density of the pair of parts. Formally,
   Definition 2. For ε > 0, a pair of vertex sets X and Y is called ε-regular, if for all subsets A ⊆ X, B ⊆ Y satisfying |A| ≥ ε|X|, |B| ≥ ε|Y|, we have
       $\left|d(X,Y)-d(A,B)\right|\leq \varepsilon .$
The natural way to define an ε-regular partition should be one where each pair of parts is ε-regular. However, some graphs, such as the half graphs, require many pairs of partitions (but a small fraction of all pairs) to be irregular. So we shall define ε-regular partitions to be one where most pairs of parts are ε-regular.
   Definition 3. A partition of $V$ into $k$ sets ${\mathcal {P}}=\{V_{1},\ldots ,V_{k}\}$ is called an $\varepsilon$-regular partition if
       $\sum _{(V_{i},V_{j}){\text{ not }}\varepsilon {\text{-regular}}}|V_{i}||V_{j}|\leq \varepsilon |V(G)|^{2}$
Now we can state the lemma:
   Szemerédi's regularity Lemma. For every ε > 0 and positive integer m there exists an integer M such that if G is a graph with at least M vertices, there exists an integer k in the range m ≤ k ≤ M and an ε-regular partition of the vertex set of G into k sets.
The bound M for the number of parts in the partition of the graph given by the proofs of Szemeredi's regularity lemma is very large, given by a O(ε$^{−5}$)-level iterated exponential of m. At one time it was hoped that the true bound was much smaller, which would have had several useful applications. However Gowers (1997) found examples of graphs for which M does indeed grow very fast and is at least as large as a ε$^{−1/16}$-level iterated exponential of m.

## Proof

We shall find an ε-regular partition for a given graph following an algorithm:
* Start with a partition
* While the partition isn't ε-regular:
** Find the subsets which witness ε-irregularity for each irregular pair.
* Refine the partition using all the witnessing subsets.
We apply a technique called the energy increment argument to show that this process stops after a bounded number of steps. To do this, we define a measure which must increase by a certain amount in each step, but it's bounded above and thus cannot increase indefinitely. This measure is called 'energy' as it's an $L^{2}$ quantity.
   Definition 4. Let U, W be subsets of V. Set $|V|=n$. The energy of the pair (U, W) is defined as:
       $q(U,W):={\frac {|U||W|}{n^{2}}}d(U,W)^{2}$
   For partitions ${\mathcal {P}}_{U}=\{U_{1},\ldots ,U_{k}\}$ of U and ${\mathcal {P}}_{W}=\{W_{1},\ldots ,W_{l}\}$ of W, we define the energy to be the sum of the energies between each pair of parts:
       $q({\mathcal {P}}_{U},{\mathcal {P}}_{W}):=\sum _{i=1}^{k}\sum _{j=1}^{l}q(U_{i},W_{j})$
   Finally, for a partition ${\mathcal {P}}=\{V_{1},\ldots ,V_{k}\}$ of V, define the energy of ${\mathcal {P}}$ to be $q({\mathcal {P}},{\mathcal {P}})$. Specifically,
       $q({\mathcal {P}})=\sum _{i=1}^{k}\sum _{j=1}^{k}q(V_{i},V_{j})=\sum _{i=1}^{k}\sum _{j=1}^{k}{\frac {|V_{i}||V_{j}|}{n^{2}}}d(V_{i},V_{j})^{2}$
Note that energy is between 0 and 1 because edge density is bounded above by 1:
    $q({\mathcal {P}})=\sum _{i=1}^{k}\sum _{j=1}^{k}{\frac {|V_{i}||V_{j}|}{n^{2}}}d(V_{i},V_{j})^{2}\leq \sum _{i=1}^{k}\sum _{j=1}^{k}{\frac {|V_{i}||V_{j}|}{n^{2}}}=1$
Now, we start by proving that energy does not decrease upon refinement.
   Lemma 1. (Energy is nondecreasing under partitioning) For any partitions ${\mathcal {P}}_{U}$ and ${\mathcal {P}}_{W}$ of vertex sets $U$ and $W$, $q({\mathcal {P}}_{U},{\mathcal {P}}_{W})\geq q(U,W)$.
   Proof: Let ${\mathcal {P}}_{U}=\{U_{1},\ldots ,U_{k}\}$ and ${\mathcal {P}}_{W}=\{W_{1},\ldots ,W_{l}\}$. Choose vertices $x$ uniformly from $U$ and $y$ uniformly from $W$, with $x$ in part $U_{i}$ and $y$ in part $W_{j}$. Then define the random variable $Z=d(U_{i},W_{j})$. Let us look at properties of $Z$. The expectation is
       $\mathbb {E} [Z]=\sum _{i=1}^{k}\sum _{j=1}^{l}{\frac {|U_{i}|}{|U|}}{\frac {|W_{j}|}{|W|}}d(U_{i},W_{j})={\frac {e(U,W)}{|U||W|}}=d(U,W)$
   The second moment is
       $\mathbb {E} [Z^{2}]=\sum _{i=1}^{k}\sum _{j=1}^{l}{\frac {|U_{i}|}{|U|}}{\frac {|W_{j}|}{|W|}}d(U_{i},W_{j})^{2}={\frac {n^{2}}{|U||W|}}q({\mathcal {P}}_{U},{\mathcal {P}}_{W})$
   By convexity, $\mathbb {E} [Z^{2}]\geq \mathbb {E} [Z]^{2}$. Rearranging, we get that $q({\mathcal {P}}_{U},{\mathcal {P}}_{W})\geq q(U,W)$ for all $U,W$.$\square$
If each part of ${\mathcal {P}}$ is further partitioned, the new partition is called a refinement of ${\mathcal {P}}$. Now, if ${\mathcal {P}}=\{V_{1},\ldots ,V_{m}\}$, applying Lemma 1 to each pair $(V_{i},V_{j})$ proves that for every refinement ${\mathcal {P'}}$ of ${\mathcal {P}}$, $q({\mathcal {P'}})\geq q({\mathcal {P}})$. Thus the refinement step in the algorithm doesn't lose any energy.
   Lemma 2. (Energy boost lemma) If $(U,W)$ is not $\varepsilon$-regular as witnessed by $U_{1}\subset U,W_{1}\subset W$, then,
       $q\left(\{U_{1},U\backslash U_{1}\},\{W_{1},W\backslash W_{1}\}\right)>q(U,W)+\varepsilon ^{4}{\frac {|U||W|}{n^{2}}}$
   Proof: Define $Z$ as above. Then,
       $Var(Z)=\mathbb {E} [Z^{2}]-\mathbb {E} [Z]^{2}={\frac {n^{2}}{|U||W|}}\left(q\left(\{U_{1},U\backslash U_{1}\},\{W_{1},W\backslash W_{1}\}\right)-q(U,W)\right)$
   But observe that $|Z-\mathbb {E} [Z]|=|d(U_{1},W_{1})-d(U,W)|$ with probability ${\frac {|U_{1}|}{|U|}}{\frac {|W_{1}|}{|W|}}$(corresponding to $x\in U_{1}$ and $y\in W_{1}$), so
       $Var(Z)=\mathbb {E} [(Z-\mathbb {E} [Z])^{2}]\geq {\frac {|U_{1}|}{|U|}}{\frac {|W_{1}|}{|W|}}(d(U_{1},W_{1})-d(U,W))^{2}>\varepsilon \cdot \varepsilon \cdot \varepsilon ^{2}$ $\square$
Now we can prove the energy increment argument, which shows that energy increases substantially in each iteration of the algorithm.
   Lemma 3 (Energy increment lemma) If a partition ${\mathcal {P}}=\{V_{1},\ldots ,V_{k}\}$ of $V(G)$ is not $\varepsilon$-regular, then there exists a refinement ${\mathcal {Q}}$ of ${\mathcal {P}}$ where every $V_{i}$ is partitioned into at most $2^{k}$ parts such that
       $q({\mathcal {Q}})\geq q({\mathcal {P}})+\varepsilon ^{5}.$
   Proof: For all $(i,j)$ such that $(V_{i},V_{j})$ is not $\varepsilon$-regular, find $A^{i,j}\subset V_{i}$ and $A^{j,i}\subset V_{j}$ that witness irregularity (do this simultaneously for all irregular pairs). Let ${\mathcal {Q}}$ be a common refinement of ${\mathcal {P}}$ by $A^{i,j}$'s. Each $V_{i}$ is partitioned into at most $2^{k}$ parts as desired. Then,
       $q({\mathcal {Q}})=\sum _{(i,j)\in [k]^{2}}q({\mathcal {Q}}_{V_{i}},{\mathcal {Q}}_{V_{j}})=\sum _{(V_{i},V_{j}){\text{ }}\varepsilon {\text{-regular}}}q({\mathcal {Q}}_{V_{i}},{\mathcal {Q}}_{V_{j}})+\sum _{(V_{i},V_{j}){\text{ not }}\varepsilon {\text{-regular}}}q({\mathcal {Q}}_{V_{i}},{\mathcal {Q}}_{V_{j}})$
   Where ${\mathcal {Q}}_{V_{i}}$ is the partition of $V_{i}$ given by ${\mathcal {Q}}$. By Lemma 1, the above quantity is at least
       $\sum _{(V_{i},V_{j}){\text{ }}\varepsilon {\text{-regular}}}q(V_{i},V_{j})+\sum _{(V_{i},V_{j}){\text{ not }}\varepsilon {\text{-regular}}}q(\{A^{i,j},V_{i}\backslash A^{i,j}\},\{A^{j,i},V_{j}\backslash A^{j,i}\})$
   Since $V_{i}$ is cut by $A^{i,j}$ when creating ${\mathcal {Q}}$, so ${\mathcal {Q}}_{V_{i}}$ is a refinement of $\{A^{i,j},V_{i}\backslash A^{i,j}\}$. By lemma 2, the above sum is at least
       $\sum _{(i,j)\in [k]^{2}}q(V_{i},V_{j})+\sum _{(V_{i},V_{j}){\text{ not }}\varepsilon {\text{-regular}}}\varepsilon ^{4}{\frac {|V_{i}||V_{j}|}{n^{2}}}$
   But the second sum is at least $\varepsilon ^{5}$ since ${\mathcal {P}}$ is not $\varepsilon$-regular, so we deduce the desired inequality. $\square$
Now, starting from any partition, we can keep applying Lemma 3 as long as the resulting partition isn't $\varepsilon$-regular. But in each step energy increases by $\varepsilon ^{5}$, and it's bounded above by 1. Then this process can be repeated at most $\varepsilon ^{-5}$ times, before it terminates and we must have an $\varepsilon$-regular partition.

## Applications
### Graph counting lemma

If we have enough information about the regularity of a graph, we can count the number of copies of a specific subgraph within the graph up to small error.
   Graph Counting Lemma. Let $H$ be a graph with $V(H)=[k]$, and let $\varepsilon >0$. Let $G$ be an $n$-vertex graph with vertex sets $V_{1},\dots ,V_{k}\subseteq V(G)$ such that $(V_{i},V_{j})$ is $\varepsilon$-regular whenever $\{i,j\}\in E(H)$. Then, the number of labeled copies of $H$ in $G$ is within $e(H)\varepsilon |V_{1}|\cdots |V_{k}|$ of
       $\left(\prod _{\{i,j\}\in E(H)}d(V_{i},V_{j})\right)\left(\prod _{i=1}^{k}|V_{i}|\right).$
This can be combined with Szemerédi's regularity lemma to prove the Graph removal lemma. The graph removal lemma can be used to prove Roth's Theorem on Arithmetic Progressions, and a generalization of it, the hypergraph removal lemma, can be used to prove Szemerédi's theorem.
The graph removal lemma generalizes to induced subgraphs, by considering edge edits instead of only edge deletions. This was proved by Alon, Fischer, Krivelevich, and Szegedy in 2000. However, this required a stronger variation of the regularity lemma.
Szemerédi's regularity lemma does not provide meaningful results in sparse graphs. Since sparse graphs have subconstant edge densities, $\varepsilon$-regularity is trivially satisfied. Even though the result seems purely theoretical, some attempts have been made to use the regularity method as compression technique for large graphs.

### Frieze-Kannan regularity

A different notion of regularity was introduced by Frieze and Kannan, known as the weak regularity lemma. This lemma defines a weaker notion of regularity than that of Szemerédi which uses better bounds and can be used in efficient algorithms.
Given a graph $G=(V,E)$, a partition of its vertices ${\mathcal {P}}=\{V_{1},\ldots ,V_{k}\}$ is said to be Frieze-Kannan $\epsilon$-regular if for any pair of sets $S,T\subseteq V$:
    $\left|e(S,T)-\sum _{i,j=1}^{k}d(V_{i},V_{j})|S\cap V_{i}||T\cap V_{j}|\right|\leq \epsilon |V|^{2}$
The weak regularity lemma for graphs states that every graph has a weak $\epsilon$-regular partition into at most $4^{\epsilon ^{-2}}$ parts.
This notion can be extended to graphons by defining a stepping operator. Given a graphon $W$ and a partition ${\mathcal {P}}$ of $[0,1]$, we can define $W_{\mathcal {P}}$ as a step-graphon with steps given by ${\mathcal {P}}$ and values given by averaging $W$ over each step.
A partition ${\mathcal {P}}$ is weak $\epsilon$-regular if:
    $\|W-W_{\mathcal {P}}\|_{\square }\leq \epsilon$
The weak regularity lemma for graphons states that every graphon has a weak $\epsilon$-regular partition into at most $4^{\epsilon ^{-2}}$ parts. As with Szemerédi's regularity lemma, the weak regularity also induces a counting lemma.

### Algorithmic applications

One of the initial motivations for the development of the weak regularity lemma was the search for an efficient algorithm for estimating the maximum cut in a dense graph. It has been shown that approximating the max-cut problem beyond 16/17 is NP-hard, however an algorithmic version of the weak regularity lemma gives an efficient algorithm for approximating the max-cut for dense graphs within an $\epsilon n^{2}$ additive error. These ideas have been further developed into efficient sampling algorithms for estimating max-cut in dense graphs.
The smaller bounds of the weak regularity lemma allow for efficient algorithms to find an $\epsilon$-regular partition. Graph regularity has further been used in various area of theoretical computer science, such as matrix multiplication and communication complexity.

## Strong regularity lemma

The strong regularity lemma is a stronger variation of the regularity lemma proven by Alon, Fischer, Krivelevich, and Szegedy in 2000. Intuitively, it provides information between non-regular pairs and could be applied to prove the induced graph removal lemma.

### Statement

For any infinite sequence of constants $\epsilon _{0}\geq \epsilon _{1}\geq ...>0$, there exists an integer $M$ such that for any graph $G$, we can obtain two (equitable) partitions ${\mathcal {P}}$ and ${\mathcal {Q}}$ such that the following properties are satisfied:
* ${\mathcal {Q}}$ refines ${\mathcal {P}}$, that is every part of ${\mathcal {P}}$ is the union of some collection of parts in ${\mathcal {Q}}$.
* ${\mathcal {P}}$ is $\epsilon _{0}$-regular and ${\mathcal {Q}}$ is $\epsilon _{|{\mathcal {P}}|}$-regular.
* $q({\mathcal {Q}})<q({\mathcal {P}})+\epsilon _{0}$
* $|{\mathcal {Q}}|\leq M$

### Proof

We apply the regularity lemma repeatedly to prove the stronger version. A rough outline:
* Start with ${\mathcal {P}}_{0}$ be an $\epsilon _{0}$ regular partition
* Repeatedly find its refinement ${\mathcal {Q}}$ that is $\epsilon _{|{\mathcal {P}}|}$ regular. If the energy increment of ${\mathcal {Q}}\leq \epsilon _{0}$, we simply return $({\mathcal {P}},{\mathcal {Q}})$. Otherwise, we replace ${\mathcal {P}}$ with ${\mathcal {Q}}$ and continue.
We start with ${\mathcal {P}}_{0}$ be an $\epsilon _{0}$ regular partition of $G$ with $\leq M(\epsilon _{0})$ parts. Here $M(t)$ corresponds to the bound of parts in regularity lemma when $\epsilon =t$.
Now for $i=0,1,\cdots$, we set ${\mathcal {P_{i+1}}}$ to be an $\epsilon _{|P_{i}|}$regular refinement of ${\mathcal {P_{i}}}$ with $\leq M(\epsilon _{|P_{i}|})|{\mathcal {P}}_{i}|$ parts. By the energy increment argument, $q({\mathcal {P}}_{i+1})\geq q({\mathcal {P}}_{i})$. Since the energy is bounded in $[0,1]$, there must be some $i\leq 1/\epsilon _{0}+1$ such that $q({\mathcal {P}}_{i+1})-q({\mathcal {P}}_{i})<\epsilon _{0}$. We return $({\mathcal {P}}_{i},{\mathcal {P}}_{i+1})$ as $({\mathcal {P}},{\mathcal {Q}})$.
By our choice of ${\mathcal {P}}_{i+1},$ the regular and refinement conditions hold. The energy condition holds trivially. Now we argue for the number of parts. We use induction to show that $\forall i$, there exists $M_{i}$ such that $|{\mathcal {P}}_{i}|\leq M_{i}$. By setting $M_{0}=M(\epsilon _{0})$, we have $|{\mathcal {P}}_{0}|\leq M_{0}$. Note that when $|P_{i}|\leq M_{i}$, $|P_{i+1}|\leq M(\epsilon _{|P_{i}|})|{\mathcal {P}}_{i}|\leq M(\epsilon _{|M_{i}|})M_{i}$, so we could set $M_{i+1}=M(\epsilon _{|M_{i}|})M_{i}$ and the statement is true for $i+1$. By setting $M=\max _{i\leq 1/\epsilon _{0}+2}M_{i}$, we have $|P|,|Q|\leq M.$

### Remarks on equitable

A partition is equitable if the sizes of any two sets differ by at most $1$. By equitizing in each round of iteration, the proof of regularity lemma could be accustomed to prove the equitable version of regularity lemma. And by replacing the regularity lemma with its equitable version, the proof above could prove the equitable version of strong regularity lemma where ${\mathcal {P}}$ and ${\mathcal {Q}}$ are equitable partitions.

### A useful corollary
#### Statement

For any infinite sequence of constants $\epsilon _{0}\geq \epsilon _{1}\geq ...>0$, there exists $\delta >0$ such that there exists a partition ${\mathcal {P}}={V_{1},...,V_{k}}$ and subsets $W_{i}\subset V_{i}$ for each $i$ where the following properties are satisfied:
* $|W_{i}|>\delta n$
* $(W_{i},W_{j})$ is $\epsilon _{|{\mathcal {P}}|}$-regular for each pair $1\leq i\leq j\leq k$
* $|d(W_{i},W_{j})-d(V_{i},V_{j})|\leq \epsilon _{0}$ for all but $\epsilon _{0}|{\mathcal {P}}|^{2}$ pairs $1\leq i\leq j\leq k$

#### Motivation

The corollary explores deeper the small energy increment. It gives us a partition together with subsets with large sizes from each part, which are pairwise regular. In addition, the density between the corresponding subset pairs differs "not much" from the density between the corresponding parts.

#### Proof of corollary

We'll only prove the weaker result where the second condition only requires $(W_{i},W_{j})$ to be $\epsilon _{|{\mathcal {P}}|}$-regular for $1\leq i<j\leq k$. The full version can be proved by picking more subsets from each part that are mostly pairwise regular and combine them together.
Let $r=\epsilon _{0}^{3}/20$. We apply the strong regularity lemma to find equitable ${\mathcal {P}}$ that is a $r$ regular partition and equitable ${\mathcal {Q}}$ that is a $r/|P|^{4}$ regular refinement of ${\mathcal {P}}$ , such that $q({\mathcal {Q}})-q({\mathcal {P}})\leq r$ and $|{\mathcal {Q}}|\leq M$.
Now assume that $P=\{V_{1},\cdots ,V_{k}\}$, we randomly pick a vertex $v_{i}$ from each $V_{i}$ and let $W_{i}$ to be the set that contains $v_{i}$ in ${\mathcal {Q}}$. We argue that the subsets $W_{i}$ satisfy all the conditions with probability $>0$.
By setting $\delta ={\frac {1}{2M}}$ the first condition is trivially true since ${\mathcal {Q}}$ is an equitable partition. Since at most ${\frac {r}{|P|^{4}}}{\binom {n}{2}}\leq \epsilon _{0}{\frac {|V_{i}||V_{j}|}{3|P|^{2}}}$ vertex pairs live between irregular pairs in ${\mathcal {Q}}$ , the probability that the pair $W_{i}$ and $W_{j}$ is irregular $\leq {\frac {1}{3|P|^{2}}}$, by union bound, the probability that at least one pair $W_{i}$, $W_{i}$ is irregular $\leq 1/3$. Note that
${\begin{aligned}r&\geq q({\mathcal {Q}})-q({\mathcal {P}})\\&=\sum _{i,j}{\frac {|V_{i}||V_{j}|}{n^{2}}}\mathbb {E} |d(W_{i},W_{j})-d(V_{i},V_{j})|^{2}\\&\geq \sum _{i,j}{\frac {1}{4|P|^{2}}}\mathbb {E} |d(W_{i},W_{j})-d(V_{i},V_{j})|^{2}\\&={\frac {1}{4|P|^{2}}}\mathbb {E} \sum _{i,j}|d(W_{i},W_{j})-d(V_{i},V_{j})|^{2}\end{aligned}}$
So by Markov's inequality $P(\sum _{i,j}|d(W_{i},W_{j})-d(V_{i},V_{j})|^{2}\geq 8|P|^{2}r)\leq 1/2$, so with probability $\geq 1/2$, at most $\epsilon _{0}|P|^{2}$ pairs could have $d(W_{i},W_{j})-d(V_{i},V_{j})\geq \epsilon _{0}$. By union bound, the probability that all conditions hold $\geq 1-1/2-1/3>0$.

## History and extensions

Szemerédi (1975) first introduced a weaker version of this lemma, restricted to bipartite graphs, in order to prove Szemerédi's theorem, and in (Szemerédi 1978) he proved the full lemma. Extensions of the regularity method to hypergraphs were obtained by Rödl and his collaborators and Gowers.
János Komlós, Gábor Sárközy and Endre Szemerédi later (in 1997) proved in the blow-up lemma that the regular pairs in Szemerédi regularity lemma behave like complete bipartite graphs under the correct conditions. The lemma allowed for deeper exploration into the nature of embeddings of large sparse graphs into dense graphs.
The first constructive version was provided by Alon, Duke, Lefmann, Rödl and Yuster. Subsequently, Frieze and Kannan gave a different version and extended it to hypergraphs. They later produced a different construction due to Alan Frieze and Ravi Kannan that uses singular values of matrices. One can find more efficient non-deterministic algorithms, as formally detailed in Terence Tao's blog and implicitly mentioned in various papers.
An inequality of Terence Tao extends the Szemerédi regularity lemma, by revisiting it from the perspective of probability theory and information theory instead of graph theory. Terence Tao has also provided a proof of the lemma based on spectral theory, using the adjacency matrices of graphs.
It is not possible to prove a variant of the regularity lemma in which all pairs of partition sets are regular. Some graphs, such as the half graphs, require many pairs of partitions (but a small fraction of all pairs) to be irregular.
It is a common variant in the definition of an $\varepsilon$-regular partition to require that the vertex sets all have the same size, while collecting the leftover vertices in an "error"-set $V_{0}$ whose size is at most an $\varepsilon$-fraction of the size of the vertex set of $G$.
A stronger variation of the regularity lemma was proven by Alon, Fischer, Krivelevich, and Szegedy while proving the induced graph removal lemma. This works with a sequence of $\varepsilon$ instead of just one, and shows that there exists a partition with an extremely regular refinement, where the refinement doesn't have too large of an energy increment.
Szemerédi's regularity lemma can be interpreted as saying that the space of all graphs is totally bounded (and hence precompact) in a suitable metric (the cut distance). Limits in this metric can be represented by graphons; another version of the regularity lemma simply states that the space of graphons is compact.