A proof of Ringel's Conjecture

A typical decomposition question asks whether the edges of some graph $G$ can be partitioned into disjoint copies of another graph $H$. One of the oldest and best known conjectures in this area, posed by Ringel in 1963, concerns the decomposition of complete graphs into edge-disjoint copies of a tree. It says that any tree with $n$ edges packs $2n+1$ times into the complete graph $K_{2n+1}$. In this paper, we prove this conjecture for large $n$.

Osthus [12] have proved Ringel's conjecture for very large bounded-degree trees. Ferber and Samotij [8] obtained an almost-perfect packing of almost-spanning trees with maximum degree O(n/ log n), thus giving an approximate version of Ringel's conjecture for trees with maximum degree O(n/ log n). A different proof of this was obtained by Adamaszek, Allen, Grosu, and Hladký [1], using graph labellings. Allen, Böttcher, Hladký and Piguet [3] almostperfectly packed arbitrary spanning graphs with maximum degree O(n/ log n) and constant degeneracy 1 into large complete graphs. Recently Allen, Böttcher, Clemens, and Taraz [2] found perfect packings of complete graphs into specified graphs with maximum degree o(n/ log n), constant degeneracy, and linearly many leaves. To tackle Ringel's conjecture, the above mentioned papers developed many powerful techniques based on the application of probabilistic methods and Szemerédi's regularity lemma. Yet, despite the variety of these techniques, they all have the same limitation, requiring that the maximum degree of the tree should be much smaller than n.
A lot of the work on Ringel's Conjecture has used the graceful labelling approach. This is an elegant approach proposed by Rósa [22]. For an (n + 1)-vertex tree T a bijective labelling of its vertices f : V (T ) → {0, . . . , n} is called graceful if the values |f (x) − f (y)| are distinct over the edges (x, y) of T . In 1967 Rósa conjectured that every tree has a graceful labelling. This conjecture has attracted a lot of attention in the last 50 years but has only been proved for some special classes of trees, see e.g., [9]. The most general result for this problem was obtained by Adamaszek, Allen, Grosu, and Hladký [1] who proved it asymptotically for trees with maximum degree O(n/ log n). The main motivation for studying graceful labellings is that one can use them to prove Ringel's conjecture. Indeed, given a graceful labelling f : V (T ) → {0, . . . , n}, think of it as an embedding of T into {0, . . . , 2n}. Using addition modulo 2n + 1, consider 2n + 1 cyclic shifts T 0 , . . . , T 2n of T , where the tree T i is an isomorphic copy of T whose vertices are V (T i ) = {f (v) + i | v ∈ V (T )} and whose edges are E(T i ) = {(f (x) + i, f (y) + i) | (x, y) ∈ E(T )}. It is easy to check that the fact that f is graceful implies that the trees T i are edge disjoint and therefore decompose K 2n+1 .
Rósa also introduced a related proof approach to Ringel's conjecture called "ρ-valuations". We describe it using the language of "rainbow subgraphs", since this is the language which we ultimately use in our proofs. A rainbow copy of a graph H in an edge-coloured graph G is a subgraph of G isomorphic to H whose edges have different colours. Rainbow subgraphs are important because many problems in combinatorics can be rephrased as problems asking for rainbow subgraphs (for example the problem of Euler on Latin squares mentioned above). Ringel's conjecture is implied by the existence of a rainbow copy of every n-edge tree T in the following edge-colouring of the complete graph K 2n+1 , which we call the near distance (ND-)colouring. Let {0, 1, . . . , 2n} be the vertex set of K 2n+1 . Colour the edge ij by colour k, where k ∈ [n], if either i = j + k or j = i + k with addition modulo 2n + 1. Kotzig [22] noticed that if the ND-coloured K 2n+1 contains a rainbow copy of a tree T , then K 2n+1 can be decomposed into copies of T by taking 2n + 1 cyclic shifts of the original rainbow copy, as explained above (see also Figure 1). Motivated by this and Ringel's Conjecture, Kotzig conjectured that the ND-coloured K 2n+1 contains a rainbow copy of every tree on n edges. To see the connection with graceful labellings, observe that such a labelling of the tree T is equivalent to a rainbow copy of this tree in the ND-colouring whose vertices are {0, . . . , n}. Clearly, specifying exactly the vertex set of the tree adds an additional restriction which makes it harder to find such a rainbow copy.
In [19] we gave a new approach to embedding large trees (with no degree restrictions) into edge-colourings of complete graphs, and used this to prove Conjecture 1.1 asymptotically. Here, we further develop and refine this approach, combining it with several critical new ideas to prove Ringel's conjecture for large complete graphs. 8 Figure 1: The ND-colouring of K 9 and a rainbow copy of a tree T with four edges. The colour of each edge corresponds to its Euclidean length. By taking cyclic shifts of this tree around the centre of the picture we obtain 9 disjoint copies of the tree decomposing K 9 (and thus a proof of Ringel's Conjecture for this particular tree). To see that this gives 9 disjoint trees, notice that edges must be shifted to other edges of the same colour (since shifts are isometries).

Proof outline
From the discussion in the introduction, to prove Theorem 1.2 it is sufficient to prove the following result.
Theorem 2.1. For sufficiently large n, every ND-coloured K 2n+1 has a rainbow copy of every n-edge tree.
That is, for large n, and each (n + 1)-vertex tree T , we seek a rainbow copy of T in the ND-colouring of the complete graph with 2n + 1 vertices, K 2n+1 . Our approach varies according to which of 3 cases the tree T belongs to. For some small δ > 0, we show that, for every large n, every (n + 1)-vertex tree falls in one of the following 3 cases (see Lemma 3.5), where a bare path is one whose internal vertices have degree 2 in the parent tree.
A T has at least δ 6 n non-neighbouring leaves.
B T has at least δn/800 vertex-disjoint bare paths with length δ −1 .
C Removing leaves next to vertices adjacent to at least δ −4 leaves gives a tree with at most n/100 vertices.
As defined above, our cases are not mutually disjoint. In practice, we will only use our embeddings for trees in Case A and B which are not in Case C. In [19], we developed methods to embed any (1− )n-vertex tree in a rainbow fashion into any 2-factorized K 2n+1 , where n is sufficiently large depending on . A colouring is a 2-factorization if every vertex is adjacent to exactly 2 edges of each colour. In this paper, we embed any (n + 1)-vertex tree T in a rainbow fashion into a specific 2-factorized colouring of K 2n+1 , the ND-colouring, when n is large. To do this, we introduce three key new methods, as follows.

M1
We use our results from [18] to suitably randomize the results of [19]. This allows us to randomly embed a (1 − )n-vertex tree into any 2-factorized K 2n+1 , so that the image is rainbow and has certain random properties. These properties allow us to apply a case-appropriate finishing lemma with the uncovered colours and vertices.

M2
We use a new implementation of absorption to embed a small part of T while using some vertices in a random subset of V (K 2n+1 ) and exactly the colours in a random subset of C(K 2n+1 ). This uses different absorption structures for trees in Case A and in Case B, and in each case gives the finishing lemma for that case.
M3 We use an entirely new, deterministic, embedding for trees in Case C.
For trees in Cases A and B, we start by finding a random rainbow copy of most of the tree using M1, as outlined in Section 2.1. Then, we embed the rest of the tree using uncovered vertices and exactly the unused colours using M2, which gives a finishing lemma for each case. These finishing lemmas are discussed in Section 2.2. We use M3 to embed trees in Case C, which is essentially independent of our embeddings of trees in Cases A and B. This method is outlined in Section 2.3. In Section 2.4, we state our main lemmas and theorems, and prove Theorem 2.1 subject to these results.
The rest of the paper is structured as follows. Following details of our notation, in Section 3 we recall and prove various preliminary results. We then prove the finishing lemma for Case A in Section 4 and the finishing lemma for Case B in Section 5 (together giving M2). In Section 6, we give our randomized rainbow embedding of most of the tree (M1). In Section 7, we embed the trees in Case C with a deterministic embedding (M3). Finally, in Section 8, we make some concluding remarks.

M1: Embedding almost all of the tree randomly in Cases A and B
For a tree T in Case A or B, we carefully choose a large subforest, T say, of T , which contains almost all the edges of T . We find a rainbow copyT of T in the ND-colouring of K 2n+1 (which exists due to [19]), before applying a finishing lemma to extendT to a rainbow copy of T . Extending to a rainbow copy of T is a delicate businesswe must use exactly the n − e(T ) unused colours. Not every rainbow copy of T will be extendable to a rainbow copy of T . However, by combining our methods in [18] and [19], we can take a random rainbow copyT of T and show that it is likely to be extendable to a rainbow copy of T . Therefore, some rainbow copy of T must exist in the ND-colouring of K 2n+1 .
AsT is random, the setsV := V (K 2n+1 ) \ V (T ) andC := C(K 2n+1 ) \ C(T ) will also be random. The distributions ofV andC will be complicated, but we will not need to know them. It will suffice that there will be large (random) subsets V ⊆V and C ⊆C which each do have a nice, known, distribution. Here, for example, V ⊆ V (K 2n+1 ) has a nice distribution if there is some q so that each element of V (K 2n+1 ) appears independently at random in V with probability q -we say here that V is q-random if so, and analogously we define a q-random subset C ⊆ C(K 2n+1 ) (see Section 3.2). A natural combination of the techniques in [18,19] gives the following.
Theorem 2.2. For each > 0, the following holds for sufficiently large n. Let K 2n+1 be 2-factorized and let T be a forest on (1 − )n vertices. Then, there is a randomized subgraphT of K 2n+1 and random subsets V ⊆ V (K 2n+1 ) \ V (T ) and C ⊆ C(K 2n+1 ) \ C(T ) such that the following hold for some p := p(T ) (defined precisely in Theorem 2.5).
A1T is a rainbow copy of T with high probability.
A2 V is (p + )/6-random and C is (1 − ) -random. (V and C may depend on each other.) We will apply a variant of Theorem 2.2 (see Theorem 2.5) to subforests of trees in Cases A and B, and there we will have that p poly . Note that, then, C will likely be much smaller than V . This reflects thatT ⊆ K 2n+1 will contain fewer than n out of 2n + 1 vertices, while C(K 2n+1 ) \ C(T ) contains exactly n − e(T ) out of n colours.
As explained in [19], in general the sets V and C cannot be independent, and this is in fact why we need to treat trees in Case C separately. In order to finish the embedding in Cases A and B, we need, essentially, to find some independence between the sets V and C (as discussed below). The embedding is then as follows for some small δ governing the case division, with = δ 6 in Case A and¯ δ in Case B. Given an (n + 1)-vertex tree T in Case A or B we delete either n non-neighbouring leaves (Case A) or¯ n/k vertex-disjoint bare paths with length k = δ −1 (Case B) to obtain a forest T . Using (a variant of) Theorem 2.2, we find a randomized rainbow copŷ T of T along with some random vertex and colour sets and apply a finishing lemma to extend this to a rainbow copy of T .
After a quick note on the methods in [18] and [19], we will discuss the finishing lemmas, and explain why we need some independence, and how much independence is needed.

Randomly embedding nearly-spanning trees
In [19], we embedded a (1 − )n-vertex tree T into a 2-factorization of K 2n+1 by breaking it down mostly into large stars and large matchings. For each of these, we embedded the star or matching using its own random set of vertices and random set of colours (which were not necessarily independent of each other). In doing so, we used almost all of the colours in the random colour set, but only slightly less than one half of the vertices in the random vertex set. (This worked as we had more than twice as many vertices in K 2n+1 than in T .) For trees not in Case C, a substantial portion of a large subtree was broken down into matchings. By embedding these matchings more efficiently, using results from [18], we can use a smaller random vertex set. This reduction allows us to have, disjointly from the embedded tree, a large random vertex subset V .
More precisely, where q, n −1 , using a random set V of 2qn vertices and a random set C of qn colours, in [19] we showed that, with high probability, from any set X ⊆ V (K 2n+1 ) \ V with |X| ≤ (1 − )qn, there was a C-rainbow matching from X into V . Dividing V randomly into two sets V 1 and V 2 , each with qn vertices, and using the results in [18], we can use V 1 to find the C-rainbow matching (see Lemma 3.18). Thus, we gain the random set V 2 of qn vertices which we do not use for the embedding of T , and we can instead use it to extend this to an (n + 1)-vertex tree in K 2n+1 . Roughly speaking, if in total pn vertices of T are embedded using matchings, then we gain altogether a random set of around pn vertices.
If a tree is not in Case C, then the subtree/subforest we embed using these techniques has plenty of vertices embedded using matchings, so that in this case we will be able to take p ≥ 10 −3 when we apply the full version of Theorem 2.2 (see Theorem 2.5). Therefore, we will have many spare vertices when adding the remaining n vertices to the copy of T . Our challenges are firstly that we need to use exactly all the colours not used on the copy of T and secondly that there can be a lot of dependence between the sets V and C. We first discuss how we ensure that we use every colour.

M2: Finishing the embedding in Cases A and B
To find trees using every colour in an ND-coloured K 2n+1 we prove two finishing lemmas (Lemma 2.6 and 2.7). These lemmas say that, for a given randomized set of vertices V and a given randomized set of colours C, we can find a rainbow matching/path-forest which uses exactly the colours in C, while using some of the vertices from V . These lemmas are used to finish the embedding of the trees in Cases A and B, where the last step is to (respectively) embed a matching or path-forest that we removed from the tree T to get the forest T . Applying (a version of) Theorem 2.2 we get a random rainbow copyT of T and random setsV = V (K n ) \ V (T ) and In order to apply the case-appropriate finishing lemma, we need some independence betweenV andC, for reasons we now discuss for Case A, and then Case B. Next, we discuss the independence property we use and how we achieve this independence. (Essentially, this property is thatV andC contain two small random subsets which are independent of each other.) Finally, we discuss the absorption ideas for Case A and Case B.

Finishing with matchings (for Case A)
In Case A, we take the (n + 1)-vertex tree T and remove a large matching of leaves, M say, to get a tree, T say, that can be embedded using Theorem 2.2. This gives a random copy,T say, of T along with random sets V ⊆ V (K 2n+1 ) \ V (T ) and C ⊆ C(K 2n+1 ) \ C(T ) which are (p + )/6-random and (1 − ) -random respectively. For trees not in Case C we will have p . Let X ⊆ V (T ) be the set of vertices we need to add neighbours to as leaves to makeT into a copy of T .
We would like to find a perfect matching from X toV := V (K 2n+1 ) \ V (T ) with exactly the colours in C := C(K 2n+1 ) \ C(T ), using that V ⊆V and C ⊆C. (A perfect matching from X toV is such a matching covering every vertex in X.) Unfortunately, there may be some x ∈ X with no edges with colour inC leading tō V . (If C and V were independent, then this would not happen with high probability.) If this happens, then the desired matching will not exist.
In Case B, a very similar situation to this may occur, as discussed below, but in Case A there is another potential problem. There may be some colour c ∈C which does not appear between X andV , again preventing the desired matching existing. This we will avoid by carefully embedding a small part of T so that every colour appears between X andV on plenty of edges.

Finishing with paths (for Case B)
In Case B, we take the (n + 1)-vertex tree T and remove a set of vertex-disjoint bare paths to get a forest, T say, that can be embedded using Theorem 2.2. This gives a random copy,T say, of T along with random sets V ⊆ V (K 2n+1 ) \ V (T ) and C ⊆ C(K 2n+1 ) \ C(T ) which are (p + )/6-random and (1 − ) -random respectively. For trees not in Case C we will have p . Let and X = {x 1 , . . . , x , y 1 , . . . , y } ⊆ V (T ) be such that to get a copy of T fromT we need to add vertex-disjointly a suitable path between x i and y i , for each i ∈ [ ]. We would like to find these paths with interior vertices inV := V (K 2n+1 ) \ V (T ) so that their edges are collectively rainbow with exactly the colours in C := C(K 2n+1 ) \ C(T ), using that V ⊆V C ⊆C. Unfortunately, there may be some x ∈ X with no edges with colour inC leading to V . (If C and V were independent, then, again, this would not happen with high probability.) If this happens, then the desired paths will not exist.
Note that the analogous version of the second problem in Case A does not arise in Case B. Here, it is likely that every colour appears on many edges within V , so that we can use any colour by putting an appropriate edge within V in the middle of one of the missing paths.

Retaining some independence
To avoid the problem common to Cases A and B, when proving our version of Theorem 2.2 (that is, Theorem 2.5), we set aside small random sets V 0 and C 0 early in the embedding, before the dependence between colours and vertices arises. This gives us a version of Theorem 2.2 with the additional property that, for some µ , there are additional random sets such that the following holds in addition to A1 and A2.
A3 V 0 is a µ-random subset of V (K 2n+1 ), C 0 is a µ-random subset of C(K 2n+1 ), and they are independent of each other.
Then, by this independence, with high probability, every vertex in K 2n+1 will have µ 2 n/2 adjacent edges with colour in C 0 going into the set V 0 (see Lemma 3.15).
To avoid the problem that only arises in Case A, consider the set U ⊆ V (T ) of vertices which need leaves added to them to reach T from T . By carefully embedding a small subtree of T containing plenty of vertices in U , we ensure that, with high probability, each colour appears plenty of times between the image of U and V 0 . That is, we have the following additional property for some 1/n ξ µ.
A4 With high probability, if Z is the copy of U inT , then every colour in C(K 2n+1 ), has at least ξn edges between Z and V 0 .
Of course, A3 and A4 do not show that our desired matching/path-collection exists, only that (with high probability) there is no single colour or vertex preventing its existence. To move from this to find the actual matching/path-collection we use distributive absorption.

Distributive absorption
To prove our finishing lemmas, we use an absorption strategy. Absorption has its origins in work by Erdős, Gyárfás and Pyber [6] and Krivelevich [15], but was codified by Rödl, Ruciński and Szemerédi [21] as a versatile technique for extending approximate results into exact ones. For both Case A and Case B we use a new implementation of distributive absorption, a method introduced by the first author in [17].
To describe our absorption, let us concentrate on Case A. Our methods in Case B are closely related, and we comment on these afterwards. To recap, we have a random rainbow treeT in the ND-colouring of K 2n+1 and a set X ⊆ V (T ), so that we need to add a perfect matching from X intoV = V (K 2n+1 ) \ V (T ) to makeT into a copy of T . We wish to add this matching in a rainbow fashion using (exactly) the colours inC = C(K 2n+1 ) \ C(T ).
To use distributive absorption, we first show that for any setĈ ⊆ C(K 2n+1 ) of at most 100 colours, we can find a set D ⊆C \ C and sets X ⊆ X and V ⊆V with |D| ≤ 10 3 , |V | ≤ 10 4 and |X | = |D| + 1, so that the following holds.
B1 Given any colour c ∈Ĉ, there is a perfect (D ∪ {c})-rainbow matching from X to V .
We call such a triple (D, X , V ) a switcher forĈ. AS |C| = |X|, a perfect (C \ D)-rainbow matching from X \ X into V \ V uses all but 1 colour inC \ D. If we can find such a matching whose unused colour, c say, lies inĈ, then using B1, we can find a perfect (D ∪ {c})-rainbow matching from X to V . Then, the two matchings combined form a perfectC-rainbow matching from X into V , as required.
The switcher outlined above only gives us a tiny local variability property, reducing finding a large perfect matching with exactly the right number of colours to finding a large perfect matching with one spare colour so that the unused colour lies in a small set (the setC). However, by finding many switchers for carefully chosen setsĈ, we can build this into a global variability property. These switchers can be found using different vertices and colours (see Section 4.1), so that matchings found using the respective properties B1 can be combined in our embedding.
We choose different setsĈ for which to find a switcher by using an auxillary graph as a template. This template is a robustly matchable bipartite graph -a bipartite graph, K say, with vertex classes U and Y ∪ Z (where Y and Z are disjoint), with the following property.
B2 For any set Z * ⊆ Z with size |U | − |Y |, there is a perfect matching in K between U and Y ∪ Z * .
Such bipartite graphs were shown to exist by the first author [17], and, furthermore, for large m and ≤ m, we can find such a graph with maximum degree at most 100, |U | = 3m, |Y | = 2m and |Z| = m + (see Lemma 4.2). To use the template, we take disjoint sets of colours, C = {c v : v ∈ Y } and C = {c v : v ∈ Z} inC. For each u ∈ U , we find a switcher (D u , X u , V u ) for the set of colours {c v : v ∈ N K (u)}. Furthermore, we do this so that the sets D u are disjoint and inC \ (C ∪ C ), and the sets X u , and V u , are disjoint and in X, andV , respectively. We can then show we have the following property.
Indeed, to see this, take any set of C * ⊆ C of m colours, let Z * = {v : c v ∈ C * } and note that |Z * | = m. By B3, there is a perfect matching in K from U into Y ∪ Z * , corresponding to the function f : Thus, we have a set of colours C from which we are free to use any colours, and then use the remaining colours together with C ∪ (∪ u∈U D u ) to find a perfect rainbow matching from ∪ u∈U X u into ∪ u∈U V u . By letting m be as large as allowed by our construction methods, and C be a random set of colours, we have a useful reservoir of colours, so that we can find a structure in T using colours in C , and then finish by attaching a matching to ∪ u∈U X u .
We have two things to consider to fit this final step into our proof structure, which we discuss below. Firstly, we can only absorb colours in C , so after we have covered most of the colours, we need to cover the unused colours outside of C (essentially achieved by C2 below). Secondly, we find the switchers greedily in a random set. There are many more unused colours from this set than we can absorb, and the unused colours no longer have good random properties, so we also need to reduce the unused colours to a number that we can absorb (essentially achieved by C1 below).

Creating our finishing lemmas using absorption
To recap, we wish to find a perfectC-rainbow matching from X intoV . To do this, it is sufficient to find partitions C1 There is a perfect C 1 -rainbow matching from X 1 into V 1 .
C2 Given any set of colours C ⊆ C 1 with |C | ≤ |C 1 | − |X 1 |, there is a perfect (C 2 ∪ C )-rainbow matching from X 2 into V 2 which uses each colour in C .
C3 Given any set of colours C ⊆ C 2 with size |X 3 | − |C 3 |, there is a perfect (C ∪ C 3 )-rainbow matching from Finding such a partition requires the combination of all our methods for Case A. In brief, however, we develop C1 using a result from [18] (see Lemma 3.18), we develop C2 using the condition A4, and we develop C3 using the distributive absorption strategy outlined above. If we can find such a partition, then we can easily show that the matching we want must exist. Indeed, given such a partition, then, using C1, let M 1 be a perfect C 1 -rainbow matching from X 1 into V 1 , and let C = C 1 \ C(M 1 ). Using C2, let M 2 be a perfect (C 2 ∪ C )-rainbow matching from X 2 into V 2 which uses each colour in C , and let The above outline also lies behind our embedding in Case B, where we finish instead by embedding paths vertex-disjointly between certain vertex pairs, for some . Instead of the partition X 1 ∪ X 2 ∪ X 3 we have a partition [ ] = I 1 ∪ I 2 ∪ I 3 , and, instead of each matching from X i to V i , i ∈ [3], we find a set of vertex-disjoint x j , y j -paths, j ∈ I i , with interior vertices in V i which are collectively C i -rainbow. The main difference is how we construct switchers using paths instead of matchings (see Section 5.1).

M3: The embedding in Case C
After large clusters of adjacent leaves are removed from a tree in Case C, few vertices remain. We remove these large clusters, from the tree, T say, to get the tree T , and carefully embed T into the ND-colouring using a deterministic embedding. The image of this deterministic embedding occupies a small interval in the ordering used to create the ND-colouring. Furthermore, the embedded vertices of T which need leaves added to create a copy of T are well-distributed within this interval. These properties will allow us to embed the missing leaves using the remaining colours. This is given more precisely in Section 7, but in order to illustrate this in the easiest case, we will give the embedding when there is exactly one vertex with high degree.
Our embedding in this case is rather simple. Removing the leaves incident to a very high degree vertex, we embed the rest of the tree into [n] so that the high degree vertex is embedded to 1. The missing leaves are then embedded into [2n + 1] \ [n] using the unused colours. Theorem 2.3 (One large vertex). Let n ≥ 10 6 . Let K 2n+1 be N D-coloured, and let T be an (n + 1)-vertex tree containing a vertex v 1 which is adjacent to ≥ 2n/3 leaves. Then, K 2n+1 contains a rainbow copy of T .
Proof. See Figure 2 for an illustration of this proof. Let T be T with the neighbours of v 1 removed and let m = |T |. By assumption, |T | ≤ n/3 + 1. Order the vertices of Embed v 1 to 1 in K 2n+1 , and then greedily embed v 2 , . . . , v m in turn to some vertex in [n] so that the copy of T which is formed is rainbow in K 2n+1 . This is possible since at each step at most |T | ≤ n/3 of the vertices in [n] are occupied, and at most e(T ) ≤ n/3 − 1 colours are used. Since the N D-colouring has 2 edges of each colour adjacent to each vertex, this forbids at most n/3 + 2(n/3 − 1) = n − 2 vertices in [n]. Thus, we can embed each v i , 2 ≤ i ≤ m using an unoccupied vertex in [n] so that the edge from v i to v 1 , . . . , v i−1 has a colour that we have not yet used. Let S be the resulting rainbow copy of T , so that V (S ) ⊆ [n].
Let S be S together with the edges between 1 and 2n + 2 − c for every c ∈ [n] \ C(S ). Note that the neighbours added are all bigger than n, and so the resulting graph is a tree. There are exactly n − e(T ) edges added, so S is a copy of T . Finally, for each c ∈ [n] \ C(S ), the edge from 1 to 2n + 2 − c is colour c, so the resulting tree is rainbow. 1 S Figure 2: Embedding the tree in Case C when there is 1 vertex with many leaves as neighbours.
The above proof demonstrates the main ideas of our strategy for Case C. Notice that the above proof has two parts -first we embed the small tree T , and then we find the neighbours of the high degree vertex v 1 . In order to ensure that the final tree is rainbow we choose the neighbours of v 1 in some interval [n + 1, 2n] which is disjoint from the copy of T , and to which every colour appears from the image of v 1 . This way, we were able to use every colour which was not present on the copy of T . When there are multiple high degree vertices v 1 , . . . , v the strategy is the same -first we embed a small rainbow tree T containing v 1 , . . . , v , then we embed the neighbours of v 1 , . . . , v . This is done in Section 7.

Proof of Theorem 2.1
Here we will state our main theorems and lemmas, which are proved in later sections, and combine them to prove Theorem 2.1. First, we have our randomized embedding of a (1 − )n-vertex tree, which is proved in Section 6.
For convenience we use the following definition.
contains at least edges of every colour in G. Given, further, W ⊆ V (G) \ V , we say (W, V ) is -replete in G if at least edges of every colour in G appear in G between W and V . When G = K 2n+1 , we simply say that V and (W, V ) are -replete. 1 and ξ poly 1/k poly log −1 n. Let K 2n+1 be ND-coloured, let T be a (1 − )n-vertex forest and let U ⊆ V (T ) contain n vertices. Let p be such that removing leaves around vertices next to ≥ k leaves from T gives a forest with pn vertices.
D1 With high probability,T is a rainbow copy of T in which, if W is the copy of U , then (W, V 0 ) is (ξn)-replete, D2 V 0 and C 0 are µ-random and independent of each other, and D3 V is (p + )/6-random and C is (1 − η) -random.
Next, we have the two finishing lemmas, which are proved in Sections 4 and 5 respectively. p ≤ 1. Let K 2n+1 be 2-factorized. Suppose that V, V 0 are disjoint subsets of V (K 2n+1 ) which are p-and µ-random respectively. Suppose that C, C 0 are disjoint subsets in C(K 2n+1 ), so that C is (1 − η) -random, and C 0 is µ-random and independent of V 0 . Then, with high probability, the following holds.
Given any disjoint sets X, Note that in the following lemma we implicitly assume that m is an integer. That is, we assume an extra condition on n, k and . We remark on this further in Section 3.1. p ≤ 1 be such that k = 7 mod 12 and 695|k. Let K 2n+1 be 2-factorized. Suppose that V, V 0 are disjoint subsets of V (K 2n+1 ) which are pand µ-random respectively. Suppose that C, C 0 are disjoint subsets in C(K 2n+1 ), so that C is (1 − η) -random, and C 0 is µ-random and independent of V 0 . Then, with high probability, the following holds with m = n/k.
For any set {x 1 , . . . , x m , y 1 , . . . , y m } ⊆ V (K 2n+1 ) \ (V ∪ V 0 ), and any set D ⊆ C(K 2n+1 ) with |D| = mk and C ∪ C 0 ⊆ D, the following holds. There is a set of vertex-disjoint x i , y i -paths with length k, i ∈ [m], which have interior vertices in V ∪ V 0 and which are collectively D-rainbow.
Finally, the following theorem, proved in Section 7, will allow us to embed trees in Case C. Theorem 2.8 (Embedding trees in Case C). Let n ≥ 10 6 . Let K 2n+1 be N D-coloured, and let T be a tree on n + 1 vertices with a subtree T with := |T | ≤ n/100 such that T has vertices v 1 , . . . , v so that adding d i ≥ log 4 n leaves to each v i produces T . Then, K 2n+1 contains a rainbow copy of T .
We can now combine these results to prove Theorem 2.1. We also use a simple lemma concerning replete random sets, Lemma 3.14, which is proved in Section 3. As used below, it implies that if V 0 and V 1 , with , are µ-and µ/2-random respectively, then, given any randomised set X such that (X, V 0 ) is with high probability replete (for some parameter), then (X, V 1 ) is also with high probability replete (for some suitably reduced parameter).
Proof of Theorem 2.1. Choose ξ, µ, η, δ,μ,η and¯ such that 1/n poly ξ poly µ poly η poly δ poly μ poly η poly ¯ poly log −1 n and k = δ −1 is an integer such that k = 7 mod 12 and 695|k. Let T be an (n + 1)-vertex tree and let K 2n+1 be ND-coloured. By Lemma 3.5, T is in Case A, B or C for this δ. If T is in Case C, then Theorem 2.8 implies that K 2n+1 has a rainbow copy of T . Let us assume then that T is not in Case C. Let k = δ −4 , and note that, as T is not in Case C, removing from T leaves around any vertex adjacent to at least k leaves gives a tree with at least n/100 vertices.
If T is in Case A, then let = δ 6 , let L be a set of n non-neighbouring leaves in T , let U = N T (L) and let T = T − L. Let p be such that removing from T leaves around any vertex adjacent to at least k leaves gives a tree with pn vertices. Note that each leaf of T which is not a leaf of T must be adjacent to a vertex in L in T . Note further that, if a vertex in T is next to fewer than k leaves in T , but at least k leaves in T , then all but at most k − 1 of those leaves in T must have a neighbour in L in T . Therefore, p ≥ 1/100 − (k + 1) ≥ 1/200. By Theorem 2.5, there is a random subgraphT ⊆ K 2n+1 and random subsets V, By Lemma 2.6 (applied with ξ = ξ/4, µ = µ/2, η = η, = , p = (p + )/6, V = V, C = C, V 0 = V 1 , and C 0 a (µ/2)-random subset of C 0 ) and D2-D3, and by D1 and Lemma 3.14, with high probability we have the following properties.
Thus, a rainbow copy of T exists with high probability in the ND-colouring of K 2n+1 , and hence certainly some such rainbow copy of T must exist. If T is in Case B, then recall that k = δ −1 and let m =¯ n/k. Let P 1 , . . . , P m be vertex-disjoint bare paths with length k in T . Let T be T with the interior vertices of P i , i ∈ [m], removed. Let p be such that removing from T leaves around any vertex adjacent to at least k leaves gives a forest with pn vertices. Note that (reasoning similarly to as in Case A) p ≥ 1/100 − 2(k + 1)m ≥ 1/200. By Theorem 2.5, there is a random subgraphT ⊆ K 2n+1 and disjoint random subsets V, V 0 ⊆ V (K 2n+1 )\V (T ) and C, C 0 ⊆ C(K 2n+1 ) \ C(T ) such that D1-D3 hold with ξ = ξ, µ =μ, η =η and =¯ . By Lemma 2.7 and D1-D3, and by D1, with high probability we have the following properties.
F2T is a rainbow copy of T .
Let D = C(K 2n+1 ) \ C(T ), so that C 0 ∪ C ⊆ D, and, asT is rainbow by F2, |D| = n. For each path P i , i ∈ [m], let x i and y i be the copy of the endvertices of P i inT . Using F1, let Q i , i ∈ [m], be a set of vertex-disjoint x i , y i -paths with length k, i ∈ [m], which have interior vertices in V ∪ V 0 and which are collectively D-rainbow.
is a rainbow copy of T . Thus, a rainbow copy of T exists with high probability in the ND-colouring of K 2n+1 , and hence certainly some such rainbow copy of T must exist.

Notation
For a coloured graph G, we denote the set of vertices of G by V (G), the set of edges of G by E(G), and the set of colours of G by C(G). For a coloured graph G, disjoint sets of vertices A, B ⊆ V (G) and a set of colours C ⊆ C(G) we use G[A, B, C] to denote the subgraph of G consisting of colour C edges from A to B, and G[A, C] to be the graph of the colour C edges within A. For a single colour c, we denote the set of colour c edges from A to B by E c (A, B). A coloured graph is globally k-bounded if every colour is on at most k edges. For a set of colours C, we say that a graph H is "C-rainbow" if H is rainbow and C(H) ⊆ C. We say that a collection of graphs H 1 , . . . , H k is collectively rainbow if their union is rainbow. A star is a tree consisting of a collection of leaves joined to a single vertex (which we call the centre). A star forest is a graph consisting of vertex disjoint stars.
For any reals a, b ∈ R, we say

Asymptotic notation
For any C ≥ 1 and x, y ∈ (0, 1], we use "x C y" to mean "x ≤ y C C ". We will write "x poly y" to mean that there is some absolute constant C for which the proof works with "x poly y" replaced by "x C y". In other words the proof works if y is a small but fixed power of x. This notation compares to the more common notation x y which means "there is a fixed positive continuous function f on (0, 1] for which the remainder of the proof works with "x y" replaced by "x ≤ f (y)". (Equivalently, "x y" can be interpreted as "for all x ∈ (0, 1], there is some y ∈ (0, 1] such that the remainder of the proof works with x and y".) The two notations "x poly y" and "x y" are largely interchangeable -most of our proofs remain correct with all instances of " poly " replaced by " ". The advantage of using " poly " is that it proves polynomial bounds on the parameters (rather than bounds of the form "for all > 0 and sufficiently large n"). This is important towards the end of this paper, where the proofs need polynomial parameter bounds.
While the constants C will always be implicit in each instance of "x poly y", it is possible to work them out explicitly. To do this one should go through the lemmas in the paper and choose the constants C for a lemma after the constants have been chosen for the lemmas on which it depends. This is because an inequality x C y in a lemma may be needed to imply an inequality x C y for a lemma it depends on. Within an individual lemma we will often have several inequalities of the form x poly y. There the constants C need to be chosen in the reverse order of their occurrence in the text. The reason for this is the same -as we prove a lemma we may use an inequality x C y to imply another inequality x C y (and so we should choose C before choosing C).
Throughout the paper, there are four operations we perform with the "x poly y" notation: x k to deduce finitely many inequalities of the form "p(x 1 , . . . , x k ) ≤ q(x 1 , . . . , x k )" where p and q are monomials with non-negative coefficients and min{i : (b) We will use x poly y to deduce finitely many inequalities of the form "x C y" for a fixed constant C.
(c) For x poly y and fixed constants C 1 , C 2 , we can choose a variable z with x C1 z C2 y.
(d) For n −1 poly 1 and any fixed constant C, we can deduce n −1 C log −1 n C 1. See [18] for a detailed explanation of why the above operations are valid.

Rounding
In several places, we will have, for example, constants and integers n, k such that 1/n poly , 1/k and require that m = n/k is an integer, or even divisible by some other small integer. Note that we can arrange this easily with a very small alteration in the value of . For example, to apply Lemma 2.7 we assume that m is an integer, and therefore in the proof of Theorem 2.1, when we choose¯ we make sure that when this lemma is applied with =¯ the corresponding value for m is an integer.

Probabilistic tools
For a finite set V , a p-random subset of V is a set formed by choosing every element of V independently at random with probability p. If V is not specified, then we will implicitly assume that V is V (K 2n+1 ) or C(K 2n+1 ), where this will be clear from context. If A, B ⊆ V with A p-random and B q-random, we say that A and B are disjoint if every v ∈ V is in A with probability p, in B with probability q, and outside of A ∪ B with probability 1 − p − q (and this happens independently for each v ∈ V ). We say that a p-random set A is independent from a q-random set B if the choices for A and B are made independently, that is, if for any outcomes A and B of A and B.
Often, we will have a p-random subset X of V and divide it into two disjoint (p/2)-random subsets of V . This is possible by choosing which subset each element of X is in independently at random with probability 1/2 using the following simple lemma. Lemma 3.1 (Random subsets of random sets). Suppose that X, Y : Ω → 2 V where X is a p-random subset of V and Y |X is a q-random subset of X (i.e. the distribution of Y conditional on the event "X = X " is that of a q-random subset of X ). Then Y is a pq-random subset of V .
Proof. First notice that, to show a set X ⊆ V is (pq)-random, it is sufficient to show that P(S ⊆ X) = (pq) |S| for all S ⊆ V (for example, by using inclusion-exclusion). Now, we prove the lemma. Since X is p-random we have We will use the following standard form of Azuma's inequality and a Chernoff Bound. For a probability space Ω = n i=1 Ω i , a random variable X : Ω → R is k-Lipschitz if changing ω ∈ Ω in any one coordinate changes X(ω) by at most k. Lemma 3.2 (Azuma's Inequality). Suppose that X is k-Lipschitz and influenced by ≤ m coordinates in {1, . . . , n}. Then, for any t > 0, Notice that the bound in the above inequality can be rewritten as . Let X be a binomial random variable with parameters (n, p). Then, for each ∈ (0, 1), we have For an event X in a probability space depending on a parameter n, we say "X holds with high probability" to mean "X holds with probability We will use this definition for the following operations.
• Azuma variant: For poly n −1 and fixed k, if Y is a k-Lipschitz random variable influenced by at most n coordinates, then, with high probability, Y = E(Y ) ± n.
• Union bound variant: For fixed k, if X 1 , . . . , X k are events which hold with high probability then they simultaneously occur with high probability.
The first two of these follow directly from Lemmas 3.2 and 3.3, the latter from the union bound.

Structure of trees
Here, we gather lemmas about the structure of trees. Most of these lemmas say something about the leaves and bare paths of a tree. It is easy to see that a tree with few leaves must have many bare paths. The most common version of this is the following well known lemma.

Lemma 3.4 ([17]
). For any integers n, k > 2, a tree with n vertices either has at least n/4k leaves or a collection of at least n/4k vertex disjoint bare paths, each with length k.
As a corollary of this lemma we show that every tree either has many bare paths, many non-neighbouring leaves, or many large stars. This lemma underpins the basic case division for this paper. The rest of the proofs focus on finding rainbow copies of the three types of trees. B There are at least δ 6 n non-neighbouring leaves.
C Removing leaves next to vertices adjacent to at least δ −4 leaves gives a tree with at most n/100 vertices.
Proof. Take T and remove leaves around any vertex adjacent to at least δ −4 leaves, and call the resulting tree T . If T has at most n/100 vertices then we are in Case C. Assume then, that T has at least n/100 vertices.
By Lemma 3.4 applied with n = |T | and k = δ −1 , the tree T either has at least δn/600 vertex disjoint bare paths with length at least δ −1 or at least δn/600 leaves. In the first case, as vertices were deleted next to at most δ 4 n vertices to get T from T , T has at least δn/600 − δ 4 n ≥ δn/800 vertex disjoint bare paths with length at least δ −1 , so we are in Case B.
In the second case, if there are at least δn/1200 leaves of T which are also leaves of T , then, as there are at most δ −4 of these leaves around each vertex in T , T has at least (δn/1200)/δ −4 ≥ δ 6 n non-neighbouring leaves, so we are in Case A. On the other hand, if there are not such a number of leaves of T which are leaves of T , then T must have at least δn/1200 leaves which are not leaves of T , and which therefore are adjacent to a leaf in T . Thus, T has at least δn/1200 ≥ δ 6 n non-neighbouring leaves, and we are also in Case A.
We say a set of subtrees T 1 , . . . , T ⊆ T divides a tree T if E(T 1 ) ∪ . . . ∪ E(T ) is a partition of E(T ). We use the following lemma.  17]). Let n, m ∈ N satisfy 1 ≤ m ≤ n/3. Given any tree T with n vertices and a vertex t ∈ V (T ), we can find two trees T 1 and T 2 which divide T so that t ∈ V (T 1 ) and m ≤ |T 2 | ≤ 3m.
Iterating this, we can divide a tree into small subtrees.
Lemma 3.7. Let T be a tree with at least m vertices, where m ≥ 2. Then, for some s, there is a set of subtrees Proof. We prove this by induction on |T |, noting that it is trivially true if |T | ≤ 4m.
Suppose then |T | > 4m and the statement is true for all trees with fewer than |T | vertices and at least m vertices. By Lemma 3.6, we can find two trees T 1 and S which divide T so that m ≤ |T 1 | ≤ 3m. As |T | > 4m, we have m < |S| < |T |, so there must be a set of subtrees T 2 , . . . , T s , for some s, For embedding trees in Cases A and B, we will need a finer understanding of the structure of trees. In fact, every tree can be built up from a small tree by successively adding leaves, bare paths, and stars, as follows.
G2 T j is formed from T j−1 by adding at most µn vertex-disjoint bare paths with length 3, G3 T 1 is formed from T 0 by adding vertex-disjoint stars with at least d leaves each, and The following variation will be more convenient to use here. It shows that an arbitrary tree T can be built out of a preselected, small subtree T 1 by a sequence of operations. It is important to control the starting tree as it allows us to choose which part of the tree will form our absorbing structure.
For forests T ⊆ T , we say that T is obtained from T by adding a matching of leaves if all the vertices in V (T ) \ V (T ) are non-neighbouring leaves in T . Proof. First, we claim that there is a subtree T 0 of order ≤ n/2d 2 containing at least n/d 6 vertices of U . To find this, use Lemma 3.7 to find s ≤ 32d 2 subtrees T 1 , . . . , T s which divide T so that n/16d 2 ≤ |T i | ≤ n/2d 2 for each i ∈ [s]. As each vertex in U must appear in some tree T i , there must be some tree T k which contains at least |U |/32d 2 ≥ n/d 6 vertices in U , as required.
Let T be the n-vertex tree formed from T by contracting T k into a single vertex v 0 and adding e(T k ) new leaves at v 0 (called "dummy" leaves). Notice that Lemma 3.8 applies to T with d = d, µ = d −3 , n = n which gives a sequence of forests T 0 , . . . , T for ≤ 10 4 d 7 ≤ d 8 . Notice that v 0 ∈ T 0 . Indeed, by construction, every vertex which is not in T 0 can have in T = T at most leaves. Since v 0 has ≥ e(T k ) > leaves in T , it must be in T 0 . For each i = 0, . . . , , let T i be T i with T k uncontracted and any dummy leaves of v 0 deleted. Let T stars We do this because when we uncontract T k the leaves which were attached to v 0 in T 0 are now attached to vertices of T k . If they form a star of size less than d we cannot add them when we form T stars 2 without violating H2 so we add them already when we form T small 1 . Since we are adding at most d leaves for every vertex of T k , we have |T small 1 | ≤ d|T k | + |T 0 | ≤ n/d so H1 holds. This ensures that at least d leaves are added to vertices of T small 1 to form T stars 2 so H2 holds. The remaining conditions H3 -H5 are immediate from the application of Lemma 3.8.

Pseudorandom properties of random sets of vertices and colours
Suppose that K 2n+1 is 2-factorized. Choose a p-random set of vertices V ⊆ V (K 2n+1 ) and a q-random set of colours C ⊆ C(K 2n+1 ). What can be said about the subgraph K 2n+1 [V, C] consisting of edges within the set V with colour in C? What "pseudorandomness" properties is this subgraph likely to have? In this section, we gather lemmas giving various such properties. The setting of the lemmas is quite varied, as are the properties they give. For example, sometimes the sets V and C are chosen independently, while sometimes they are allowed to depend on each other arbitrarily. We split these lemmas into three groups based on the three principal settings.

Dependent vertex/colour sets
In this setting, our colour set C ⊆ C(K 2n+1 ) is p-random, and the vertex set is V (K 2n+1 ) (i.e., it is 1-random). Our pseudorandomness condition is that the number of edges between any two sizeable disjoint vertex sets is close to the expected number. Though a lemma of this kind was first proved in [4], the precise pseudorandomness condition we will use here is in the following version from [19]. A colouring is locally k-bounded if every vertex is adjacent to at most k edges of each colour.
Lemma 3.10 ( [19]). Let k ∈ N be constant and let , p ≥ n −1/100 . Let K n have a locally k-bounded colouring and suppose G is a subgraph of K n chosen by including the edges of each colour independently at random with probability p. Then, with probability ) is a p-random set of vertices, then the edges going from V to V (K 2n+1 ) \ V are typically pseudorandomly coloured. The lemma below is a version of this. Here "pseudorandomly coloured" means that most colours have at most a little more than the expected number of colours leaving V . 19]). Let k be constant and , p ≥ n −1/10 3 . Let K n have a locally k-bounded colouring and let V be a p-random subset of V (K n ). Then, with probability 1 − o(n −1 ), for each A ⊆ V (K n ) \ V with |A| ≥ n 1/4 , for all but at most n colours there are at most (1 + )pk|A| edges of that colour between V and A.
A random vertex set V likely has the property from Lemma 3.11. A random colour set C likely has the property from Lemma 3.10. If we combine these two properties, we can get a property involving C and V that is likely to hold. Importantly, this will be true even if C and V are not independent of each other. Doing this, we get the following lemma.
, for all but at most n colours there are at most (1 + )p|A| edges of that colour between A and V .

Deterministic colour sets and random vertex sets
The following lemma bounds the number of edges each colour typically has within a random vertex set.
Recall that for any two sets U, V ⊆ V (G) inside a coloured graph G, we say that the pair (U, V ) is k-replete if every colour of G occurs at least k times between U and V . We will use the following auxiliary lemma about how this property is inherited by random subsets.

Independent vertex/colour sets
The setting of the next three lemmas is the same: we independently choose a p-random set of vertices V and a q-random set of colours C. For such a pair V, C we expect all vertices of the vertices v in K 2n+1 to have many C-edges going into V . Each of the following lemmas is a variation on this theme. Let V ⊆ V (K 2n+1 ) be p-random, and let C ⊆ C(K 2n+1 ) be q-random and independent of V . With probability Also |N C (v)∩V | is 2-Lipschitz and affected by 3n coordinates. By Azuma's Inequality, we have that P(|N C (v)∩V | ≤ pqn) ≤ 2e −p 2 q 2 n/1000 = o(n −2 ). The result follows by taking a union bound over all v ∈ V (K 2n+1 ). Proof. Let u, v ∈ V (K 2n+1 ) be distinct, and let X u,v be the number of colours c ∈ D 0 for which there are colour-c neighbours of both u and v in V 0 . Note that EX u,v ≥ µ 3 n, X u,v is 2-Lipschitz and affected by 3n − 1 coordinates. By Azuma's Inequality, we have that P(X u,v ≤ µ 3 n/2) ≤ 2e −µ 6 n/1000 = o(n −2 ). The result follows by taking a union bound over all distinct pairs u, v ∈ V (K 2n+1 ). Lemma 3.15 says that, with high probability, every vertex v has many colours c ∈ C for which there is a c-edge into V . The following lemma is a strengthening of this. It shows that, for any set Y of 100 vertices, there are many colours c ∈ C for which each v ∈ Y has a c-edge into V . Lemma 3.17 (Edges into independent vertex/colour sets). Let p poly q poly n −1 and let K 2n+1 be 2-factorized. Let V ⊆ V (K 2n+1 ) and C ⊆ C(K 2n+1 ) be p-random and independent. Then, with high probability, for any set Y of 100 vertices, there are qn colours c ∈ C for which each y ∈ Y has a c-neighbour in V .

Rainbow matchings
We now gather lemmas for finding large rainbow matchings in random subsets of coloured graphs, despite dependencies between the colours and the vertices that we use. Simple greedy embedding strategies are insufficient for this, and instead we will use a variant of Rödl's Nibble proved by the authors in [18]. for each e ∈ E(G).
We remark that in the statement of this lemma [18], the conditions "|G| = (1 ± γ)2n and d G (v) = (1 ± γ)δn for all v ∈ V (G)" are referred to collectively as "G is (γ, δ, n)-regular". The following lemma is at the heart of the proofs in this paper. It shows there is typically a nearly-perfect rainbow matching using random vertex/colour sets. Moreover, it allows arbitrary dependencies between the sets of vertices and colours. As mentioned before, when embedding high degree vertices such dependencies are unavoidable. Because of this, after we have embedded the high degree vertices, the remainder of the tree will be embedded using variants of this lemma. Lemma 3.19 (Nearly-perfect matchings). Let p ∈ [0, 1], β poly n −1 , and let K 2n+1 be 2-factorized. Let V ⊆ V (K 2n+1 ) be p/2-random and let C ⊆ C(K 2n+1 ) be p-random (possibly depending on each other). Then, with Proof. The lemma is vacuous when p < β, so suppose p ≥ β. We will first prove the lemma in the special case when p ≤ 1 − β. Choose p ≥ β poly α poly γ poly n −1 . With probability 1 − o(n −1 ), V and C satisfy the conclusion of Lemma 3.12 with p, γ, n. Using Chernoff's bound and p ≤ 1 − β, with probability 1 − o(n −1 ) we have |V | ≤ n. By the union bound, both of these simultaneously occur. Notice that it is sufficient to prove the lemma for sets U with |U | = pn (since any smaller set U is contained in a set of this size which is disjoint from V as |V | ≤ n). From Lemma 3.12, we have that, for U of order pn, there are subsets U ⊆ U, V ⊆ V, C ⊆ C with |U | = |V | = (1±γ)pn so that G = K 2n+1 [U , V , C ] is globally (1 + γ)p 2 n-bounded, and every vertex v ∈ V (G) has d G (v) = (1 ± γ)p 2 n. Now G satisfies the assumptions of Lemma 3.18 (with n = pn, δ = p, p = α, γ = 2γ and = 2), so it has a rainbow matching of size (1 − 2α)pn ≥ pn − βn.
The following variant of Lemma 3.19 finds a rainbow matching which completely covers the deterministic set U . To achieve this we introduce a small amount of independence between the vertices/colours which are used in the matching. Lemma 3.20 (Perfect matchings). Let 1 ≥ γ poly n −1 , let p ∈ [0, 1], and let K 2n+1 be 2-factorized. Suppose that we have disjoint sets V dep , V ind ⊆ V (K 2n+1 ), and C dep , C ind ⊆ C(K 2n+1 ) with V dep p/2-random, C dep p-random, and V ind , C ind γ-random. Suppose that V ind and C ind are independent of each other. Then, the following holds with probability 1 − o(n −1 ). For Proof. Choose β such that 1 ≥ γ poly β poly n −1 . With probability 1 − o(n −1 ), we can assume the conclusion of Lemma 3.19 holds for V = V dep , C = C dep with p = p, β = β, n = n, and, by Lemma 3.15 applied to V = V ind , C = C ind with p = q = γ, n = n that the following holds. For each v ∈ V (K 2n+1 ), we have |N C ind (v)∩V ind | ≥ γ 2 n > βn. We will show that the property in the lemma holds. Let we can construct a C ind -rainbow matching M 2 into V ind covering U \ V (M 1 ) (by greedily choosing this matching one edge at a time). The matching M 1 ∪ M 2 then satisfies the lemma.
We will also use a lemma about matchings using an exact set of colours.
Proof. Choose γ such that β poly γ poly n −1 . By Lemma 3.11 (applied with n = 2n + 1), with high probability, we have that, for any set A ⊆ V (K 2n+1 ) \ V with |A| ≥ pn ≥ (2n + 1) 1/4 , for all but at most γn colours there are at most (1+γ)p|A| edges of that colour between A and V . By Chernoff's bound, with high probability |V | = (1±γ)pn. We will show that the property in the lemma holds.

Rainbow star forests
Here we develop techniques for embedding the high degree vertices of trees, based on our previous methods in [19]. We will do this by proving lemmas about large star forests in coloured graphs. In later sections, when we find rainbow trees, we isolate a star forest of edges going through high degree vertices, and embed them using the techniques from this section. We start from the following lemma. The following version of the above lemma will be more convenient to apply. Lemma 3.23 (Star forest). Let 1 poly η poly γ poly n −1 and let K 2n+1 be 2-factorized. Let F be a star forest with degrees ≥ 1 whose set of centers is I = {i 1 , . . . , i } with e(F ) ≤ (1 − η)n. Suppose we have disjoint sets J, V ⊆ V (K 2n+1 ) and C ⊆ C(K 2n+1 ) with |V | ≥ (1 − γ)2n, |C| ≥ (1 − γ)n and J = {j 1 , . . . , j }.
Then, there is a C-rainbow copy of F with i t copied to j t , for each t ∈ [ ], whose vertices outside of I are copied to vertices in V .
The above lemma can be used to find a rainbow copy of any star forest F in a 2-factorization as long as there are more than enough colours for a rainbow copy of F . However, we also want this rainbow copy to be suitably randomized. This is achieved by finding a star forest larger than F and then randomly deleting each edge independently. The following lemma is how we embed rainbow star forests in this paper. It shows that we can find a rainbow copy of any star forest so that the unused vertices and colours are p-random sets. Crucially, and unavoidably, the sets of unused vertices/colours depend on each other. This is where the need to consider dependent sets arises.
Then, there is a randomized subgraph F which is with high probability a C-rainbow copy of F , with i t copied to j t for each t and whose vertices outside I are copied to vertices in V . Additionally there are randomized sets  p). By Lemma 3.23, there is a C-rainbow embeddingF ofF with i t copied to j t for each t and whose vertices outside I are contained in V .
Let U be a (1 − α)p-random subset of V . Let F =F \ U . By Chernoff's Bound and log −1 n, p, γ , where this holds as p, α poly η poly γ. Taking a union bound over all the centers shows that, with high probability, F contains a copy of F . SinceF was rainbow, we have that C(F ) \ C(F ) is a (1 − α)p-random subset of C(F ). LetĈ be a (1 − α)p-random subset of C \ C(F ) and set D =Ĉ ∪ (C(F ) \ C(F )). Now D and U are both (1 − α)p-random subsets of C and V respectively.

Rainbow paths
Here we collect lemmas for finding rainbow paths and cycles in random subgraphs of K 2n+1 . First we prove two lemmas about short paths between prescribed vertices. These lemmas are later used to incorporate larger paths into a tree. Let V ⊆ V (K 2n+1 ) and C ⊆ C(K 2n+1 ) be p-random and independent. Then, with high probability, for each pair of distinct vertices u, v ∈ V (K 2n+1 ) there are at least µn internally vertex-disjoint u, v-paths with length 3 and internal vertices in V whose union is C-rainbow.
Proof. Choose p poly µ poly n −1 > 0. Randomly partition C = C 1 ∪ C 2 ∪ C 3 into three p/3-random sets and V = V 1 ∪ V 2 into two p/2-random sets. With high probability the following simultaneously hold.
We claim the property holds. Indeed, pick an arbitrary distinct pair of vertices u, v ∈ V (K 2n+1 ). Let M be a maximum C 3 -rainbow matching between N C1 (v) ∩ (V 1 \ {u}) and N C2 (u) ∩ (V 2 \ {v}) (these sets have size at least p 2 n/24). Each of the 2e(M ) vertices in M has 2n neighbours in K 2n+1 , and each colour in M is on 2n + 1 edges in K 2n+1 . The number of edges of K 2n+1 sharing a vertex or colour with M is thus ≤ 7ne(M ). By maximality, and the property from Lemma 3.10, we have 7ne(M ) ≥ e C3 (U, V ) ≥ 10 −3 p 5 n 2 , which implies that e(M ) ≥ 10 −4 p 5 n ≥ 4µn. For any edge v 1 v 2 in the matching M , the path uv 1 v 2 v is a rainbow path. In the union of these paths, the only colour repetitions can happen at u or v. Since K 2n+1 is 2-factorized, there is a subfamily of µn paths which are collectively rainbow.
We can use this lemma to find many disjoint length 3 connecting paths.
Lemma 3.26 (Short connecting paths). Let p poly q poly n −1 > 0 and let K 2n+1 be 2-factorized. Let V be a p-random set of vertices, and C a p-random set of colours independent from V . Then, with high probability, for any set of {x 1 , y 1 , . . . , x qn , y qn } of vertices, there is a collection P 1 , . . . , P qn of vertex-disjoint paths with length 3, having internal vertices in V , where P i is an x i , y i -path, for each i ∈ [qn], and P 1 ∪ · · · ∪ P qn is C-rainbow.
Proof. By Lemma 3.25 applied to C, V with p = p, µ = 10q, n = n, with high probability, between any x i and y i , there is a collection of 10qn internally vertex disjoint x i , y i -paths, which are collectively C-rainbow, and internally contained in V . By choosing such paths greedily one by one, making sure never to repeat a colour or vertex, we can find the required collection of paths.

The finishing lemma in Case A
The proof of our finishing lemmas uses distributive absorption, a technique introduced by the first author in [17]. For the finishing lemma in Case A, we start by constructing colour switchers for sets of ≤ 100 colours of C. These are |C| perfect rainbow matchings, each from the same small set X into a larger set V which use the same colour except for one different colour from C per matching (see Lemma 4.1). This gives us a small amount of local variability, but we can build this into a global variability property (see Lemma 4.3). This will allow us to choose colours to use from a large set of colours, but not all the colours, so we will need to find matchings which ensure any colours outside of this are used (see Lemma 4.4). To find the switchers we use a small proportion of colours in a random set. We will have to cover the colours not used in this, with no random properties for the colours remaining (see Lemma 4.5). We put this all together to prove Lemma 2.6 in Section 4.5.
Proof. With high probability, by Lemma 3.16 we have the following property.
I For each distinct u, v ∈ V (K 2n+1 ), there are at least 100βn colours c ∈ D 0 for which there are colour-c neighbours of both u and v in V 0 .

Distributive absorption with matchings
We now put our colour switchers together to create a global flexibility property. To do this, we find certain disjoint colour switchers, governed by a suitable robustly matchable bipartite graph. This is a bipartite graph which has a lot of flexibility in how one of its parts can be covered by matchings. It exists by the following lemma.
Lemma 4.2 (Robustly matchable bipartite graphs, [17]). There is a constant h 0 ∈ N such that, for every h ≥ h 0 , there exists a bipartite graph H with maximum degree at most 100 and vertex classes X and Y ∪ Y , with |X| = 3h, and |Y | = |Y | = 2h, so that the following is true. If Y 0 ⊆ Y and |Y 0 | = h, then there is a matching between X and Y ∪ Y 0 . ξ, µ. Let K 2n+1 be 2-factorized. Suppose that V 0 ⊆ V (K 2n+1 ) and D 0 ⊆ C(K 2n+1 ) are µ-and η-random respectively, and suppose that they are independent. With high probability, the following holds.
Suppose X, Z ⊆ V (K 2n+1 ) are disjoint subsets such that (X, Z) is (ξn)-replete, α ≤ β and C ⊆ C(K 2n+1 ) \ D 0 is a set of at most 2βn colours. Then, there is a set X 0 of |D 0 | + αn vertices in X such that, for every set C ⊆ C of αn colours, there is a perfect (D 0 ∪ C )-rainbow matching from X 0 into V 0 ∪ Z.
We will show that the property in the lemma holds. For this, let X, Z ⊆ V (K 2n+1 ) be disjoint subsets such that (X, Z) is (ξn)-replete, let α ≤ β and let C ⊆ C(K 2n+1 ) \ D 0 be a set of at most 2βn colours. Let h = 2βn, and, using J1, pick a set D 1 ⊆ D 0 of (3h − αn) colours. Noting that |D 1 | ≥ 2h and |D 1 ∪ C| ≤ 4h, we can define sets Y, Y of order 2h with Y ⊆ D 1 and D 1 ∪ C ⊆ Y ∪ Y (where any extra elements of Y are arbitrary dummy colours which will not be used in the arguments). Using Lemma 4.2, let H be a bipartite graph with vertex classes [3h] and Y ∪ Y , which has maximum degree at most 100, and is such that for anyȲ ⊆ Y with |Ȳ | = h, there is a perfect matching between [3h] and Y ∪Ȳ . In particular, since |D 1 | = 3h − αn and Y ⊆ D 1 , we have the following.
J3 For each set C ⊆ C of αn colours, there is a perfect matching between [3h] and D 1 ∪ C in H.
, with sizes |D i |, |D i | − 1 and at most 300, such that the following holds. (To see that we can repeat this application of J2 this many times, note that h = 2βn and ξ poly β and so at each application we delete O(h) vertices from X or Z, leaving a pair which is still (ξn/2)-replete.) J4 For every c ∈ D i , there is a perfect (C i ∪ {c})-rainbow matching from X i into V i .
Greedily, using J1, that h = 2βn, β, η poly ξ and (X, Z) is (ξn)-replete, find a (D 0 \ ( We claim this has the property required. Indeed, suppose C ⊆ C is a set of αn colours. Using J3, let M be a perfect matching between [3h] and D 1 ∪ C in H, and label D 1 ∪ C = {c 1 , . . . , c 3h } so that, for each i ∈ [3h], c i is matched to i in M . Note that the colours c i are not dummy colours. By the definition of each D i , c i ∈ D i for each i ∈ [3h]. By J4, for each i ∈ [3h], there is a perfect (C i ∪{c i })-matching, M i say, from X i to V i . Then, M ∪M 1 ∪. . .∪M 3h is a perfect matching from X 0 into V 0 ∪ Z which is (C(M ) ∪ D 1 ∪ C ∪ C 1 ∪ . . . ∪ C 3h )-rainbow, and hence (D 0 ∪ C )rainbow, as required.

Covering small colour sets with matchings
We find perfect rainbow matchings covering a small set of colours using the following lemma.
has at least 3λn colour-C neighbours in V . Then, given any set C ⊆ C(K 2n+1 ) with at most νn colours, there is a perfect (C ∪ C)-rainbow matching from X to V which uses every colour in C .
Proof. Using that (X, V ) is (10νn)-replete, greedily find a matching M 1 with |C | edges from X to V which is C -rainbow. Then, using that every vertex v ∈ V (K 2n+1 ) has at least 3λn colour-C neighbours in V , greedily find a perfect C-rainbow matching M 2 from X \ V (M 1 ) to V \ V (M 1 ). This is possible as, when building M 2 greedily, each vertex in X \ V (M 1 ) has at most 2|X| ≤ 2λn neighbouring edges with colour used in C ∩ C(M 1 ∪ M 2 ) (as the colouring is 2-bounded) and at most |X| ≤ λn colour-C neighbours in V (M 1 ) ∪ V (M 2 ). The matching M 1 ∪ M 2 then has the required property.

Almost-covering colours with matchings
We find rainbow matchings using almost all of a set of colours using the following lemma. For every U ⊆ V (K 2n+1 ) \ (V ∪ V 0 ) with at most (q + γ + η − ν)n vertices, and any C ⊆ C(K 2n+1 ) with D ∪ D 0 ⊆ C with |C| ≥ |U | + νn, there is a perfect C-rainbow matching from U into V ∪ V 0 .
By Lemma 3.19 with V = V 2 , C = D, p = q, β = β, and n = n, we have the following.
By Lemma 3.3, we have the following.

Proof of the finishing lemma in Case A
Finally, we can put all this together to prove Lemma 2.6.
and |C | ≥ |U | + νn, there is a perfect C -rainbow matching from U into V 1 ∪ W 1 .
By Lemma 3.15, we get the following.
Finally, by Lemma 3.3, the following holds.
L6 For any set C ⊆ C(K n ) of at most νn colours, there is a perfect (C ∪ C 2 )-rainbow matching from X 2 to V 2 which uses every colour in C .
We thus have partitions X = X 1 ∪ X 2 ∪ X 3 , C = C 1 ∪ C 2 ∪ C 3 and V = V 1 ∪ V 2 ∪ V 3 , for which, by L1, L6 and L5, we have that C1-C3 hold. Therefore, by the discussion after C1-C3, we have a perfect C-rainbow matching from X into V .

The finishing lemma in Case B
Our proof of the finishing lemma in Case B has the same structure as the finishing lemma in Case A, except we first construct the colour switchers in the ND-colouring in two steps, before showing this can be done with random vertices and colours. In overview, in this section we do the following, noting the lemmas in which the relevant result is given and the comparable lemmas in Section 4.
• Lemma 5.2: We construct colour switchers in the ND-colouring for any pair of colours (c 1 , c 2 ) -that is, two short rainbow paths with the same length between the same pair of vertices, whose colours are the same except that one uses c 1 and one uses c 2 .
• Lemma 5.3: We use Lemma 5.2 to construct a similar colour switcher in the ND-colouring that can use 1 of a set of 100 colours.
• Lemma 5.5: We show that, given a pair of independent random vertex and colour sets, many of these switchers use only vertices and (non-switching) colours in the subsets (cf. Lemma 4.1).
• Lemma 5.6: We use distributive absorption to convert this into a larger scale absorption property (cf. Lemma 4.3).
• Lemma 5.8: We embed paths while ensuring that an (arbitrary) small set of colours is used (cf. Lemma 4.4).
• Lemma 5.9: We embed paths using almost all of a set of colours, in such a way that this can reduce the number of 'non-random' colours (cf. Lemma 4.5).
• Finally, we put this all together to prove Lemma 2.7, the finishing lemma in Case B (cf. the proof of Lemma 2.6).

Colour switching with paths
We start by constructing colour switchers in the ND-colouring capable of switching between 2 colours. We use switchers consisting of two paths with length 7 between the same two vertices. By using one path or the other we can choose which of two colours c 1 and c 2 are used, as the other colours used appear on both paths. i Figure 4: Two x, y-paths used to switch colours between c 1 and c 2 .
Proof. Since 2n + 1 is odd we can relabel c 1 and c 2 such that c 1 + 2k = c 2 for some k ∈ [n] (here and later in this proof all the additions are (mod 2n + 1)). We will construct a switcher as depicted in Note that, as we choose each d i , we add one more vertex to each of these paths, which have at most 4 vertices already, so at most 12 colours are ruled out by the requirement these paths are valid and avoid the mentioned vertices. Furthermore, there are at most |C| + 4 ≤ n/20 colours in C ∪ {c 1 , c 2 } or already chosen as some d j , j < i. Thus, there are at least n/2 choices for each d i , and therefore at least (n/2) 3 choices in total. Now, let d 4 := d 1 + d 2 − d 3 − k. Note that there are at most n 2 (|C| + 5) ≤ n 3 /20 choices for both being valid paths which avoid 1 + c 1 + k and 1 + c 2 , respectively. Noting that 1 + is therefore a valid path. Noting that 1 + is therefore a valid path, with endvertex 1 + c 2 . Therefore, its reverse, (1 + c 2 , d 4 , d 3 , −d 2 , −d 1 , −c 1 − k), is a valid path that ends with 1. Moving the vertex 1 to the start of the path, we get the valid path (1, Note that these conditions rule out at most 12, 12, and |C| + 6 values of i respectively, so that |I| ≥ n − 2|C| − 12 − 24 ≥ n/2.
For each i ∈ I, add x and y as the start and end of (x + i, Then, add x and y as the start and end of ( . Note that, P i and Q i are both rainbow x, y-paths with length 7, with colour sets (C i ∪ {c 1 }) and (C i ∪ {c 1 }) respectively (indeed, when we add −d i , 1 ≤ i ≤ 4 to get the next vertex of the path the colour of this edge is d i and "−" just indicates in which direction we are moving). Each vertex in X can appear as the interior vertex of at most 6 different paths P i and 6 different paths Q i . As |I| ≥ n/2 > 12|X|, there must be some j ∈ I for which the interior vertices of P j and Q j avoid X. Then, C = C j is a colour set as required by the lemma, as demonstrated by the paths P j and Q j .
The following lemma uses this to find colour switchers for an arbitary set of 100 colours {c 1 , . . . , c 100 } in the ND-colouring between an arbitrary vertex pair {x, y}. A sketch of its proof is as follows. First, we select a vertex x 1 and colours d 1 , . . . , d 100 so that c i + d i = x 1 − x for each i ∈ [100]. By choosing the vertex between x and x 1 appropriately, we can find a {c i , d i }-rainbow x, x 1 -path with length 2 for each i ∈ [100]. This allows us to use any pairs of colours {c i , d i }, so we need only construct a path which can switch between using any set of 99 colours from {d 1 , . . . , d 100 }. This we do by constructing a sequence of (d i , d i+1 )-switchers for each i ∈ [99] and putting them together between x 1 and y. Lemma 5.3 (1 in 100 colour absorbers). Let 1 poly n −1 . Suppose K 2n+1 is ND-coloured. Suppose we have a pair of distinct vertices x, y ∈ V (K 2n+1 ), a set C ⊆ C(K 2n+1 ) of 100 colours, and sets X ⊆ V (K 2n+1 ) and C ⊆ C(K 2n+1 ) with |X| ≤ n/10 3 and |C | ≤ n/10 3 .
Then, there is a setC ⊆ C(K 2n+1 ) \ (C ∪ C ) of 694 colours and a setX ⊆ V (K 2n+1 ) \ X of at most 1500 vertices so that, for each c ∈ C, there is a (C ∪ {c})-rainbow x, y-path with length 695 and internal vertices inX.
Proof. Let = 100, x 0 = x, and x = y, and label C = {c 1 , . . . , c }. Pick Each such condition forbids at most n/10 3 + 100 points and we have at most 2 = 200 conditions so we can indeed find x 1 satisfying all of them. For Next, iteratively, for each 1 ≤ i ≤ − 1, using Lemma 5.2 find a set X i of at most 12 vertices in [2n + 1] \ (X ∪ X ∪ (∪ j<i X j )) and a set C i of 6 colours in [n] \ (C ∪ C ∪ C ∪ (∪ j<i C j )) so that there is a (C i ∪ {d i })-rainbow x i , x i+1 -path with length 7 and internal vertices in X i and a (C i ∪ {d i+1 })-rainbow x i , x i+1 -path with length 7 and internal vertices in X i . LetC = C ∪ (∪ i∈[ −1] C i ) andX = X ∪ (∪ i∈[ −1] X i ), and note that |C| = + 6( − 1) = 694 and |X| ≤ 2 + 1 + 12( − 1) ≤ 1500. We will show thatC andX satisfy the condition in the lemma.
Let then j ∈ [ ]. For each 1 ≤ i < j, let P i be a (C i ∪ {d i })-rainbow x i , x i+1 -path with length 7 and internal vertices in X i . For each j ≤ i ≤ − 1, let P i be a (C i ∪ {d i+1 })-rainbow x i , x i+1 -path with length 7 and internal vertices in X i . Thus, the paths P i , i ∈ [ − 1], cover all the colours in C except for d j , as well as the colours in each set C i . Therefore, as x 0 = x and x = y, is a (C ∪ {c j })-rainbow x, y-path with length 2 + 7 × 99 = 695 whose interior vertices are all inX, as required.
The following corollary of this will be convenient to apply.
For each i ∈ [ ] and c ∈ C, there is a C i ∪ {c}-rainbow x, y-path with length 695 and interior vertices in X i .
The following lemma finds 1-in-100 colour switchers in a random set of colours and vertices.
Lemma 5.5 (Colour switchers using random vertices and colours). Let p, q poly µ poly n −1 and suppose that K 2n+1 is ND-coloured. Let X ⊆ V 2k+1 be p-random and C ⊆ C(K 2n+1 ) q-random, and such that X and C are independent. With high probability the following holds.
For every distinct x, y ∈ V (K 2n+1 ), C ⊆ C(K 2n+1 ) with |C | = 100, and X ⊆ X, C ⊆ C with |X |, |C | ≤ µn, there is a setC ⊆ C \ (C ∪ C ) of 694 colours and a set X ⊆ X \ X of at most 1500 vertices with the following property. For each c ∈ C , there is a (C ∪ {c})-rainbow x, y-path with length 695 and internal vertices in X .
Proof. We will show that for any distinct pair x, y ∈ V (K 2n+1 ) of vertices and set C ⊆ C(K 2n+1 ) of 100 colours the property holds with probability 1 − o(n −102 ) so that the lemma holds by a union bound.
Fix then distinct x, y ∈ V (K 2n+1 ) and a set C ⊆ C(K 2n+1 ) with size 100. Fix = n/10 7 and use Corollary 5.4 to find disjoint vertex sets X i ⊆ V (K 2n+1 ), i ∈ [ ], with size at most 1500 and disjoint colours sets C i ⊆ C(K 2n+1 ), i ∈ [ ], with size 694 so that for each c ∈ C and i ∈ [ ] there is a C i ∪ {c}-rainbow x, y-path with length 695 and internal vertices in X i .
Let I ⊆ [ ] be the set of i ∈ [ ] for which X i ⊆ X and C i ⊆ C. Note that |I| is 1-Lipschitz, and, for each i ∈ [ ], we have P(X i ⊆ X, C i ⊆ C) ≥ p 1500 q 695 poly µ. By Azuma's inequality, with probability 1 − o(n −102 ) we have |I| ≥ 10 4 µn.
Take then any X ⊆ X and C ⊆ C with size at most µn each. There must be some j ∈ I for which X ∩X j = ∅ and C ∩ C j = ∅. LetC = C j ⊆ C \ (C ∪ C ) and X = X j ⊆ X \ X . Then, as required, for each c ∈ C there is a (C ∪ {c})-rainbow x, y-path with interior vertices in X .

Distributive absorption with paths
We now use Lemma 5.5 and distributive absorption to get a larger scale absorption property, as follows.
Suppose that {x 1 , . . . , x , y 1 , . . . , y } ⊆ V (K 2n+1 ), α ≤ η and C ⊆ C(K 2n+1 ) \ C 0 is a set of at most ηn colours. Then, there is a setĈ ⊆ C 0 of 695 − αn colours such that, for every set C ⊆ C of αn colours, there is a set of vertex disjoint x i , y i -paths which are collectively (Ĉ ∪ C )-rainbow, have length 695, and internal vertices in V 0 .
Proof. By Lemma 5.5 (applied to X = V 0 , C = C 0 with p = q = and µ = 3µ), we have the following property with high probability. N1 For each distinct x, y ∈ V (K 2n+1 ), and every C ⊆ C(K 2n+1 ) with |C | = 100, and X ⊆ V 0 , C ⊆ C 0 with |X |, |C | ≤ 3µn, there is a setC ⊆ C 0 \ (C ∪ C ) of 694 colours and a set X ⊆ V 0 \ X of at most 1500 vertices with the following property.
For each c ∈ C , there is a (C ∪ {c})-rainbow x, y-path with length 695 and internal vertices in X .
N2 For each set C ⊆ C of αn colours, there is a perfect matching between [3h] andĈ 0 ∪ C in H.
Iteratively, for each 1 ≤ i ≤ 3h, let D i = N H (i) and, using N1, find sets , with sizes 694 and at most 1500, such that the following holds.
N3 For each c ∈ D i , there is a (C i ∪ {c})-rainbow x i , y i -path with length 695 with internal vertices in V i .
By N3, for each i ∈ [3h], there is an x i , y i -path, P i say, with length 695 which is (C i ∪ {c})-rainbow with internal vertices in V i . Then, P 1 , . . . , P 3h are the paths required.
The following corollary of Lemma 5.6 will be convenient to apply. Let K 2n+1 be 2-factorized. Suppose that V 0 is an -random subset of V (K 2n+1 ) and C 0 is an -random subset of C(K 2n+1 ), which is independent of V 0 . Suppose that = µn/k and 695|k. With high probability, the following holds.
Suppose that {x 1 , . . . , x , y 1 , . . . , y } ⊆ V (K 2n+1 ), α ≤ η and C ⊆ C(K 2n+1 ) is a set of at most ηn colours. Then, there is a setĈ ⊆ C 0 of k − αn colours such that, for every set C ⊆ C of αn colours, there is a set of vertex disjoint x i , y i -paths which are collectively (Ĉ ∪ C )-rainbow, have length k, and internal vertices in V 0 .
Then, there is a setĈ of 695 − α n colours such that, for every set C ⊆ C of α n colours, there is a set of vertex disjoint x i , y i -paths which are collectively (Ĉ ∪ C )-rainbow, have length 695, and internal vertices in V 1 .

Covering small colour sets with paths
We now show that paths can be found using every colour in an arbitrary small set of colours.
For any set C ⊆ C(K n+1 ) \ C 0 of at most ξn colours, and any set {x 1 , . . . , x m , y 1 , . . . , y m } ⊆ V (K 2n+1 ) \ V 0 , there is a set of vertex-disjoint paths x i , y i -paths, i ∈ [m], each with length k and interior vertices in V 0 , which are collectively (C ∪ C 0 )-rainbow and use all the colours in C.
By Lemma 3.26 applied with p = β/2, q = 4ξ, V = V 2 and C = C 2 , with high probability, we have the following property.
P3 For any m ≤ 4ξn and set {x 1 , y 1 , . . . , x m , y m } ⊆ V (K 2n+1 ) there is a collection P 1 , . . . , P m of vertexdisjoint paths with length 3, with internal vertices in V 2 , where P i is an x i , y i -path, for each i ∈ [m ], and P 1 ∪ · · · ∪ P m is C 2 -rainbow.
We will now show that the property in the lemma holds. Let then C ⊆ C(K n+1 ) \ C 0 have at most ξn colours and let X := {x 1 , . . . , x m , y 1 , . . . , y m } ⊆ V (K 2n+1 ) \ V 0 . Take = (k − 3)/4, and note that this is an integer and m ≥ ξn. Using P1, take an order m set C ⊆ C ∪ C 1 with C ⊆ C and label Using P2, greedily find independent edges s i,j t i,j , i ∈ [m], j ∈ [ ], with vertices in V 1 , so that each edge s i,j t i,j has colour c i,j . Note that, when the edge s i,j t i,j is chosen at most 2m ≤ 2mk ≤ 10ξn vertices in V 1 are in already chosen edges.
Using P3 with m = m( + 1), find vertex-disjoint paths P i,j , i ∈ [m], 0 ≤ j ≤ , with length 3 and internal vertices in V 2 so that these paths are collectively C 2 -rainbow and the following holds for each i ∈ [m].
Then, the paths P i = ∪ 0≤j≤ P i,j , i ∈ [m], use each colour in C ⊆ C ∪ C 1 , and hence C, and otherwise use colours in C 2 , have interior vertices in V 0 and, for each i ∈ [m], P i is a length 3( + 1) + = k path from x i to y i . That is, the paths P i , i ∈ [m], satisfy the condition in the lemma.

Almost-covering colour sets with paths
We now show that paths can be found using almost every colour in a set of mostly-random colours.
For any set C ⊆ C(K n+1 ) with D ∪ D 0 ⊆ C of mk + ηn colours, and any set X := {x 1 , . . . , x m , y 1 , . . . , y m } ⊆ V (K 2n+1 ) \ (V ∪ V 0 ), there is a set of vertex-disjoint paths x i , y i -paths with length k, i ∈ [m], which have interior vertices in V ∪ V 0 and which are collectively C-rainbow.
By Lemma 3.13, with high probability the following holds.
By Lemma 3.26, applied with p = γη and q = 2q/k to D 0 and a (γη)-random subset of V 0 , with high probability the following holds.
By Lemma 3.3, with high probability the following holds.
By Lemma 3.19, applied for each i ∈ [2 ] and j ∈ [ ] with p = m /n and β = η 2 /k 2 , with high probability the following holds.
Q6 For each i ∈ [2 ] and j ∈ [ ] and any vertex set Y ⊆ V (K 2n+1 ) \ V with |Y | ≤ m there is a C i -rainbow matching from Y into V j with at least |Y | − η 2 n/k 2 edges.
We will show that the property in the lemma holds. Set then C ⊆ C(K n+1 ) with D ∪D 0 ⊆ C so that |C| = mk +ηn and let X : Note that, using Q4, and take disjoint sets Greedily, using Q1, take vertex disjoint edges x c y c , c ∈ C , with vertices in V so that the edge x c y c has colour c. Note that these edges have 2m ≤ qn vertices in total, so that this greedy selection is possible. Let M be the matching For each i ∈ [ − 1], use Q6 to find a C i -rainbow matching M i with m − η 2 n/k 2 edges from Z i into V i , and a C i+ -rainbow matching, M i say, with m − η 2 n/k 2 edges from Y i into V i−1 . Note that, by Q5 these matchings overlap in at least m − 4η 2 n/k 2 vertices. Therefore, putting together M with the matchings M i , M i , i ∈ [ ] gives at least m − · 4η 2 n/k 2 ≥ m vertex disjoint paths with length 3 − 2. Furthermore, these paths are collectively rainbow with colours in (C \ D 0 ). Take m such paths, Q i , i ∈ [m]. Apply Q2, to connect one endpoint of Q i to x i and another endpoint to y i using two paths of length 3 and new vertices and colours in V 0 and D 0 respectively to get the paths with length k = 3 + 4 as required.
By Lemma 5.8, applied with m = m 2 , V 0 ⊆ W 2 a β-random subset and C 0 = D 2 , with high probability, we have the following.

R4
For every set C ⊆ D 2 of |D 2 | − 4ξn colours, there is a set of vertex disjoint x i , y i -paths, i ∈ I 3 , which are collectively (D 3 ∪ C )-rainbow, have length k, and internal vertices in W 3 .
Let C 1 = D \ (D 2 ∪ D 3 ), C 2 = D 2 and C 3 = D 3 . We now reason analogously to the discussion after C1-C3. Note that C ∪ D 1 ⊆ C 1 and Therefore, using R1, we can find m 1 paths {P 1 , . . . , P m1 } such that P i is an x i , y i -path with length k, for each i ∈ I 1 , so that these paths are vertex disjoint with internal vertices in V 1 = V 1 ∪W 1 and are collectively C 1 -rainbow.
Let C = C 1 \ (∪ i∈X1 C(P i )), so that, by (2), |C | = ξn. Using R2, we can find m 2 paths {P 1 , . . . , P m2 } such that P i is an x i , y i -path with length k, for each i ∈ I 2 , so that these paths are vertex disjoint with internal vertices in V 2 = V 2 ∪ W 2 and are collectively (C 2 ∪ C )-rainbow and use every colour in C .
Let C = C 2 \ (∪ i∈X2 C(P i )), and note that |C | = |C 2 ∪ C | − m 2 k = |D 2 | + ξn − m 2 k = |D 2 | − 4ξn. Using R4 and that C 3 = D 3 , we can find m 3 paths {P 1 , . . . , P m3 } such that P i is an x i , y i -path with length k, for each i ∈ I 3 , so that the paths are vertex disjoint with internal vertices in V 3 = V 3 ∪W 3 which are collectively (C 3 ∪C )-rainbow.
Then, for each i ∈ [ ], the path P i is an x i , y i -path with length k, so that all the paths are vertex disjoint with internal vertices in V 1 ∪ V 2 ∪ V 3 ⊆ V 0 ∪ V and which are collectively D-rainbow, as required.

Randomized tree embedding
In this section, we prove Theorem 2.5. We start by formalising what we mean by a random rainbow embedding of a tree. Definition 6.1. For a probability space Ω, tree T and a coloured graph G, a randomized rainbow embedding of T into G is a triple φ = (V φ , C φ , T φ ) consisting of a random set of vertices V φ : Ω → V (G), a random set of colours C φ : Ω → C(G), and a random subgraph T φ : Ω → E(G) such that: • With high probability, T φ is a rainbow copy of T .
We will embed a tree bit by bit, starting with a randomized rainbow embedding of a small tree and then extending it gradually. For this, we need a concept of one randomized embedding extending another. Definition 6.2. Let G be a graph and T 1 ⊆ T 2 two nested trees. Let φ 1 = (V φ1 , C φ1 , S φ1 ) and φ 2 = (V φ2 , C φ2 , S φ2 ) be randomized rainbow embeddings of T 1 and T 2 respectively into G. We say that φ 2 extends φ 1 if • T φ1 ⊆ T φ2 , C φ1 ⊆ C φ2 , and V φ1 ⊆ V φ2 always hold.
The above definition implicitly assumes that the two randomized embeddings are defined on the same probability space, which is the case in our lemmas, except for Lemma 6.3. When φ 1 and φ 2 are defined on different probability spaces Ω φ1 and Ω φ2 respectively, we use the following definition. We say that an extension of φ 1 is a measure preserving transformation f : Ω φ2 → Ω φ1 (i.e. P(f −1 (A)) = P(A) for any A ⊆ Ω φ1 ). We say that is a randomized embedding of T 1 defined on Ω φ2 which is equivalent to φ 1 (i.e. the probability of any outcomes φ 1 and φ 1 are the same). It also ensures that φ 2 is an extension of φ 1 as in Definition 6.2.
The following lemma extends randomized embeddings of trees by adding a large star forest. Recall that a p-random subset of some finite set is formed by choosing every element of it independently with probability p. Let T 1 ⊆ T 2 be forests such that T 2 is formed by adding stars with ≥ d leaves to vertices of T 1 . Let K 2n+1 be 2-factorized and suppose that |T 2 | = (1 − p)n. Let φ 1 = (V φ1 , C φ1 , T φ1 ) be a randomized rainbow embedding of T 1 into K 2n+1 where V φ1 and C φ1 are both γ-random.
Then, φ 1 can be extended into a randomized rainbow embedding φ 2 = (V φ2 , C φ2 , T φ2 ) of T 2 so that V φ2 and C φ2 are (1 − p + β)-random sets (with V φ2 and C φ2 allowed to depend on each other).
Proof. Choose α such that β poly α poly γ. Let θ = |T 1 |/n and F = T 2 \ T 1 , noting that F is a star forest with degrees ≥ d and e(F ) = (1 − p − θ)n. Let I ⊆ V (T 1 ) be the vertices to which stars are added to get T 2 from T 1 . Let Ω be the probability space for φ 1 . We call ω ∈ Ω successful if T φ1 (ω) is a copy of T 1 and if we have |V φ1 (ω)|, |C φ1 (ω)| ≤ 4γn. Using Chernoff's bound and the fact that φ 1 is a randomized embedding of T 1 we have that with high probability a random ω ∈ Ω is succesful.
For every successful ω, let J ω be the copy of I in T φ1 (ω). We can apply Lemma 3.24 with F = F , J = J ω , (ω), p = p + θ, α = α, γ = 4γ, d = d and n = n. This gives a probability space Ω ω , and a randomized subgraph F ω , and randomized sets D ω are functions from Ω ω to the families of subgraphs/subsets of vertices/sets of colours of K 2n+1 respectively). From Lemma 3.24 we know that, for each ω, F ω is with high probability a copy of F , and that U ω and D ω are (1 − α)(p + θ)-random subsets of V (K 2n+1 ) \ V φ1 (ω) and C(K 2n+1 ) \ C φ1 (ω) respectively. Setting T ω = F ω ∪ T φ1 (ω) gives a subgraph which is a copy of T 2 with high probability (for successful ω). For every unsuccessful ω, set T ω = T φ1 (ω), and choose (ω) to be independent (1 − α)(p + θ)-random subsets (in this case letting Ω ω be an arbitrary probability space on which such U ω , D ω are defined).
The following lemma extends randomized embeddings of trees by adding connecting paths. Lemma 6.4 (Extending with connecting paths). Let p poly q poly n −1 . Let T 1 ⊆ T 2 be forests such that T 2 is formed by adding qn paths of length 3 connecting different components of T 1 . Let K 2n+1 be 2-factorized. Let φ 1 = (V φ1 , C φ1 , T φ1 ) be a randomized rainbow embedding of T 1 into K 2n+1 and let U ⊆ V (K 2n+1 ) \ V φ1 , D ⊆ C(K 2n+1 ) \ C φ1 be p-random, independent subsets. Let V φ2 = V φ1 ∪ U and C φ2 = C φ1 ∪ D.
Let Ω be the probability space for φ 1 . We say that ω ∈ Ω is successful if T φ1 (ω) is a copy of T 1 and the conclusion of Lemma 3.26 holds with V = U , C = D, p = p, q = q and n = n. As φ 1 is a randomized embedding of T 1 , and by Lemma 3.26, we have that, with high probability, ω is successful. For each successful ω, let x ω 1 , y ω 1 , . . . , x ω qn , y ω qn be the vertices of T φ1 (ω) which need to be joined by paths of length 3 to get a copy of T 2 . From the conclusion of Lemma 3.26, for each successful ω, we can find paths P ω i , i ∈ [qn], so that the paths are vertex disjoint and collectively D-rainbow, and each path P ω i is an x i , y i -path with length 3 and internal vertices in U . Letting T φ2 = T φ1 (ω) ∪ P ω 1 ∪ · · · ∪ P ω qn , (V φ2 , C φ2 , T φ2 ) gives the required randomized embedding of T 2 .
The following lemma extends randomized embeddings of trees by adding a sequence of matchings of leaves. Lemma 6.5 (Extending with matchings). Let −1 , p, q poly n −1 . Let T 1 ⊆ T be forests such that T is formed by adding a sequence of matchings of leaves to T 1 . Let K 2n+1 be 2-factorized. Suppose |T | − |T 1 | ≤ pn. Let φ 1 = (V φ1 , C φ1 , T φ1 ) be a randomized rainbow embedding of be p/2-random, and D dep ⊆ C(K 2n+1 ) \ (C φ1 ∪ D ind ) p-random (possibly depending on each other).
Then φ 1 can be extended into a randomized rainbow embedding φ = (V φ , C φ , T φ ) of T into V φ = V φ1 ∪ U ind ∪ U dep and C φ = C φ1 ∪ D ind ∪ D dep .
Proof. Without loss of generality, suppose that |T | − |T 1 | = pn. Define forests T 1 , . . . , T , and p 1 , . . . , p ∈ [0, 1] such that each T i+1 is constructed from T i by adding a matching of p i n leaves. Randomly partition U dep = {U 1 dep , . . . , U dep } and D dep = {D 1 dep , . . . , D dep } so that each set U i dep ⊆ V (K 2n+1 ) is p i /2-random and each set D i dep ⊆ C(K 2n+1 ) is p i -random. Randomly partition U ind = {U 1 ind , . . . , U ind }, D ind = {D 1 ind , . . . , D ind } so that each set U i ind and D i ind is (q/ )-random. Let Ω be the probability space for φ 1 . We say that ω ∈ Ω is successful if T φ1 (ω) is a copy of T 1 and, for each i ∈ [ ], the conclusion of Lemma 3.20 holds for U i dep , U i ind , D i dep , D i ind , p = p i , γ = q/ and n = n. As φ 1 is a randomized embedding of T 1 , and by Lemma 3.20, we have that, with high probability, ω is successful. Note that, for this, we take a union bound over events, using that the conclusion of Lemma 3.20 holds with probability 1 − o(n −1 ) in each application.
For each successful ω, define a sequence of trees T ω 0 , T ω 1 , . . . , T ω . Fix T ω 0 = T φ1 (ω) and recursively construct T ω i+1 from T ω i by adding an appropriate (D i dep ∪ D i ind )-rainbow size p i n matching into U i dep ∪ U i ind to make T ω i into a copy of T i+1 (which exists as the conclusion of Lemma 3.20 holds because ω is successful). Letting T φ (ω) = T ω gives the required randomized embedding of T .
The following lemma gives a randomized embedding of any small tree. Lemma 6.6 (Small trees with a replete subset). Let q poly γ ≥ ν poly ξ poly n −1 . Let T be a tree with |T | = γn containing a set U ⊆ V (T ) with |U | = νn. Let K 2n+1 be 2-factorized with V φ , C φ q-random sets of vertices and colours respectively. Then, there is a randomized rainbow embedding φ = (T φ , V φ , C φ ) along with independent q/2random sets V 0 ⊆ V φ \ V (T φ ), C 0 ⊆ C φ \ C(T φ ) with (V 0 , U φ ) ξn-replete with high probability (where U φ is the copy of U in T φ ).
Proof. Choose α such that q poly α poly γ, ν. Inside V φ choose disjoint sets V 0 , V 1 , V 2 which are q/2-random, α-random, and 100ν/q-random respectively. Inside C φ choose disjoint sets C 0 , C 1 , C 2 which are q/2-random, q/4-random, and q/4-random respectively. Notice that the total number of edges of any particular color is 2n + 1 and the probability that any such edge is going from V 2 to V 1 ∪ V 2 is 2(100ν/q)(100ν/q + α). Therefore by Lemmas 3.15 and 3.2 the following hold with high probability.
Using R1, we can greedily find a rainbow copy T φ of T in V 1 ∪V 2 ∪C 1 ∪C 2 with U embedded into V 2 . Indeed, embed one vertex at a time, always embedding a vertex which has one neighbour into preceding vertices. Moreover, put a vertex from T \ U into V 1 using an edge of colour from C 1 and put a vertex from U into V 2 using an edge of colour from C 2 . Let U φ be the copy of U in T φ . By R2, and as |U φ | = νn, (U φ , V (K 2n+1 ) \ (V 1 ∪ V 2 )) is 0.9νn-replete. Indeed, for every color there are at least |U φ | edges of this color incident to U φ and at most 0.1|U φ | of them going to V 1 ∪ V 2 .
The following is the main result of this section. It finds a rainbow embedding of every nearly-spanning tree. Given the preceding lemmas, the proof is quite simple. First, we decompose the tree into star forests, matchings of leaves, and connecting paths using Lemma 3.9. Then, we embed each of these parts using the preceding lemmas in this section. For each i ∈ {2, . . . , 5} (and the label * meaning "small, stars, match or paths" appropriately), let p i = (|T * i | − |T * i−1 |)/n. Set p 6 = − β. These constants represent the proportion of colours which are used for embedding each of the subtrees (with p 6 representing the proportion of colours left over for the set C in the statement of the lemma). Notice that p = p 3 + p 4 + p 5 + p 6 + β. For each i ∈ [6], choose disjoint, independent 2µ-random sets V i ind , C i ind . Do the following.
For odd m, relabel vertices in V 1 so that, if u i is the image of v i under the embedding, then, for each i ∈ [m], the vertices in the image of V 1 appear in I 1 in the following order: u 1 , u 3 , u 5 , . . . , u m , u m−1 , u m−3 , . . . , u 2 .
For even m, relabel vertices in V 1 so that, if u i is the image of v i under the embedding, then, for each i ∈ [m], the vertices in the image of V 1 appear in I 1 in the following order: For each 1 ≤ i ≤ m, if i is odd we say that u i is type 1, and if i is even we say that u i is type 2. For each m < i ≤ , we say that u i is type 3. Note that, if m = 1, then there are no type 2 vertices. Furthermore, note that, if m = 1, then V (S ) ⊆ {u 1 }∪I 0 ∪I 2 ⊆ {u 1 }∪[0.83n, 0.92n], while, if m > 1, then V (S ) ⊆ [u 1 , u 2 ]∪I 0 ∪I 2 ⊆ [u 1 , u 2 ]∪[0.83n, 0.92n].
For each i ∈ [ ], do the following.
• If u i is a type 1 vertex, embed the vertices in U i := {u i − c : c ∈ C i } as neighbours of u i .
• If u i is a type 2 or 3 vertex, embed the vertices in U i := {u i + c : c ∈ C i } as neighbours of u i .
This conjecture was proved for many isolated classes of trees like caterpillars, trees with ≤ 4 leaves, firecrackers, diameter ≤ 5 trees, symmetrical trees, trees with ≤ 35 vertices, and olive trees (see Chapter 2 of [9] and the references therein). Conjecture 8.1 is also known to hold asymptotically for trees of maximum degree at most n/ log n [1] but solving it for general trees, even asymptotically, is already wide open. Another very interesting related problem is the Gýarfás Tree Packing Conjecture. This also concerns decomposing a complete graph into specified trees, but the trees are allowed to be different from each other. Conjecture 8.2 (Gyárfás, [11]). Let T 1 , . . . , T n be trees with |T i | = i for each i ∈ [n]. The edges of K n can be decomposed into n trees which are isomorphic to T 1 , . . . , T n respectively. This conjecture has been proved for bounded degree trees by Joos, Kim, Kühn and Osthus [12] but in general it is wide open. It would be interesting to see if any of our techniques can be used here to make further progress.