Polynomial removal lemmas for ordered graphs

A recent result of Alon, Ben-Eliezer and Fischer establishes an induced removal lemma for ordered graphs. That is, if $F$ is an ordered graph and $\varepsilon>0$, then there exists $\delta_{F}(\varepsilon)>0$ such that every $n$-vertex ordered graph $G$ containing at most $\delta_{F}(\varepsilon) n^{v(F)}$ induced copies of $F$ can be made induced $F$-free by adding/deleting at most $\varepsilon n^2$ edges. We prove that $\delta_{F}(\varepsilon)$ can be chosen to be a polynomial function of $\varepsilon$ if and only if $|V(F)|=2$, or $F$ is the ordered graph with vertices $x<y<z$ and edges $\{x,y\},\{x,z\}$ (up to complementation and reversing the vertex order). We also discuss similar problems in the non-induced case.


Introduction
Graph removal lemmas are among the most powerful tools in combinatorics, with further applications in number theory, logic, and property testing. The celebrated graph removal lemma, which originates in the work of Ruzsa and Szemerédi [RS78], states that if F is a graph and ε > 0, then there exists δ = δ F (ε) > 0 such that every n-vertex graph G containing at most δn v(F ) copies of F can be made F -free by deleting at most εn 2 edges. Alon, Fischer, Krivelevich and Szegedy [AFKS00] established an analogue of this for induced subgraphs. This result, known as the induced removal lemma, states that if G contains at most δ F (ε)n v(F ) induced copies of a graph F , then G can be made induced F -free by adding/deleting at most εn 2 edges. A generalization to arbitrary hereditary graph properties was later obtained by Alon and Shapira [AS08]. For a general survey on graph removal lemmas, we refer the reader to [CF13].
In this paper, we are interested in ordered variants of the graph removal lemma. An ordered graph is a graph with a linear ordering ≤ on its vertex set. An ordered graph H is a subgraph of an ordered graph G if there exists an order preserving embedding from V (H) to V (G) which maps edges into edges, and an induced subgraph if it also maps non-edges into non-edges. The natural analogue of the induced (and also non-induced) removal lemma for ordered graphs was established by Alon, Ben-Eliezer and Fischer [ABEF17]; see also [ABE20] for related results.
All of the above results build on the regularity lemma of Szemerédi [Sze75] or its appropriate generalizations. Consequently, the lower bounds on δ F (ε) supplied by these proofs are quite poor. Even in the case of the original graph removal lemma, the current best known bound is 1/δ ≤ tower(O(log 1/ε)), as proved by Fox in [Fox11]. Here, tower(x) denotes a tower of x exponents. On the other hand, in some special cases better bounds are known. This motivated the natural question of characterizing the cases in which the removal lemma has polynomial bounds, namely, when 1/δ can be taken as a polynomial function of 1/ε. By now there are several results of this type. In the case of graphs, Alon [Alo02] showed that the F -removal lemma has polynomial bounds if and only if F is bipartite. For the case of induced subgraphs, a result of Alon and Shapira [AS06] tells us that the induced F -removal lemma does not have polynomial bounds, unless |V (F )| = 2, or F ∈ {P 3 , P 3 , P 4 , C 4 , C 4 }, where P k , C k are the path and cycle on k vertices, respectively. A polynomial bound in the case F = P 3 is easy to show. Alon and Fox [AF15] proved that the induced-P 4 -removal lemma has polynomial bounds as well. The case F = C 4 is still open, see [GS19,GS21] for the currently best known bounds. The results of [AS05] and [GT21] completely characterize the k-uniform hypergraphs which admit polynomial induced removal lemmas, for k ≥ 3.

Polynomial induced removal lemma for ordered graphs
In the extended version of [ABEF17], Alon, Ben-Eliezer and Fischer proposed the problem of finding ordered graph properties with polynomial induced removal lemmas. Addressing this question, we give a complete characterization of ordered graphs F for which the induced-F -removal lemma has polynomial bounds. It turns out that there is essentially only one such nontrivial ordered graph. For an ordered graph G, we denote by G the complement of G, and by G ← the ordered graph obtained by reversing the vertex order. It is easy to see that the (induced/non-induced) removal lemma for F is equivalent to the (induced/non-induced) removal lemma for F ← . In the induced case, there is also symmetry with respect to complementation: the induced removal lemma for F is equivalent to the induced removal lemma for F . In the rest of the paper we will denote by D the ordered graph with vertices x < y < z and edges {x, y}, {x, z}. A graph is chordal if it contains no induced cycle of length at least 4. It is well known that a graph is chordal if and only if it has a vertex ordering such that the resulting ordered graph is induced D-free (such an ordering is called a perfect elimination order), see e.g. [FG65]. It was recently proved by de Joannis de Verclos [dV19] that the property of being chordal also admits a polynomial removal lemma. Despite the similarity with Theorem 1, it is unclear whether there are any implications between these two results, as the ordering imposes additional structure.

Polynomial (non-induced) removal lemma for ordered graphs
We also consider the non-induced variant of the previous theorem. In the case of directed graphs (digraphs), Alon and Shapira [AS04] gave a complete characterization of digraphs F such that the F -removal lemma has polynomial bounds. This result can be stated as follows. A homomorphism from a digraph G 1 to a digraph G 2 is a function ϕ : V (G 1 ) → V (G 2 ) that satisfies (u, v) ∈ E(G 1 ) ⇒ (ϕ(u), ϕ(v)) ∈ E(G 2 ). The core of a digraph G is the smallest subgraph K for which there is a homomorphism from G to K. Then, for a connected digraph F , the F -removal lemma has polynomial bounds if and only if the core of F is an oriented tree or a directed cycle of length 2.
In a highly parallel manner, we propose a conjecture characterizing ordered graphs which admit a polynomial removal lemma, and prove its "only if" part. A homomorphism between ordered graphs is a graph homomorphism which also preserves the vertex orderings. Formally, for two ordered graphs G 1 , G 2 , a map ϕ : Observe that for such ϕ, the preimage of each vertex of G 2 is an interval in G 1 which spans an independent set. For an ordered graph G, the core of G, denoted by core(G), is the smallest subgraph of G (in terms of number of vertices) to which there is a homomorphism from G. In the preliminaries, we will show that the core is well defined, that is, the smallest such subgraph is unique up to isomorphism. We prove that if core(F ) is not a forest, then F has no polynomial removal lemma.
Theorem 2. Let F be an ordered graph such that core(F ) is not a forest, let ε > 0 be sufficiently small, and let n ≥ n 0 (ε). Then there exists an ordered graph G on n vertices such that G contains at most ε Ω(log 1/ε) n v(F ) copies of F , but one has to remove at least εn 2 edges to destroy all copies of F in G.
Unfortunately, we were unable to prove that the converse also holds in general, and leave it as an interesting open problem.
Conjecture 3. For an ordered graph F , if core(F ) is a forest, then the F -removal lemma has polynomial bounds.
In order to prove Conjecture 3, it is enough to show that it holds when F itself is a forest. Indeed, let K = core(F ) and suppose that the K-removal lemma has polynomial bounds. Let us assume that V (K) = [k] and that the vertex order on V (K) is given by the natural order on [k]. Let s i be the number of vertices of F mapped to i ∈ [k] under some fixed homomorphism ϕ : F → K. Let G be an ordered graph which is ε-far from being F -free. Then G is also ε-far from being K-free (because K is a subgraph of F ), and hence G contains at least δn k copies of K, where δ = δ K (ε) = poly(ε). Consider the k-uniform hypergraph on V (G) whose edges correspond to copies of K. It is easy to show, using a standard Kővári-Sós-Turán-type argument, that this hypergraph contains at least (1 − o(1))δ s 1 ···s k n s 1 +···+s k = poly(ε)n v(F ) copies of the complete k-uniform hypergraph K (k) s 1 ,...,s k in which the side of size s i appears before the side of size s j for every 1 ≤ i < j ≤ k. Every such copy of K (k) s 1 ,...,s k contains a copy of F in G. We remark that ordered forests are quite hard to analyze in many contexts, so it is not surprising that the corresponding question about removal lemmas is also difficult. For example, the extremal numbers (also known as Turán numbers) of ordered forests are already not understood. This problem is the subject of the celebrated Füredi-Hajnal conjecture [FH92], see [KTTW19] for the state of the art.
Let us note that the results of this paper can also be stated in the language of property testing. A tester for a graph property P is a randomized algorithm which, given an input graph G and an approximation parameter ε, distinguishes between the case that G satisfies P and the case that G is ε-far from P, with success probability at least 2 3 in both cases. Here, G being ε-far from P means that one must add/delete at least εn 2 edges to turn G into a graph satisfying P, where n = |V (G)|. The algorithm works by sampling vertices of G and making edge-queries on pairs of sampled vertices. The measure of complexity, called query complexity, is the total number of queries that the algorithm makes. It turns out that many properties can be tested with query complexity which depends only on ε, i.e., is independent of the size of the input graph. This is in particular true for every hereditary property, as proved in [AS08] for (unordered) graphs, and in [ABEF17] for ordered graphs. A tester has one-sided error if it outputs the correct answer with probability 1 in the case that G satisfies P. It is not hard to see that the optimal query complexity of a one-sided-error tester for (induced) F -freeness is essentially given by the bounds for the (induced) F -removal lemma. Hence, Theorem 1 implies that in ordered graphs, induced F -freeness can be tested with query complexity poly(1/ε) with one-sided error if and only if |V (F )| = 2 or F ∈ D, D ← , D, D ← . For more on property testing, we refer the reader to the book of Goldreich [Gol17].

Preliminaries
Given an (ordered) graph G, we denote by v(G) its number of vertices, and by e(G) its number of edges. Also, if For a vertex v and a set X, we denote by N X (v) the neighbourhood of v inside X. We denote by d(X) = e(X)/ |X| 2 the density of X, where e(X) is the number of edges inside X. We say that a graph is a disjoint union of cliques if its vertex set partitions into cliques with no edges between them (equivalently, if the graph has no induced path with three vertices).
Given a set X and a linear ordering ≤ on X, an interval in X is a set of the form {x ∈ X : a ≤ x ≤ b} for some a, b ∈ X. We say that an (ordered) graph G on n vertices is ε-far from an (ordered) graph property P, if one has to add/delete at least εn 2 edges in G in order to turn it into a graph which has property P.
As promised in the introduction, let us show that core(G) is well defined. Let K be a smallest subgraph of G to which there is a homomorphism from G. Observe that every homomorphism ϕ from K to itself is surjective and hence bijective; indeed, otherwise one could compose ϕ with a homomorphism from G to K to obtain a homomorphism from G to a proper subgraph of K, in contradiction to the minimality of K. It follows that every homomorphism from K to itself is an isomorphism. Since a homomorphism must also preserve the vertex order, it follows that the only homomorphism from K to itself is the identity map. An ordered graph K with the property that every homomorphism from K to itself is the identity will be called a core. Note that K is a core if and only if core(K) = K.
If K 1 , K 2 are two smallest subgraphs of G to which there are homomorphisms ϕ i : G → K i , then ϕ 1 | V (K 2 ) and ϕ 2 | V (K 1 ) are both surjective, which implies that K 1 and K 2 are isomorphic.

Polynomial bounds for the induced-D-removal lemma
In this section we prove the positive direction of Theorem 1. By symmetry with respect to complementation and order reversal, it is enough to prove the following: Theorem 4. There exists c > 0 such that the following holds. Let G be an n-vertex ordered graph which is ε-far from being induced D-free. Then G contains at least Ω(ε c ) · n 3 induced copies of D.
We prepare the proof with a few lemmas. One of our key lemmas shows that an ordered graph with few induced copies of D can be partitioned into a constant number of almost-cliques and one additional set which contains few edges. In order to prove this, we first show that if G is a dense ordered graph containing few copies of D, then G contains a very dense subset of linear size.
Proof. For each v ∈ V (G), let N v be the forward neighbourhood of v, namely, the set of vertices u > v such that {u, v} ∈ E(G). Since v∈V (G) |N v | = e(G) ≥ γn 2 , there is a set U of at least γn/2 vertices v with |N v | ≥ γn/2. If there exists v ∈ U such that d(N v ) ≥ 1 − δ, then we are done. Otherwise, each v ∈ U is the first vertex in at least δ |Nv| 2 ≥ δ γn/2 2 ≥ δγ 2 n 2 /16 induced copies of D. Altogether, this gives γn/2 · δγ 2 n 2 /16 = δγ 3 n 3 /32 induced copies of D, a contradiction.
Let G be an ordered graph. For disjoint A, B ⊆ V (G), we write A < B to mean that a < b for all a ∈ A, b ∈ B. A subset A ′ ⊆ A is called a suffix of A if for all a 1 , a 2 ∈ A, if a 1 ∈ A ′ and a 1 < a 2 then a 2 ∈ A ′ . Similarly, A ′ is a prefix of A if for all a 1 , a 2 ∈ A, if a 2 ∈ A ′ and a 1 < a 2 then a 1 ∈ A ′ .
We now describe the structure of an induced D-free graph consisting of two cliques. Lemma 2.3 handles the case when one of the cliques precedes the other one. Lemma 2.4 then takes care of the general case.
Proof. Using that A and B are cliques, if G contains three vertices x < y < z such that {x, y}, {x, z} ∈ E(G) and {y, z} ∈ E(G), then we must have x, y ∈ A and z ∈ B. For a given z, the existence of such x and y is equivalent to the statement that N A (z) is not a suffix of A.

For every
Suppose that x < y < z form an induced copy of D. Without loss of generality, suppose that x ∈ A. If x ∈ J then y, z ∈ J, but (A ∪ B) ∩ J is a clique, contradicting that {y, z} / ∈ E(G). So we must have x ∈ I. If z ∈ I, then y ∈ I, but I ∩ (A ∪ B) is the disjoint union of cliques by item 1, so G[I ∩ (A ∪ B)] cannot contain an induced copy of D. Hence, z ∈ J. But then y ∈ I by item 2. This also implies y ∈ A, as otherwise {x, y} is a non-edge by item 1. It now follows that z ∈ B, as {y, z} is a non-edge and A is a clique. However, this setup runs into a contradiction with item 3, so x, y, z cannot induce a copy of D.
Now we show that if G[A ∪ B] is induced D-free then there is a partition V (G) = I ∪ J satisfying 1-4. Take J to be a maximal suffix of V (G) with the property that the bipartite graph between A ∩ J and B ∩ J is complete. So item 2 holds by definition. If J = V (G) then we are done. Otherwise, setting I = V (G)\J, we show that the bipartite graph between A∩I and B ∩I is empty. Let x be the largest element of (A ∪ B) ∩ I, and suppose without loss of generality that x ∈ A. By the maximality x form an induced copy of D, and if {x, b} ∈ E(G) then b, x, y form an induced copy of D. Assume now that b < a. If {a, y} / ∈ E(G) then b, a, y form an induced copy of D, and if {a, y} ∈ E(G) then a, x, y form an induced copy of D. This proves item 1. Items 3-4 follow from Lemma 2.3.
We now prove the removal versions of Lemmas 2.3 and 2.4.
Lemma 2.5. Let G be an ordered graph and let A, can be made induced D-free by adding/deleting at most γ|A||B| edges between A and B.
Proof. Fix any b ∈ B. If b has at most γ|A|/2 non-neighbours in A, then add all edges between b and A. Suppose now that b has at least γ|A|/2 non-neighbours in A, and let A b be a suffix of A such that b has exactly γ|A|/2 non-neighbours in , add all edges between b and A b and delete all edges between b and A \ A b . This way we make at most γ|A|/2 + d b edge changes for each b ∈ B, resulting in a total of at most γ|A||B|/2 + b∈B d b ≤ γ|A||B| edge changes. By construction, after these changes contains an induced copy of D; this follows from Lemma 2.4 applied to {a 1 , a 2 }, {b 1 , b 2 }. Each induced copy of D is counted at most max{|A|, |B|} times this way. Hence, G contains at least

For an ordered set V and disjoint subsets
The next lemma we need is a removal lemma for ordered sequences, which follows from the main result of [RR21].
Lemma 2.7. Let k ≥ 1, then there exists c k > 0 such that the following holds. Let V be an ordered set of size n and let What was actually proved in [RR21] is that if a sample of q = O(k/ε) elements of V , taken uniformly at random and independently, contains no (A 1 , . . . , A k ) sequence with probability larger than 1 3 , then there is a set S ⊆ V , |S| ≤ εn, which intersects every (A 1 , . . . , A k )-sequence. Observe that if the number of (A 1 , . . . , A k )-sequences is N , then the probability that such a sample contains an (A 1 , . . . , A k )-sequence is at most (q/n) k N . Hence, if N ≤ c k ε k n k then this probability is less than 2/3 (with an appropriate choice of c k ), and Lemma 2.7 follows.
We now move on to the following lemma, which is one of the main ingredients in the proof of Theorem 4.
Lemma 2.8. Let c = c 3 /64, where c 3 is the constant defined in Lemma 2.7. Let G be an n-vertex ordered graph with a vertex-partition V (G) = X 1 ∪ · · · ∪ X m such that X 1 , . . . , X m are cliques and G[X i ∪ X j ] is induced D-free for all i < j. Let γ > 0 and suppose that G has at most cγ 6 n 3 /m 15 induced copies of D. Then there is a set S ⊆ V (G), |S| ≤ γn, and a partition of V (G) \ S into intervals I 1 , . . . , I t , t ≤ 2m 3 , such that the following holds: Proof. For each 1 ≤ i < j ≤ m, Lemma 2.4 states that there is a partition V (G) = I i,j ∪ J i,j into intervals such that the bipartite graph between X i ∩I i,j and X j ∩I i,j is empty, and the bipartite graph between X i ∩ J i,j and X j ∩ J i,j is complete. Let I ′ 1 , . . . , I ′ s be the common refinement of the partitions {I i,j , J i,j : 1 ≤ i < j ≤ m}. Then s ≤ m 2 + 1 ≤ m 2 /2, as the right endpoints of the intervals I i,j together with the last vertex of V (G) are the right endpoints of the intervals I ′ 1 , . . . , I ′ s . Observe that for each 1 ≤ ℓ ≤ s and 1 ≤ i < j ≤ m, the bipartite graph between X i ∩ I ′ ℓ and X j ∩ I ′ ℓ is either complete or empty, because Fix any 1 ≤ ℓ ≤ s. If |I ′ ℓ | < γn/m 2 then put all vertices of I ′ ℓ into S. This puts at most s·γn/m 2 ≤ γn/2 vertices in S altogether. Suppose now that |I ′ ℓ | ≥ γn/m 2 . We run the following process. If there are distinct 1 ≤ i 1 , i 2 , i 3 ≤ m such that the number of (X i 1 , X i 2 , X i 3 )-sequences inside I ′ ℓ is at least 1 and at most c 3 ( γ 2m 3 ) 3 |I ′ ℓ | 3 , then use Lemma 2.7 to delete γ 2m 3 · |I ′ ℓ | vertices from I ′ ℓ and thus destroy all (X i 1 , X i 2 , X i 3 )-sequences in I ′ ℓ . Add the deleted vertices to S and update I ′ ℓ . Let I ′′ ℓ ⊆ I ′ ℓ be the interval at the end of the process. Note that each triple i 1 , i 2 , i 3 can only cause vertex-deletion once (because following this vertex-deletion, there are no more (X i 1 , X i 2 , X i 3 )-sequences in I ′ ℓ ). Hence, the total number of deleted vertices is at most . Doing this step for every 1 ≤ i ≤ ℓ adds a total of at most γ/2 · s ℓ=1 |I ′ ℓ | ≤ γn/2 vertices to S. Thus, the total number of vertices in S at this point is at most γn.
Observe that after this step, for every triple of distinct 1 ≤ i 1 , i 2 , i 3 ≤ m, either there are no (X i 1 , X i 2 , X i 3 )-sequences inside I ′′ ℓ , or the number of these sequences is at least For each 1 ≤ i ≤ m, let J ℓ i be the minimal subinterval of I ′′ ℓ which contains the set X i ∩ I ′′ ℓ . By minimality, the first and last elements of J ℓ i belong to X i . Now take the common refinement of the intervals J ℓ 1 , . . . , J ℓ m , giving a partition of I ′′ ℓ into at most 2m + 1 intervals. Doing this for every 1 ≤ ℓ ≤ s, we get a partition I 1 , . . . , which is smaller or equal to the first element of I j (indeed, the first element of J ℓ i satisfies this), as well as an element of X i ∩ I ′′ ℓ which is bigger or equal to the last element of I j (indeed, the last element of J ℓ i satisfies this). Let us show that I 1 , . . . , I t have the property stated in the lemma. Fix any 1 ≤ j ≤ t. By construction, there is 1 ≤ ℓ ≤ s such that I j is a subinterval of I ′′ ℓ . Recall that for all 1 ≤ i 1 = i 2 ≤ m, the bipartite graph between X i 1 ∩ I ′′ ℓ and X i 2 ∩ I ′′ ℓ is either complete or empty. If G[I j ] is not a disjoint union of cliques then it contains an (unordered) path on 3 vertices. Since X 1 , . . . , X m are cliques and all bipartite graphs X i 1 ∩I ′′ ℓ and X i 2 ∩I ′′ ℓ are complete or empty, this path cannot contain two vertices from the same clique. Hence, there are distinct 1 ≤ i 1 , i 2 , i 3 ≤ m such that X i 1 , X i 2 , X i 3 all intersect I j , the bipartite graphs (X i 1 ∩ I ′′ ℓ , X i 2 ∩ I ′′ ℓ ) and (X i 1 ∩ I ′′ ℓ , X i 3 ∩ I ′′ ℓ ) are complete, and the bipartite graph (X i 2 ∩ I ′′ ℓ , X i 3 ∩ I ′′ ℓ ) is empty. Since X i 1 intersects I j , there exists x i 1 ∈ X i 1 ∩ I ′′ ℓ such that x i 1 is smaller or equal to the first element of I j . Similarly, since X i 2 and X i 3 intersect I j , there exist x i 2 ∈ X i 2 ∩ I ′′ ℓ and x i 3 ∈ X i 3 ∩ I ′′ ℓ such that x i 2 , x i 3 are bigger or equal to the last element of I j . Without loss of generality, suppose that By construction, there are at least cγ 6 n 3 /m 15 such sequences. Now observe that each such sequence spans an induced copy of D, contradicting the assumption of the lemma. This completes the proof.
In the next lemma we prove a D-removal lemma for graphs which can be partitioned into two intervals, each of which induces a disjoint union of cliques. An important feature is that edge changes are only made between the intervals, not inside them, so that each interval remains a disjoint union of cliques after the changes. Proof. Suppose that G[I] is the disjoint union of cliques A 1 , . . . , A k and G[J] is the disjoint union of cliques B 1 , . . . , B ℓ . By assumption, k, ℓ ≤ m. We will make G[I ∪ J] induced D-free in two steps.
Fix i ∈ [k] and j ∈ [ℓ] with |A i | ≥ γ|I| 4m and |B j | ≥ γ|J| 4m . Then δ 2 |A i | 2 |B j |/4 ≥ γ 15 2 40 m 9 |I| 2 |J|. By assumption, the number of induced copies of D in G[A i ∪ B j ] is at most δ 2 |A i | 2 |B j |/4. Apply Lemma 2.5 to make G[A i ∪ B j ] induced D-free with at most δ|A i ||B j | edge changes. By Lemma 2.3, the neighbourhood in A i of each vertex in B j is now a suffix of A i . Performing step 1 for all pairs i ∈ [k], j ∈ [ℓ] requires at most δ|I||J| edge changes altogether.
We claim that after step 2, G[I ∪ J] is induced D-free. Suppose that this is not the case. Note that G[I] and G[J] are induced D-free because each is a disjoint union of cliques. If an induced copy of D has two vertices in I and one in J, then it must be contained in A i ∪ B j for some i, j, since A 1 , . . . , A k are cliques with no edges between them. However, in steps 1 and 2 we made sure that . Since a is adjacent to b and b ′ , we did not make any edge changes in the bipartite graphs (A i , B j ) and (A i , B j ′ ) in step 2. Hence, it must be the case that and Since b and b ′ are not adjacent, j = j ′ . There are no edges between B j and B j ′ . Recall that the neighbourhood in A i of each vertex in B j ∪ B j ′ is a suffix of A i . This means that if a 1 , a 2 ∈ A i and a 1 < a 2 , then N B j (a 1 ) ⊆ N B j (a 2 ) and N B j ′ (a 1 ) ⊆ N B j ′ (a 2 ). Let A ′ be the set of the last γ|A i |/8 elements of A i . Due to (2), there exist at least . This gives a total of at least induced copies of D, each having one vertex in I and two in J. The at most δ|I||J| edges we added/deleted in step 1 can participate in at most δ|I||J| 2 of these copies. Hence, at least δ|I||J| 2 must be present in the original graph, a contradiction to the assumption of the lemma.
In the following lemma we show that under certain conditions, if there are few induced D-copies of a certain type, then they can be destroyed by deleting few vertices (rather than by adding/deleting edges). This is useful because vertex deletion, as opposed to edge changes, cannot create new induced copies.
Lemma 2.10. Let G be an ordered graph and let A, B, C ⊆ V (G) be disjoint cliques with A < B < C, whose union is has at most s 3 /12 induced copies of D, then there is a set S of at most 3s vertices whose deletion destroys every induced copy of Proof. Clearly, if G contains a copy of D with vertices a < b < c, then a ∈ A, b ∈ B, c ∈ C. Let  (a 1 , b 1 , c 1 ), . . . , (a r , b r , c r ) be a maximum collection of vertex-disjoint induced copies of D with a i ∈ A, b i ∈ B, c i ∈ C (i = 1, . . . , r). It is enough to show that r ≤ s, because then S = {a i , b i , c i : i ∈ [r]} suffices. Assume without loss of generality that a 1 < · · · < a r . By Lemma 2.3, the neighbourhood of each vertex of B ∪ C in A is a suffix of A (as G[A ∪ B] and G[A ∪ C] are induced D-free). For each 1 ≤ i ≤ r, a i is adjacent to b i and c i . Hence, for each pair of indices 1 ≤ j ≤ i ≤ r, a i is adjacent to b j and c j .
For each 1 ≤ i ≤ r, {b i , c i } / ∈ E(G). This implies that for every 1 ≤ j < k ≤ r, at least one of the pairs {b j , c k }, {c j , b k } must be a non-edge. Indeed, otherwise b j , c j , b k , c k span an induced 4-cycle, which must contain an induced copy of D, contradicting the assumption that G[B ∪ C] is induced D-free. We have shown that for every triple of indices 1 ≤ j < k ≤ i ≤ r, a i forms an induced copy of D with one of the pairs {b j , c k } or {c j , b k }. This gives a total of at least r i=1 i 2 = r+1 3 ≥ r 3 /12 induced copies of D. By the assumption of the lemma, r ≤ s, as required.
In the following lemma we prove a D-removal statement in the following setting. Suppose that V (G) = X ∪ Y , Y is independent, and G[X] is induced D-free. Then one can efficiently destroy the remaining induced D-copies by deleting edges between X and Y .
Lemma 2.11. Let G be an ordered graph and let V (G) = X ∪ Y be a vertex partition such that Y is an independent set and G[X] is induced D-free. Let γ > 0 with |Y | ≥ 4/γ. Suppose that G has at most γ 2 32 |X||Y | min{|X|, |Y |} induced copies of D. Then G can be made induced D-free by deleting at most γ|X||Y | edges between X and Y .
Proof. We delete edges in two steps. For each x ∈ X, let d x be the number of y ∈ Y , y > x, such that {x, y} ∈ E(G). Let e := x∈X d x be the number of edges in which the first vertex is in X and the second in Y . We claim that e ≤ γ|X||Y |/2. If e ≤ 2|X| then this holds because |Y | ≥ 4/γ by assumption. Suppose that e ≥ 2|X|. Observe that as Y is an independent set, each x participates in dx 2 induced copies of D, in which the other two vertices are from Y . By using our assumption on the one hand and Jensen's inequality on the other, we get where the last inequality uses e ≥ 2|X|. So indeed e ≤ γ|X||Y |/2. Delete all edges in which the first vertex is in X and the second in Y . This destroys all induced D-copies in which the first vertex is in X (since G[X] is induced D-free by assumption). Next, for each y ∈ Y , let N y ⊆ X be the set of all x ∈ X, x > y, with {x, y} ∈ E(G). Let M y be a largest matching of non-edges inside N y . Observe that for every {x 1 , x 2 }, {x 3 , x 4 } ∈ M y , at least one of the pairs {x 1 , x 3 }, {x 1 , x 4 }, {x 2 , x 3 }, {x 2 , x 4 } must be a non-edge. Indeed, otherwise x 1 , x 2 , x 3 , x 4 span an induced 4-cycle, which must contain an induced copy of D, in contradiction to the assumption that G[X] is induced D-free. Note that y forms an induced D-copy with every non-edge inside N y . Hence, y is part of at least |M y | + |My| 2 ≥ |My| 2 2 induced D-copies, in which the other two vertices are from X. Using our assumption and Jensen's inequality, we get Hence y∈Y |M y | ≤ γ|X||Y |/4. For each y ∈ Y , delete the edges between y and x 1 , x 2 for every {x 1 , x 2 } ∈ M y . By the choice of M y , after this step the set {x ∈ X : x > y, {x, y} ∈ E(G)} is a clique. Hence, this step destroys all induced D-copies in which the first vertex is in Y (recall that Y is an independent set). The number of edge deletions in this second step is 2 y∈Y |M y | ≤ γ|X||Y |/2. Hence, the total number of edges deleted is at most γ|X||Y |.
We are finally in a position to prove Theorem 4.
Proof of Theorem 4. We may and will assume that n is larger than some suitable polynomial function of 1/ε. Set Here, c is the constant from Lemma 2.8. We show that if G contains less than N := δε 3 1 n 3 /32 induced copies of D, then we can make G induced D-free by adding/deleting at most εn 2 edges.
First, apply Lemma 2.2 with parameters γ = ε 1 and δ. As G contains less than δε 3 1 n 3 /32 induced copies of D, there exists a partition V (G) = X 1 ∪ · · · ∪ X m ∪ Y satisfying the following properties.
Note that m ≤ 2/ε 1 . Let X = X 1 ∪ · · · ∪ X m . If X = ∅, then we can make G induced D-free by deleting all the edges, which is at most ε 1 n 2 ≤ εn 2 changes. So we can assume that X = ∅, which implies that |X| ≥ ε 1 n/2. We will modify G in 6 steps.
Step 1. Make X 1 , . . . , X m cliques and Y an independent set. This requires at most δ · m i=1 |X i | 2 ≤ δ |X| 2 ≤ δ|X| 2 /2 edge changes inside X := X 1 ∪ · · · ∪ X m , and at most ε 1 n 2 edge changes inside Y . Set K 1 := δ|X| 2 /2 + ε 1 n 2 . Denote the resulting graph by G 1 . Note that every modified edge participates in at most n induced copies of D, and in at most |X| induced copies of D which are contained in X. Hence, G 1 [X] contains at most M 1 = N + δ|X| 3 /2 < δ|X| 3 induced copies of D.
Step 2. For every 1 ≤ i < j ≤ m, make G 1 [X i ∪ X j ] induced D-free. By Lemma 2.6, this can be done by at most ε 3 |X i ||X j | edge changes. Indeed, otherwise G 1 [X i ∪ X j ] contains at least induced copies of D, contradiction. Executing these changes for all pairs 1 ≤ i < j ≤ m requires adding/deleting at most ε 3 |X| 2 ≤ ε 3 n 2 /2 =: K 2 edges altogether. Let G 2 be the resulting graph. Note that G 2 [X] contains at most M 2 = M 1 + ε 3 |X| 3 /2 < ε 3 |X| 3 induced copies of D.
Let us now apply Lemma 2.8 to G 2 [X] with parameter γ = ε/12. Note that c ε 12 Hence, G 2 [X] contains at most c ε

12
6 |X| 3 m 15 induced copies of D, meaning that the condition of Lemma 2.8 is satisfied. Therefore, there is a set S ⊆ X of size at most εn/12 and a partition of X \ S into t ≤ 2m 3 ≤ 16/ε 3 1 intervals I 1 , . . . , I t such that for every j ∈ [t], G 2 [I j ] is the disjoint union of cliques, each clique of the form I j ∩ ( i∈M X i ) for some M ⊂ [m]. It follows that G 2 [I j ] is induced D-free. From this point on, we will make no edge changes inside the sets I 1 , . . . , I t , so this property will continue to hold.
Step 4. Fix any 1 ≤ j 1 < j 2 < j 3 ≤ t and 1 ≤ i 1 , i 2 , i 3 ≤ m. Apply Lemma 2.10 to the cliques is at most M 3 , and we have Step 5. Delete all edges touching the vertices in S. This requires at most |S|n ≤ εn 2 /4 =: K 5 edge changes. Note that if |Y | ≤ εn/2, then by deleting all edges touching Y , of which there are at most |Y |n ≤ εn 2 /2, we make the graph induced D-free. Since the total number of edge changes in all previous steps is at most K 1 + K 2 + K 3 + K 5 < 2ε 1 n 2 + εn 2 /4 ≤ εn 2 /2, this would contradict the assumption that G is ε-far from being induced D-free. Hence, |Y | ≥ εn/2. By similar reasoning, we may assume that |X \ S| ≥ εn/2, since otherwise we may delete all the at most εn 2 /2 edges touching X \ S and thus make the graph empty (recall that G 3 [Y ] is an empty graph).
Step 6. Note that G 3 [(X \ S) ∪ Y ] contains at most N + (K 1 + K 2 + K 3 )n ≤ 2ε 1 n 3 induced copies of D. We have ε 2 32 · |X \ S| · |Y | · min{|X \ S|, |Y |} ≥ ε 2 32 hence, we can apply Lemma 2.11 with parameter γ = ε to make G 3 [(X \ S) ∪ Y ] induced D-free by changing at most ε|X \ S||Y | ≤ εn 2 /4 =: K 6 edges between X \ S and Y . This makes the entire graph induced D-free. The overall number of edge changes in all steps is at most contradicting the assumption that G is ε-far from being induced D-free. This completes the proof.

Lower bounds
In this section we prove the "only if" part of Theorem 1, as well as Theorem 2. Two subgraphs of a graph G will be called pair-disjoint if they share at most one vertex. We will use the obvious fact that if G contains a collection of εn 2 pairwise pair-disjoint (induced) copies of F , then G is ε-far from being (induced) F -free. We need the following simple claim.
Lemma 3.1. For k ≥ 2 and r ≥ 2k, there is a collection R ⊆ [r] k , |R| ≥ r 2 /4, such that any two k-tuples in R coincide on at most one coordinate.
Proof. Let p be a prime such that r/2 < p ≤ r, which exists by Bertrand's postulate. For a, b ∈ F p , let x a,b ∈ F k p be the k-tuple x a,b (i) = a + (i − 1)b, i = 1, . . . , k. For (a 1 , b 1 ) = (a 2 , b 2 ), there is at most one 1 ≤ i ≤ k with x a 1 ,b 1 (i) = x a 2 ,b 2 (i). Indeed, if there are two such 1 ≤ i = j ≤ k, then a 1 + (i − 1)b 1 = a 2 + (i − 1)b 2 and a 1 + (j − 1)b 1 = a 2 + (j − 1)b 2 . Solving this system of equations gives a 1 = a 2 and b 1 = b 2 , a contradiction. Here we use the fact that i ≡ j (mod p), which follows from p > r/2 ≥ k.
We will adapt the constructions in [Alo02] and [AS06] to ordered graphs. These constructions use generalizations of Behrend's example [Beh46] of large sets of integers with no 3-term arithmetic progressions, see Lemma 3.1 in [Alo02] and Lemma 4.1 in [AS06]. We will use the following common generalization of these two lemmas.
The proof of Lemma 3.2 is very similar to the proofs of the aforementioned lemmas from [Alo02, AS06] (which themselves closely follow Behrend's original argument). The proof is thus omitted.
The proof of the "only if" part of Theorem 1 involves a case analysis over several small ordered graphs, each of which needs a slightly different variant of a construction from [Alo02]. To avoid repetitions, we now introduce a general setting in which this construction can be applied. A pattern P is a complete ordered graph, say on [k] with the natural ordering, whose edges are colored with the colors black, white and gray. An ordered graph G is said to have the pattern P if there is a partition V (G) = V 1 ∪ · · · ∪ V k into independent sets with V 1 < · · · < V k , such that the following condition is satisfied: for every 1 ≤ i < j ≤ k, if {i, j} is colored black then the bipartite graph (V i , V j ) is complete, and if {i, j} is colored white then the bipartite graph {i, j} is empty. The partition (V 1 , . . . , V k ) is called a P -partition of G. A completion of P is an ordered graph F on [k] which has pattern P , i.e. {i, j} ∈ E(F ) if {i, j} is black in P and {i, j} / ∈ E(F ) if {i, j} is white in P . In other words, a completion is obtained by recoloring the gray edges with black/white. Let A be a set of subsets of V (P ). We say that F is (P, A)-good if for every ordered graph G with P -partition (V 1 , . . . , V k ) and for every induced copy Note that in such a copy, v i must play the role of i due to the vertex order. If A = {A} then we will simply write "(P, A)-good" in place of "(P, {A})-good". The following is a generalization of the aforementioned construction from [Alo02].
Lemma 3.3. Let P be a pattern on [k], let A be a set of subsets of V (P ), and suppose that there is a bijection σ : [k] → [k] such that for every A ∈ A, there is a cycle i 1 , . . . , i t , i 1 of gray edges in P [A] such that σ(i 1 ) < · · · < σ(i t ). Let F be a completion of P which is (P, A)-good. Then for every small enough ε and n ≥ n 0 (ε), there is an n-vertex ordered graph G with the following properties: 1. G has pattern P .
Proof. As above, we assume that V (F ) = V (P ) = [k] (with the natural vertex order). Let m be the maximal integer satisfying e −c k √ log m ≥ 4k 4 ε, where c k is from Lemma 3.2. It is easy to see that m ≥ (1/ε) Ω(log 1/ε) . Let S be the set guaranteed by Lemma 3.2; so |S| ≥ 4k 4 εm by our choice of m. Let σ : [k] → [k] be a bijection as in the statement of the lemma. We start by defining an ordered graph H, as follows. The vertex-set of H consists of k pairwise-disjoint independent sets For each x ∈ [m] and s ∈ S, add a copy of F on vertices v 1 , . . . , v k , where v i = x + (σ(i) − 1) · s ∈ V i ; this copy is denoted by F x,s . Next, for each black edge {i, j} of P , make the bipartite graph (V i , V j ) complete, and for each white edge {i, j} of P , make the bipartite graph (V i , V j ) empty. This agrees with the copies F x,s , since F has pattern P . Finally, for each gray edge {i, j} of P and for each , and a non-edge of H if {i, j} ∈ E(F ). By construction, H has pattern P with P -partition (V 1 , . . . , V k ).
For distinct pairs (x 1 , s 1 ), (x 2 , s 2 ) ∈ [m] × S, the copies F x 1 ,s 1 and F x 2 ,s 2 are pair-disjoint. Indeed, if F x 1 ,s 1 and F x 2 ,s 2 have the same vertex in V i and V j (for some 1 ≤ i < j ≤ k), then x 1 +(σ(i)−1)s 1 = x 2 + (σ(i) − 1)s 2 and x 1 + (σ(j) − 1)s 1 = x 2 + (σ(j) − 1)s 2 . Solving this system of equations, we get that x 1 = x 2 and s 1 = s 2 . So we conclude that the copies (F x,s ) (x,s)∈[m]×S of F are pair-disjoint and hence induced. The number of these copies is m|S| ≥ 4k 4 εm 2 . Now, let G be the n v(H) -blowup of H. For 1 ≤ i ≤ k, denote by W i the blowup of V i . It is easy to see that G has pattern P with P -partition (W 1 , . . . , W k ). Each induced copy of F in H gives rise to n 2v(H) 2 pair-disjoint induced copies of F in G, by Lemma 3.1 with parameter r = n v(H) . Hence, G contains a collection of 4k 4 εm 2 · n 2v(H) 2 ≥ εn 2 pair-disjoint induced copies of F .
To complete the proof it remains to show that item 3 holds. So let F ′ be an induced copy of form an induced copy of F [A] in H. By the assumption of the lemma, there is a cycle i 1 , . . . , i t , i 1 in P [A] consisting of gray edges, such that σ(i 1 ) < · · · < σ(i t ). By the construction of H, for every gray edge {i, j} of P [A], it must be that ) · s t . Now we use our choice of S via Lemma 3.2, taking p 1 , . . . , p t−1 in Lemma 3.2 to be p j = σ(i j+1 ) − σ(i j ). (Here we use that σ(i 1 ) < · · · < σ(i t ) so that p 1 , . . . , p t−1 are positive.) We obtain that s 1 = · · · = s t =: s. We now get that x j = v i j+1 − (σ(i j+1 ) − 1) · s = x j+1 (for every 1 ≤ j ≤ t − 1), and hence x 1 = · · · = x t .
So far we have shown that for every induced copy 3 · n k−3 = n k /v(H) 3 ≤ n k /m 3 . So overall, the number of induced copies of F in G is at most O(1) · m 2 · n k /m 3 = O(n k /m) ≤ ε Ω(log 1/ε) n k , as required.
Evidently, for every specific cycle i 1 , . . . , i t , i 1 in P , one can choose a bijection σ : [k] → [k] with σ(i 1 ) < · · · < σ(i t ). Hence, a bijection σ as in Lemma 3.3 always exists when A = {A}. We therefore have the following corollary: Lemma 3.4. Let P be a pattern, and let A ⊆ V (P ) such that P [A] has a cycle consisting of gray edges. Let F be a (P, A)-good completion of P . Then the conclusion of Lemma 3.3 holds.
Lemma 3.3 implies the following statement, which extends a construction from [AS06] to ordered graphs.
Lemma 3.5. Let F be an ordered graph which contains a triangle. Then for every sufficiently small ε > 0 and n > n 0 (ε), there is an n-vertex ordered graph G which contains εn 2 pair-disjoint induced copies of F , but only ε Ω(log 1/ε) n v(F ) induced copies of F altogether.
Proof. Take P to be the pattern on V (F ) in which all non-edges of F are white and all edges of F are gray. Take A to be the set of all (vertex sets of) triangles in F . Observe that F is (P, A)-good. Indeed, let G be an ordered graph with P -partition (V 1 , . . . , V k ) and let F ′ be a copy of F in G.
Then F ′ has a triangle, say on vertices v i ∈ V i , v j ∈ V j , v ℓ ∈ V ℓ . Then {i, j}, {i, ℓ}, {j, ℓ} must be gray edges in P and hence must be edges in F . So i, j, ℓ is a triangle in F , meaning that v i , v j , v ℓ form a copy of F [A] for A = {i, j, ℓ} ∈ A. Now take σ : [k] → [k] to be an arbitrary bijection. For a triangle it is always possible to choose a starting point and an orientation such that the triangle (as a cycle) is increasing with respect to σ. So the conditions of Lemma 3.3 are satisfied, and the assertion follows from Lemma 3.3.
Lemma 3.4 easily implies the following: Lemma 3.6. Let K be an ordered core which has a cycle. Then for every small enough ε and large enough n, there is an n-vertex ordered graph G with the following properties: 1. G is homomorphic to K.
Proof. We reduce to Lemma 3.4. Let P be the pattern on [k] = V (K) in which {i, j} is gray if {i, j} ∈ E(K) and white if {i, j} / ∈ E(K). Observe that an ordered graph G has pattern P if and only if G is homomorphic to K. The fact that K is a core implies that K is (P, V (P ))-good. Apply Lemma 3.4 to get an ordered graph G satisfying items 1-3 in Lemma 3.3. Then G is homomorphic to K because G has pattern P . Observe that every copy of K in G is induced because K is a core and G is homomorphic to K. Lemma 3.6 follows.
Using Lemma 3.6, we can prove Theorem 2.
Proof of Theorem 2. Let K be the core of F , and suppose that V (K) = [k]. Apply Lemma 3.6 with parameters v(F ) 2 · ε (in place of ε) and n v(F ) (in place of n) to obtain an ordered graph G ′ on n v(F ) vertices with the properties stated in the lemma. Since G ′ is homomorphic to K, we have V (G ′ ) = V 1 ∪ · · · ∪ V k for independent sets V 1 < · · · < V k . Let G be the v(F )-blowup of G ′ , and denote by W i the blowup of V i (for i = 1, . . . , k). By item 2 in Lemma 3.6, G ′ contains a collection K 1 , . . . , K M of M ≥ v(F ) 2 · ε · ( n v(F ) ) 2 = εn 2 pair-disjoint copies of K. For each 1 ≤ i ≤ M , let B i be the v(F )-blowup of K i , and let E i be the set of edges of B i which go between the sets W 1 , . . . , W k . Since K 1 , . . . , K M are pair-disjoint, the sets E 1 , . . . , E M are disjoint. Observe that each B i contains a copy of F , and that in order to destroy this copy one must delete some edge of E i . Since E 1 , . . . , E M are disjoint, one must delete at least M ≥ εn 2 edges from G to make it F -free, as required.
To complete the proof, let us bound the number of copies of F in G. Since K is a subgraph of F , every copy of F must contain a copy of K. Each copy of K can be completed to a copy of F in at most n v(F )−k ways. Since K is a core and G ′ (and hence also G) is homomorphic to K, every copy of K in G corresponds to a copy of K in G ′ . On the other hand, each copy of K in G ′ gives rise to v(F ) k = O(1) copies of K in G. By item 3 in Lemma 3.6, G ′ has at most ε Ω(log 1/ε) · n k copies of K. Hence, the number of copies of F in G is at most O(1) · ε Ω(log 1/ε) · n k · n v(F )−k = ε Ω(log 1/ε) n v(F ) , as required.
Next, we prove the "only if" part of Theorem 1, which we restate as follows: Theorem 5. Let F be an ordered graph, v(F ) ≥ 3, F / ∈ D, D ← , D, D ← . Then for every sufficiently small ε > 0 and n > n 0 (ε), there is an n-vertex ordered graph G which is ε-far from being induced F -free but contains at most ε Ω(log 1/ε) n v(F ) induced copies of F .
Proof. If F contains a triangle then the assertion follows from Lemma 3.5. By symmetry with respect to taking graph complements, the same is true if F contains an independent set of size 3. This in particular proves the theorem for F on at least 6 vertices, since every such F contains a triangle or an independent set of size 3. We will assume that F contains neither of these.
Denote by P mon k the monotone path with k vertices, that is, the ordered path with vertex set [k] and edges {i, i + 1} for i = 1, . . . , k − 1. It is easy to see that P mon k is (P, V (P ))-good for the pattern , and we already handled these cases. If v(F ) = 5 then F must be a 5-cycle, because every other 5-vertex graph contains a triangle or an independent set of size 3. Every ordered 5-cycle is a core (because the homomorphic image of an odd cycle must itself contain an odd cycle). So for these F , the assertion follows from Lemma 3.6.
It remains to handle the case v(F ) = 4. The only 4-vertex (unordered) graphs which have no triangle and no independent set of size 3 are the 4-cycle, the complement of the 4-cycle, and the path with four vertices.
We first consider the 4-cycle. There are 3 non-isomorphic ordered 4-cycles. Assuming the vertices are 1, 2, 3, 4, these 4-cycles are: C  is (P, V (P ))-good. Indeed, let G be a graph with pattern P , and let (V 1 , V 2 , V 3 , V 4 ) be a P -partition of G. Note that the bipartite graphs (V 1 , V 2 ) and (V 3 , V 4 ) are complete. Let C be an induced copy of C (2) 4 in G, and let a i be the vertex of C playing the role of i (for i = 1, . . . , 4). It is enough to show that |C ∩ V i | = 1 for all 1 ≤ i ≤ 4, as this would imply that a i ∈ V i . Suppose by contradiction that |C ∩ V i | ≥ 2 for some i. Then |C ∩ V i | = 2 because V i is an independent set and C is does not have an independent set of size 3. The two vertices in C ∩ V i must play the role of some non-edge e of C. If e is {a 1 , a 3 }, {a 2 , a 4 } or {a 1 , a 4 }, then |C ∩V i | ≥ 3, because for each of those edges, there is another vertex of C between the endpoints of the edge. Hence e = {a 2 , a 3 }. Since a 1 comes before V i and a 4 after V i , it must be that i = 2 or i = 3; without loss of generality, i = 2. Then a 1 ∈ V 1 . But then a 1 is adjacent to a 3 ∈ V 2 because the bipartite graph (V 1 , V 2 ) is complete, a contradiction.
The assertion of Theorem 5 for C 4 is (P, A)-good. Indeed, let G be a graph with pattern P , and let (V 1 , V 2 , V 3 , V 4 ) be a P -partition of G. Note that the bipartite graph (V 2 , V 3 ) is empty. Let C be an induced copy of C  = 1, . . . , 4). We need to show that a 1 ∈ V 1 , a 4 ∈ V 4 , and a 2 ∈ V 2 or a 3 ∈ V 3 . Observe that a 2 , a 3 ∈ V 2 ∪ V 3 , because a 1 , a 4 are adjacent to both a 2 and a 3 , a 1 comes before a 2 , a 3 , and a 4 comes after a 2 , a 3 . If a 2 ∈ V 2 and a 3 ∈ V 3 then we must have  Figure 1: The ordered 4-cycles a 1 ∈ V 1 and a 4 ∈ V 4 , so we are done. Suppose then that a 2 , a 3 ∈ V 2 or a 2 , a 3 ∈ V 3 ; without loss of generality, we may assume that a 2 , a 3 ∈ V 2 . This implies that a 1 ∈ V 1 . Also, since the bipartite graph (V 2 , V 3 ) is empty, we must have a 4 ∈ V 4 . Therefore, C Then P (1) 4 is (P, V (P ))-good. Indeed, let G be a graph with pattern P , and let (V 1 , . . . , V 4 ) be a P -partition of G. Then the bipartite graphs (V 1 , V 3 ) and (V 2 , V 4 ) are empty. Let X be an induced copy of P (1) 4 in G, and let a i be the vertex of X playing the role of i (for i = 1, . . . , 4). It is enough to show that |X ∩ V i | = 1 for all 1 ≤ i ≤ 4, as this will imply that a i ∈ V i , showing that P (1) 4 is (P, V (P ))-good. Suppose by contradiction that |X ∩ V i | ≥ 2 for some i. Then |X ∩ V i | = 2 because V i is an independent set and X has no independent set of size 3. The two vertices in X ∩ V i must play the role of some non-edge e of X. If e = {a 1 , a 3 }, {a 2 , a 4 } then |X ∩ V i | ≥ 3, because for each of those e, there is another vertex of X between the endpoints of e. Hence e = {a 2 , a 3 }. Since a 1 comes before V i and a 4 after V i , it must be that i = 2 or i = 3; without loss of generality, i = 2. Then a 1 ∈ V 1 . It follows that a 4 ∈ V 4 , because a 4 is adjacent to a 1 and there are no edges between V 1 and V 3 . But now, a 4 is not adjacent to a 3 ∈ V 2 , as there are no edges between V 2 and V 4 . This is a contradiction. is (P, A)-good. Indeed, let G be an ordered graph with pattern P , and let (V 1 , V 2 , V 3 , V 4 ) be a P -partition of G. Note that the bipartite graphs (V 2 , V 3 ) and (V 2 , V 4 ) are empty. Let X be an induced copy of P (2) 4 in G, and let a i be the vertex of X playing the role of i (for i = 1, . . . , 4). We need to show that a i ∈ V i for i = 1, 3, 4. We first claim that a 3 ∈ V 3 . Since a 1 , a 4 are adjacent to a 3 , a 1 comes before a 3 , and a 4 comes after a 3 , it must be that a 3 ∈ V 2 ∪ V 3 . If a 3 ∈ V 2 then a 4 cannot be adjacent to a 3 because the bipartite graphs (V 2 , V 3 ) and (V 2 , V 4 ) are empty, a contradiction. So a 3 ∈ V 3 . It follows that a 4 ∈ V 4 . Similarly, as the bipartite graph (V 2 , V 3 ) is empty, it must be that a 1 ∈ V 1 , as required.
We apply Lemma 3.4 to conclude. is (P, A)-good. Therefore, we can again apply Lemma 3.4 to finish the proof.