Rainbow variations on a theme by Mantel: extremal problems for Gallai colouring templates

Let G := ( G 1 , G 2 , G 3 ) be a triple of graphs on the same vertex set V of size n . A rainbow triangle in G is a triple of edges ( e 1 , e 2 , e 3 ) with e i ∈ G i for each i and { e 1 , e 2 , e 3 } forming a triangle in V . The triples G not containing rainbow triangles, also known as Gallai colouring templates, are a widely studied class of objects in extremal combinatorics. In the present work, we fully determine the set of edge densities ( α 1 , α 2 , α 3 ) such that if | E ( G i ) | > α i n 2 for each i and n is suﬃciently large, then G must contain a rainbow triangle. This resolves a problem raised by Aharoni, DeVos, de la Maza, Montejanos and ˇS´amal, generalises several previous results on extremal Gallai colouring templates, and proves a recent conjecture of Frankl, Gy¨ori, He, Lv, Salia, Tompkins, Varga and Zhu.


Introduction
Mantel's Theorem from 1907 [21] is one of the foundational results in extremal graph theory.It asserts that a triangle-free graph G on n vertices has at most ⌊ n 2 4 ⌋ edges, with equality if and only if G is (isomorphic to) the complete balanced bipartite graph T 2 (n).While the proof of Mantel's theorem is a simple combinatorial exercise, triangle-free graphs act as a kind of theoretical lodestone in extremal combinatorics: many important extremal tools or problems are first developed or studied in the context of triangle-free graphs.One may think, for example, of results on the independence number of triangle-free graphs [23], the chromatic threshold phenomenon [2,24], the triangle removal lemma [22], and on random [8] and tripartite [6] versions of Mantel's theorem.
In this paper we will consider a rainbow variation on Mantel's triangle-free theme, which was first introduced by Gallai in 1967.Fix an n-set V and some integer r ≥ 2.
Definition 1.1.[Colouring templates, colourings] An r-colouring template on V is an r-tuple G (r) = (G 1 , G 2 , . . ., G r ), where each of the G i is a graph on V .Whenever r is clear from context, we omit the superscript r and write G for G (r) .
An r-coloured graph (H, c) is a graph H = (V (H), E(H)) together with an r-colouring of its edges c : E(H) → {1, 2, . . ., r}. (Note that an r-coloured graph may be identified with an r-colouring template where the colour classes G i , 1 ≤ i ≤ r, are pairwise edge-disjoint.)Theorem 1.4.[Aharoni, DeVos, de la Maza, Montejano and Šámal] For all n sufficiently large, any n-vertex 3-colouring template G satisfying contains a rainbow triangle.
Moreover, the lower bound in Theorem 1.4 is tight up to a O(n) additive term, as can be seen by considering the following family of constructions.Set [n] := {1, 2 . . ., n}, and write S (2) for the collection of unordered pairs of elements from a set S.  2) , F 2 := A (2) ∪ C (2) , and (2) \ A (2) .
In this terminology 1 , the authors of [1] proposed the following generalisation of Diwan and Mubayi's question: Problem 1.7.Determine the set of forcing triples. 1 In this paper we use the normalisation term n 2 /2 instead of the n 2 term used in [1] as most of our argument will be written in terms of binomial coefficients n 2 .Recently Frankl [13,Theorem 1.4] gave a new proof of Theorem 1.3 on the maximum arithmetic mean of the sizes of the colour classes in a Gallai r-colouring template, and raised the problem of maximising the geometric mean of the sizes of the colour classes for such templates in the case 2 r = 3.This can be viewed as a different way of forcing all three colour classes G 1 , G 2 and G 3 to be (reasonably) large, and of moving away from the extremal construction where two of the colour classes are complete and the third is empty.
Frankl proved an upper bound of n 2 4 on this geometric mean under the assumption that the colour classes were nested [13,Theorem 1.5].This result is tight under the nestedness assumption: a lower bound construction is obtained by taking three identical copies of T 2 (n) for the three colour classes.
Frankl conjectured that his upper bound on the geometric mean was tight in general, without the nestedness assumption on the colour classes [13,Conjecture 3].This was subsequently disproved by Frankl, Győri, He, Lv, Salia, Tompkins, Varga and Zhu, who provided a different construction, which they conjectured [14,Conjecture 2] maximises the geometric mean of the sizes of the colour classes in a Gallai 3-colouring template.Their construction turns out to be a special case of a more general construction that will play a key role in this paper, and which we define below.Write (S, T ) (2) for the collection of unordered pairs taking one vertex from each of S and T .  2, and (2) .
2 For r ≥ 4, the AM-GM inequality together with Theorem 1.3 immediately implies the geometric mean of the colour classes in a Gallai r-colouring template is at most ⌊ n 2 4 ⌋ for all n sufficiently large, so the case r = 3 is the only one for which this question is open.
See Figure 1 for a picture of the 3-colouring template H(a, b, c).The special case c = 0, b = n − a corresponds to the constuction provided by the authors of [14].It is readily checked that H is rainbow K 3 -free.Let υ denote the value of x ∈ [0, 1] maximising the value of the function The value of υ may be computed explicitly, though the exact form is not pleasant.Numerically, we have υ ≈ 0.7927 and h(υ) ≈ 0.1568.Setting a = ⌈υn⌉, b = n − a and c = 0, we have that which is significantly larger than n 2 4 for all n sufficiently large.Thus, as noted by the authors of [14], the Gallai 3-colouring template H for these values of a, b and c provides a counterexample to the aforementioned conjecture of Frankl.However they conjectured [14, Conjecture 2] that asymptotically one could not do better than the H(⌈υn⌉, n − ⌈υn⌉, 0) Gallai 3-colouring template: Conjecture 1.9 (Frankl, Győri, He, Lv, Salia, Tompkins, Varga and Zhu).Let G be a Gallai 3-colouring template on n vertices.Then The authors of [14] proved their conjecture under the assumption that the union of the colour classes covers the entire graph [14, Theorem 2] -the same assumption made earlier by Magnant, and which, as we remarked above, is both natural and highly restrictive in terms of the possible structure of G.

Results
In the present work we fully resolve Problem 1.7.This asymptotically generalises previous Turántype results for Gallai 3-colouring templates (Theorem 1.3 and Theorem 1.4), and settles Conjecture 1.9 in the affirmative.To state our result, we must define three regions in [0, 1] 2 .
while satisfying x + √ α 1 − x 2 ≤ 1.Now, (1.1) can be rewritten as a quartic equation whose solutions can be computed explicitly via radicals in terms of α 1 and α 2 .Further, as we show in Proposition 2.3, for (α 1 , α 2 ) ∈ R 1 , there exists a unique such solution , and that setting y ⋆ = α 1 − (x ⋆ ) 2 we have x ⋆ ≤ √ α 1 and x ⋆ + y ⋆ ≤ 1, yielding the canonical pair (x ⋆ , y ⋆ ).The boundary between R ′ 1 and R 1 \ R ′ 1 then corresponds to the solutions (α 1 , α 2 ) ∈ R 1 to the equation Note that for all pairs (α 1 , α 2 ) ∈ R 1 ∪ R 2 we have 1 4 ≤ α 2 ≤ α 1 and 1 2 < α 1 .See Figure 2 for a picture of the regions R ′ 1 and R 2 .Before stating our main result, we record a useful observation of Aharoni et al [1].Suppose that there exists an N -vertex Gallai colouring template G with no rainbow triangle satisfying e(G i ) = α i 2 N 2 + ε i N 2 for each i ∈ {1, 2, 3}, where the ε i are strictly positive real numbers.Write G(k) for the balanced blow-up of G obtained by replacing each vertex v of G by a set of k vertices X v and for each i replacing each edge uv ∈ E(G i ) by a complete balanced bipartite graph between X u and X v .Then for any C > 0 and all k sufficiently large, we have Since G(k) is rainbow triangle-free, this implies the existence of Gallai colouring templates J on n > N vertices with e(J i ) > α i n 2 + Cn for each i ∈ {1, 2, 3}.In particular, it is enough to resolve Problem 1.7 up to additive linear terms and with the normalisation factor n 2 replaced by the more conventional factor n 2 .With this observation in place, we can now state our main result: for any pair of densities 1 ≥ α 1 ≥ α 2 ≥ 0, we determine the least α 3 ≤ α 2 such that (α 1 , α 2 , α 3 ) is a forcing triple.Theorem 1.13.There exists a constant C > 0 such that for any (α 1 , α 2 ) ∈ [0, 1] 2 with α 1 ≥ α 2 , the following hold.

Further remarks and open problems
Minimum degree conditions: in both of our extremal colouring templates F and H, there are colour classes with isolated vertices.Indeed, we have δ(F 1 ) = δ(F 2 ) = 0 (by considering vertices in C and B respectively) and δ(G 2 ) = 0 (by considering vertices in B ∪ C).Given this, it is natural to ask how Problem 1.7 changes when we impose minim-degree rather than density conditions.We study this question in a companion paper [11], in which given δ(G 1 ) we determine the maximum possible value of δ(G 2 ) + δ(G 3 ) in a Gallai colouring template G.It turns out the extremal behaviour for this problem is starkly different from the one we established for Problem 1.7 in this paper.Indeed, the maximum possible value of δ(G 2 ) + δ(G 3 ) jumps from 2n r to 2n r+1 when δ 1 (G) increases from n − ⌈ n r ⌉ to ⌈n − n r ⌉ + 1, in contrast to the more continuous behaviour seen in Theorem 1.13.Other cliques: in [1], Aharoni, DeVos, de la Maza, Montejano and Šámal asked what happens when the triangle K 3 is replaced with a complete graph K r on r vertices when r ≥ 4.
Question 1.16.Let r ≥ 4. What is the smallest real number δ r so that for all n sufficiently large, 2 must contain a rainbow copy of K r ?
Is this bound tight for any r?Other graphs: besides larger cliques, one can ask for conditions guaranteeing the existence of rainbow copies of some other graph H. Babiński and Grzesik [3] recently considered this problem when H = P 3 , the path on 4 vertices with 3 edges.For every r ≥ 3, they determined the value of the least α(r, P 3 ) ≥ 0 such that for all α > α(r, P 3 ) and all n sufficiently large, every n-vertex r-colouring template G with min In a similar direction, Frankl, Győri, He, Lv, Salia, Tompkins, Varga and Zhu [14] successfully determined the (asymptotic behaviour of the) maximum of the geometric mean of the colour classes in r-colouring templates with no rainbow copy of H when r ∈ {3, 4} and H = P 3 and when r = 4 and H = P 4 , the path on five vertices.It would be interesting to obtain generalisation of both of these results for longer paths.Stability, colourings vs templates: we expect that the proof of Theorem 1.13 can be adapted to give stability versions of our results, but we had not explored this further due to the length of the paper.Finally, we focused in this work on colouring templates, in which colour classes may overlap.Following Erdős and Tuza [10], one could instead consider analogous problems for colourings of K n or of subgraphs of K n .Can one obtain analogues of Theorem 1.13 in this setting?

Notation
As noted above, we write [n] := {1, 2, . . .n}, S (2) Where convenient, we identify G i with its edge-set E(G i ).We also write xy for {x, y}.We use G i [X] and G i [X, Y ] as a notation for the subgraph of G i induced by the vertex-set X and for the bipartite subgraph of G i induced by the bipartition X ⊔ Y respectively.Throughout the remainder of the paper, we shall use respectively.We use Landau big O notation, and note that g = O(f ) or g = o(f ) is an assertion about the order of g and not its sign (so we do not differentiate between 1 − o(1) and 1 + o(1), for example).
Given a 3-colouring template G on a set V , we call a pair xy ∈ V (2) a rainbow edge if xy ∈ 3 i=1 G i .Further, we call a pair xy which is contained in at least two of the colour classes G 1 , G 2 , G 3 a bi-chromatic edge.The following notion of density for a colouring template will be a useful tool in our analysis: Definition 1.17 (Colour density vector).Given an r-colouring template G = (G 1 , G 2 , . . ., G r ) on an n-set V , the colour density vector of G is .
2 Critical colour densities for rainbow triangles

Preliminary remarks
We begin by analysing the colour density vectors yielded by Constructions 1.5 and 1.8.
Proposition 2.1.For a = xn, b = yn and c = zn, the colour density vectors of F and H are respectively.In particular, for z = 0 (and thus x + y = 1) they coincide asymptotically and are both equal to Proof.Simple calculation.
Recall that τ = 4− √ 7 9 .The next two propositions establish that certain (α 1 , α 2 , α 3 ) are trivially not forcing triples and that for (α 1 , α 2 ) there exists a unique canonical representation for some non-negative reals x, y with x + y ≤ 1 and Proof.For each of the four cases (a)-(d), we construct a suitable n-vertex Gallai 3-colouring template based on F = F(a, b, c) whose colour density vector is coordinate-wise asymptotically strictly greater than (α 1 , α 2 , α 3 ) (possibly after rearranging the order of the colours).Since F is rainbow K 3 -free, this suffices to show that (α 1 , α 2 , α 3 ) is not a forcing triple.
Proof.Set y(x) := √ α 1 − x 2 and z(x) := 1 − x − y(x).Our goal is to show there exists a unique solution x ⋆ to x 2 + (z(x)) 2 = α 2 with x ≥ 1 2 , y(x) real and z(x) ≥ 0. Solving the appropriate quadratic equations, it is easily checked that for . It is clear geometrically that x 0 ≤ x 1 (these values of x corresponding as they do to intersections of the circle x 2 + y 2 = α 1 with the lines y = 1 − x and y = (1 − x)/2 in the first quadrant of the plane).Further, solving another two quadratic equations, it is easily checked that x 1 ≤ √ α 1 with equality if and only if It remains to show the uniqueness of this solution.Suppose there exists x = x ⋆ + d x for some d x ≥ 0 and y, z with x + y + z = 1 such that (x, y, z) satisfies (2.1).Clearly we must have y = y(x ⋆ ) − d y and z = z(x ⋆ ) − d z for some non-negative d y , d z with d x = d y + d z (otherwise one of the equations in (2.1) or the condition x + y + z = 1 must fail).Since x ≥ 1 2 we have y ≤ 1 2 and 2 ) and hence d y = 0, and the uniqueness of our triple (x ⋆ , y(x ⋆ ), z(x ⋆ )).Definition 2.4 (Good pair).We say that a pair of non-negative real numbers and in addition the unique (x, y, z) ∈ [0, 1] 3 with x + y + z = 1 and x ≥ 1 2 such that (2.1) holds satisfies 2x 2 + z 2 ≥ 1.Given a good pair, we refer to this unique (x, y, z) (whose existence is guaranteed by Proposition 2.3) as the canonical representation of (α 1 , α 2 ).

Proof strategy
We divide the proof of Theorem 1.13 into two parts, depending on whether or not the edge densities α 1 and α 2 of the two largest colour classes satisfy In both cases, we prove a technical statement of the form 'if the colour classes of a colouring template satisfy certain inequalities, then it must contain a rainbow triangle'.To do so, we consider a putative minimal counterexample G to our technical statement, and use its minimality to rule out the existence of rainbow edges.
We then consider a largest matching M of bi-chromatic edges in G, which we use to obtain a partition of V = V (G) into sets V ij of vertices meeting a bi-chromatic edge of M in colours ij and a left-over set D. We perform a series of modification of G to obtain a new colouring template G ′′ such that the sizes of the colour classes of G ′′ satisfy the same inequalities as those of G up to some small O(n) error terms.The crux is, however, that G ′′ is very well-structured with respect to the partition obtained in the previous step, so that we have a good control over the sizes of its colour classes.In the final step of the argument, we use this information to derive a contradiction from our family of inequalities.
The idea of considering a largest matching of bi-chromatic edges and modifying G based on the resulting partition appeared previously in the work of Aharoni, DeVos, de la Maza, Montejanos and Šámal [1], more specifically their key Lemma 2.3 which inspired our approach in the case An important additional ingredient in our proof in the case is the idea of looking a vertex-minimal counterexample G which also maximises the size of the largest colour class G 1 .Indeed, this allows us to 'push' G towards a much more amenable bipartite extremal structure, which we are able to analyse.

2.3
The F-extremal region: the case Note that for α 1 ≥ 1/2 and α 2 ≥ 1/4, the inequality for α 1 , α 2 we have in this case is equivalent to the lower bound for α 2 we had in our definition of a good pair in Section 2.1: Theorem 2.5.Let (α 1 , α 2 ) be a good pair and let (x, y, z) be its associated canonical representation. Set for all distinct i, j ∈ [3], then G contains a rainbow triangle.
Proof.Observe that for n ≤ 6, the statement of Theorem 2.5 is vacuous, since 5n ≥ 2 n 2 .Suppose Theorem 2.5 is false, and let N ≥ 7 be the least value of n for which there exists a Gallai 3-colouring template G which provides a counterexample.Without loss of generality, we may assume the vertexset of G is V = [N ].We begin our proof with an analogue of [1, Lemma 2.4], which establishes inter alia that there are no rainbow edges.Lemma 2.6.For every non-empty proper subset X of V , at least one of the induced subgraphs G i [X], i ∈ [3], fails to contain a perfect matching.
Proof.Let X be a 2ℓ-set in V with 0 < ℓ < N/2.Suppose for a contradiction that the graphs (2) .
Fix a colour k ∈ [3], and let i, j denote the other two colours in [3].Let vv ′ be an edge of M k .Then every vertex u ∈ V \ X can send at most 2 edges in colour i or j to {x, x ′ } (for otherwise we have a rainbow triangle).Summing over all edges of M 3 , it follows that v} would contain a rainbow triangle).Note that the vertices v, v ′ are uniquely specified by uu ′ and the matching M k .
Thus given any uu ′ ∈ X (2) \ M k we can define a pair of edges F (uu ′ ) = {uv ′ , u ′ v}, with v, v ′ as above, such that either Observe that F (uu ′ ) ∩ F (ww ′ ) ̸ = ∅ if and only if M k contains a matching from {u, u ′ } to {w, w ′ } (i.e. if and only if ww ′ = vv ′ ), in which case F (uu ′ ) = F (ww ′ ).In particular we have that (2.5) Putting (2.4) and (2.5) together, we have Proof.Rearranging terms, what we must show is Note first of all that α i + α j ≥ 1.Indeed, since (α 1 , α 2 ) is a good pair, this is by definition the case for {i, j} = {1, 2}.Further, the definition of α 3 := 1 − x 2 ensures α 1 + α 3 = 1 + y 2 and α 2 + α 3 = 1 + z 2 are both at least 1.Now, since X was a proper non-empty subset of V , we have N > 2ℓ, and hence the first term in the sum on the left hand-side of (2.7) is non-negative.As α i + α j ≤ 2, the second term in 2.7 is strictly positive.Thus (2.7) holds, as required.
Since i, j were arbitrary, it follows from (2.6) and Claim 2.7 that G[V \ X] is a Gallai 3-colouring template on n = N − |X| < N vertices satisfying (2.3), and hence a smaller counterexample to Theorem 2.5, contradicting the minimality of N .
Still following Aharoni et al's approach from [1], we consider a largest matching M of bichromatic edges (called digons in [1]), to obtain a partition of the vertex set.For ij ∈ [3] (2) , set M ij := M ∩ G i ∩ G j , and let V ij denote the collection of vertices contained in an edge of M ij .Set D := V \ (V 13 ⊔ V 23 ⊔ V 23 ) to be the set of vertices not contained in an edge of M .As observed by Aharoni et al, one can perform some local modifications of G to obtain a new colouring template G ′′ which is well-structured with respect to the partition V = V 13 ⊔ V 12 ⊔ V 23 ⊔ D, may possibly contain rainbow triangles, but importantly satisfies the bounds (2.3) up to a small correction term which is linear in N .More explicitly, combining [1, Claims 1-3], one obtains the following: Proposition 2.9 (Claims 1-3 in [1]).There exists a 3-colouring template G ′′ on V such that the following hold: holds for all distinct i and j; (ii) 3 i=1 G ′′ i = ∅ (i.e.there are no rainbow edges) V ij induces a bi-chromatic clique of edges in colours i and j, and thus by condition (ii) above contains no edge in the third colour); (iv) there are no bi-chromatic edges inside D or between distinct sets Proof.Immediate from the construction of the modified colour classes G ′′ i , i ∈ [3] in [1, Claims 1-3] (which only rely on Lemma 2.6, Proposition 2.8 and the self-contained graph theoretic lemma [1, Lemma 2.2]).Note that we started out with a slightly larger linear term in our inequality (2.3), whence the slightly larger term in the expression to the right of the last inequality in condition (i).
Set a ij := |V ij |/N and d := |D|/N .We are now ready to proceed with the last part of the proof of Theorem 2.5, where we use the structure of the colouring template G ′′ to derive upper bounds for the sizes of its colour classes in terms of (a 12 , a 13 , a 23 , d) (Lemma 2.10 below), which we then show contradict the lower bounds from Proposition 2.9(i) (Lemma 2.12 below).Lemma 2.12 is also the point in the proof of Theorem 2.5 where we depart from the approach of Aharoni et al [1].
Lemma 2.10.The following inequalities are satisfied: ) ) Proof.For inequality (2.8), we bound the sum of the number of edges in colours 1 and 2. Clearly a pair of vertices from V can contribute at most 2 to the sum However by Proposition 2.9(iii) and (iv), pairs of vertices from (V 13 ) (2) , (V 23 ) (2) and D (2) contribute at most 1 to this sum.Further, by Proposition 2.9(iv), a vertex-pair xx ′ with x, x ′ coming from two different sets V ij can contribute at most 1 to this sum.Finally, by Proposition 2.9(v), each edge from M 13 or M 23 sends at most two edges in colours 1 or 2 to a vertex y ∈ D, while each edge of M 12 sends at most three edges in colours 1 or 2 to a vertex y ∈ D. Summing over all such edges, we see that the total contribution to |G Combining this upper bound with the lower bound for |G ′′ 1 | + |G ′′ 2 | from Proposition 2.9(i), subtracting N from both sides and dividing through by N  2 , we get the desired inequality (2.8).Inequalities (2.9) and (2.10) are obtained in the same way, mutatis mutandis.
Next we turn our attention to the proof of inequality (2.11).This is done by bounding the number of edges in colours 1, 2 and 3. We see that each pair xx ′ contributes at most one to the sum i |G ′′ i |, with two exceptions.If x, x ′ ∈ V ij , then xx ′ is a bi-chromatic edge and contributes 2 to this sum.Finally, some pairs x ∈ V ij , y ∈ D may also contribute up to 2 to this sum; we bound the contribution of those pairs by appealing to Proposition 2.9(v) which implies that for each pair xx ′ from M ij , the sum of the contributions from xy and x ′ y to On the other hand, summing up the lower bounds for |G ′′ i | + |G ′′ j | we get from Proposition 2.9(i) for all three pairs ij ∈ [3] (2) , we have We shall now derive a contradiction from the system of inequalities we have derived (which unfortunately requires a significant amount of careful calculations).To do so, we shall make use of the following simple fact.Lemma 2.12.Suppose that a 12 , a 13 , a 23 and d are non-negative real numbers satisfying inequalities (2.8)-(2.14).Then we have a 12 + a 13 + a 23 + d > 1.
Proof.Since (α 1 , α 2 ) is a good pair, we have by definition α 1 ≥ α 2 and α 2 − α 3 = 2x 2 + z 2 − 1 ≥ 0, and hence α 2 ≥ α 3 .In particular, the right hand-side in the inequalities (2.8), (2.9) and (2.10) form a decreasing sequence.On the other hand, for d fixed, the expressions on the left hand-side of the inequalities inequalities (2.8), (2.9) and (2.10) are increasing functions of a 12 , a 13 and a 23 respectively.Similarly the right-hand sides of the inequalities (2.12), (2.13) and (2.14) form an increasing sequence, and for d fixed, the expressions on the left hand side are increasing functions of a 12 , a 13 and a 23 respectively.Since the inequality (2.11) is invariant under any permutation of (a 12 , a 13 , a 23 ), it follows that we may permute the first three coordinates of (a 12 , a 13 , a 23 , d) to ensure a 12 ≥ a 13 ≥ a 23 , while still satisfying our constraints and without decreasing the value of a 12 + a 13 + a 23 + d.
We may thus assume a 12 ≥ a 13 ≥ a 23 in the remainder of the proof.With this assumption in hand, some of our inequalities become superfluous.Moving forward in the proof, we relax (2.10) to a non-strict inequality and only use (2.9), the relaxed inequality (2.10), (2.11) and (2.12).Suppose for the sake of contradiction that we have chosen non-negative real numbers a ij and d so that a 12 + a 13 + a 23 + d ≤ 1 and the inequalities (2.9), (2.10), (2.11) and (2.12) are satisfied.Given the value of a 13 + a 23 , we can increase the value of a 13 while decreasing a 23 without violating the inequalities (2.9), (2.11) or (2.12), as long as the inequality (2.10) remains satisfied and as long the inequality a 12 ≥ a 13 is still satisfied.This is evident from the symmetric role played by the variables a 13 and a 23 and the convexity of the expressions in (2.11) and (2.12).
Thus we may assume that either a 12 = a 13 or the inequality (2.10) is tight.First let us suppose that a 12 = a 13 and a 12 + a 13 + a 23 + d ≤ 1.Then it follows that However, it is easy to check that the inequality , and hence we are done in this case.
Hence we may suppose that the inequality (2.10) is tight, i.e. that we have (a 23 ) 2 + da 23 = z 2 .Hence it follows that Let δ ≥ 0 be chosen so that a 2 13 + da 13 = y 2 + δ, and note that the non-negativity of δ is guaranteed by (2.9).Hence we have Combining this with (2.16), we can simplify the inequalities (2.12) and (2.11) to obtain the following lower bounds for a 12 : We start by observing that we must have d > 0. Indeed, if d = 0, then (2.16) and (2.17) imply that a 13 ≥ y and a 23 = z.Increasing the value of a 12 if necessary, we may assume that a 12 + a 13 + a 23 = 1 without violating (2.11).However, then Proposition 2.11 implies that a 2  12 + a 2  13 + a 2 23 ≤ x 2 + y 2 + z 2 , which contradicts (2.11).Thus we must have d > 0. Next, we note that we may assume δ < x 2 −y 2 2 .
Assuming from now on that δ < x 2 −y 2 2 , we make a useful observation on the value of x before splitting our analysis into two cases, depending on which of the two inequalities (2.18) and (2.19) gives the best lower bound for a 12 .
Proof.Since (α 1 , α 2 ) is a good pair, we have Solving the associated quadratic inequality and using the fact that x ≥ 0 yields the claimed lower bound on x: Let us fix d > 0, and define the function and observe that by (2.18) we have a 12 + a 13 + a 23 + d ≥ f (δ).Thus our aim is to prove that the least value of f on this interval is strictly greater than 1.The derivative of f can be written as .
In particular, there exists a constant c = , we may turn our attention to analysing It is easy to check that we have Let us consider (2.21) with z and d fixed, and varying x and y while keeping x + y as constant.Set s := x + y, and note that by Claim 2.14 we have x ≥ 1 − 2τ and thus s ≥ 1+x 2 ≥ 1 − τ .Rewriting (2.21) as a function g(x) = g s,z,d (x) of x, we obtain whose derivative is given by Our aim is to show that g ′ (x) is positive for 1−2τ ≤ x ≤ 1.We first note that 4d √ x 2 + d 2 −3d 2 > d 2 .Since x − s < 0, we obtain that Thus it suffices to prove that g ′ (x) > 0 in order to deduce that x 2 4(s This follows from the fact that 2(s We now substitute the value x = 1−2τ into (2.21) and set By differentiating and using the facts that y ≤ 1 − x = 2τ , that z ≤ 1−x 2 ≤ τ , and that 4 √ This concludes the proof in this case.
. Let ℓ(δ) = ℓ x,y,z,d (δ) denote the function given by Since δ ≤ x 2 −y 2 2 , it follows that d 2 + 4x 2 − 4δ ≥ d 2 + 4y 2 + 4δ, and hence we have ℓ ′ (δ) ≥ 0 for δ ≤ x 2 −y 2 2 .Thus ℓ(δ) attains its minimum on our interval d As the inequalities (2.18) and (2.19) give the same bound for a 12 when δ 1 (the latter strict inequality being proved in our analysis of Case 1).Thus in this case also we must have a 12 + a 13 + a 23 + d > 1.Combined with Claim 2.13, our case analysis proves Lemma 2.12.Now the conclusion Lemma 2.12 contradicts the fact that we have a 12 + a 13 + a 23 + d = 1; this contradiction shows no counterexample to Theorem 2.5 exists, concluding the proof of the theorem.

2.4
The H-extremal region: the case Given a 3-colouring template G on N vertices with 2 for i ∈ [3] and assuming α 3 ≤ α 2 , (2.23) implies after rearranging terms and dividing through by , which up to the error term is exactly the bound we require in Theorem 1.13 part (b).
Proof.Let C > 0 be a sufficiently large constant to be specified later.It will be convenient to give a name to the function of max {|G 2 |, |G 3 |} involved in the definition of g(G).Set therefore f n : R ≥0 → R to be the function given by When n is clear from context, we often omit the subscript n and write f for the function f n .
Proposition 2.17.The function f is strictly decreasing in the interval [0, 1   4   n 2 ] and strictly increasing in the interval Proof.Simple calculus.
Suppose Theorem 2.15 is false, and let N be the least value of n ≥ 3 for which there exists a Gallai 3-colouring template satisfying the assumptions of Theorem 2.15.Among such Gallai colouring templates, let G be one maximising the size of the largest colour class |G 1 |.In the next lemma, we show that the sizes of the vertex set and of the colour classes in this putative counterexample to Theorem 2.15 cannot be too small.
Lemma 2.18.The following hold: Lemma 2.20.There are no rainbow edges in G: Proof.Suppose for a contradiction that xx ′ ∈ G 1 ∩ G 2 ∩ G 3 .We shall show the subtemplate G ′ induced by V \ {x, x ′ } is a smaller counterexample to Theorem 2.15.
Observe that for every y ∈ V \ {x, x ′ }, if one of the edges xy, x ′ y is bi-chromatic or rainbow, then the other edge must be missing from 3 i=1 G i (as otherwise we have a rainbow triangle in G).In particular, writing R for the number of rainbow edges from xx ′ to V \ {x, x ′ } (which by our observation satisfies R ≤ N − 2), we have Clearly, the size of the second largest colour class in and |G 3 | decreased by at least R + 1 when we removed the rainbow edge xx ′ and the R rainbow edges from xx ′ to V \ {x, x ′ }).Now, we have that . Further, by our observation above R + 1 ≤ N − 1, whence ρ ≤ 1.By a straightforward asymptotic analysis, Combining this fact with (2.24), (2.25) and (2.26), and picking C > 5 sufficiently large to ensure that we can absorb the O(1) term in (2.26) with the 2C − 5 term in (2.24) (recall that N > 4C by Lemma 2.18(ii), so picking C sufficiently large ensures N itself can be made sufficiently large), we get We are now done once we observe that if g ′ 2 is the size of the second largest colour class in G ′ , then . Indeed, as we noted above, g ′ 2 ≤ |G 2 | − R − 1.On the other hand, note that all colour classes have lost at most 1 + 2(N − 2) = 2N − 3 edges when we removed xx ′ from V .Thus by Lemma 2.18(iii) Step 2: cleaning inside the V 1j .We sequentially go through the pairs of distinct edges X, X ′ ∈ M 12 .For each such pair, if there is one edge in colour 3 between X and X ′ then we have that (a) XX ′ is an edge in our our auxiliary graph A, and (b) there are at least two edges from X to X ′ which are missing in G 1 ∪ G 2 (by Proposition 2.22(i)).We then delete this edge in colour 3, and arbitrarily add in one of the at least two missing edges in colour 1 between X and X ′ .If there are two edges in colour 3 between X and X ′ , then we replace them with the two missing edges from G 1 [X, X ′ ], one after the other.By Proposition 2.24, this does not decrease the value of g(G ′ ).
Note that there cannot be more than 2 edges in colour 3 between them as N , then we stop our procedure and output the colouring template G ′′ = G ′ .
We then repeat the same procedure with colours 2 and 3 switching roles, i.e. replace edges in colours 2 inside V 13 by edges in colour 1 (and outputting G ′′ = G ′ if the size of the second largest colour class ever becomes too small).Throughout, the value of g(G ′ ) does not decrease (and thus remains at least g(G) − N ).If the size of the second largest colour class in G ′ does not become too small in the process, then when we are done with this sequence of operations we have that for j ∈ {2, 3} the set V 1j only contains edges in colours 1 or j and for every edge XX ′ ∈ A[V 1j ], there is (still) at least one edge in (X, X ′ ) (2) missing in G ′ j .
Step 3: cleaning across V 12 ×V 13 .Recall the auxiliary graph A introduced after Proposition 2.22.We sequentially go through the pairs X ∈ M 12 , Y ∈ M 13 with XY / ∈ A. For each such pair, we have To be more precise, at each step of this subprocess we let j ∈ {2, 3} be the second largest colour class in G ′ and k the third largest colour class.If there is in (M 12 , M 13 ) (2) any edge f of G j and at least one missing edge in G 1 , then we remove the edge f in colour j from G ′ and replace it by an edge f ′ in colour 1; if this brings max(|G ′ 2 |, |G ′ 3 |) below 1 4 N 2 + N , then we stop our procedure and output the colouring template G ′′ = G ′ .Otherwise if there is in (M 12 , M 13 ) (2) any edge f of G k and any edge f ′ missing from G 1 , then we remove the edge f in colour k from G ′ and replace it by an edge in colour 1.By Proposition 2.24(i) this does not decrease g.
When the subprocess ends, we have at most + N , then we stop our procedure and output the colouring template G ′′ = G ′ .Otherwise, we have decreased the value of g by at most N/4 in total in this step, whence g(G ′ ) ≥ g(G) − 2N , and G ′ has the following property for j ∈ {2, 3}: at most half of the edges from V 1j to D are in G ′ j , and all other edges of G ′ j lie inside V 1j . (2.27) We set G ′′ = G ′ and terminate our modification procedure.We are now ready to bound g(G ′′ ) and obtain the desired contradiction.
Proof.Since, as noted at the end of our modification procedure, g(G) ≤ g(G ′′ ) + 2N , it follows from Lemma 2.25 that g(G) ≤ 5N , whence G fails to satisfy (2.23) (since C was chosen so that C > 5), a contradiction.Thus there is no counterexample to Theorem 2.15, concluding our proof.

Construction 1 . 5 (
F(a, b, c)-templates).Let a, b and c be non-negative integers with a+b+c = n.Arbitrarily partition [n] as [n] = A ⊔ B ⊔ C, with |A| = a, |B| = b and |C| = c.Define graphs F 1 , F 2 and F 3 on the vertex set [n] by setting

Figure 1 :F
Figure 1: The Gallai colouring templates F (a, b, c) and H (a, b, c) with red (thin lines), green (thick lines) and blue (doubled lines) representing edges in colours 1, 2 and 3 respectively.A

Construction 1 . 8
(H(a, b, c)-templates).Let a, b and c be non-negative integers with a+b+c = n.Arbitrarily partition [n] as [n] = A ⊔ B ⊔ C, with |A| = a, |B| = b and |C| = c.Define graphs H 1 , H 2 and H 3 on the vertex set [n] by setting
along this curve, our extremal 3-colouring templates H and F both have |C| = o(n) and (up to changing at most o(n 2 ) edges into non-edges and vice versa in each of the colour classes) degenerate down to the same 3-colouring template G on

Proposition 2 . 11 .
Let b 0 , c 0 and s be given non-negative reals satisfying c 0 ≤ b 0 and 2b 0 + c 0 ≤ s.Then the expression a 2 + b 2 + c 2 attains its maximum value subject to the conditions b ≥ b 0 , c ≥ c 0 , a + b + c = s and a ≥ b ≥ c uniquely when a = s − b 0 − c 0 , b = b 0 and c = c 0 .Proof.Immediate from the convexity of the function x → x 2 .
Let k(d) denote the function on the right hand side of the inequality above.As shown in the Appendix (inequality (A.1)), the function k(d) is positive for d ∈ [0, 1].In particular, it follows that h ′ (d) is positive for all d ∈ [0, 1], and hence h(d) is increasing.Thus h(d) > h(0) = x+y +z = 1 for all d > 0, which implies that f d √ x 2 + d 2 − d 2 > 1. Hence a 12 + a 13 + a 23 + d > 1 whenever

4 i=1 3 |) below 1 4 N 2 +
G i [X, Y ] ≤ 4. So we can sequentially delete edges from X to Y in colours 2 or 3, and replace them by edges from X to Y in colour 1.If this change brings max(|G ′ 2 |, |G ′ N , then we stop our procedure and output the colouring template G ′′ = G ′ .By Proposition 2.24(i), this does not decrease the value of g(G ′ ).Next, we turn our attention to the pairs X ∈ M 12 , Y ∈ M 13 with XY ∈ A. It follows from Proposition 2.22(iii) that for each X ∈ M 12 , the collection of Y ∈ M 13 with XY ∈ A forms a clique in A. By a graph theoretic result of Aharoni et al [1, Lemma 2.2], under such a condition on the neighbourhoods we have |A[M 12 , M 13 ]| ≤ |A[M 12 ]| + |A[M 13 ]| + |M 12 | + |M 13 | 2 For convenience, set e 12 = |A[M 12 ]|, e 13 = |A[M 13 ]| and e = |A[M 12 , M 13 ]|.We begin by moving min{e 12 , e} edges from G 2 [M 12 , M 13 ] to G 2 [M 12 ] and min{e 13 , e} edges from G 3 [M 12 , M 13 ] to G 3 [M 13 ] (adding edges in colour 1 to preserve G ′ 2 ⊔ G ′ 3 ⊆ G ′ 1 if necessary).This clearly does not decrease the value of g.Next we go through the remaining edges in colours 2 or 3 in (M 12 , M 13 ) (2) one after the other, and replace all but at most e − min(e, e 12 ) − min(e, e 13 ) ≤ |M 12 |+|M 13 | 2 of them by edges in colour 1.

Figure 3 :
Figure 3: A plot of the function k(d) from (A.1) for d ∈ [0, 1] this latter possibility occurring if and only if we have (up to permutations of the pairs jk, xx ′ and yy ′ 1, so combining this lower bound with the upper bound in (2.15), we get the desired inequality (2.11).Inequalities (2.12), (2.13) and (2.14) can be proved similarly.For instance, (2.12) follows by counting edges in G ′′ 1 and G ′′ 2 twice and edges in G ′′ 3 three times, and analysing how many times different types of pairs can be counted in this sum.Inequalities (2.13) and (2.14) can be proved by counting similar linear combinations of the |G ′′ i |.