Testing Hereditary Properties of Ordered Graphs and Matrices
Noga Alon∗, Omri Ben-Eliezer†, Eldar Fischer‡

arXiv:1704.02367v1 [] 7 Apr 2017

April 11, 2017

Abstract
We consider properties of edge-colored vertex-ordered graphs, i.e., graphs with a totally
ordered vertex set and a finite set of possible edge colors. We show that any hereditary property
of such graphs is strongly testable, i.e., testable with a constant number of queries. We also
explain how the proof can be adapted to show that any hereditary property of 2-dimensional
matrices over a finite alphabet (where row and column order is not ignored) is strongly testable.
The first result generalizes the result of Alon and Shapira [FOCS’05; SICOMP’08], who showed
that any hereditary graph property (without vertex order) is strongly testable. The second result
answers and generalizes a conjecture of Alon, Fischer and Newman [SICOMP’07] concerning
testing of matrix properties.
The testability is proved by establishing a removal lemma for vertex-ordered graphs. It states
that for any finite or infinite family F of forbidden vertex-ordered graphs, and any ǫ > 0, there
exist δ > 0 and k so that any vertex-ordered graph which is ǫ-far from being F -free contains
at least δn|F | copies of some F ∈ F (with the correct vertex order) where |F | ≤ k. The proof
bridges the gap between techniques related to the regularity lemma, used in the long chain of
papers investigating graph testing, and string testing techniques. Along the way we develop a
Ramsey-type lemma for k-partite graphs with “undesirable” edges, stating that one can find
a Ramsey-type structure in such a graph, in which the density of the undesirable edges is not
much higher than the density of those edges in the graph.

∗
Sackler School of Mathematics and Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv 69978,
Israel. Email: nogaa@tau.ac.il. Research supported in part by a USA-Israeli BSF grant 2012/107, by an ISF grant
620/13 and by the Israeli I-Core program.
†
Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv 69978, Israel. Email: omribene@gmail.com.
‡
Faculty of Computer Science, Israel Institute of Technology (Technion), Haifa, Isarel.
Email:
eldar@cs.technion.ac.il.

1

Introduction

Property Testing is dedicated to finding fast algorithms for decision problems of the following type:
Given a combinatorial structure S, distinguish quickly between the case where S satisfies a property
P and the case where S is far from satisfying the property. Being far means that one needs to
modify a significant fraction of the data in S to make it satisfy P. Property Testing was first
formally defined by Rubinfeld and Sudan [43], and the investigation in the combinatorial context
was initiated by Goldreich, Goldwasser and Ron [31]. This area has been very active over the last
twenty years, see, e.g. [30] for various surveys on it.
In this paper we focus on property testing of two-dimensional structures over a finite alphabet,
or equivalently, two-variable functions with a fixed finite range. Specifically, we consider graphs
and matrices. Graphs are functions G : V2 → {0, 1} where V is the vertex set; more generally

edge-colored graphs (with finite color set Σ) are functions G : V2 → Σ. Matrices over a finite
alphabet Σ (or images) are functions M : U × V → Σ. In this paper we generally consider edgecolored graphs rather than standard graphs, as the added generality will prove useful later, so the
term graph usually refers to an edge-colored graph.
For a fixed finite set Σ, a property of functions over Σ is simply a collection of functions
whose range is Σ. Specifically, an ordered graph property is a collection of (edge-colored) graphs
G : V2 → Σ. An unordered graph property is an ordered graph property that is also invariant
under vertex permutations: If G ∈ P and π is any permutation on VG , then the graph Gπ , defined
by Gπ (π(u)π(v)) = G(uv) for any u 6= v ∈ VG , satisfies Gπ ∈ P. Similarly, an (ordered) matrix
property, or an image property, is a collection of functions M : [m] × [n] → Σ. For simplicity, most
definitions given below
are only stated for graphs, but they carry over naturally to matrices.
[n]
A graph G : 2 → Σ is ǫ-far from the property P if one needs to modify the value G(ij) for


at least ǫ n2 of the edges ij, where ij denotes the (unordered) edge {i, j} ∈ [n]
2 . A tester for the
property P is a randomized algorithm that is given a parameter ǫ > 0 and query access to its input
graph G. The tester must distinguish, with error probability at most 1/3, between the case where
G satisfies P and the case where G is ǫ-far from satisfying P. The tester is said to have one-sided
error if it always accepts inputs from P, and rejects inputs that are ǫ-far from P with probability
at least 2/3. It is desirable to obtain testers that are efficient in terms of the query complexity (i.e.
the maximal possible number of queries made by the tester). A property P is strongly testable if
there is a one-sided error tester for P whose query complexity is bounded by a function Q(P, ǫ).
In other words, the query complexity of the tester is independent of the size of the input.
From now on, we generally assume (unless it is explicitly stated that we consider unordered
graphs) that the vertex set V of a graph G has a total ordering (e.g. the natural
one for V = [n]),

which we denote by <. The (induced) ordered subgraph of the graph G : V2 → Σ on U ⊆ V , where
the elements of U are u1 < . . . < uk , is the graph H : [k] → Σ which satisfies H(ij) = G(ui uj )
for any i < j ∈ [k]. For a family F of “forbidden” graphs, the property PF of F-freeness consists
of all graphs G for which any ordered subgraph H of G satisfies H ∈
/ F. Finally, a property P is
hereditary if it is closed under taking induced subgraphs. That is, for any G ∈ P and any ordered
subgraph H of G, it holds that H ∈ P. Note that a property P is hereditary if and only if P = PF
for some (finite or infinite) family F of graphs over Σ.
The analogous notions of ordered subgraphs, F-freeness and hereditary properties for matrices
are “structure preserving”. Here, the ordered submatrix of the matrix M : [m] × [n] → Σ on A × B,
where the elements of A and B are a1 < . . . < ak and b1 < . . . < bl , is the matrix N : [k] × [l] → Σ
defined by N (i, j) = M (ai , bj ) for any i ∈ [k] and j ∈ [l].

1

1.1

Previous results on graphs and matrices

Some of the most interesting results in property testing have been those that identify large families
of properties that are efficiently testable, and those that show that large families of properties
cannot be tested efficiently.
One of the most widely investigated questions in property testing has been that of characterizing
the efficiently testable unordered graph properties. In the seminal paper of Goldreich, Goldwasser
and Ron [31] it was shown that all unordered graph properties that can be represented by a
certain graph partitioning, including properties such as k-colorability and having a large clique,
are strongly testable. See also [33]. Alon, Fischer, Krivelevich and Szegedy [4] showed that the
property of F-freeness is strongly testable for any finite family F of forbidden unordered graphs
(here the term unordered graphs refers to the usual notion of graphs with no order on the vertices).
Their main technical result, now known as the induced graph removal lemma, is a generalization of
the well-known graph removal lemma [3, 45].
Theorem 1.1 (Induced graph removal lemma [4]) For any finite family F of unordered graphs
and ǫ > 0 there exists δ = δ(F, ǫ) > 0, such that any graph G which is ǫ-far from F-freeness contains
at least δnq copies of some F ∈ F with q vertices.
The original proof of Theorem 1.1 uses a strengthening of the celebrated Szemerédi graph regularity
lemma [45], known as the strong graph regularity lemma.
It is clear that having a removal lemma for a family F immediately implies that F-freeness is
strongly testable: A simple tester which picks a subgraph H whose size depends only on F and ǫ,
and checks whether H contains graphs from F or not, is a valid one-sided tester for F-freeness.
Hence, removal lemmas have a major role in property testing. They also have implications in
different areas of mathematics, such as number theory and discrete geometry. For more details, see
the survey of Conlon and Fox [21].
By proving a variant of the induced graph removal lemma that also holds for infinite families,
Alon and Shapira [8] generalized the results of [4]. The infinite variant is as follows.
Theorem 1.2 (Infinite graph removal lemma [8]) For any finite or infinite family F of unordered graphs and ǫ > 0 there exist δ = δ(F, ǫ) > 0 and q0 = q0 (F, ǫ), such that any graph G
which is ǫ-far from F-freeness contains at least δnq copies of some F ∈ F on q ≤ q0 vertices.
Theorem 1.2 directly implies that any hereditary unordered graph property is strongly testable,
exhibiting the remarkable strength of property testing.
Theorem 1.3 (Hereditary graph properties are strongly testable [8]) Let Σ be a finite set
with |Σ| ≥ 2. Any hereditary unordered graph property over Σ is strongly testable.
Alon, Fischer, Newman and Shapira later presented [6] a complete combinatorial characterization
of the graph properties that are testable (with two-sided error) using a constant number of queries,
building on results from [26, 33]. Independently, Borgs, Chayes, Lovász, Sós, Szegedy and Vesztergombi obtained an analytic characterization of such properties through the theory of graph limits
[15]. See also [38, 37].
An efficient finite induced removal lemma for binary matrices with no row and column order
was obtained by Alon, Fischer and Newman [5]. In this case, δ−1 is polynomial in ǫ−1 (where ǫ, δ
play the same roles as in the above removal lemmas). It was later shown by Fischer and Rozenberg
[27] that when the alphabet is bigger than binary, the dependence of δ−1 on ǫ−1 is super-polynomial
in general, and in fact testing submatrix-freeness over a non-binary alphabet is at least as hard as
testing triangle-freeness in graphs, for which the dependence is also known to be super-polynomial
2

in general [1], see also [2]. Actually, the main tool in [5] is an efficient conditional regularity lemma
for ordered binary matrices, and it was conjectured there that this regularity lemma can be used
to obtain a removal lemma for ordered binary matrices.
Conjecture 1.4 (Ordered binary matrix removal lemma [5]) For any finite family F of ordered binary matrices and any ǫ > 0 there exists δ = δ(F, ǫ) such that any n × n binary matrix
which is ǫ-far from F-freeness contains at least δna+b copies of some a × b matrix from F.
In contrast to the abundance of general testing results for two-dimensional structures with an
inherent symmetry, such as unordered graphs and matrices, no similar results for ordered twodimensional structures (i.e. structures that do not have any underlying symmetry) have been
established. Even seemingly simple special cases, such as F -freeness for a single ordered graph
F , or M -freeness for a single 2 × 2 ordered matrix M , are not known to be strongly testable in
general [2]. A good survey on the role of symmetry in property testing is given by Sudan [46], who
suggests that the successful characterization of the strongly testable unordered graph properties is
attributable to the underlying symmetry of these properties. See also [32].
Despite the lack of general results as above for the ordered case, property testing of multidimensional ordered structures has recently been an active area of research. Notable examples of
properties that were investigated in the setting of ordered matrices include monotonicity (see, e.g.,
[18, 19] for some of the recent works in the matrix setting), extensions of monotonicity such as
k-monotonicity [17] and more generally poset properties [25], visual and geometric properties of
images, such as connectedness, convexity, being a half plane [42, 13] and being a Lipschitz function
[10, 14], and local properties, such as consecutive pattern-freeness [12]. Ordered graphs were less
investigated in the context of property testing, but are the subject of many works in Combinatorics
and other areas. See, e.g., a recent work on Ramsey-type questions in the ordered setting [22], in
which it is shown that Ramsey numbers of simple ordered structures might differ significantly from
their unordered counterparts.
Finally, we mention a relevant result on one-dimensional structures. Alon, Krivelevich, Newman
and Szegedy [7] showed that regular languages are strongly testable. One can combine this result
with the well-known Higman’s lemma in order theory [35] to show that any hereditary property of
words (i.e. one dimensional functions) over a finite alphabet is strongly testable.

1.2

Our contributions

We prove generalizations of Theorems 1.3 and 1.2 to the ordered setting, as well as analogous results
for matrices. The following result generalizes Theorem 1.3.
Theorem 1.5 (Hereditary properties of ordered graphs are strongly testable) Fix a finite set Σ with |Σ| ≥ 2. Any hereditary ordered graph property over Σ is strongly testable.
To prove Theorem 1.5, we establish an order-preserving induced graph removal lemma, which
holds for finite and infinite families of ordered graphs. This is a generalization of Theorem 1.2.
Theorem 1.6 (Infinite ordered graph removal lemma) Fix a finite set Σ with |Σ| ≥ 2. For
any (finite or infinite) family F of ordered graphs F : [n2F ] → Σ and any ǫ > 0 there exist

→ Σ that is ǫ-far from
q0 = q0 (F, ǫ) and δ = δ(F, ǫ) > 0, such that any ordered graph G : [n]
2
q
F-freeness contains at least δn induced copies of some graph F ∈ F on q ≤ q0 vertices.
An analogue of Theorem 1.5 for matrices is also proved.

3

Theorem 1.7 (Hereditary properties of ordered matrices are strongly testable) Fix a finite set Σ with |Σ| ≥ 2. Any hereditary (ordered) matrix property over Σ is strongly testable.
As in the case of ordered graphs, to prove Theorem 1.7 we establish the following ordered matrix
removal lemma, which holds for finite and infinite families of matrices, and settles a generalized
form of Conjecture 1.4.
Theorem 1.8 (Infinite ordered matrix removal lemma) Fix a finite set Σ with |Σ| ≥ 2. For
any (finite or infinite) family F of ordered matrices over Σ and any ǫ > 0 there exist q0 = q0 (F, ǫ) >
0 and δ = δ(F, ǫ) > 0, such that any ordered matrix over Σ that is ǫ-far from F-freeness contains
′
at least δnq+q copies of some q × q ′ matrix F ∈ F, where q, q ′ ≤ q0 .
Actually, the proof of Theorem 1.8 is almost identical to that of Theorem 1.6, so we only describe
what modifications are needed to make the proof of Theorem 1.6 also work here, for the case of
square matrices. However, all proofs can be adapted to the non-square case as well. An outline for
the proof of the graph case is given in Section 2, and all of the sections after it are dedicated to the
full proof. The needed modifications for the matrix case appear in Subsection 7.3.
To the best of our knowledge, Theorems 1.5 and 1.7 are the first known testing results of
this type for ordered two-dimensional structures, and Theorems 1.6 and 1.8 are the first known
order-preserving removal lemmas for two-dimensional structures.
It is interesting to note that some of the properties mentioned in Subsection 1.1, such as monotonicity, k-monotonicity, and forbidden-poset type properties in matrices, are hereditary (as all of
them can be characterized by a finite set of forbidden submatrices), so Theorem 1.7 gives a new
proof that these properties, and many of their natural extensions, are strongly testable. Naturally,
our general testers are much less efficient than the testers specifically tailored for each of these
properties (in terms of dependence of the underlying constants on the parameters of the problem),
but the advantage of our result is its generality, that is, the fact that it applies to any hereditary
property. Thus, for example, for any fixed ordered graph H and any integer k, the property that an
ordered graph G admits a k-edge coloring with no monochromatic (ordered) induced copy of H is
strongly testable. As mentioned above Ramsey properties of this type have been considered in the
Combinatorics literature, see [22] and the references therein. Another family of examples includes
properties of (integer) intervals on the line. Any interval can be encoded by an edge connecting
its two endpoints, where the order on the vertices (the endpoints) is the usual order on the real
line. A specific example of a hereditary property is that the given set of intervals is closed under
intersection. The forbidden structure is a set of 4 vertices i < j < k < l where ik and jl are edges
(representing intervals) whereas jk is a non-edge.
Finally, there are various examples of unordered hereditary graph properties that have simple
representations using a small finite forbidden family of ordered subgraphs, while in the unordered
representation, the forbidden family is infinite. Some examples of such properties are bipartiteness,
being a chordal graph, and being a strongly chordal graph [23, 16]. For such properties, when
the input graph is supplied with the “right” ordering of the vertices, one can derive the strong
testability using the version of Theorem 1.6 for finite families of forbidden ordered subgraphs – see
Theorem 6.1 below – instead of using the infinite unordered version, Theorem 1.2.

1.3

Discussion and open questions

Several possible directions for future research follow from our work.

4

Dependence between the parameters of the ordered removal lemmas
Our proofs rely heavily on strong variants of the graph regularity lemma. Regularity-based proofs
generally have a notoriously bad dependence between the parameters of the problem. In the
notation of Theorem 1.6, for a fixed finite family F of forbidden ordered subgraphs, δ−1 is generally
very large in terms of ǫ−1 , meaning that the number of queries required for the corresponding tester
for such properties is very large in terms of ǫ−1 . Indeed, the original Szemerédi regularity lemma
imposes a tower-type dependence between these parameters [34, 39, 40], while the variant we use
is at least as strong (and at least as expensive) as the strong regularity lemma [4], which is known
to have a wowzer (tower of towers) type dependence between its parameters [20, 36]. Note that for
infinite families F the dependence between the parameters may be arbitrarily bad [9].
In a breakthrough result of Fox [28], the first known proof for the (unordered) graph removal
lemma that does not use the regularity lemma is given. However, the dependence between the
parameters there is still of a tower type. In any case, it will be interesting to try to obtain a proof
for the ordered case, that does not go through the strong regularity needed in our proof.
Better dependence for specific properties
As discussed in Subsection 1.1, for ordered binary matrices there is an efficient conditional regularity
lemma [5], in which the dependence of δ−1 on ǫ−1 is polynomial. It will be interesting to try to
combine the ideas from our proof with this binary matrix regularity lemma, to obtain a removal
lemma for finite families of ordered binary matrices with better dependence between the parameters.
Ideally, one hopes for a removal lemma with polynomial dependence, but even obtaining such a
lemma with, say, exponential dependence will be interesting.
More generally, it will be interesting to find large families of hereditary ordered graph or matrix
properties that have more efficient testers than those obtained from our work. See, e.g., [29] for
recent results of this type for unordered graph properties.
Characterization of strongly testable ordered properties
For unordered graphs, Alon and Shapira [8] showed that a property is strongly testable using
an oblivious one-sided tester, which is a tester whose behavior is independent of the size of the
input, if and only if the property is (almost) hereditary. It will be interesting to obtain similar
characterizations in the ordered case.
More generally, in the ordered case there are other general types of properties that may be of
interest. Ben-Eliezer, Korman and Reichman [12] recently raised the question of characterizing the
efficiently testable local properties, i.e., properties that are characterized by a collection of forbidden
local substructures. It will also be interesting to identify and investigate large classes of visual (or
geometric) properties. Due to the lack of symmetry, obtaining a complete characterization of the
efficiently testable properties of ordered graphs and matrices seems to be very difficult. In fact,
considering that all properties whatsoever can be formulated as properties of ordered structures
(e.g. strings), any characterization here will have to define and refer to some “graphness” of our
setting, even that we do not allow the graph symmetries.
Generalization to ordered hypergraphs and hypermatrices
It will be interesting to obtain similar removal lemmas (and consequently, testing results) for the
high-dimensional analogues of ordered graphs and matrices, namely ordered k-uniform hypergraphs
and k-dimensional hypermatrices. Such results were proved for unordered hypergraphs [44, 41, 47].
5

Analytic analogues via graph limits
The theory of graph limits has provided a powerful approach for problems of this type in the
unordered case [15, 38, 37]. It will be interesting to define and investigate a limit object for ordered
graphs; this may also help with the characterization question above.

2

Paper outline

A proof of a graph removal lemma typically goes along the following lines: First, the vertex set of
the graph is partitioned into a “constant” (not depending on the input graph size itself) number of
parts, and a corresponding regularity scheme is found. The regularity scheme essentially allows that
instead of considering the original graph, one can consider a very simplified picture of a constant size
structure approximately representing the graph. On one hand, the structure has to approximate
the original graph in the sense that we can “clean” the graph, changing only a small fraction of the
edges, so that the new graph will not contain anything not already “predicted” by the representing
structure. On the other hand, the structure has to be “truthful”, in the sense that everything
predicted by it in fact already exists in the graph.
In the simplest case, just a regular partition given by the original Szemerédi Lemma would
suffice. More complex cases, like [4, 8], require a more elaborate regularity scheme. In our case,
Section 5 provides a regularity scheme that addresses both edge configuration and vertex order,
combining a graph regularity scheme with a scheme for strings.
Given a regularity scheme, we have to provide the graph cleaning procedure, as well as prove that
if the cleaned graph still contains a forbidden subgraph, then the original graph already contains
a structure containing many such graphs (this will consist of some vertex sets referenced in the
regularity scheme). In Section 6 we show how to use the scheme to prove the removal lemma and
the testability theorem for the case of a finite family F of forbidden subgraphs, while in Section
7 we show how to extend it for the case of a possibly infinite family F. The latter section also
contains a formal definition of what it means for the regularity scheme to predict the existence of
a forbidden subgraph, while for the finite case it is enough to keep it implicit.
To extract the regularity scheme we need two technical aids. One of which, in Subsection 4.2,
is just a rounding lemma that allows us to properly use integer quantities to approximate real
ones. While in many works the question of dealing with issues related to the divisibility of the
number of vertices is just hand-waved away, the situation here is complex enough to merit a formal
explanation of how rounding works.
In Subsection 4.1 we develop a Ramsey-type theorem that we believe to be interesting in its
own right. The use of Ramsey-type theorems is prevalent in nearly all works dealing with regularity
schemes, as a way to allow us to concentrate only on “well-behaved” structures in the scheme when
we are about to clean the graph. Because of the extra complication of dealing with vertex-ordered
graphs, we cannot just find Ramsey-type instances separately in different parts of the regularity
scheme. Instead, we need to find the well-behaved structure “all at once”, and furthermore assure
that we avoid enough of the “undesirable” parts where the regularity scheme does not reflect the
graph. The fraction of undesirable features, while not large, must not depend on any parameters
apart from the original distance parameter ǫ (and in particular must not depend on the size of the
regularity scheme), which requires us to develop the new Ramsey-type theorem.
Roughly speaking, the theorem states the following: If we have a k-partite edge-colored graph
with sufficiently many vertices in each part, then we can find a subgraph where the edges between
every two parts are of a single color (determined by the identity of the two parts). However, we do
it in a way that satisfies another requirement: If additionally the original graph is supplied with a
6

set of “undesirable” edges comprising an α fraction of the total number of edges, then the subgraph
we find will include not more than an (1 + η)α fraction of the undesirable edges, for an η as small
as we would like (in our application η = 1 will suffice).

2.1

Finding a regularity scheme

To prove the removal lemma we need a regularity scheme, that is a sequence of vertex sets whose
“interaction” with the graph edges, and in our case also the graph vertex order, allows us to carry
a cleaning procedure using combinatorial lemmas.
Historically, in the case of properties like triangle-freeness in ordinary graphs, a regular equipartition served well enough as a regularity scheme. One needs then to just remove all edges that are
outside the reach of regularity, such as edges between the sets that do not form regular pairs. When
moving on to more general properties of graphs, this is not enough. We need a robust partition
(see [26]) instead of just a regular one, and then we can find a subset in each of the partition sets so
that these “representative” sets will all form regular pairs. This allows us to decide what to do with
problem pairs, e.g. whether they should become complete bipartite graphs or become edgeless (we
also need to decide what happens inside each partition set, but we skip this issue in the sketch).
For vertex ordered graphs, a single robust partition will not do. The reason is that even if we
find induced subgraphs using sets of this partition, there will be no guarantees about the vertex
order in these subgraphs. The reason is that the sets of the robust partition could interact in
complex ways with regards to the vertex order. Ideally we would like every pair of vertex sets to
appear in one of the following two possible ways: Either one is completely before the other, or the
two are completely “interwoven”.
To interact with the vertex order, we consider the robust partition along with a secondary
interval partition. If we consider what happens between two intervals, then all vertices in one of
the intervals will be before all vertices in the other one. This suggests that further dividing a robust
partition according to intervals is a good idea. However, we also need that inside each interval,
the relevant robust partition sets will be completely interwoven. In more explicit terms, we will
consider what happens when we intersect them with intervals of a refinement of the original interval
partition. If these intersections all have the “correct” sizes in relation of the original interval (i.e., a
set that intersects an interval also intersects all relevant sub-intervals with sufficient vertex count),
then we will have the “every possible order” guarantee.
Section 5 is dedicated to the formulation and existence proof of a regularity scheme suitable for
ordered graphs. In Subsection 5.1 we present the concept of approximating partitions, showing several useful properties of them. Importantly, the notion of a robust partition is somewhat preserved
when moving to a partition approximating it.
In Subsection 5.2 we develop the lemma that gives us the required scheme. Roughly speaking,
it follows the following steps.
• We find a base partition P of the graph G, robust enough with regards to the graph edge
colors, so as to ensure that it remains robust even after refining it to make it fit into a
secondary interval partition.
• We consider an interval partition J of the vertex set V of G, that is robust with respect to P .
That is, if we partition each interval of J into a number of smaller intervals (thus obtaining
a refinement J ′ ), most of the smaller intervals will contain about the same ratio of members
of each set of P as their corresponding bigger intervals.

7

• Now we consider what happens if we construct a partition resulting from taking the intersections of the members of P with members of J ′ . In an ideal world, if a set of P intersects an
interval of J, then it would intersect “nicely” also the intervals of J ′ that are contained in
that interval. However, this is only mostly true. Also, this “partition by intersections” will
usually not be an equipartition.
• We now modify a bit both P and J, to get Q and I that behave like the ideal picture, and are
close enough to P and J. Essentially we move vertices around in P to make the intersections
with the intervals in J ′ have about the same size inside each interval of J. We also modify
the intersection set sizes (which also affects J a little) so they will all be near multiples of a
common value (on the order of n). This is so we can divide them further into an equipartition
that refines both the robust graph partition and the interval partition. The rounding Lemma
4.8 helps us here.
The above process generates the following scheme. Q is the modified base equipartition, and its
size (i.e. number of parts) is denoted by k. I is the modified “bigger intervals” equipartition, and
its size is denoted by m. We are allowed to require in advance that m will be large enough (that
is, to have m bigger than a predetermined constant m0 ). There is an equipartition Q′ of size mt
which refines both Q and I. That is, each part of Q′ is fully contained in a part of Q and a part of
I, and so each part of Q contains exactly t parts of Q′ . Moreover, there is the “smaller intervals”
equipartition I ′ which refines I, and has size mb where b = r(m, t) for a two-variable function r
that we are allowed to choose in advance (r is eventually chosen according to the Ramsey-type
arguments needed in the proof). Each part of I contains exactly b parts of I ′ . Finally, there is a
“perfect” equipartition Q′′ which refines Q′ and I ′ and has size mbt, such that inside any bigger
interval from I, the intersection of each part of Q′ with each smaller interval from I ′ consists of
exactly one part of Q′′ . Additionally, Q′ can be taken to be very robust, where we are allowed to
choose the robustness parameters in advance.
We are guaranteed that the numbers m and t are bounded in terms of the above function r, the
robustness parameters, and m0 for which we required that m ≥ m0 . These bounds do not depend
on the size of the input graph. See Lemma 5.8 for more details.

2.2

Proving a finite removal lemma


Consider an ordered colored graph G : [n]
2 → Σ, and consider a regularity scheme consisting of
equipartitions Q, I, Q′ , I ′ , Q′′ for G as described above.
We start by observing that if Q′′ is robust enough, then there is a tuple W of “representatives”
for Q′′ , satisfying the following conditions.
• For each part of Q′′ there is exactly one representative, which is a subset of this part.
• Each representative is not too small: it is of order n (where the constants here may depend
on all other parameters discussed above, but not on the input size n).
• All pairs of representatives are very regular (in the standard Szemerédi regularity sense).
• The densities of the colors from Σ between pairs of representatives are usually similar to the
densities of those colors between the pairs of parts of Q′′ containing them. Here the density
of a color σ ∈ Σ between vertex sets A and B is the fraction of σ-colored edges in A × B.

8

Actually, the idea of using representatives, as presented above, was first developed in [4]. Note
that each part of Q′ contains exactly b representatives (since it contains b parts from Q′′ ) and each
small interval of I ′ contains exactly t representatives.
Now if Q′ is robust enough then the above representatives for Q′′ also represent Q′ in the
following sense: Densities of colors between pairs of representatives are usually similar to the
densities of those colors between the pairs of parts of Q′ containing them.
Consider a colored graph H whose vertices are the small intervals of I ′ , where the “color” of the
edge between two vertices (i.e. small intervals) is the t×t “density matrix” described as follows: For
any pair of representatives, one from each small interval, there is an entry in the density matrix.
This entry is the set of all colors from Σ that are dense enough between these two representatives,
i.e., all colors whose density between these representatives is above some threshold.
An edge between two vertices of H is considered undesirable if the density matrix between
these intervals differs significantly from a density matrix of the large intervals from I containing
them. If Q′ is robust enough, then most density matrices for pairs of small intervals are similar
to the density matrices of the pairs of large intervals containing them. Therefore, the number of
undesirables in H is small in this case.
Consider now H as an m-partite graph, where each part consists of all of the vertices (small
intervals) of H that are contained in a certain large interval from I. We apply the undesirabilitypreserving Ramsey on H, and then a standard multicolored Ramsey within each part, to obtain an
induced subgraph D of H with the following properties.
• D has exactly dF vertices (small intervals) inside each part of H, where dF is the maximum
number of vertices in a graph from the forbidden family F.
• For any pair of parts of H, all D-edges between these parts have the same “color”, i.e. the
same density matrix.
• For any part of H, all D-edges inside this part have the same “color”.
• The fraction of undesirables among the edges of D is small.

Finally we wish to “clean” the original graph G as dictated by D. For any pair Q′1 , Q′2 of (not
necessarily distinct) parts from Q′ , let I1 , I2 be the large intervals from I ′ containing them, and
consider the density matrix that is common to all D-edges between I1 and I2 . In this matrix there
is an entry dedicated to the pair Q′1 , Q′2 , which we refer to as the set of colors from Σ that are
“allowed” for this pair. The cleaning of G is done as follows: For every u ∈ Q′1 and v ∈ Q′2 , if the
original color of uv in G is allowed, then we do not recolor uv. Otherwise, we change the color of
uv to one of the allowed colors.
It can be shown that if D does not contain many undesirables, then the cleaning does not
change the colors of many edges in G. Therefore, if initially G is ǫ-far from F-freeness, then there
exists an induced copy of a graph F ∈ F in G with l ≤ dF vertices after the cleaning. Considering
our cleaning method, it can then be shown that there exist representatives R1 , . . . , Rl with the
following properties. For any i, all vertices of Ri come before all vertices of Ri+1 in the ordering
of the vertices, and for any i < j, the color of F (ij) has high density in Ri × Rj . Recalling that
all pairs of representatives are very regular, a well-known lemma implies that the representatives
R1 , . . . , Rl span many copies of F , as desired.

2.3

From finite to infinite removal lemma

After the finite removal lemma is established, adapting the proof to the infinite case is surprisingly
not difficult. The only problem of the finite proof is that we required D to have exactly dF vertices
9

in each large interval, where dF is the maximal number of vertices of a graph in F. This requirement
does not make sense when F is infinite. Instead we show that there is a function dF (m, t) that
“plays the role” of dF in the infinite case.
dF (m, t) is roughly defined as follows: We consider the (finite) collection C(m, t) of all colored
graphs with loops that have exactly m vertices, where the set of possible colors is the same as that
of H (so the number of possible colors depends only on |Σ| and t). We take dF (m, t) to be the
smallest number that guarantees the following. If a graph C ∈ C(m, t) exhibits (in some sense) a
graph from F, then C also exhibits a graph from F with no more than dF (m, t) vertices.
The rest of the proof follows as in the finite case, replacing any occurrence of dF in the proof
with dF (m, t). Here, if G contains a copy of a graph from F after the cleaning, then there is a
set of no more than dF (m, t) different representatives that are very regular in pairs and have the
“right” densities with respect to some F ∈ F with at most dF (m, t) vertices, so we are done as in
the finite case.
From ordered graphs to ordered matrices To prove Theorem 1.8 for square matrices, we
reduce the problem to a graph setting. Suppose that M : U × V → Σ is a matrix, and add an
additional color σ0 to Σ. All edges between U and V will have the original colors from Σ, and
edges inside U and inside V will have the new color σ0 . Note that we are not allowed to change
colors to or from the color σ0 , as it actually signals “no edge”. The proof now follows from the
proof for graphs: We can ask the partition I into large intervals to “respect the middle”, so all
parts of I are either fully contained in U or in V . Moreover, colors of edges inside U or inside V are
not modified during the cleaning step, and edges between U and V are not recolored to σ0 , since
this color does not appear at all between the relevant representatives (and in particular, does not
appear with high density).
To adapt the proof of Theorem 1.8 for non-square matrices, we need the divisibility condition
to be slightly different than respecting the middle. In the case that m = o(n), we need to construct
two separate “large intervals” equipartitions, one for the rows and one for the columns, instead of
one such equipartition I as in the graph case. The rest of the proof does not change.

3

Preliminaries and definitions

In general, we may and will assume whenever needed throughout the paper that n is large enough
with respect to all relevant parameters. We generally denote “small” parameters and functions
(whose values are always positive but can be arbitrarily close to zero) by small Greek letters1 ,
and “large” parameters and functions (whose values are always finite natural numbers but can be
arbitrarily large) by Latin letters. We assume that all parameters in all statements of the lemmas
are monotone in the “natural” direction, as in the following examples: T (α, b) ≤ T (α′ , b′ ) for
α ≥ α′ , b ≤ b′ , and γ(c, δ) ≤ γ(c′ , δ′ ) for c ≥ c′ , δ ≤ δ′ . We also assume that all “small” parameters
are smaller than one, and all “large” parameters are larger than one.
We also assume that all functions are “bounded by their parameters”, for example γ(α, k) ≤ α
and T (α, k) ≥ k. These definitions extend naturally to any set of parameters, and are easily seen
to be without loss of generality as long as we do not try to optimize bounds.
1

The only exception is λ, which will denote general real numbers, and ℓ which will denote their rounding

10

Colored graphs and charts
A Σ-colored
graph G = (V, cG ) is defined by a totally ordered set of vertices V and a function

V
cG : 2 → Σ. That is, G is a complete ordered graph whose edges are colored by elements of
Σ. The standard notion of an (ordered) graph is equivalent to a {0, 1}-colored graph. A Σ-colored
graph with loops G′ = (V, cG′ ) is defined by a totally ordered set V and a function cG′ : V2 ∪V → Σ.
We identify the notation cG′ (vv) with cG′ (v) for any v ∈ V .
With a slight abuse of notation, we denote by U1 × U2 = {{u1 , u2 } : u1 ∈ U1 , u2 ∈ U2 } the set
of edges between two disjoint vertex sets U1 and U2 . A (k, Σ)-chart C = (V1 , . . . S
, Vk , cC ) is defined
by k disjoint vertex sets V1 , . . . , Vk and a function cC : EC → Σ, where EC = 1≤i<j≤k Ui × Uj .
In other words, it is an edge-colored
Sk complete k-partite graph. For C and G as above, we say
that C is a partition of G if V = i=1 Vi and cG (e) = cC (e) for any edge e ∈ EC . Moreover, C
is equitable if ||Vi | − |Vj || ≤ 1 for any 1 ≤ i, j ≤ k; an equitable partition is sometimes called an
equipartition. The size |C| of the partition C is the number of parts in it. For a partition C as above,
a (k′ , Σ)-chart C ′ which is also a partition of G is saidSto be a G-refinement of C if we can write
i
Vil . Note that cG (e) = cC (e) = cC ′ (e)
C ′ = (V11 , . . . , V1j1 , . . . , Vk1 , . . . , Vkjk , cC ′ ) where Vi = jl=1
for any edge e ∈ EC . We will sometimes omit the coloring from the description of a partition when
it is clear from the context (as the coloring is determined by the partition of the vertices and the
coloring of the graph).
For two disjoint sets of vertices U, W and a coloring c : U × W → Σ, we say that the density of
σ ∈ Σ in (U, W, c) is dσ (U, W, c) = |(U × W ) ∩ c−1 (σ)|/|U ||W |. the squared density is denoted by
d2σ (U, W, c). The index of (U, W, c) is
X
d2σ (U, W, c).
ind(U, W, c) =
σ∈Σ

Note that 0 ≤ ind(U, V, c) ≤ 1 always holds. When the coloring c is clear from context, we will
usually simply write dσ (U, V ) for density and ind(U, V ) for index.
For a chart C as above we define the index of C as
ind(C) =

X

1≤i<i′ ≤k

|Vi ||Vi′ |
 ind(Vi , Vi′ , c ↾Vi ×Vi′ )
|V |
2

S
where V = ki=1 Vi . By the Cauchy-Schwarz inequality, for any two partitions C, C ′ of G where
C ′ is a G-refinement of C we have
0 ≤ ind(C) ≤ ind(C ′ ) ≤ 1.

(1)

For a function f : N → N and a constant γ > 0, we say that an equipartition C of size k
is (f, γ)-robust if there exists no refining equipartition C ′ of C of size at most f (k) for which
ind(C ′ ) > ind(C) + γ. The following observation states that for any colored graph G and any
equipartition C of G, there exists an (f, γ)-robust equipartition C ′ refining C. The first explicit
definition of robustness was given in [26].
Observation 3.1 (Robust partitioning of colored graphs [26]) For any integer k > 0, function f : N → N and real γ > 0 there exists T = T3.1 (k, f, γ) such that for any equipartition C of
′ (C, f, γ) that
a colored graph G with |C| = k, there exists an (f, γ)-robust equipartition C ′ = C3.1
′
refines C, where |C | ≤ T .

11

Proof: Initially pick C ′ = C. Now, as long as C ′ is not (f, γ)-robust, let k ′ denote the number of
parts of C ′ ; we may replace C ′ by a G-refinement C ′′ of it with at most f (k′ ) parts and ind(C ′′ ) >
ind(C ′ ) + γ. This process stops after at most 1/γ iterations, by inequality (1).

The definition of robustness immediately implies the following.
Observation 3.2 Let P = (V1 , . . . , Vk ) be an equipartition of a Σ-colored graph G = (V, c), and
suppose that P is (f ◦ g, γ)-robust for two functions f, g : N → N and γ > 0. Then any equitable
refinement of P with no more than g(k) parts is (f, γ)-robust.
The notion of robustness is stronger than the more commonly used notion of regularity. For a
Σ-colored graph G = (V, c) and an equipartition P = (V1 , . . . , Vk ) of G, a pair (Vi , Vj ) is ǫ-regular if
|dσ (Vi , Vj )−dσ (Vi′ , Vj′ )| ≤ ǫ for any σ ∈ Σ and Vi′ ⊆ Vi , Vj′ ⊆ Vj that satisfy |Vi′ | ≥ ǫ|Vi |, |Vj′ | ≥ ǫ|Vj |.

P is an ǫ-regular partition if all but at most ǫ k2 of the pairs (Vi , Vj ) are ǫ-regular. The following
lemma states that robust partitions are also regular; a lemma like it is implicit in the ideas of the
original proof of [45]. The original was formulated only for non-colored graphs (Σ = {0, 1}), but
the extension to colored graphs is not hard (and was also done in prior work).
(ǫ)

Lemma 3.3 ([45], see also [26]) For any ǫ > 0 there exist f = f3.3 : N → N and δ =
δ3.3 (|Σ|, ǫ) > 0 such that any (f, δ)-robust equipartition P of a Σ-colored graph G is also ǫ-regular.
The next lemma was first formulated (with different notation and without the extension to
general Σ) in [4], but in a sense the basic idea was already used in implicitly proving Lemma 3.3
in [45]. It will be useful for us later.
Lemma 3.4 ([4], see also [26]) For any ǫ > 0 there exists δ = δ3.4 (|Σ|, ǫ) > 0, so that for
every f : N → N, any (f, δ)-robust equipartition P = (V1 , . . . , Vk ) of a Σ-colored graph G, and
′
any equitable refinement
Sb P = (V11 , . . . , V1b , . . . , Vk1 , . . . , Vkb ) of P where kb ≤ f (k), choosing the
indexes so that Vi = r=1 Vir for any i ∈ [k], it holds that
1

X X

X

k 2
2 b σ∈Σ i,i′ ∈[k] j,j ′ ∈[b]

|dσ (Vij , Vi′ j ′ ) − dσ (Vi , Vi′ )| ≤ ǫ.

Another lemma that will be useful later is the following. This is Lemma 3.2 in [4].
η
: N → N, so that for any integer
Lemma 3.5 ([4]) For any η > 0 there exists a function β = β3.5
l > 0 there exists κ = κ3.5 (η, l) with the following property: If H = ([l], cH ) and V1 , . . . , Vl are
disjoint vertex sets of G = (V, c), such that for any i < j, (Vi , Vj ) is β(l)-regular and dcH (ij) (Vi , Vj ) ≥
η, then the number
Ql of induced H-copies in G with a vertex from Vi playing the role of vertex i of
H is at least κ i=1 |Vi |.

Strings and intervals

Consider an ordered set V whose elements are v1 < . . . < vn . A string S : V → Σ is a mapping
from the ordered set V to an alphabet Σ. An interval partition I = (I1 , . . . , Ik ) of the string
S : V → Σ is a partition V = I1 . . . Ik into consecutive substrings of S: That is, there exist
0 = a0 < . . . < ak−1 < ak = n such that Ii = S(vai−1 +1 ) . . . S(vai ) for any 1 ≤ i ≤ k. I is equitable
(or an interval equipartition) if ai −ai−1 ∈ {⌊n/k⌋, ⌈n/k⌉} for any 1 ≤ i ≤ k. An interval refinement
I ′ of I is an interval partition of S such that any part of I ′ is fully contained in a part of I. The
size |I| of an interval partition I is its number of parts.
12

Next we define notions of index and robustness that are suitable for strings and interval partitions. Similar notions were established in [11, 24]. For a string S : V → Σ, the density of σ ∈ Σ
in S is dσ (S) = |S −1 (σ)|/|S| where S −1 (σ) = {v ∈ VP: S(v) = σ}, and the squared density of σ in
S is denoted by d2σ (S). The index of S is ind(S) = σ∈Σ d2σ (S). Finally, the index of an interval
partition I = (I1 , . . . , Ik ) of S is
k
X
|Ii |
ind(Ii ).
ind(I) =
|V |
i=1

As in the case of charts, for an interval equipartition I of a string S, we say that I is (f, γ)-robust
if any interval equipartition I ′ of size at most f (k) that refines I satisfies ind(I ′ ) ≤ ind(I) + γ (in
the other direction, ind(I) ≤ ind(I ′ ) always holds). The following is an analogue of Observation
3.1, and its proof is essentially identical.
Observation 3.6 (Robust partitioning of intervals) For any integer k > 0, function f : N →
N and real γ > 0 there exists T = T3.6 (k, f, γ) such that any interval equipartition I of a string
′ (I, f, γ) consisting of at most T
S where |I| = k has an (f, γ)-robust interval refinement I ′ = I3.6
intervals.
The next lemma is an analogue of Lemma 3.4 for strings, and its proof is similar.
Lemma 3.7 For any ǫ > 0 there exists δ = δ3.7 (|Σ|, ǫ) > 0, so that for every f : N → N, any
(f, δ)-robust interval equipartition I = (I1 , . . . , Ik ) of a string S : V → Σ, and any equitable interval
refinement
I ′ = (I11 , . . . , I1b , . . . , Ik1 , . . . , Ikb ) of I where kb ≤ f (k), choosing the indexes so that
Sb
Ii = r=1 Iir for any i ∈ [k], it holds that
1 XXX
|dσ (Iij ) − dσ (Ii )| ≤ ǫ.
kb
σ∈Σ i∈[k] j∈[b]

We finish by defining the string that a partition of an ordered set induces on that set. The
strings that we will consider in this paper are of this type.
Definition 3.8 (String of a partition) For a partition P = (V1 , . . . , Vk ) of an ordered set V ,
the P -string SP : V → [k] maps any v ∈ V to the element i ∈ [k] such that v ∈ Vi .
With slight abuse of notation, we will also use the notion of an interval partition in the context of
ordered graphs; here each interval will simply be a set of consecutive vertices (with no accompanying
function, in contrast to the case of strings).

4

Technical aids

We develop here two tools that we will use for our proofs. The first tool is a Ramsey-type theorem
that we believe to be interesting in its own right. We will use it to find a “uniform” structure with
a global view on our graph.
The second tool is a rounding lemma that allows us to evenly partition graphs also when the
number of sets does not divide the number of vertices, without hand-waving away the divisibility
issues (which might have been questionable in our context).

13

4.1

A quantitative Ramsey-type theorem

The multicolored Ramsey number Ram(s, k) is the minimum integer n so that in any coloring of
Kn with s colors there is a monochromatic copy of Kk . It is well known that this number exists
(i.e. is finite) for any s and k. For our purposes, we will also need a different Ramsey-type result,
that keeps track of “undesirable” edges, as described in the following subsection.
Given a k-partite Σ-chart, we would like to pick a given number of vertices from each partition
set, so that all edges between remaining vertices in each pair of sets are of the same color. However,
in our situation we also have a “quantitative” requirement: A portion of the edges is marked
as “undesirable”, and we require that in the chart induced on the picked vertices the ratio of
undesirable edges does not increase by much.
Formally, we prove the following, which we state as a theorem because we believe it may have
uses beyond the use in this paper.
Theorem 4.1 There exists a function R4.1 : N × N × N × (0, 1] → N, so that if G = (V
S1 , . . . , Vk , c)
is a k-partite Σ-chart with n ≥ R4.1 (|Σ|, k, t, α) vertices in each class, and B ⊆ i<j∈[k](Vi ×

Vj ) is a set of “undesirable edges” of size at most ǫ k2 n2 , then G contains an induced subchart
H4.1 (G, B, t, α) = (W1 , . . . , Wk , c ↾S1≤i<j≤k (Wi ×Wj ) ) with the following properties.
• |Wi | = t for every 1 ≤ i ≤ k.
• c ↾Wi ×Wj is a constant function for every 1 ≤ i < j ≤ k.

S
• The size of B ∩ ( 1≤i<j≤k (Wi × Wj )) is at most (1 + α)ǫ k2 t2 .

In our use, these “vertices” would actually be themselves sets of a robust partition of the original
graph, and “colors” will encode densities; an undesirable pair would have the “wrong” densities.
Also, in our use case the undesirability of an edge will be determined solely by its color and the
Wi that its end vertices belong to, which means that for each 1 ≤ i < i′ ≤ k the edge set Wi × Wi′
consist of either only desirable edges or only undesirable edges. When this happens, a later pick of
smaller sets Wi′ ⊂ Wi will still preserve the ratio of undesirable edges (we will in fact perform such
a pick using the original Ramsey’s theorem inside each Wi ). The following corollary summarizes
our use of the theorem.
S
Definition 4.2 Given a k-partite Σ-chart G = (V1 , . . . , Vk , c) and a set B ⊆ i<j∈[k](Vi × Vj ), we
say that B is orderly if for every 1 ≤ i < j ≤ k there are no e ∈ (Vi × Vj ) ∩ B and e′ ∈ (Vi × Vj ) \ B
for which c(e) = c(e′ ). In other words, the “position” and color of an edge fully determines whether
it is in B.
S
Corollary 4.3 There exists a function R4.3 : N × N × N → N, so that if G = ( ki=1 Vi , c) is a
Σ-colored graph with |Vi | = n ≥ R4.3 (|Σ|, k, t) for any i ∈ [k] and Vi ∩ Vj = ∅ for any i 6= j ∈ [k],

S
and B ⊆ i<j∈[k] (Vi × Vj ) is an orderly set of “undesirable edges” of size at most ǫ k2 n2 , then G
contains an induced subgraph D satisfying the following.
S
• The vertex set of D is li=1 Ui where Ui ⊆ Vi and |Ui | = t for any i ∈ [k].
• For any i ∈ [k], all edges inside Ui have the same color.

• For any i < j ∈ [k], all edges in Ui × Uj have the same color.

P
k 2
•
i<j∈[k] |B ∩ (Ui × Uj )| ≤ 2ǫ 2 t .
14

Proof: Take R4.3 (s, k, t) = R4.1 (s, k, Ram(s, t), 1) (recall that Ram(s, t) denotes the “traditional”
s-colored Ramsey function). By Theorem 4.1, there exists a chart H = (W1 , . . . , Wk ) with the
following properties.
• Wi ⊆ Vi and |Wi | = Ram(t, |Σ|) for every i ∈ [k].
• For any pair i < j ∈ [k], all edges in Wi × Wj have the same color.
P
2
k
•
i<j∈[k] |B ∩ (Wi × Wj )| ≤ 2ǫ 2 (Ram(t, |Σ|)) .

Observe that for any pair i < j ∈ [k], either Wi × Wj ⊆ B or (Wi × Wj ) ∩ B = ∅, since all edges
in Wi × Wj have the same color and B is orderly. Therefore, the number of pairs i < j for which

(Wi × Wj ) ∩ B 6= ∅ is at most 2ǫ k2 . Now we apply the traditional Ramsey’s theorem inside each
W to obtain a set Uj ⊆ Wj of size t such that all edges inside Wj have the same color. Since
Pj
P
k 2

i<j |B ∩ (Ui × Uj )| ≤
i<j:(Wi ×Wj )∩B6=∅ |B ∩ (Ui × Uj )| ≤ 2ǫ 2 t , the proof follows.
Before moving to the proof of Theorem 4.1 itself, let us quickly note that a quantitative counterpart for the traditional (not k-partite) graph case does not exist (indeed, Corollary 4.3 is a way
for us to circumvent such issues).

Proposition 4.4 For any α > 0, m, k, and large enough l, for infinitely many n there is a graph
1 n
G and a set of undesirable pairs B, so that G has n vertices, B consists of at most mk
2 pairs,

1
G has no independent set of size l, and every clique of l vertices in G holds at least ( m − α) 2l
members of B.
Proof: We construct G for any n that is a multiple of mk larger than lk. The graph G will be the
union of k vertex-disjoint cliques, each with n/k vertices. In particular, G contains no independent
set with l vertices, and any clique with l vertices must be fully contained in one of the cliques of G.
Now B will be fully contained in the edge-set of G, and will consist of the edge-set of mk vertexdisjoint cliques with n/mk vertices each, so that each of the cliques of G contains m ofthem. It is
1
− αl ) 2l ) members
now not hard to see that any clique with l vertices in G will contain at least ( m
of B, where liml→∞ αl = 0.

Moving to the proof, the following is our main lemma. It essentially says that we can have
a probability distribution over “Ramsey-configurations” in our chart that has some approximate
uniformity properties.
Lemma 4.5 There exists a function R4.5 : N × N × N × (0, 1] → N, so that if G = (V1 , . . . , Vk , c)
is a k-partite Σ-chart with n ≥ R4.5 (|Σ|, k, t, δ) vertices in each class, then G contains a randomized induced subchart H4.5 (G, t, δ) = (W1 , . . . , Wk , c ↾S1≤i<j≤k (Wi ×Wj ) ) satisfying the following
properties.
• Either |Wi | = t for every 1 ≤ i ≤ k, or the chart is empty (Wi = ∅ for every i).
• c ↾Wi ×Wj is a constant function for every 1 ≤ i < j ≤ k (with probability 1).
• For every 1 ≤ i ≤ k, every v ∈ Vi will be in Wi with probability at most t/n.
• For every 1 ≤ i < j ≤ k, every v ∈ Vi and every w ∈ Vj , the probability for both v ∈ Wi and
w ∈ Wj to hold is bounded by (t/n)2 .
15

• The probability that the chart is empty is at most δ.
Before we prove this lemma, we show how it implies Theorem 4.1.
Proof of Theorem 4.1 We set R4.1 (a, k, t, α) = R4.5 (a, k, t, α/3). Given the k-partite Σ-chart
G, we take the randomized subchart H = H4.5 (G, t, α/3) = (W1 , . . . , Wk , c ↾S1≤i<j≤k (Wi ×Wj ) ), and
prove that with positive
S probability it is the required subchart.
Let B ′ = B ∩ ( 1≤i<j≤k Wi × Wj ) denote the set of undesirable pairs that are contained in
H. By the probability
bound on pair containment and by the linearity of expectation,
E[|B ′ |] ≤


k 2
k 2
2
′
(t/n) |B| ≤ ǫ 2 t . Therefore, the probability for |B | to be larger than (1 + α)ǫ 2 t is bounded
1
≤ 1 − α/2. Therefore, with positive probability, both |B ′ | is not too large and H is not the
by 1+α
empty chart. Such an H is the desired subchart.

To prove Lemma 4.5 we shall make good use of the following near-trivial observation.
Observation 4.6 There exists a function m4.6 : N × N × (0, 1] → N, such that if A is a set of
size at least m4.6 (k, t, δ) and A = (A1 , . . . , Ak ) is a partition of A to k sets, then there exists a
randomized subset B = B4.6 (A, t, δ) satisfying the following properties.
• Either |B| = t or B = ∅.
• B is fully contained in a single Ai .
• For every a ∈ A, the probability for a ∈ B is at most t/|A|.
• The probability for B = ∅ is at most δ.
Proof: To choose the randomized subset B, first choose a random index I where Pr[I = i] =
|Ai |/|A| for all 1 ≤ i ≤ k. Next, if |AI | < t then set B = ∅, and otherwise
set B to be a

|AI |
subset of size exactly t of AI , chosen uniformly at random from all t possibilities. Setting
m4.6 (k, t, δ) = tk/δ, it is not hard to see that all properties for the random set B indeed hold. 
Proof of Lemma 4.5 The proof is done by induction over k. The base case k = 1 is easy – set
R4.5 (|Σ|, 1, t, δ) = t, and let W1 be a uniformly random subset of size t of V1 .
1
δ), where
For the induction step from k − 1 to k, we set R4.5 (|Σ|, k, t, δ) = m4.6 (|Σ|s , r, k+1
1
1
k−1
s = m4.6 (|Σ| , t, k+1 δ) and r = R4.5 (|Σ|, k − 1, t, k+1 δ). We set W1 , . . . , Wk to be the result of
the following random process.
First, we set V1′ ⊆ V1 to be a uniformly random subset of size exactly s. Then, for every
1
δ), where Vi is the partition of Vi
2 ≤ i ≤ k, we set Vi′ ⊆ Vi to be the random set B4.6 (Vi , r, k+1
obtained by classifying every v ∈ Vi according to the colors hc(w, v)iw∈V1′ , i.e., two vertices in Vi
are in the same partition set if all their pairs with vertices from V1′ have the same colors.
If any of the Vi′ came out empty, we set all Wi to ∅ and terminate the algorithm (this occurs
with probability at most k−1
k+1 δ), and otherwise we continue. Note now, in particular, that for every
w ∈ V1 and v ∈ Vi the probability for both w ∈ V1′ and v ∈ Vi′ to hold is bounded by (s/n)(r/n).
This is since the probability guarantees of Observation 4.6 hold for any possible value of V1′ . Also,
since each Vi′ was independently drawn, for v ∈ Vi and w ∈ Vj (where 1 < i < j ≤ k) the probability
for both v ∈ Vi′ and w ∈ Vj′ to hold is bounded by (r/n)2 .
We now let H ′ denote the (k − 1)-partite Σ-chart induced by V2′ , . . . , Vk′ , and use the induction
1
δ). As
hypothesis to (randomly) set W2 , . . . , Wk as the corresponding vertex sets of H4.5 (H ′ , t, k+1
before, if we receive empty sets then we also set W1 = ∅ and terminate. Note that for 1 < i ≤ k
16

and v ∈ Vi′ , the probability for v to be in Wi is bounded by t/r. Hence, for v ∈ Vi , the probability
for v ∈ Wi to hold is bounded by (r/n)(t/r) = t/n. Similarly, for 1 < i < j ≤ k, for every v ∈ Vi
and w ∈ Vj the probability for both v ∈ Wi and w ∈ Wj to hold is bounded by (t/n)2 . Also by
similar considerations, for v ∈ V1 and w ∈ Vi , the probability for both v ∈ V1′ and w ∈ Wi to hold
is bounded by (s/n)(t/n).
1
δ), where V ′ is the partition of V1′ obtained
Finally, we set W1 to be the random set B4.6 (V ′ , t, k+1
by classifying each v ∈ V1′ by the colors hc(v, w)iw∈Wi . Note that c(v, w) in that expression depends
only on v and the index i for which w ∈ Wi , because of how we chose each Vi′ above. In particular,
after the choice of W1 , the function c ↾W1 ×Wi is constant for each 1 < i ≤ k. Again, if we got an
empty set for W1 , we set all W2 , . . . , Wk to be empty as well. By similar considerations as in the
preceding steps, also here, for any v ∈ V1 the probability of v ∈ W1 is bounded by t/n, and for
w ∈ Vi where 1 < i ≤ k, the probability of both v ∈ W1 and w ∈ Wi is bounded by (t/n)2 .
The probability of obtaining empty sets in any of the steps is bounded by δ by a union bound,
and all other properties of the random sets W1 , . . . , Wk have already been proven above.


4.2

Multipartitions and rounding

The following is a mechanism to handle “with one stroke” rounding issues throughout the paper.
Definition 4.7 (Multipartitions) A multipartition of a set L is a family M of subsets of L,
that in particular includes L and all the singletons {i} for i ∈ L, and furthermore every two sets
A, B ∈ M are either disjoint or one is contained in the other.
To get an idea, an object that can be modeled as a multipartition is a partition of L (the
multipartition would contain the partition sets, along with L itself and all singleton sets {i}), but
also other objects, such as a partition and its refinement together, can be modeled as multipartitions.
Here is the main lemma.
Lemma 4.8 (rounding feasibility) If M and N are two multipartitions of the same set L, and
λi ∈ R is a real value attached to every i ∈ L, then there exist integer values ℓi ∈ Z attached to
i ∈ L, satisfying the following.
• ℓi ∈ {⌊λi ⌋, ⌈λi ⌉} for every i ∈ L.
P
P
P
•
i∈A ℓi ∈ {⌊ i∈A λi ⌋, ⌈ i∈A λi ⌉} for every A ∈ M and for every A ∈ N .
P
P
P
•
i∈L ℓi ∈ {⌊ i∈L λi ⌋, ⌈ i∈L λi ⌉}.

Proof: Note that the middle item implies the other two (since M and N in particular include L
and all singleton sets {i} for i ∈ L). We define the following problem of solving a flow network
with minimal and maximal constraints (for an exposition of flow networks see [48]).
• The node set of the flow network is {uA : A ∈ M } ∪ {wA : A ∈ N }.
• The start node is uL and the target node is wL .
• For every A, B ∈ M , so that A ( B and there
P is no C ∈ M for which A (
PC ( B, we put an
edge from uB to uA with minimum flow ⌊ i∈A λi ⌋ and maximum flow ⌈ i∈A λi ⌉.

• For every A, B ∈ N , so that A ( B and there
C ( B, we put an
P is no C ∈ N for which A (P
edge from wA to wB with minimum flow ⌊ i∈A λi ⌋ and maximum flow ⌈ i∈A λi ⌉.
17

• For every i ∈ L we put an edge from ui to wi with minimum flow ⌊λi ⌋ and maximum flow
⌈λi ⌉.
P
P
• We require the total flow of the network to be between ⌊ i∈L λi ⌋ and ⌈ i∈L λi ⌉.

This flow network has a real-valued solution by assigning λi flow to each edge of the type ui , wi ,
and then assigning the corresponding sums to all other network edges. Hence (since all constraints
are integer-valued), the flow network has an integer-valued solution as well (see, e.g., the analysis
of Lawler’s algorithm in [48], page 602). Fixing such a solution, and setting ℓi to be the flow in the
edge ui , wi for every i ∈ L, completes the proof.

An example of using the lemma is when we want to round the values in a 2-dimensional matrix
so that the row sums and column sums are also rounded versions of the original sums (and in
particular equal to the original sums if they happen to be integers). In our use the resulting integer
values would be set sizes for an equipartition, that in turn refines other partitions with set size
requirements.
We also note here that the statement of this lemma is false when we are presented with three
multipartitions. Take for example the 3-dimensional matrix of size 2 × 2 × 2, where λ111 = λ100 =
λ010 = λ001 = 21 , with all other λ values being zero. Also for each of the three dimensions take the
partition into two axes-parallel planes. The values on every set of every partition sum up to 1, and
yet there are no corresponding ℓijk ∈ {⌊λijk ⌋, ⌈λijk ⌉} satisfying these constraints.

5

A regularity scheme for ordered graphs

5.1

The approximating partition framework

Definition 5.1 (δ-approximating partitions) Let P = (V1 , . . . , Vk ) and Q = (U1 , . . . , Ul ) be
partitions of a set V of size n. We say that Q is a δ-approximation of P , or equivalently, that
P and Q are δ-close, if there exists T ⊆ V with |T | ≤ δn such that Vi \ T = Ui \ T for any
1 ≤ i ≤ max{k, l}, where for i > k we define Vi = φ, and similarly Ui = φ for i > l.
Lemma 5.2 For any ǫ > 0 there exists δ = δ5.2 (ǫ) > 0 such that any two δ-close partitions P and
Q of (the vertex set of ) a colored graph G = (V, c) satisfy |ind(P ) − ind(Q)| ≤ ǫ.
Proof: Let P = (V1 , . . . , Vk ) and Q = (U1 , . . . , Ul ) be δ-close partitions ofPG, where we assume
w.l.o.g. that k < l. For any 1 ≤ i√≤ k let Wi = Vi ∩ Ui , and observe that ki=1P|Wi | ≥ (1 − √
δ)n.
we say
√ if |Wi | ≤ (1 − δ) min{|Vi |, |Ui |} and good otherwise. Then i bad |Vi | ≤ δn
P that i is bad
and i bad |Ui | ≤ δn. When i and j are both good, we have
X
X
dσ (Vi , Vj ) − dσ (Wi , Wj )
(d2σ (Vi , Vj ) − d2σ (Wi , Wj ) ≤ 2
ind(Vi , Vj ) − ind(Wi , Wj ) ≤
σ∈Σ

σ∈Σ

≤2

X

σ∈Σ

dσ (Vi , Vj )





√
|c−1 (σ) ∩ ((Vi × Vj ) \ (Wi × Wj ))|
|Vi ||Vj |
−1 +
= O( δ)
|Wi ||Wj |
|Wi ||Wj |

where the second inequality holds since dσ (Vi , Vj ) + dσ (Ui , Uj ) ≤ 2, the third inequality follows
from the fact that |x − y| ≤ z − x + z − y√for z ≥ max{x, y} and the last inequality follows
from the observation that |Vi ||Vj | = (1 + O( δ))|Wi ||Wj |. Similarly, it holds that |ind(Ui , Uj ) −

18

√
√
ind(Wi , Wj )| = O( δ), so |ind(Vi , Vj ) − ind(Ui , Uj )| = O( δ) when i, j are good. We finish by
observing that
!
X
√
√
|Ui ||Uj |
|Vi ||Vj |
ind(P ) − ind(Q) ≤
n ind(Vi , Vj ) −
n ind(Ui , Uj ) + 2 δ = O( δ)
i<j good

2

2

√

P
P
where the first inequality holds since
|Vi ||Vj |ind(Vi , Vj )/ n2 ≤ 2 δ and the second
i
bad
j6
=
i


√ 
√ 
inequality is true since |Vi ||Vj | = 1 + O( δ) |Ui ||Uj | and ind(Vi , Vj ) = 1 + O( δ) ind(Ui , Uj )

when i and j are good, and since ind(Q) ≤ 1. Therefore, taking a suitable δ = Θ(ǫ2 ) in the
statement of the lemma suffices.

Lemma 5.3 Let P, Q be δ-close equipartitions of a colored graph G, where |P | = |Q|. Then any
equitable refinement Q′ of Q is δ-close to an equitable refinement P ′ of P , with |P ′ | = |Q′ |.
′
Proof:
. , Ukr ) where
k1 , . . P
Sr Write P = (V1 , . . . , Vk ), Q = (U1 , . . . , Uk ), Q = (U11 , . . . , U1r , . . . , UP
Ui = j=1 Uij . Also, for any i, j let Wi = Vi ∩ Ui and Wij = Vi ∩ Uij . Then ki=1 rr=1 |Wij | =
Pk
′
i=1 |Wi | ≥ (1 − δ)n, so we may take a refinement P = (Vij )1≤i≤k,1≤j≤r of P as follows: For any
i, j we take Vij that contains Wij and ℓij arbitrary additional elements from Vi \ Wi , where ℓij is
chosen by using Lemma 4.8 in the following manner.
For 1 ≤ i ≤ k and 1 ≤ j ≤ r we set λij = |Vi |/r − |Wij |. We set the multipartition M to
consist of all singleton sets {ij}, the set [k] × [r], and the sets {i} × [r] for 1 ≤ i ≤ k. We set the
multipartition N to be the trivial one, just the singleton
Pr sets and [k] × [r]. Invoking Lemma 4.8, we
claim the following about the resultingP
ℓij : Since j=1 λij = |Vi | − |Wi |, which is an integer, this
will also equal the corresponding sum rj=1 ℓij = |Vi | − |Wi |, so we can get this way a refinement
m+1
of P . Also, for any integer m (in our case |Vi |) it holds that ⌊ m
r ⌋ = ⌈ r ⌉ − 1, so the resulting Vij
would form an equipartition. The last issue that we need to deal with is when we have ℓij = −1
for some i and j, which could in fact happen. We claim however that in such a case we can move
to another solution for which ℓij = 0. To see this, we note that ℓij = −1 only if |Vi |/r is not an
integer, |Wij | = |Uij | = ⌈|Vi |/r⌉, and ℓij = ⌊λij ⌋. But in this case one can see that there exists

j ′ 6= j so that ℓij ′ = ⌈λij ′ ⌉ > 0, and so we can increase ℓij by 1 at the expense of ℓij ′ .

Lemma 5.4 For any ǫ > 0 there exists δ = δ5.4 (ǫ) > 0 such that the following holds: If P and
Q are δ-close equipartitions of a colored graph G, P is (f, δ)-robust and |P | = |Q|, then Q is
(f, ǫ)-robust.
Proof: Let P, Q be equipartitions as in the statement and pick δ = δ5.2 (ǫ/3). Consider an
equitable refinement Q′ of Q of size at most f (|Q|) = f (|P |). By Lemma 5.3 there exists some
equitable refinement P ′ of P which δ-approximates Q′ where |P ′ | = |Q′ | ≤ f (|P |). The robustness
of P implies that ind(P ′ ) − ind(P ) ≤ δ ≤ ǫ/3. By Lemma 5.2, |ind(P ) − ind(Q)| ≤ ǫ/3 and
|ind(P ′ ) − ind(Q′ )| ≤ ǫ/3. We conclude that ind(Q′ ) − ind(Q) ≤ ǫ. Thus, Q is (f, ǫ)-robust.

The definition of δ-close partitions works exactly the same for interval partitions. We observe
that interval equipartitions and their densities are mostly determined by the number of parts.
2

Observation 5.5 Any two interval equipartitions I and J of [n] into m parts are mn -close to each
other. In particular, for any f , m and
ǫ, if n is large enough as a function of m and ǫ, then for
1 Pm P
such I and J the densities satisfy m i=1 σ∈Σ |dσ (Ii ) − dσ (Ji )| ≤ ǫ.
19

Proof:
If I and J are two interval equipartitions of [n] with |I| = |J| = m, then we can set
Sm−1
m
n
⌋ + 1, i⌈ m
⌉]. Clearly |T | < m2 and Ii \ T = Ji \ T for every i ∈ [m]. The second
T = i=1 [i⌊ m
part of the observation then follows easily from the first part for n large enough.


5.2

The core lemmas

Definition 5.6 (Least Common Refinement) For two partitions P = (V1 , . . . , Vk ) and Q =
(U1 , . . . , Ul ) of a colored graph G, the least common refinement (LCR) P ⊓ Q of P and Q is the
partition (V1 ∩ U1 , . . . , V1 ∩ Ul , . . . , Vk ∩ U1 , . . . , Vk ∩ Ul ) (after removing empty sets from the list).
Note that even if P and Q are equitable, P ⊓ Q is not necessarily equitable.
The following lemma allows us to combine an “order-respecting” interval partition and a robust
graph partition. The last statement in the formulation (about even n and m) is not needed for
the rest of the proofs concerning ordered graphs, but we will refer to it when we discuss ordered
matrices.
Lemma 5.7 For any δ > 0 and positive integers k, m and b, there exists γ = γ5.7 (δ, k) > 0
such that the following holds: If P is an equipartition of an n-vertex colored graph G (for n ≥
N5.7 (δ, k, m, b)) with |P | = k, and J is an interval equipartition of SP of size m which is (f, γ)robust, where f (m) ≥ mb, then there exist an interval equipartition I = I5.7 (δ, P, m, b) of size
′ (δ, P, m, b) of size mb which refines I, an equipartition Q =
m, an interval equipartition I ′ = I5.7
Q5.7 (δ, P, m, b) of size k which δ-approximates P , and an equipartition Q′ = Q′5.7 (δ, P, m, b) of
size at most T5.7 (δ, k, m) which is a refinement of both I and Q, all satisfying that the LCR
Q′′ = I ′ ⊓ Q′ is an equipartition of size |Q′′ | = b|Q′ | = |Q′ ||I ′ |/|I| (i.e., each set of Q′ intersects
“nicely” all subintervals of the interval of I that contains it).
Pm/2
Furthermore, if m and n are even, then I “respects the middle”, that is i=1 |Ii | = n2 .

Proof: We denote P = (V1 , . . . , Vk ), and set γ5.7 (δ, k) = δ3.7 (k, δ/20). The sets of the original
interval equipartition J will be denoted by J1 , . . . , Jm .
We denote the eventual intervals of I Sby (I1 , . . . , Im ), denote the eventual intervals of I ′ by
(I11 , . . . , I1b , . . . , Im1 , . . . , Imb ) where Ii = bj=1 Iij for any i ∈ [m]. The eventual sets of Q will be
S
denoted by (U1 , . . . , Uk ), the sets of Q′ by (W11 , . . . , W1t , . . . , Wm1 , . . . , Wmt ) where Ii = ts=1 Wis ,
and the eventual sets of Q′′ will be denoted as Wijs = Wis ∩ Iij . We pick t = k⌈20/δ⌉, and
correspondingly T5.7 (δ, k, m) = mt.
Before choosing the partition intervals and sets themselves, we will choose sizes for the sets,
and also choose sets of indexes K1 , . .S
. , Kk describing the connection of Q to its refinement Q′ .
That is, eventually we will have Ua = (is)∈Ka Wis for every a ∈ [k]. Finally defining
S the eventual
Kia = {s
S : (is) ∈ Ka }, Uia = Ii ∩ Ua and Uija = Iij ∩ Ua , we will also have Uia = s∈Kia Wis and
Uija = s∈Kia Wijs .
We next determine the sizes |Kia |, which will be found through our first use of Lemma 4.8 (and
some further processing). We set the following parameters and multipartitions.
• λia = t|Ji ∩ Va |/|Ji |.
• N contains the singletonPsets {(ia)}, the set [m] × [k], and the set {i}
Pk× [k] for every i ∈ [m].
k
Note that in particular a=1 λia = t is an integer, so we also have a=1 ℓia = t.
20

• M contains the singleton sets {(ia)}, the set [m] × [k], and the set [m] × {a}Pfor every
m
n
k n
n
± 1 = (1 ± m
a ∈ [k]. Note that since |Ji | = m
i=1 λia =
n ) m and |Va | = (1 ±P
n ) k , we have
m
mt
mt
(1 ± 2 m+k
)
,
which
means
that
for
n
large
enough
all
the
sums
ℓ
will
equal
i=1 ia P
n
k
k ±1
m
mt
mt
(note that k is an integer), and moreover the number of a ∈ [k] for which i=1 ℓia = k + 1
will equal the number of a ∈ [k] for which this value is mt
k − 1.
′
After obtaining the values ℓP
ia through Lemma 4.8, we obtain ℓia from ℓia through the following
m
mt
′
process: For all a forP
which i=1 ℓia = k , we set ℓia = ℓia forPall i ∈ [m]. Otherwise we each time
m
mt
mt
′
take an a for which m
i=1 ℓia = k + 1 and an a for which
i=1 ℓia′ = k − 1. We choose i for
which ℓia > ℓia′ set ℓ′ia = ℓia − 1, ℓ′ia′ = ℓia′ + 1, and for all other i′ we set ℓ′i′ a = ℓi′ a and ℓ′i′ a′ = ℓi′ a′ .
P
P
mt
′
′
The resulting ℓ′ia satisfy ka=1 ℓ′ia = t, m
i=1 ℓia = k , and ℓia = λia ± 2.
Now we construct disjoint K1 , . . . , Kk ⊂ [m] × [t] so that for every i ∈ [m] and every a ∈ [k] we
have |Kia | = ℓ′ia . By the equations on the sums of ℓ′ia above this is doable, and results in |Ka | = mt
k
for every a ∈ [k].
Next, we determine the sizes of the sets Iij of I ′ and Wijs of Q′′ , through a second use of Lemma
4.8. We set the following parameters and multipartitions, for determining ℓijs = |Wijs |.
n
for all i ∈ [m], j ∈ [b] and s ∈ [t]. Since all values are the same,
• We plainly set λijs = λ = mbt
the ℓijs will have value differences bounded by 1, as befits the equipartition Q′′ .

• M consists of the singletons, the set [m] × [b] × [t], and the following.
S
– The set s∈Kia ({i} × {j} × {s}) for every i ∈ [m], j ∈ [b] and a ∈ [k]. This will make
Uija have size between ⌊ |Ktia | |Iij |⌋ and ⌈ |Ktia | |Iij |⌉ (see about |Iij | below).

– P
The set {i} × {j} × [t] for each i ∈ [m] and j ∈ [b]. Eventually we will have |Iij | =
t
n
n
′
s=1 ℓijs ∈ {⌊ mb ⌋, ⌈ mb ⌉}, so I will be equitable.
P
P
– The set {i} × [b] × [t] for each i ∈ [m]. Eventually we will have |Ii | = ts=1 bj=1 ℓijs ∈
n
n
⌋, ⌈ m
⌉}, so I will be equitable.
{⌊ m
– If n and m are both even, we also add the sets [1, m/2]×[b]×[t] and [m/2+1, m]×[b]×[t]
Pm/2
P
to M . Eventually we will have i=1 |Ii | = m
i=m/2+1 |Ii | = n/2.

• N consists of the singletons, the set [m] × [b] × [t], and the following.

– The set {i} × [b] × {s} for every i ∈ [m] and s ∈ [t]. This will ensure that the eventual
Q′ is equitable.
S
– The set s∈Kia ({i} × [b] × {s}) for every i ∈ [m] and a ∈ [k]. This will make every Uia

have size between ⌊ |Ktia | |Ii |⌋ and ⌈ |Ktia | |Ii |⌉.
S
– The set (is)∈Ka ({i} × [b] × {s}) for every a ∈ [k]. This will ensure that the eventual Q
is equitable.

After obtaining the values ℓijs for the respective set sizes |Wijs |, we finally construct the partitions
P
P
themselves. First we construct I as the only interval partition for which |Ii | = ts=1 bj=1 ℓijs for
P
every i ∈ [m], and I ′ as the only refinement of I for which |Iij | = ts=1 ℓijs for every i ∈ [m] and
j ∈ [b]. For every i ∈ [m] and s ∈ [t] let bis ∈ [k] be the index such that (is) ∈ Kbis . We now go over
the indexes i ∈ [m] and j ∈ [b], and partition the vertices of Iij into the sets Wijs so that as many
members of Vbis ∩ Iij as possible will go into every Wijs . When
P we can no longer assign vertices
in this manner (because |Iij ∩ Vb | will not necessarily equal bis =b ℓijs ), we assign the remaining
vertices to complete the sets that do not yet have the correct size.
21

S
Having defined I, I ′ and Q′′ , weSdefine Q′ by setting Wis = bj=1 Wijs for every i ∈ [m] and
s ∈ [t], and define Q by setting Ua = (is)∈Ka Wis . All properties of I, I ′ , Q, Q′ and Q′′ immediately
follow from the construction, apart from the relationship between Q and P that we still need to
prove.
Because of the way we chose the sets Wijs to maximize the number of vertices they contain
from the “correct” sets of P , The partitions P and Q will be δ-close if
k
b X
m X
X
i=1 j=1 a=1

|Va ∩ Iij | − |Ua ∩ Iij | ≤ δn.

Denote the densities according to the string SP by dP,a (Iij ) (where a ∈ [k]), and the densities
according to SQ by dQ,a (Iij ). For n large enough, because I ′ is an equipartition (interval sizes
differ by not more than 1), we have
m

b

m

k

b

k

2 XXX
1 XXX
|dP,a (Iij ) − dQ,a (Iij )|.
|Va ∩ Iij | − |Ua ∩ Iij | ≤
n
mb
a=1
a=1
i=1 j=1

i=1 j=1

From now on we bound the sums on the right hand side. Recall that J denotes the original interval
equipartition of sizeP
m, andPlet J ′ P
be any refinement of J of size mb. By Observation 5.5, for n large
1
enough we have mb a∈[k] i∈[m] j∈[b] |dP,a (Iij )−dP,a(Jij )| ≤ δ/20. By Lemma 3.7, we know that
P
P
1 P
a∈[k]
i∈[m]
j∈[b] |dP,a (Jij ) − dP,a (Ji )| ≤ δ/20. Now, recall that we chose the sets Ka so that
mb
P
1 P
|Kia | = t · dP,a (Ji ) ± 2. This means that m
a∈[k]
i∈[m] |dP,a (Ji ) − dQ,a (Ii )| ≤ δ/5 (recalling also
P
P
1 P
how we chose t). Finally, by our construction, for n large enough, mb
a∈[k]
i∈[m]
j∈[b] |dQ,a (Ii )−
dQ,a (Iij )| ≤ δ/20. This follows from the size restriction that we ensured for the sets Uia and Uija .
Using triangle inequalities with all these bounds on the density differences concludes the proof. 
Lemma 5.8 For any positive integer k, real value γ, functions r : N × N → N and f : N → N, and
any n-vertex ordered colored graph G (for large enough n), there exist an interval equipartition I into
m parts where k ≤ m ≤ S5.8 (γ, k, f, r), an equipartition Q′ of G into mt parts (not necessarily an
interval equipartition) which refines I and is additionally (f, γ)-robust, where mt ≤ T5.8 (γ, k, f, r),
and an interval equipartition I ′ into m · r(m, t) parts also refining I, so that the LCR Q′′ = Q′ ⊓ I ′
is an equipartition into exactly mt · r(m, t) parts (so each set of Q′ intersects “nicely” all relevant
intervals in I ′ ).
Moreover, if n is even, then m will be even and I will respect the middle.
Proof: For each l ∈ N we define a function gl : N → N by setting for every m ∈ N
gl (m) = m · r(m, T5.7 (δ5.4 (γ), l, m)/m).
Then we define a function h : N → N setting for every l ∈ N
h(l) = f (T5.7 (δ5.4 (γ), l, T3.6 (k, gl , γ5.7 (δ5.4 (γ), l)))).
We start with an equipartition P that is (h, δ5.4 (γ))-robust that we obtain by Observation 3.1,
and then with respect to the string SP we obtain by Observation 3.6 an interval equipartition J
that has at least k parts and is (g|P | , γ5.7 (δ5.4 (γ), |P |))-robust. Note that |P | ≤ T3.1 (1, h, δ5.4 (γ)),
and hence |J| ≤ T3.6 (k, gT (1,h,δ (γ)) , γ5.7 (δ5.4 (γ), T3.1 (1, h, δ5.4 (γ)))), which we set as our
3.1
5.4
S5.8 (γ, k, f, r).
22

If n is even, then we make sure that k is also even (otherwise we replace it with k + 1 in all of
the above), and then |J| will be even as well (and our subsequent use of Lemma 5.7 will provide
an I that respects the middle).
We then invoke Lemma 5.7 to get our partitions I = I5.7 (δ5.4 (γ), P, |J|, g|P | (|J|)/|J|), I ′ =
′ (δ
′
′
I5.7
5.4 (γ), P, |J|, g|P | (|J|)/|J|), and Q = Q5.7 (δ5.4 (γ), P, |J|, g|P | (|J|)/|J|). By the size guarantees of Lemma 5.7 we have |I| = |J| (ensuring our size bound for |I|), and |Q′ | is bounded by
T5.7 (δ5.4 (γ), T3.1 (1, h, δ5.4 (γ)), S5.8 (γ, k, f, r)), which we set as our T5.8 (γ, k, f, r).
Lemma 5.7 guarantees all requirements apart from the robustness of Q′ . To prove it, we
note that Q′ is a refinement of the partition Q = Q5.7 (δ5.4 (γ), P, |J|, g|P | (|J|)/|J|) into at most
T5.7 (δ5.4 (γ), |P |, T3.6 (k, g|P | , γ5.7 (δ5.4 (γ), |P |))) parts, where |Q| = |P | and Q and P are δ5.4 (γ)close. Hence by invoking Lemma 5.4 (which makes Q (h, γ)-robust), and then Observation 3.2, we
get that Q′ is indeed (f, γ)-robust.


6

The finite case for graphs

This section contains the proof of Theorem 1.6 for the case that the forbidden family F is finite.
This is the ordered generalization of the finite induced graph removal lemma (Theorem 1.1).
Theorem 6.1 (Finite ordered graph removal
lemma) Fix a finite set Σ with |Σ| ≥ 2. For
[nF ]
any finite family F of ordered graphs F : 2 → Σ and any ǫ > 0 there exists δ = δ(F, ǫ) > 0,

such that any ordered graph G : V2 → Σ that is ǫ-far from F-freeness contains at least δnq induced
copies of some graph F ∈ F.
The proof of Theorem 1.6 is completed in Section 7, by considering the case where F is infinite.
The proof for the infinite case mostly relies on ideas and tools presented in this section, but requires
another step, which is motivated by the ideas of Alon and Shapira [8] for the unordered case.

6.1

Representing subsets

Fix a finite alphabet Σ and a finite family F over Σ. Let dF denote the largest number of vertices in a graph from F. Now let G = (V, c) be an n-vertex Σ-colored graph and suppose that
I, I ′ , Q′ , Q′′ are equipartitions of G of sizes m, mb, mt, mbt respectively, so that I, I ′ are interval
partitions, I ′ and Q′ refine I, and Q′′ = I ′ ⊓ Q′ . More specifically, we write I = (I1 , . . . , Im ),
′
′′
I ′ = (I11 , . .S
. , I1b , . . . , Im1
St, . . . , Imb ), Q = (U11 , . . . , U1t , . . . , Um1 , . . . , Umt ), Q = (U111 , . . . , Umbt ),
b
where Ij = r=1 Ijr = s=1 Ujs for any j ∈ [m] and Ujrs = Ijr ∩ Ujs for any j ∈ [m], r ∈ [b], s ∈ [t].
Note that this is the same setting as the one obtained in Lemma 5.8, but we do not apply the
lemma at this point; in particular, we currently do not make any assumptions on the equipartitions
other than those stated above. We may and will assume whenever needed that n is large enough
(as a function of all relevant parameters), and that any tuple of subsets of V considered in this
section has at least two parts (i.e., it is not trivial).
Definition 6.2 (Representing subsets) Let α, β, µ > 0 be real numbers and suppose that A =
(A1 , . . . , Al ) is an equipartition of G. We say that B = (B1 , . . . , Bl ) represents A if Bi ⊆ Ai for
any i ∈ [l]. Furthermore, we say that B (α, β, µ)-represents A if the following holds.
• Bi ⊆ Ai and |Bi | ≥ αn for any i ∈ [l].
• All pairs (Bi , Bj ) with i < j ∈ [l] are β-regular.
23

•

1
l
2

()

P

i<j∈[l]

P

σ∈Σ

|dσ (Bi , Bj ) − dσ (Ai , Aj )| ≤ µ.

The following lemma is a slight variant of Corollary 3.4 in [4], suggesting that partitions that
are robust enough have good representing subsets. The proof follows along the same lines of the
proof of Lemma 3.2 in [21], so we omit it.
Lemma 6.3 ([4, 21]) For any µ > 0 and function β : N → (0, 1) there exist a function f =
(β,µ)
f6.3 : N → N and a real number γ = γ6.3 (µ) > 0, such that for any integer l > 0 there is a real
number α = α6.3 (β, µ, l) > 0, all satisfying the following. If A = (A1 , . . . , Al ) is an (f, γ)-robust
equipartition of G, then there exists a tuple B = (B1 , . . . , Bl ) which (α, β(l), µ)-represents A.
The next lemma is not hard to derive from Lemma 6.3 using Lemma 3.4, and is more suitable
to our setting.
Lemma 6.4 For any function β : N → (0, 1), function g : N → N, and real number µ > 0, there
β,g,µ
: N → N and a real number γ = γ6.4 (µ) > 0, so that for any integer l > 1
exist a function f = f6.4
there exists α = α6.4 (β, g, µ, l) > 0 satisfying the following: If A = (A1 , . . . , Al ) is an (f, γ)-robust
′
equipartition of G and
SLA = (A11 , . . . , A1L , . . . , Al1 , . . . AlL ) is an equitable refinement of A, where
lL ≤ g(l) and Ai = j=1 Aij for any i ∈ [l], then there exists B = (B11 , . . . , B1L , . . . Bl1 , . . . , BlL )
which (α, β(lL), µ)-represents A′ , and satisfies
X X X
1
|dσ (Bij , Bi′ j ′ ) − dσ (Ai , Ai′ )| ≤ 2µ.

l
2
2 L i<i′ ∈[l] j,j ′ ∈[L] σ∈Σ
(β,µ)

β,g,µ
= f6.3 ◦ g and γ = γ6.4 (µ) = min{δ3.4 (|Σ|, µ), γ6.3 (µ)}. Also pick
Proof: Pick f = f6.4
α = α6.4 (β, g, µ, l) = α6.3 (β, µ, g(l)), and suppose that A is (f, γ)-robust. By Observation 3.2
(β,µ)
and the fact that |A′ | = lL ≤ g(l), we know that A′ is (f6.3 , γ6.3 (µ))-robust, so by Lemma 6.3
there exists a tuple B = (B11 , . . . , B1L , . . . Bl1 , . . . , BlL ) which (α6.3 (β, µ, lL), β(lL), µ)-represents
A′ , and by the monotonicity of α, B also (α, β(lL), µ)-represents A′ . In particular,

X X X
1
|dσ (Bij , Bi′ j ′ ) − dσ (A′ij , A′i′ j ′ )| ≤ µ.

l
2
L
2
i<i′ ∈[l] j,j ′ ∈[L] σ∈Σ

Now by Lemma 3.4, and since |A′ | ≤ g(l) ≤ f (l),

X X X
1
|dσ (A′ij , A′i′ j ′ ) − dσ (Ai , Ai′ )| ≤ µ.

l
2
2 L i<i′ ∈[l] j,j ′ ∈[L] σ∈Σ

Combining the above two inequalities and using the triangle inequality concludes the proof.

6.2



The graph of the representatives and its coloring

For the next step, let Γ = Γ(Σ, t) denote the collection of all t × t matrices M of the following form:
Each entry of M is a non-empty subset of the color set Σ (where a subset is allowed to appear in
2
multiple entries of M ), so |Γ(Σ, t)| < 2|Σ|t .

24

Definition 6.5 (Threshold color matrices, threshold graphs, undesirability) Suppose
that W = (W111 , . . . , Wmbt ) represents Q′′ and define Wjr = (Wjr1 , . . . , Wjrt ) and Xj = (Uj1 , . . . , Ujt )
for any j ∈ [m] and r ∈ [b]. Let 0 < η < ρ < 1/|Σ| be real numbers.
For two t-tuples A = (A1 , . . . , At ) and B = (B1 , . . . , Bt ) where As , Bs ⊆ V for any s ∈ [t], the
η-threshold matrix M = M (A, B, η) ∈ Γ of the pair A, B is the t × t matrix whose (s, s′ ) entry (for
(s, s′ ) ∈ [t]2 ) is the set of colors σ ∈ Σ that satisfy dσ (As , Bs′ , c ↾As ,Bs′ ) ≥ η. Note that this set
cannot be empty since η < 1/|Σ|.
η
The (η, W )-threshold graph HW
is an (ordered) Γ-colored graph defined as follows: The vertices
η
′
of HW are all parts of I , and the color of the edge Ijr Ij ′ r′ is M (Wjr , Wj ′ r′ , η).
η
2 satisfy
is ρ-undesirable if j ′ > j and at least ρt2 of the pairs (s, s′ ) ∈ [t]
The edge Ijr Ij ′ r′ of HW
η
m 2
′
′
M (Xj , Xj ′ , ρ)[s, s ] * M (Wjr , Wj ′ r′ , η)[s, s ]. Finally, HW is ρ-undesirable if at least ρ 2 b of the
edges Ijr Ij ′ r′ in it are ρ-undesirable, and ρ-desirable otherwise.
In other words, an edge Ijr Ij ′ r′ is undesirable if there are many pairs of sets Wjrs, Wj ′ r′ s′ in W ,
for which the density of some original edge color in Wjrs × Wj ′ r′ s′ is significantly smaller than its
η
is undesirable if it contains many undesirable edges. Note that the set
density in Ujs × Uj ′ s′ . HW
η
η
is undesirable or not
of ρ-undesirable edges in HW
is orderly: Whether an edge Ijr , Ij ′ r′ of HW
depends only on its color M (Wjr , Wj ′ r′ , η) and on M (Xj , Xj ′ , ρ).
The following lemma relates the robustness of our partitions to the desirability of the resulting
threshold charts.
Lemma 6.6 For any 0 < ρ < 1/|Σ| and functions β : N → (0, 1/|Σ|) and g : N → N, there
ρ,β,g
: N → N and positive real numbers µ = µ6.6 (ρ) ≤ ρ, γ = γ6.6 (ρ) and
exist a function f = f6.6
α = α6.6 (ρ, β, g, m, t), such that if Q′ is (f, γ)-robust and |Q′′ | ≤ g(|Q′ |), then there is a tuple
ρ/2
W = (W111 , . . . , Wmbt ) which (α, β(mbt), µ)-represents Q′′ , and furthermore HW is ρ-desirable.
ρ/2

Proof: Let 0 < ρ < 1/|Σ| and suppose that HW is ρ-undesirable, where W is any tuple that
represents Q′′ . The definition of undesirability implies that
 2 2
X
X X X
ρ m
b ρt ρ/2
ρ3
1
2


′ r ′ s′ ) − dσ (Ujs , Uj ′ s′ )| ≥
.
(2)
|d
(W
,
W
=
σ
jrs
j
m 2 2
m 2 2
2
′
′
′
2 t b
2 t b
σ∈Σ
j<j ∈[m] s,s ∈[t] r,r ∈[b]

Indeed, if M (Xj , Xj ′ , ρ)[s, s′ ] * M (Wjr , Wj ′ r′ , ρ/2)[s, s′ ] then there exists some σ ∈ Σ for which
dσ (Ujs , Uj ′ s′ ) ≥ ρ but dσ (Wjrs , Uj ′ r′ s′ ) ≤ ρ/2, so each such event contributes ρ/2 to the sum in the
left hand side.
ρ/2
Therefore, HW is ρ-desirable if the above sum is smaller than ρ3 /2. Thus, we pick µ(ρ) = ρ3 /5.
β,g,µ
ρ,β,g
, γ6.6 (ρ) = γ6.4 (µ), and α6.6 (ρ, β, g, m, t) = α6.4 (β, g, µ, mt). Since Q′
= f6.4
Also pick f6.6


β,g,µ
, γ6.4 (µ) -robust, and since |Q′′ | ≤ g(|Q′ |), Lemma 6.4 implies that there exists W =
is f6.4
(W111 , . . . , Wmbt ) which (α, β(mbt), µ)-represents Q′ , also guaranteeing that the left hand side of
ρ/2

(2) is at most 2µ < ρ3 /2, so HW is ρ-desirable.
Definition 6.7 (Nicely colored subgraph) Let
SmW = (W111 , . . .η, Wmbt ) be a tuple of subsets that
′′
represents Q and let η > 0. A subgraph D = ( j=1 Dj , cD ) of HW is said to be nicely colored if
the following conditions hold.
• For any j ∈ [m], Dj ⊆ Ij and |Dj | = dF .
25

(D)

• For any fixed j ∈ [m], all edges inside Dj have the same color from Γ, denoted by Cjj .
• For any fixed j < j ′ ∈ [m], all edges between Dj and Dj ′ have the same color from Γ, denoted
(D)
by Cjj ′ .
The next lemma follows directly from Corollary 4.3.
Lemma 6.8 For any two integers m, t > 0 there exists R = R6.8 (m, t) satisfying the following: If
b ≥ R6.8 (m, t), then for any tuple W = (W111 , . . . , Wmbt ) that represents Q′′ and any η > 0 there
η
η
exists a nicely colored subgraph D = D6.8 (W, η) of HW
. Moreover, if HW
is ρ-desirable for some
2
η < ρ < 1/|Σ|, then the number of ρ-undesirable edges in D is at most 2ρ m
2 (dF ) .
2

Proof: Take R6.8 (m, t) = R4.3 (2|Σ|t , m, dF ) > R4.3 (|Γt |, m, dF ). Since the set of ρ-undesirable
η
η
edges in HW
is orderly, we may apply Corollary 4.3 on HW
, to get a nicely colored subgraph
D
η
m 2
of it. If HW is ρ-desirable for some η < ρ < 1/|Σ|, then by definition it has at most ρ 2 b ρ2
undesirable edges, and so the last condition in Corollary 4.3 implies that D has at most 2ρ m
2 (dF )
ρ-undesirable edges.


6.3

Cleaning the original graph

Definition 6.9 (Cleaned graph) Let W = (W111 , . . . , Wmbt ) be a tuple of subsets which repreη
sents Q′′ , let η > 0, and suppose that D is a nicely colored subgraph of HW
. The cleaned graph
′
′
′
G = G (G, D) = (V, c ) is defined as follows. For any u < v ∈ V where u ∈ Ijs and v ∈ Ij ′ s′ ,
(D)
we set c′ (uv) = c(uv) if c(uv) ∈ Cjj ′ [s, s′ ], and otherwise we set c′ (uv) to an arbitrary color from
(D)

Cjj ′ [s, s′ ].

η
The next lemma states that if D comes from a desirable HW
, then G′ (G, D) is close to G.
η
Lemma 6.10 Suppose that D is a nicely
colored subgraph of some HW
with W representing Q′′

2
′
′
and 0 < η < ρ, such that at most 2ρ m
2 dF edges of D are ρ-undesirable. Then G = G (G, D) is
(7|Σ|ρ + 2/m)-close to G, where m = |I|.

Proof: Write G′ = (V, c′ ) and let J denote the set of pairs j < j ′ ∈ [m] such that Dj × Dj ′ contains

an undesirable edge. An edge e ∈ V2 may satisfy c′ (e) 6= c(e) only if at least one of the following
holds (some of the inequalities stated below rely on the assumption that n is large enough).


P
|Ij |
2 n
1. e lies inside some part Ij of I. The number of such edges is m
≤ m ⌈n/m⌉
<m
j=1 2
2 .
2

2. e ∈ Ij1 × Ij2 where (j1 , j2 ) ∈ J . But |J | ≤ 2ρ m
2 : The number of ρ-undesirable edges in D is
exactly |J |d2F , since D is orderly (with
 2 respect to the parts D1 , . . . , Dm ) and has dF vertices
in each Di . Thus, |J |d2F ≤ 2ρ m
2 dF , which implies
 the desired inequality. Therefore, the
number of edges e of of this type is less than 3ρ n2 .

/ J , and M (Xj , Xj ′ , ρ)[s, s′ ] * Cjj ′ (D)[s, s′ ]. But
3. e ∈ Ujs × Uj ′ s′ where j < j ′ ∈ [m], (j, j ′ ) ∈
′
2
since the number of pairs (s, s ) ∈ [t] that satisfy this condition for a fixed (j, j ′ ) ∈
/ J is at
2
most ρt , only at most 3ρ|Ij ||Ij ′ |/2 of the edges e ∈ Ij × Ij ′ belong here, implying that the
total number of edges of this type is less than 2ρ n2 .
26

/ J , and M (Xj , Xj ′ , ρ)[s, s′ ] ⊆ Cjj ′ (D)[s, s′ ], but
4. e ∈ Ujs × Uj ′ s′ where j < j ′ ∈ [m], (j, j ′ ) ∈
dc(e) (Ujs , Uj ′ s′ ) < ρ. The number of such edges in Ujs × Uj ′ s′ is at most |Σ| · ρ|Ujs ||Uj ′ s′ |, and
the total number of such edges is less than 2ρ|Σ| n2 .

Therefore, the total number of edges e with c(e) 6= c′ (e) is less than (7ρ|Σ| + 2/m) n2 .

Lemma 6.11 Let W = (W111 , . . . , Wmbt ) be a tuple that represents Q′′ and let η > 0. If D is a
η
and the cleaned G′ (G, D) contains a copy of some F = ([nF ], cF ) ∈ F,
nicely colored subgraph of HW
then there exist Wj1 r1 s1 , . . . , WjnF rnF snF ∈ W with the following properties.
• For any i ∈ [nF − 1], either ji+1 > ji , or ji+1 = ji and ri+1 > ri .
• For any i < i′ ∈ [nF ] it holds that dcF (ii′ ) (Wji ri si , Wji′ ri′ si′ ) ≥ η.
Proof: Suppose that G′ (G, D) = (V, c′ ) contains a copy of F whose vertices in V are v1 <
. . . < vnF . For any i ∈ [nF ], let ji ∈ [m], si ∈ [t] be the indices for which vi ∈ Iji si and denote
the vertices of D inside Iji by Dji = {Iji ri1 , . . . , Iji ridF }, where ri1 < . . . < ridF ∈ [b] for any
i ∈ [nF ]. Then for any i, i′ ∈ [nF ] and l, l′ ∈ [dF ], for which either i < i′ , or i = i′ and l < l′ ,
(D)
it holds that cF (ii′ ) = c′ (vi , vi′ ) ∈ Cji j ′ [si , si′ ] = M (Wji ril , Wji′ ri′ l′ , η)[si , si′ ], and so by definition
i
dcF (ii′ ) (Wji ril si , Wji′ ri′ l′ si′ ) ≥ η.
Therefore, the sets Wj1 r11 s1 , . . . , WjnF rnF nF snF satisfy the conditions of the lemma: They exist,
since nF ≤ dF . The first condition holds since j1 ≤ . . . ≤ jnF , and if ji = ji+1 then rii = r(i+1)i <
r(i+1)(i+1) . The second condition holds by the first paragraph of the proof (putting l = i and l′ = i′ ).


6.4

Proof of Theorem 6.1

Suppose that G is ǫ-far from F-freeness. Take the function r = R6.8 (note that r is a two-variable
function) and let g : N → N be defined by g(l) = lr(l, l) for any l ∈ N. Also take k = ⌈20/ǫ⌉,
ρ/2
ρ = ǫ/8|Σ|, and β : N → (0, 1/|Σ|) as a constant function that satisfies β(l) = β3.5 (dF ) for any

ρ,β,g
, and γ = γ6.6 (ρ).
l ∈ N. Also take f = f6.6
Apply Lemma 5.8 with parameters k, γ, r, f , obtaining the equipartitions I, I ′ , Q′ , Q′′ of sizes
m, mb, mt, mbt as in the statement of the lemma, where k ≤ m ≤ S5.8 (γ, k, f, r), mt ≤ T5.8 (γ, k, f, r),
b = r(m, t) = R6.8 (m, t), and Q′ is (f, γ)-robust. Observe that |Q′′ | = mtr(m, t) ≤ g(mt) = g(|Q′ |).
Next, define α = α6.6 (ρ, β, g, S5.8 (γ, k, f, r), T5.8 (γ, k, f, r)) and µ = µ6.6 (ρ). By Lemma 6.6,
ρ/2
ρ/2
and since β(l) = β3.5 (dF ) for any l ∈ N, there is a tuple W which (α, β3.5 (dF ), µ)-represents Q′′ ,
ρ/2

b = R6.8 (m, t), there is a nicely colored subgraph
and HW is ρ-desirable. By Lemma 6.8, and since

2 ρ-undesirable edges.
D = D6.8 (W, ρ/2), containing at most 2ρ m
(d
)
F
2
Lemma 6.10 implies that G′ = G′ (G, D) is (7|Σ|ρ + 2/m)-close to G; but 7|Σ|ρ + 2/m ≤
7ǫ/8 + 2/k < ǫ, so G′ contains a copy of some F = ([nF ], cF ) ∈ F. Therefore, by Lemma 6.11
(putting η = ρ/2 in the statement of the lemma), there exist Wj1 r1 s1 , . . . , WjnF ,rnF ,snF ∈ W that
ρ/2

satisfy the conditions of the lemma. As all pairs of sets from W are β3.5 (nF )-regular (since
nF ≤ dF ), we can apply Lemma 3.5 to conclude that the number of F -copies in G is at least δnq
for q = nF ≤ dF and δ = κ3.5 (ρ/2, nF )αnF ≥ κ3.5 (ρ/2, dF )αdF , concluding the proof.

27

7

The infinite case

In this section we use the same notation as in Section 6, unless stated otherwise. The proof of
Theorem 1.6 follows that of Theorem 6.1 almost word by word, with only one major difference: In
the proof of Theorem 6.1 we have picked dF to be the largest number of vertices in a graph from F,
and showed that if G is ǫ-far from F-freeness than there must be a set of at most dF representatives
of parts in Q′′ , that span a large number of F -copies for some F ∈ F. However, in the infinite case,
such a definition of dF cannot work. Instead, we take dF (m, t) to be a parameter that depends on
the family F, the size of the alphabet |Σ| and the integers m, t (where m = |I|, mt = |Q′ |). It is
then shown that with this choice of dF , the proof follows similarly to the finite case, with Lemmas
6.8 and 6.11 being replaced with similar lemmas that are suitable for the infinite case (Lemmas 7.3
and 7.5 below, respectively).

7.1

Embeddability

Definition 7.1 (Embeddability) For a finite alphabet Σ, integers m, t > 0, Γ(Σ, t)-colored graph
with loops H = ([m], cH ) and Σ-colored graph F = ([nF ], cF ), we say that F is embeddable in H
if there exists a mapping h : [nF ] → VH with the following properties.
• h is weakly order-preserving: h(1) ≤ . . . ≤ h(nF ).
• There exist integers s1 , . . . , snF ∈ [t] so that cF (ii′ ) ∈ cH (h(i), h(i′ ))[si , si′ ] for any i < i′ ∈
[nF ].
A family F of Σ-colored graphs is embeddable in H if some F ∈ F is embeddable in H.
The next lemma states that the desired dF is indeed well-defined. It is similar in spirit to the
ideas of Alon and Shapira [8] (see Section 4 there).
Lemma 7.2 Fix a finite alphabet Σ. For any (finite or infinite) family F of Σ-ordered graphs and
(7.2)
integers m, t > 0, there exists dF = dF (m, t) with the following property. If H = ([m], cH ) is a
Γ(Σ, t)-colored graph with loops, and if F is embeddable in H, then there is a graph F ∈ F which
(7.2)
is embeddable in H and has at most dF (m, t) vertices.
Proof: Let H = Hm,t denote the set of all Γ(Σ, t)-colored graphs H = ([m], cH ) with loops, such
2 2
2
that F is embeddable in H. Note that |Hm,t | ≤ |Γ(Σ, t)|m ≤ 2|Σ|t m . For any H ∈ H let FH ⊆ F
denote the collection of all graphs in F that are embeddable in H. Finally define
(7.2)
dF (m, t) = max

min |F |

H∈Hm,t F ∈FH

where |F | denotes the number of vertices in F . Since Hm,t is finite, and since the set FH is non(7.2)
empty for any H ∈ H (by definition of H), the function dF (m, t) is well defined. Now let H be a
graph as in the statement of the lemma and suppose that F is embeddable in H. Then H ∈ Hm,t ,
(7.2)

so there exists F ∈ FH of size at most dF (m, t).

28

7.2

Adapting the proof for infinite families

For what follows, a nicely colored (m, t)-subgraph is defined exactly like a nicely colored subgraph
(7.2)
(see Definition 6.7), except that each set Dj is of size dF (m, t). The following is a variant of
Lemma 6.8 for the infinite case.
Lemma 7.3 For any two integers m, t > 0 there exists R = R7.3 (m, t) satisfying the following: If
b ≥ R7.3 (m, t), then for any tuple W = (W111 , . . . , Wmbt ) that represents Q′′ and any η > 0 there
η
η
is ρ-desirable for
. Moreover, if HW
exists a nicely colored (m, t)-subgraph D = D7.3 (W, η) of HW
m (7.2 )
some η < ρ < 1/|Σ|, then the number of ρ-undesirable edges in D is at most 2ρ 2 (dF (m, t))2 .
The proof of Lemma 7.3 is essentially identical to that of Lemma 6.8, with any occurrence of dF
2
(7.2 )
(7.2)
replaced by dF (m, t). In particular we take R7.3 (m, t) = R4.3 (2|Σ|t , m, dF (m, t)).
Next we state the variant of Lemma 6.10 for the infinite case. The proof is essentially identical.

η
with W representing
Lemma 7.4 Suppose that D is a nicely colored (m, t)-subgraph of some HW

(
7.2
)
(m, t))2 edges of D are ρ-undesirable. Then
Q′′ and 0 < η < ρ, such that at most 2ρ m
2 (dF
′
′
G = G (G, D) is (7|Σ|ρ + 2/m)-close to G, where m = |I|.

The next lemma is the variant of Lemma 6.11 that we use in the infinite case. In contrast to
the previous two lemmas, here the proof is slightly modified, and makes use of Lemma 7.2.
Lemma 7.5 Let W = (W111 , . . . , Wmbt ) be a tuple that represents Q′′ and let η > 0. If D is a
η
nicely colored (m, t)-subgraph of HW
and G′ (G, D) contains a copy of a graph from F, then there
(7.2)
exist F = ([nF ], cF ) ∈ F, where nF ≤ dF (m, t), and sets Wj1 r1 s1 , . . . , WjnF rnF snF ∈ W , with the
following properties.
• For any i ∈ [nF − 1], either ji+1 > ji , or ji+1 = ji and ri+1 > ri .
• For any i < i′ ∈ [nF ] it holds that dcF (ii′ ) (Wji ri si , Wji′ ri′ si′ ) ≥ η.
(D)

Proof: Consider the Γ-colored graph with loops D ′ = ([m], cD′ ): For any j ≤ j ′ , cD′ (jj ′ ) = Cjj ′ .
Suppose that G′ (G, D) = (V, c′ ) contains a copy of A = ([nA ], cA ) ∈ F, whose vertices in V are
v1 < . . . < vnA . For any i ∈ [nA ], let ji ∈ [m], si ∈ [t] be the indices for which vi ∈ Iji si . Then for any
(D)
i < i′ ∈ [nA ] we have cA (ii′ ) = c′ (vi vi′ ) ∈ Cji j ′ [si , si′ ] = cD′ (ji ji′ )[si , si′ ], and so A is embeddable in
i
D ′ (by the mapping i 7→ ji ). By Lemma 7.2, there exists F = ([nF ], cF ) ∈ F which is embeddable
(7.2)
in D ′ , where nF ≤ dF (m, t). Let h : [nF ] → D ′ denote a mapping that satisfies the conditions of
Definition 7.1 and let s′1 , . . . , s′nF ∈ [t] be the indices satisfying cF (ii′ ) ∈ cD′ (h(i), h(i′ ))[s′i , s′i′ ] for
any i < i′ ∈ [nF ].
′ <
′ , . . . , Ih(i)r ′
For any i ∈ [nF ] denote the vertices of D inside Ih(i) by Ih(i)ri1
, where ri1
idF (m,t)

′
′ s′ , . . . , Wh(n )r ′
′
satisfy the desired
. . . < rid
∈ [b] for any i ∈ [nF ]. The sets Wh(1)r11
F nF nF snF
1
F (m,t)
(7.2)
conditions: They exist, since nF ≤ dF (m, t), the first condition holds since h is order-preserving,
(D)
and the second condition holds since cF (ii′ ) ∈ cD′ (h(i), h(i′ ))[s′i , s′i′ ] = Ch(i)h(i′ ) [s′i , s′i′ ].


Proof of Theorem 1.6 The proof goes along the same lines as the proof of Theorem 6.1, but any
occurrence of dF in the proof of Theorem 6.1 and the accompanying lemmas is replaced here by
(7.2)
dF (m, t), including in the definitions of the functions β, r, and the term nicely colored subgraph
is replaced by nicely colored (m, t)-subgraph. More specifically, here are the exact changes needed
with respect to the proof of Theorem 6.1.
29

ρ/2

• We take the functions β = β3.5 and r = R7.3 (in the finite case we took β as a suitable
constant function and r = R6.8 ). The function g is defined as g(l) = lr(l, l). Following the
application of Lemma 5.8, we have b = R7.3 (m, t).
• As in the the proof of Theorem 6.1, there is a tuple W which (α, β(mbt), µ)-represents Q′′ ,
ρ/2
and HW is ρ-desirable. By Lemma 7.3, and by our new choice of b, there is a nicely colored
2
  (7.2)
ρ/2
(m,
t)
d
ρ-undesirable edges.
(m, t)-subgraph D of HW , with at most 2ρ m
F
2

• Lemma 7.4 implies that G′ contains a copy of a graph from F. Now Lemma 7.5 implies
(7.2)
the existence of sets Wj1 r1 s1 , . . . , WjnF ,rnF ,snF ∈ W with nF ≤ dF (m, t), that satisfy the
ρ/2

conditions of the lemma for η = ρ/2. Since all pairs of sets from W are β3.5 (mbt)-regular,
ρ/2
(7.2)
and since mbt ≥ b ≥ dF (m, t) ≥ nF , these pairs are also β3.5 (nF )-regular. We apply
Lemma 3.5 to get that the number of F -copies in G is at least δnq for
(7.2)
(7.2)
q = nF ≤ dF (m, t) ≤ dF (S5.8 (γ, k, f, r), T5.8 (γ, k, f, r)),
 (7.2)

(7.2 )
δ = κ3.5 (ρ/2, nF ) αnF ≥ κ3.5 ρ/2, dF (m, t) αdF (m,t)
(7.2 )
(7.2 )
d
(S
5.8 (γ,k,f,r),T5.8 (γ,k,f,r)) .
≥ κ3.5 (ρ/2, dF (S5.8 (γ, k, f, r), T5.8 (γ, k, f, r)))α F

Indeed, the above bounds for q and δ depend only on |Σ|, ǫ, F, and not on n.

7.3



Adapting the proof for matrices

Finally we give a sketch of the proof of Theorem 1.8 for square matrices. The proof is very similar
to the graph case, so we only describe why the proof for graphs also works here. Finally, we describe
shortly how the proof can be adapted to the case of non-square matrices.
Proof sketch for Theorem 1.8 Given a square matrix M : U × V → Σ where U, V are ordered,
and a family F of forbidden submatrices, consider the Σ′ -colored graph G = (U ∪ V, c) where
Σ′ = Σ ∪ {σ0 } for some σ0 ∈
/ Σ, and the union U ∪ V is ordered as follows: All elements of V come
after all elements of U , and the internal orders of U and V remain as before. The edge colors of G
satisfy c(uv) = M (uv) for any u ∈ U and v ∈ V , and c(uv) = σ0 otherwise.
The proof now follows as in the graph case. It is important to note that while in the graph case
one is allowed to change the color of any edge, here we are not allowed to change the color of an
edge from or to the color σ0 . However, the proof still works, by the following observations.
• Since |U | = |V |, the number of vertices in G is even, and so the interval partition I obtained
here “respects the middle”. That is, each part Ij of I will be fully contained in U or in V .
Therefore, for every two parts Ij , Ij ′ of I, either all edges in Ij × Ij ′ are colored by σ0 or none
of them is colored by σ0 .
• It follows that the set of edges of the cleaned graph G′ = G′ (G, D) that are colored by σ0
is identical to that of G. In other words, to generate the cleaned graph we do not modify
edge colors to or from σ0 . Since G is made F-free only by modifying colors between U and
V to other colors in Σ, one needs to modify at least ǫ|U ||V | edge colors, so the proof follows
without changing the main arguments.

30


The above proof works for square matrices, but it can be adapted to general m × n matrices:
If m = Θ(n), then the condition on I needed is slightly different than respecting the middle,
but this only slightly changes the structure of the equipartitions that we obtain via Lemma 5.8,
without significantly affecting the proof. The proof can also be formulated for matrices with, say,
m = o(n) and m = ω(1), but then Lemma 5.8 needs to be especially adapted to accommodate
the two “types” of vertices (row and column). Essentially we will have two interval equipartitions,
one of the row vertices and one of the column vertices, along with their corresponding refinements.
Finally, the case where m = Θ(1) is essentially the case of testing one-dimensional strings; strings
can be handled as per the discussion in the end of Subsection 1.1.
It is important to note that one cannot use Theorem 1.6 as a black box to prove Theorem 1.8,
as the distance of the graph G to F-freeness might (potentially) be significantly smaller than ǫ,
considering that the set of σ0 -colored edges in the F-free graph that is closest to G might differ
from the set of σ0 -colored edges in G.

References
[1] N. Alon, Testing subgraphs in large graphs, Random Structures & Algorithms 21 (2002), 359–
370; also FOCS’01: Proc. 42nd Annu. Symp. Foundations of Computer Science (FOCS), IEEE,
2001, 434–441.
[2] N. Alon, O. Ben-Eliezer, Removal lemmas for matrices, arXiv:1609.04235, 2016.
[3] N. Alon, R. A. Duke, H. Lefmann, V. Rödl, R. Yuster, The algorithmic aspects of the regularity
lemma, Journal of Algorithms 16 (1994), 80–109; also FOCS’92: Proc. 33th Annu. Symp. Foundations of Computer Science (FOCS), IEEE, 1992, 473–481.
[4] N. Alon, E. Fischer, M. Krivelevich, M. Szegedy, Efficient testing of large graphs, Combinatorica 20 (2000), 451–476; also FOCS’99: Proc. 40th Annu. Symp. Foundations of Computer
Science, IEEE, 1999, 656–666.
[5] N. Alon, E. Fischer, I. Newman, Efficient testing of bipartite graphs for forbidden induced
subgraphs, SIAM J. Comput. 37 (2007), 959–976.
[6] N. Alon, E. Fischer, I. Newman, A. Shapira, A combinatorial characterization of the testable
graph properties: it’s all about regularity, SIAM J. Comput. 39 (2009), 143–167; also STOC’06:
Proc. 38th Ann. ACM Symp. Theory of Computing, 251–260, ACM, 2006.
[7] N. Alon, M. Krivelevich, I. Newman, M. Szegedy, Regular languages are testable with a constant number of queries, SIAM J. Comput. 30 (2001), 1842–1862; also FOCS’99: Proc. 40th
Annu. Symp. Foundations of Computer Science, IEEE, 1999, 645–655.
[8] N. Alon, A. Shapira, A characterization of the (natural) graph properties testable with one-sided
error, SIAM J. Comput. 37 (2008), 17031727; also FOCS’05: Proc. 46th Annu. Symp. Foundations of Computer Science, IEEE, 2005, 429–438.
[9] N. Alon, A. Shapira, Every monotone graph property is testable SIAM J. Comput. 38 (2008),
505–522; also STOC’05: Proc. 37th Ann. ACM Symp. Theory of Computing, 128–137, ACM,
2005.
31

[10] P. Awasthi, M. Jha, M. Molinaro, S. Raskhodnikova, Testing Lipschitz functions on hypergrid
domains, Algorithmica 74 (2016), 1055–1081.
[11] M. Axenovich, Y. Person, S. Puzynina, A regularity lemma and twins in words, J. Combin. Theory Ser. A 120 (2013), 733–743.
[12] O. Ben-Eliezer, S. Korman, D. Reichman, Deleting and testing forbidden patterns in multidimensional arrays, arXiv:1607.03961, 2017.
[13] P. Berman, M. Murzabulatov, S. Raskhodnikova, Tolerant testers of image properties,
ICALP’16: Proc. 43rd International Colloquium on Automata, Languages, and Programming
(ICALP), 90:1–90:14, 2016.
[14] E. Blais, S. Raskhodnikova, G. Yaroslavtsev, Lower bounds for testing properties of functions
over hypergrid domains, CCC’14: IEEE 29th Conf. Computational Complexity, IEEE, 2014,
309–320.
[15] C. Borgs, J. Chayes, L. Lovász, V. T. Sós, B. Szegedy, K. Vesztergombi, Graph limits and
parameter testing, STOC’06: Proc. 38th Ann. ACM Symp. Theory of Computing, 261–270,
ACM, 2006.
[16] A. Brandstädt, V. B. Le, J. P. Spinrad, Graph classes: a survey, SIAM Monographs on Discrete
Mathematics and Applications, SIAM, 1999.
[17] C. Canonne, E. Grigorescu, S. Guo, A. Kumar, K. Wimmer, Testing k-monotonicity, ITCS’17:
Proc. 8th Innovations in Theoretical Computer Science, to appear.
[18] D. Chakrabarty, C. Seshadhri, Optimal bounds for monotonicity and Lipschitz testing over
hypercubes and hypergrids, STOC’13: Proc. 2013 ACM Symp. Theory of Computing, 419–428,
ACM, 2013.
[19] D. Chakrabarty, C. Seshadhri, An optimal lower bound for monotonicity testing over hypergrids, Theory Comput. 10 (2014), 453–464.
[20] D. Conlon, J. Fox, Bounds for graph regularity and removal lemmas, Geom. Funct. Anal. 22
(2012), 1191–1256.
[21] D. Conlon, J. Fox, Graph removal lemmas, Surveys in Combinatorics 2013, 1–49, London
Math. Soc. Lecture Note Ser. 409, Cambridge Univ. Press, Cambridge, 2013.
[22] D. Conlon, J. Fox, C. Lee, B. Sudakov, Ordered Ramsey numbers, J. Combin. Theory Ser. B
122 (2017), 353–383.
[23] P. Damaschke, Forbidden ordered subgraphs, Topics in combinatorics and graph theory, 219–
229, Physica, 1990.
[24] U. Feige, T. Koren, M. Tennenholtz, Chasing ghosts: competing with stateful policies, SIAM
J. Comput. 46 (2017), 190–23; also FOCS’14: Proc. 55th Annu. Symp. Foundations of Computer Science, IEEE, 2014, 100–109.
[25] E. Fischer, I. Newman, Testing of matrix-poset properties, Combinatorica 27 (2007), 293–327.

32

[26] E. Fischer, I. Newman, Testing versus estimation of graph properties, SIAM J. Comput. 37
(2007), 482–501; also STOC’05: Proc. 37th Ann. ACM Symp. Theory of Computing, 138–146,
ACM, 2005.
[27] E. Fischer, E. Rozenberg, Lower bounds for testing forbidden induced substructures in bipartitegraph-like combinatorial objects, Proc. RANDOM 2007, 464–478.
[28] J. Fox, A new proof of the graph removal lemma, Ann. of Math. 174 (2011), 561–579.
[29] L. Gishboliner, A. Shapira, Removal lemmas with polynomial bounds, STOC’17: Proc. 2017
ACM Symp. Theory of Computing, to appear.
[30] O. Goldreich (ed.), Property Testing: Current Research and Surveys, Vol. 6390 of Lecture
Notes in Comput. Sci., Springer, 2010.
[31] O. Goldreich, S. Goldwasser, D. Ron, Property testing and its connection to learning and
approximation, J. ACM 45 (1998), 653–750; also Proc. 37th Annu. Symp. Foundations of
Computer Science (FOCS), IEEE, 1996, 339–348.
[32] O. Goldreich, T. Kaufman, Proximity oblivious testing and the role of invariances, in Studies in
complexity and cryptography, 173–190, Vol. 6650 of Lecture Notes in Comput. Sci., Springer,
2011.
[33] O. Goldreich, L. Trevisan, Three theorems regarding testing graph properties, Random Structures Algorithms 23 (2003), 23–57; also FOCS’01: Proc. 42th Annu. Symp. Foundations of
Computer Science, IEEE, 2001, 460–469.
[34] W. T. Gowers, Lower bounds of tower type for Szemerédi’s uniformity lemma,
Geom. Funct. Anal. 7 (1997), 322–337.
[35] G. Higman, Ordering by divisibility in abstract algebras, Proc. London Math. Soc. (3) 2 (1952),
326–336.
[36] S. Kalyanasundaram, A. Shapira, A wowzer-type lower bound for the strong regularity lemma,
Proc. Lond. Math. Soc. (3) 106 (2013), 621–649.
[37] L. Lovász, Large networks and graph limits, American Mathematical Society, Providence, RI,
2012.
[38] L. Lovász, B. Szegedy, Szemerédi’s Lemma for the Analyst, Geom. Funct. Anal. 17 (2007),
252–270.
[39] L. M. Lovász, J. Fox, A tight lower bound for Szemerédi’s regularity lemma, Combinatorica,
to appear.
[40] G. Moshkovitz, A. Shapira, A short proof of Gowers’ lower bound for the regularity lemma,
Combinatorica 36 (2016), 187–194.
[41] B. Nagle, V. Rödl, M. Schacht, The counting lemma for regular k-uniform hypergraphs, Random Structures & Algorithms 28 (2006), 113–179.
[42] S. Raskhodnikova, Approximate testing of visual properties, Approximation, randomization,
and combinatorial optimization, 370–381, Lecture Notes in Comput. Sci., 2764, Springer, 2003.
33

[43] R. Rubinfeld, M. Sudan, Robust characterizations of polynomials with applications to program
testing, Siam J. Comput. 25 (1996), 252–271.
[44] V. Rödl, J. Skokan, Regularity lemma for uniform hypergraphs, Random Structures & Algorithms 25 (2004), 1–42.
[45] E. Szemerédi, Regular partitions of graphs, Proc. Colloque Inter. CNRS No. 260
(J. C. Bermond, J. C. Fournier, M. Las Vergnas and D. Sotteau, eds.), 1978, 399–401.
[46] M. Sudan, Invariance in property testing, in Property Testing: Current Research and Surveys
(O. Goldreich, ed.), Vol. 6390 of Lecture Notes in Computer Science, Springer, 2010, 211–227.
[47] T. Tao, A variant of the hypergraph removal lemma, J. Combin. Theory Ser. A 113 (2006),
1257–1280.
[48] J. van Leeuwen, Graph Algorithms, Handbook of Theoretical Computer Science (J. van
Leeuwen Ed.), vol. A , 525–631, MIT Press, 1990.

34

