A sharp threshold for van der Waerden's theorem in random subsets

We establish sharpness for the threshold of van der Waerden's theorem in random subsets of $\mathbb{Z}/n\mathbb{Z}$. More precisely, for $k\geq 3$ and $Z\subseteq \mathbb{Z}/n\mathbb{Z}$ we say $Z$ has the van der Waerden property if any two-colouring of $Z$ yields a monochromatic arithmetic progression of length $k$. R\"odl and Ruci\'nski (1995) determined the threshold for this property for any k and we show that this threshold is sharp. The proof is based on Friedgut's criteria (1999) for sharp thresholds, and on the recently developed container method for independent sets in hypergraphs by Balogh, Morris and Samotij (2015) and by Saxton and Thomason (2015).


Introduction
One of the main research directions in extremal and probabilistic combinatorics over the last two decades has been the extension of classical results for discrete structures to the sparse random setting. Prime examples include Ramsey's theorem for graphs and hypergraphs [2,8,9], Turán's theorem in extremal graph theory, and Szemerédi's theorem on arithmetic progressions [2,12] (see also [1,3,11]). Results of that form establish the threshold for the classical result in the random setting. For a property the threshold is given by a functionp "ppnq such that for every p 0 !p the random graph Gpn, p 0 q (or a random binomial subset of rns " t1, 2, . . . , nu) with parameter p 0 , the probability the property holds is asymptotically zero, whereas if p 0 is replaced by some p 1 "p the property does hold asymptotically almost surely (a.a.s.), i.e., for a property P of graphs and probabilities p " ppnq we have lim nÑ8 P`Gpn, pq P P˘" The two statements involving p 0 and p 1 are referred to as the 0-statement and the 1-statement.
For the properties mentioned above it can be shown that the optimal parameters p 0 and p 1 for which the 0-statement and the 1-statement hold, only differ by a multiplicative constant. The threshold for van der Waerden's theorem [15] is such an example and was obtained by Rödl and Ruciński in [9,10]. We denote by rns p the binomial random subset of rns, where every element of rns is included independently with probability p " ppnq. Furthermore, for a subset A Ď rns we write A Ñ pk-APq r to denote the fact that no matter how one colours the elements of A with r colours there is always a monochromatic arithmetic progression with k elements in A.
Theorem 1 (Rödl & Ruciński). For every k ě 3 and r ě 2 there exist constants c 0 , c 1 ą 0 such that lim nÑ8 Pprns p Ñ pk-APq r q " For the corresponding result in Z{nZ and for two colours we close the gap between c 0 and c 1 . More precisely, we show that there exist bounded sequences c 0 pnq and c 1 pnq with ratio tending to 1 as n tends to infinity such that the statement holds (see Theorem 2 below). In other words, we establish a sharp threshold for van der Waerden's theorem for two colours in Z{nZ.
Similarly to the situation for subsets of rns we write A Ñ pk-APq r for subsets A Ď Z{nZ if any r-colouring of A yields a monochromatic arithmetic progression with k-elements in Z{nZ and we write A Û pk-APq r if A fails to have this property. Moreover, we denote by Z n,p the binomial random subset of Z{nZ with parameter p. With this notation at hand we can state our main result. PpZ n,p Ñ pk-APq 2 q " We have to insist on the setting of Z{nZ (instead of rns) since the symmetry will play a small but crucial rôle in our proof. Another shortcoming is the restriction to two colours r " 2 and we believe it would be very interesting to extend the result to arbitrary r. We remark that only a few sharp thresholds for Ramsey properties are known (see, e.g., [6,7]) so far.
Among other tools our proof relies heavily on the criterion for sharp thresholds of Friedgut and its extension due to Bourgain [4]. Another crucial tool is the recent container theorem for independent sets in hypergraphs due to Balogh, Morris and Samotij [1] and Thomason and Saxton [11].
Our proof extends to other Ramsey properties for two colours, as long as the corresponding extremal problem is degenerate, i.e., positive density yields many copies of the target structure and the target structure is strictly balanced with respect to its so-called 2-density. For example, even cycles in graphs, complete k-partite, k-uniform hypergraphs, and strictly balanced, density regular Rado systems (see [10]) satisfy these assumptions. Moreover, Schacht and Schulenburg [13] noted that the approach undertaken here can be refined to give a shorter proof for the sharp threshold of the Ramsey property for triangles and two colours from [7] and, more generally, for arbitrary odd cycles.

Locality of coarse thresholds
In [4] Friedgut gave a necessary condition for a graph property to have a coarse threshold, namely, that it is approximable by a "local" property. In the appendix to this work Bourgain proved a similar result for more general discrete structures. Here we state the special case applicable for properties in Z{nZ.

Theorem 3 (Bourgain).
There exist functions δpC, τ q and KpC, τ q such that the following holds. Let p " op1q as n tends to infinity, let A be a monotone family of subsets of Z{nZ, with τ ă µpp, Aq :" PpZ n,p P Aq ă 1´τ , and assume also p¨d µpp,Aq dp ď C. Then there exists some B Ď Z{nZ with |B| ď K such that PpZ n,p P A | B Ď Z n,p q ą PpZ n,p P Aq`δ . (1) Note that whenever a property A (or rather, a series of properties A n ) has a coarse threshold there exist constants C and τ such that for infinitely many values of n the hypothesis of the theorem holds. For applications, it would be problematic if there exists a B with |B| ď K and B P A, since this would trivialise the conclusion (1). However, as observed in [5], the above theorem can be strengthened, without modifying the original proof, to deduce that the set of B's for which the assertion holds has non-negligible measure, i.e., there exists a family B such that where η ą 0 depends only on C and τ but not on n, and every B P B satisfies the conclusion of Theorem 3, i.e., |B| ď K and PpZ n,p P A | B Ď Z n,p q ą PpZ n,p P Aq`δ .
This allows us to make assumptions about B in the application below, as long as the set of B's violating the assumptions has negligible measure. In particular, Lemma 4 below implies that any collection of sets B Ď Z{nZ, each of bounded size and with B Ñ pk-APq 2 , appear only with probability tending to zero in Z n,p for p " Opn´1 k´1 q. Consequently, in our proof we can therefore assume that the set B, provided by Theorem 3 on the assumption that Z n,p Ñ pk-APq 2 has a coarse thresholds, itself fails to have the van der Waerden property, i.e., B Û pk-APq 2 .
Lemma 4. Let B be a family of subsets of Z{nZ with the property that every B P B satisfies |B| ď log log n and B Ñ pk-APq 2 . Then for every c ą 0 and every sequence of probabilities p " ppnq ď cn´1 k´1 we have PpB Ď Z n,p for some B P Bq " op1q.
Lemma 4 was implicitly proved in [10, Section 7] (see the Deterministic and the Probabilistic Lemma there). For completeness we include a sketch of the proof here.
Proof (Sketch). Let k ě 3 be an integer and let p " ppnq ď cn´1 {pk´1q for some c P R ą0 . For a set Z Ď Z{nZ we consider the auxiliary k-uniform hypergraph H Z,k with vertex set Z and hyperedges corresponding to k-APs in Z. The Deterministic Lemma [10, p. 500] asserts that if Z Ñ pk-APq 2 , then one of the following configurations must appear as a subhypergraph of H Z,k : (i ) either H Z,k contains a subhypergraph of type T 1 consisting of a hyperedge e 0 and a loose cycle C of some length ě 3, i.e., C consists of hyperedges e 1 , . . . , e satisfying for every while the additional hyperedge e 0 has at least one vertex outside the cycle and shares at least two vertices with the cycles, i.e., 2 ď |e 0 X V pC q| ă k ; (ii ) or H Z,k contains a subhypergraph of type T 2 consisting of a non-induced loose path P of some length ě 2, i.e., hyperedges e 1 , . . . , e satisfying for 1 ď i ă j ď |e i X e j | " The condition that P is non-induced means that there exists some hyperedge e 0 in EpH Z,k q EpP q such that e 0 Ď V pP q.
A simple first moment argument shows that a.a.s. no hypergraph on at most log n vertices of types T 1 or T 2 appears in H Zn,p,k . For that let X 1 (resp. X 2 ) be the random variable counting the number of copies of hypergraphs of type T 1 (resp. T 2 ) on at most log n vertices in Z n,p . Below we show that there exists a constant K " Kpk, cq such that EX 1 ď plog nq K¨p and EX 2 ď plog nq K¨p (2) and since p ď cn´1 {pk´1q ! plog nq´K the lemma follows from Markov's inequality. DISCRETE ANALYSIS, 2016:7, 19pp. We start with the random variable X 1 . Since the hyperedges of H Zn,p,k correspond to k-APs the number Y of loose cycles C of length at least ě 3 in H Zn,p,k satisfies EY ď Opp pk´1q ¨n q " Opc pk´1q n´ ¨n q " Opc k q .
For a given loose cycle C the additional hyperedge e 0 (to complete C to a hypergraph of type T 1 ) shares at least two vertices with C . However, with these two vertices fixed there are less than k 2 possibilities to complete this choice to a k-AP in Z{nZ, i.e., these two vertices can be completed in at most k 2 ways to form the hyperedge e 0 in H Z{nZ,k . In other words, for a fixed loose cycle C on pk´1q vertices there are at most pk´1q 2 2¨k2 possibilities to complete C to a hypergraph of type T 1 . Furthermore, since the hyperedge e 0 is required to have at least one vertex outside C we have Op 2 p¨c k q ď plog nq K¨p for some constant K " Kpk, cq, which establishes the first estimate in (2).
Similarly, for the random variable X 2 we first observe that the expected number Y 1 of loose paths P of length at least ě 2 in Z n,p satisfies EY 1 ď Opp k n 2¨ppk´1qp ´1q n p ´1q q " Oppn¨c k q .
Since the additional hyperedge e 0 reduces the expected number of choices for at least one of the hyperedges of P from Opp k´1 nq to Opp k´1 q and since e 0 is fixed after selecting two of its vertices within P we arrive at Op 2 p¨c k q ď plog nq K¨p for some constant K " Kpk, cq, which establishes the second estimate in (2) and concludes the proof of the lemma.
We summarise the discussion above in the following corollary of Theorem 3, which is tailored for our proof of Theorem 2.

Corollary 5.
Assume that the property tZ Ď Z{nZ : Z Ñ pk-APq 2 u does not have a sharp threshold. Then there exist constants c 1 , c 0 , α, ε, µ ą 0, and K and a function cpnq : N Ñ R with c 0 ă cpnq ă c 1 so that for infinitely many values of n and p " cpnqn´1 k´1 the following holds.
There exists a subset B of Z{nZ of size at most K with B Û pk-APq 2 such that for every family Z of subsets from Z{nZ satisfying PpZ n,p P Zq ą 1´µ there exists a Z P Z so that (a ) PpZ Y pB`xq Ñ pk-APq 2 q ą α, where x P Z{nZ is chosen uniformly at random, and We remark that the Pp¨q in Corollary 5 concern different probability spaces. While the assumption PpZ n,p P Zq ą 1´µ concerns the binomial random subset Z n,p , we consider x chosen uniformly at random from Z{nZ in (a ) and the binomial random subset Z n,εp in (b ). We close this section with a short sketch of the proof of Corollary 5.
Proof (Sketch). For k ě 3 we consider the property A " tZ Ď Z{nZ : Z Ñ pk-APq 2 u and assume that it does not have a sharp threshold. Consequently, there exists a function p " ppnq such that for infinitely many n the assumptions of Theorem 3 hold, which implicitly yields constants C, τ , δ, and K. LetĀ " PpZ{nZq A be the family of subsets of Z{nZ that fail to have the van der Waerden property. Since we assume that the threshold for A is not sharp, we may fix ε ą 0 sufficiently small, such that there must be some α with δ{2 ą α ą 0 so that if we let Z 1 ĎĀ be the sets Z PĀ for which then PpZ n,p P Z 1 | Z n,p PĀq ě 1´δ{4. Also for p " ppnq we have τ ă PpZ n,p Ñ pk-APq 2 q " PpZ n,p P Aq ă 1´τ , so by Theorem 1 there exist some constants c 1 ě c 0 ą 0 such that p " ppnq " cpnqn´1 k´1 for some function cpnq : N Ñ R satisfying c 0 ď cpnq ď c 1 . Strictly speaking, we should use the version of Theorem 1 for Z{nZ instead of rns. However, it is easy to see that the 1-statement for random subsets of rns implies the 1-statement for random subsets of Z{nZ (up to a different constant c 1 ) and the proof of the 0-statement from [10] can be straightforwardly adjusted for subsets of Z{nZ. Moreover, for any such n Theorem 3 yields a family B of subsets of Z{nZ each of size at most K such that (1) holds and an element of B appears as a subset of Z n,p with probability at least η. Consequently, Lemma 4 asserts that at least one such B P B fails to have the van der Waerden property itself, i.e., B Û pk-APq 2 . By symmetry it follows from (1), that the same holds for every translate B`x with x P Z{nZ. In particular, consider the family Z 2 ĎĀ of all sets Z PĀ such that for at least pδ{2qn translates B`x we have Z Y pB`xq Ñ pk-APq 2 , i.e., PpZ Y pB`xq Ñ pk-APq 2 q ą δ{2 ą α for x chosen uniformly at random from Z{nZ. Then PpZ n,p P Z 2 | Z n,p PĀq ě δ{2. So, taking µ ă δ¨PpZ n,p PĀq{8 we have that if PpZ n,p P Zq ě 1´µ then Z X Z 1 X Z 2 ‰ ∅. Any Z in this non-empty family has the desired properties.

Lemmas and the proof of the main theorem
In this section we state all the necessary notation and lemmas to give the proof of Theorem 2. We start with an outline of this proof.

Outline of the proof
The point of departure is Corollary 5 and we will derive a contradiction to its second property. To this end, we consider an appropriate set Z as given by Corollary 5 and let Φ denote the set of all colourings of Z without a monochromatic k-AP. The main obstacle is to find a partition of Φ into i 0 " 2 oppnq classes Φ 1 , . . . , Φ i 0 , such that any two colourings ϕ, ϕ 1 from any partition class Φ i agree on a relatively dense subset C i of Z, i.e. ϕpzq " ϕ 1 pzq for all z P C i . Let B i denote the larger monochromatic subset of C i , say of colour blue. We consider the the set F pB i q of those elements in Z{nZ, which extend a blue pk´1q-AP in B i to an k-AP. Note that Corollary 5 allows us to impose further conditions on Z as long as Z n,p satisfies them almost surely. One of these properties will assert that F pB i q is of size linear in n Consequently, by a quantitative version of Szemerédi's theorem we know that the number of k-APs in the focus of B i is Ωpn 2 q. Consider U i " pZ{nZq εp X F pB i q and note that if any element of U i is coloured blue then this induces a blue k-AP with Z under any colouring ϕ P Φ i . Hence, to extend any ϕ P Φ i to a colouring of Z Y U i without a monochromatic k-AP it is necessary that all elements in U i are coloured red. Consequently, the probability of a successful extension of any colouring in Φ i is bounded from above by the probability that U i does not contain a k-AP. This, however, is at most expp´Ωpp k n 2 qq " expp´Ωppnqq by Janson's inequality. We conclude by the union bound that after the second round, i.e. Z n,εp , the probability that any k-AP-free colouring of Z survives is i 0 expp´Ωppnqq " op1q which contradicts (b ).
To establish the above mentioned partition of Φ we will define an auxiliary hypergraph H in such a way that every ϕ P Φ can be associated with a hitting set of H. As the complements of hitting sets are independent and as H will be "well-behaved" we can apply a structural result of Balogh, Morris and Samotij [1] on independent sets in uniform hypergraphs (see Theorem 15) to "capture" the hitting sets of H and hence a partition of Φ with the properties mentioned above (see Lemma 8). We remark, that the proof of showing that H is indeed well-behaved will use (a ) and additional properties of Z, which hold a.a.s. in Z n,p . Next we will introduce the necessary concepts along with the lemmas needed to give the proof of the main theorem. The proof of Theorem 2 will then be given in Section 3.3.

Lemmas
We call pZ, Bq an interacting pair if Z Û pk-APq 2 and B Û pk-APq 2 but Z Y B Ñ pk-APq 2 . Further, pZ, B, Xq is called an interacting triple if pZ, B`xq is interacting for all x P X. Note that Corollary 5 asserts that there is an interacting triple pZ, B, Xq with |X| ą αn. In the following we shall concentrate on elements which are decisive for interactions. Given a (not necessarily interacting) pair pA, Bq we say that an element a P A focuses The set of vertices of particular interest, given a pair pA, Bq, is M pA, Bq " ta P A : there is a b P B such that a focuses on bu and for a triple pA, B, Xq we define the hypergraph H " HpA, B, Xq with the vertex set A and the edge set consisting of all M pA, B`xq with x P X. We are interested in the hypergraph HpZ, B, Xq with an interacting triple pZ, B, Xq. We will make use of the fact that Corollary 5 allows us to put further restrictions on Z as long these events occur a.a.s. for Z n,p . The requirement we want to make is that the maximum degree and co-degree of HpZ, B, Xq are well behaved.

Lemma 6.
For given c 1 , k, K and all B Ă Z{nZ of size |B| ď K the following holds a.a.s. for 2 log n ď p ď c 1 n´1 {pk´1q : There is a set Y Ă Z{nZ of size at most n 1´1{pk´1q log n such that the hypergraph H " HpZ n,p , B, pZ{nZq Y q satisfies ∆ 1 pHq ď 10k 3 Kp k´2 n, and where ∆ 1 pHq and ∆ 2 pHq denote the maximum vertex degree of H and maximum co-degree of pairs of vertices of H.
We postpone the proof of Lemma 6. It can be found in Section 4. A set of vertices of a hypergraph is called a hitting set if it intersects every edge of this hypergraph. The conditions in Lemma 6 will be used to control the hitting sets of HpZ, B, Xq which play an important rôle as explained in the following. A colouring of a set is called k-AP free if it does not exhibit a monochromatic k-AP. For an interacting triple pZ, B, Xq we fix a k-AP free colouring σ : B Ñ tred,blueu of B, which exists since B Û pk-APq 2 . We also consider the "same" colouring for all its translates B`x. More precisely, let B " tb 1 , . . . , b |B| u and for every x P X we consider the k-AP free colouring σ x : pB`xq Ñ tred,blueu defined by σ x pb i`x q " σpb i q.
For any k-AP-free colouring ϕ of Z and any x P X the colouring of Z Y pB`xq induced by σ x and ϕ must exhibit a monochromatic k-AP (intersecting both Z and B`x) since pZ, B`xq is interacting. Hence, for each x P X the edge M pZ, B`xq contains an element z focussing on an element b P B`x such that ϕpzq " σ x pbq. Such a vertex z P M pZ, B`xq we call activated by σ x and ϕ and we define the set of activated vertices A σx ϕ pZ, B`xq " tz P Z : z is activated by σ x and ϕu which is a non-empty subset of M pZ, B`xq.
Observation 7. Suppose that we are given an interacting triple pZ, B, Xq, a k-AP free colouring σ : B Ñ tred,blueu of B " tb 1 , . . . , b |B| u, and suppose for every x P X the translate B`x is coloured with the same pattern σ x . Further, let ϕ be a k-AP free colouring of Z. Then the set of activated vertices is a hitting set of HpZ, B, Xq.
The following lemma shows that the hitting sets of well-behaved uniform hypergraphs can be "captured" by a small number of sets of large size called cores.

Lemma 8.
For every natural k ě 3, ě 2 and all positive C 0 , C 1 there are C 1 and β ą 0 such that the following holds.
If H is an -uniform hypergraph with m vertices, C 0 m 1`1{pk´2q edges, ∆ 1 pHq ď C 1 m 1{pk´2q , and ∆ 2 pHq ď C 1 log m then there is a family C of subsets of V pHq, which we shall call cores, such that ii ) |C| ě βm for every C P C, and (iii ) every hitting set of H contains some C from C. Lemma 8 will follow from the main result from [1]. The proof can be found in Section 5. As it turns out, we can insist that the interacting triple pZ, B, Xq guaranteed by Corollary 5 has the additional property that X contains a suitable subset X 1 Ă X so that the hypergraph HpZ, B, X 1 q is uniform. In this case Lemma 8 allows us to partition the sets of all k-AP free colourings of Z into a small number of partition classes tΦ C u CPC , each represented by a big core C P C.
However, we wish to refine the partition classes further so that every two colourings ϕ, ϕ 1 P Φ C from the same partition class agree on a large vertex set. This can be accomplished by applying Lemma 8 to HpZ, B, X 1 q for a more refined subset X 1 Ă X. Indeed, we will make sure that there is a set which guarantees that the colours of the activated vertices A ϕ under ϕ as defined in Observation 7 are already "determined" by σ. This implies that any two colourings ϕ, ϕ 1 P Φ C agree on A ϕ X A ϕ 1 , hence, on the core C representing them, i.e. ϕpzq " ϕ 1 pzq for all z P C. To make this formal we need the following definitions.
In the following we fix some linear order on the elements of Z{nZ, which we denote simply by ă. A triple pZ, B, Xq is called regular if for all x P X every element of Z focuses on at most one element in B`x. Given a regular triple pZ, B, Xq and an x P X let z 1 ă¨¨¨ă z denote the elements of M x " M pZ, B`xq P HpZ, B, Xq. We say that z P M pZ, B`xq has index i if z " z i and the triple pZ, B, Xq is called index consistent if for any element z P Z and any two edges M x , M x 1 containing z the indices of z in M x and M x 1 are the same.
Further, let B " tb 1 , . . . , b |B| u. We associate to the edge M x its profile which is the function π : r s Ñ r|B|s indicating which z i focusses on which b j`x , formally: πpiq " j if z i focusses on b j`x . Since pZ, B, Xq is regular, each z P M x focuses on exactly one element from B`x, thus, the profile of M x is well-defined and unique. We call the length of the profile and we say that the triple pZ, B, Xq has profile π with length if all edges of HpZ, B, Xq do. We summarise the desired properties for the hitting sets of HpZ, B, Xq associated to k-AP free colourings of Z. Observation 9. Fix some linear order on Z{nZ. Suppose the triple pZ, B, Xq in Observation 7 with B " tb 1 , . . . , b |B| u is index consistent and has profile π. Let A ϕ " A σ ϕ pZ, B, Xq be the vertex set activated by ϕ and σ as defined in Observation 7. Then for any vertex z P A ϕ the colour ϕpzq of z is already determined by σ and the (unique) index i of z, indeed, ϕpzq " σpb πpiq q. In particular, any two k-AP free colourings ϕ and ϕ 1 of Z agree on A ϕ X A ϕ 1 , i.e. ϕpzq " ϕ 1 pzq for all z P A ϕ X A ϕ 1 .
The following lemma will allow us to restrict considerations to index consistent triples with a bounded length profile. For any linear order on Z{nZ there is a set Y n Ă Z{nZ of size at most n 1´1{pk´1q log n such that for every set X Ă Z{nZ of size X ě αn there is a set X 1 Ă X Y n of size |X 1 | ě α 1 n and a profile π of length at most L such that pZ n,p , B, X 1 q is index consistent and has profile π.
The proof of Lemma 10 can be found in Section 4. Lastly, we put another restriction on Z as to make sure that any relatively dense subset of any core creates many k-AP's for the second round.
Lemma 11. For every c 0 ą 0 and γ ą 0 there is a δ ą 0 such that for p ě c 0 n´1 {pk´1q a.a.s. the following holds. The size of Z n,p is at most 2pn and for every subset S Ă Z n,p of size |S| ą γpn the set F pSq " tz P Z{nZ : there are a 1 , . . . , a k´1 P S which form a k-AP with zu has size at least δn.
The proof of Lemma 11 can be found in Section 6. We are now in the position to prove the main theorem.

Proof of the main theorem
The proof of the main theorem uses the lemmas introduced in the previous section and follows the scheme described.
Proof of Theorem 2. For a given k ě 3 assume for contradiction that Z n,p Ñ pk-APq does not have a sharp threshold. By Corollary 5 there exist constants c 0 , c 1 , α, ε, µ ą 0 and K and a function ppnq " cpnqn´1 {pk´1q for some functin cpnq satisfying c 0 ď cpnq ď c 1 such that for infinitely many n there exists a subset B Ă Z{nZ of size at most K with B Û pk-APq 2 .
For each n we define Z n to be the sets of subsets Z Ă Z{nZ which satisfy the conclusions of Lemma 6, Lemma 10 and Lemma 11 (with Z n,p replaced by Z) with the constants given and chosen from above. As these lemmas assert properties of Z n,p that hold a.a.s. we know that for sufficiently large n we have PpZ n,p P Z n q ą 1´µ. Hence, by Corollary 5 there is an interacting triple pZ, B, Xq such that |B| ď K, |X| ě αn and Z P Z n . In particular, since Z satisfies the conclusion of Lemma 6 and Lemma 10 there exists a set Y n of size at most 2n 1´1{pk´1q log n and a profile π of length 1 ď ď L and a set X 1 Ă X Y n such that • the (interacting) triple pZ, B, X 1 q is index consistent and has profile π, • the hypergraph H " HpZ, B, X 1 q satisfies 2pn ě vpHq " |Z| ě pn{2, the maximum degree of H satisfies ∆ 1 pHq ď 10k 3 Kp k´2 n and ∆ 2 pHq ď 8 log n.
As pZ, B, X 1 q is regular we have ě k´1 ě 2 by definition. Further, H is an -uniform hypergraph on m " |Z| vertices which satisfies the assumptions of Lemma 8 with the constants chosen above. Hence, by the conclusions of Lemma 8 we obtain a family C of cores, such that ii ) |C| ě βm for every C P C, and (iii ) every hitting set of H contains some C from C.
Let Φ be the set of all k-AP free colourings of Z. By Observation 7 and Observation 9 we can associate to each ϕ P Φ a hitting set A ϕ of H such that any two colourings ϕ, ϕ 1 P Φ agree on A ϕ X A ϕ 1 , i.e. ϕpzq " ϕ 1 pzq for all z P A ϕ X A ϕ 1 . For any C P C we define Φ C to be the set of ϕ P Φ such that C Ă A ϕ and obtain Φ " Ť CPC Φ C . Clearly, for any C P C, any two ϕ, ϕ 1 P Φ C agree on C Ă A ϕ X A ϕ 1 . Let B C Ă C be the larger monochromatic subset of C under (any) ϕ P Φ C , say of colour blue. Then B C has size |B C | ě |C|{2 ě γpn and as Z P Z n we know by Lemma 11 that |F pB C q Z| ą δn{2. Let PpCq denote the set of all k-APs contained in F pB C q. By the quantitative version of Szemerédi's theorem (see [14]) we know that there is an η ą 0 such that for sufficiently large n we have |PpCq| ě ηn 2 . Consider the second round exposure U C " Z n,εp X F pB C q and let t i be the indicator random variable for the event i P U C . We are interested in the probability that there is a ϕ P Φ C which can be extended to a k-AP free colouring of Z Y U C . To extend any colouring ϕ P Φ C of Z to a k-AP free colouring of Z Y U C , however, it is necessary that U C Ă F pB C q is completely coloured red, i.e. that U C does not contain any k-AP. This probability can be bounded using Janson's inequality for X " ř P PPpCq ś iPP t i given by for large enough n. We obtain P pDϕ P Φ C : ϕ can be extended to a k-AP free colouring of Z Y U C q ď P pU C does not contain a k-APq ă expt´η 2 pn{4u.
Taking the union bound we conclude P ppZ Y Z n,εp q Û pk-APq 2 q ď |C| expt´η 2 pn{4u which goes to zero as n goes to infinity. This, however, contradicts property (b ) of Corollary 5.

Proofs of the Lemmas 6 and 10
In this section we prove the lemmas introduced in the previous section. We start with some technical observations. Given B Ă Z{nZ and an element z P pZ{nZq B let Ppz, Bq " P Ă Z{nZ : There is a b P B such that P Y tz, bu forms a k-AP ( and let Ppz, z 1 , Bq " Ppz, BqˆPpz 1 , Bq where z and z 1 need not be distinct. Further, let Ppz, B, Z{nZq " Ť xPZ{nZ Ppz, B`xq and in the same manner define Ppz, z 1 , B, Z{nZq. Fact 12. Let z, z 1 P Z{nZ and a P Z{nZ be given. Then (1 ) the number of P P Ppz, B, Z{nZq such that a P P is at most k 3 |B|.
(2 ) the number of pairs pP, P 1 q P Ppz, z 1 , B, Z{nZq such that a P P Y P 1 is at most 2k 5 |B| 2 .
Proof. We only prove the second property. For that we count the number of pairs pP, P 1 q P Ppz, z 1 , B, Z{nZq such that a is in, say, P . Recall that there must exist x P Z{nZ and b, b 1 P B`x such that P Y tz, bu and P 1 Y tz 1 , b 1 u are both k-APs. Choosing the positions of z and a uniquely determines the first k-AP. There are at most pk´2q choices for b to be contained in the k-AP and at most |B| choices of x such that b P B`x. Each such choice determines P and moreover, gives rise to at most |B| choices for b 1 . Choosing the positions of b 1 and z 1 then determines the second k-AP, hence also P 1 .
We define P 0 pz, Bq " P P Ppz, Bq : P and B are disjoint ( and P 0 pz, z 1 , Bq " pP, P 1 q P Ppz, z 1 , Bq : P Y tzu, P 1 Y tz 1 u and B are pairwise disjoint ( .
For given sets A, B Ă Z{nZ we call x P Z{nZ bad (with respect to A and B) if (1 ) there are z P A B`x and P P P 1 pz, B`xq such that P Y tzu Ă A Y B`x or (2 ) there are z, z 1 P A B`x and pP, P 1 q P P 1 pz, Proof. We will show that the expected size of Y n is of order pn so that the statement follows from Markov's inequality. For a fixed x we first deal with the case that x is bad due to the first property, i.e. there is a k-AP P Y tz, bu with b P B`x, P intersecting B`x and z P Z n,p which does not belong to B`x. Note that after choosing b, one common element of P and B`x and their positions the k-AP is uniquely determined. Then there are at most pk´2q choices for z each of which uniquely determines one P . Hence the probability that x is bad due to the first property is at most |B|k 3 p and summing over all x we conclude that the expected number of bad elements due to the first property is at most |B|k 3 pn.
If x is bad due to the second property then there are two k-APs P Ytz, bu and P 1 Ytz 1 , b 1 u such that two of the three sets P Y tzu, We distinguish two cases and first consider all tuples pP, P 1 , z, z 1 , b, b 1 q with the above mentioned properties such that P (or P 1 respectively) does not intersect B`x. Note that with this additional property the probability that x is bad due to pP, P 1 , z, z 1 , b, b 1 q is at most p k since z, z 1 and P all need to be in Z n,p . First, we count the number of such tuples with the additional property that P 1 (or P respectively) also has empty intersection with B`x. This implies that P and P 1 must intersect and in this case, choosing b, b 1 P B`x and one common element a P P X P 1 and the positions of b, b 1 , a in the k-AP's uniquely determines both k-APs. After these choices there are at most k 2 choices for z, z 1 . Hence, there are at most |B| 2 k 5 n such tuples for a fixed x.
Next, we count the number of tuples pP, P 1 , z, z 1 , b, b 1 q with the property that P 1 and B`x intersect. In this case choosing b 1 P B`x and one element in P 1 X B`x and their positions in the k-AP uniquely determines the second k-AP. Choosing b P B`x, another element a P Z{nZ, and their positions determines the first k-AP. After these choices there are at most k 2 choices for z, z 1 hence in total there are at most |B| 3 k 6 n such tuples for a fixed x. We conclude that the expected number of bad x due to tuples pP, P 1 , z, z 1 , b, b 1 q such that P (or P 1 respectively) does not intersect B`x is at most p k 2np|B| 2 k 5 n`|B| 3 k 6 nq.
It is left to consider the tuples pP, P 1 , z, z 1 , b, b 1 q such that pP, P 1 q P P 1 pz, z 1 , B`xq and P and P 1 both intersect B`x. In this case choosing b, b 1 , the element(s) in P X B`x and P 1 X B`x and their positions uniquely determine the two k-APs. Since z, z 1 P Z n,p with probability p 2 the expected number of bad x due to tuples pP, P 1 , z, z 1 , b, b 1 q with the above mentioned property is at most |B| 4 k 6 p 2 n.

Fact 14.
Let ě 1 be an integer and let F be an -uniform hypergraph on the vertex set Z{nZ which has maximum vertex degree at most D. Let U " Z n,p with p " cn´1 {pk´1q . Then with probability at most 2Dn´4 we have epF rU sq ą 5Dpp n{ `log nq.
Proof. For " 1 the bound directly follows from Chernoff's bound P p|X´E pXq | ą tq ď 2 exp for a binomial distributed random variable X. For ą 1 we split the edges of F into i 0 ď D matchings M 1 , . . . , M i 0 , each of size at most n{ . For an edge e P EpF q let t e denote the random variable indicating that e P EpF rU sq. Then P pt e " 1q " p and we set s " 4 maxtp n{ , log nu. By Chernoff's bound we have This finishes the proof since epF rU sq " ř iPri 0 s ř ePM i t e which exceeds Ds with probability at most 2Dn´4.

Proof of Lemma 6 and Lemma 10
Based on the preparation from above we give the proof of Lemma 6 and Lemma 10 in this section.
Proof of Lemma 6. Let t i be the indicator random variable for the event i P Z n,p . Consequently, vpHq " ř iPZ{nZ t i is binomially distributed and the first property directly follows from Chernoff's bound (4).
For the second and third properties we first consider all elements from Z{nZ which are bad with respect to Z n,p and B. By Fact 13 we know that a.a.s. the set Y n of bad elements has size at most n 1´1{pk´1q log n and in the following we will condition on this event.
We consider the degree and co-degree in the hypergraph HpZ n,p , B, pZ{nZq Y n q. Let z, z 1 P Z{nZ be given. If z is contained in an edge M x " M pZ n,p , B`xq then there is an element P P Ppz, B`xq such that P Ă Z n,p Y B`x. It is sufficient to focus on those P P P 0 pz, B`xq since after removing Y n those P P P 1 pz, B`xq will have no contribution. Hence we can assume P Ă Z n,p or equivalently ś iPP t i " 1. Further, there are at most three different values of y such that P is contained in P 0 pz, B`yq. Hence, letting P 0 pz, B, Z{nZq " Ť xPZ{nZ P 0 pz, B`xq we can bound the degree of z by Similarly, if z, z 1 are contained in an edge M x then there is a pair pP, P 1 q P P 0 pz, z 1 , B`xq such that P Y P 1 Ă Z n,p Y B`x, i.e. ś iPP YP 1 t i " 1. We obtain codegpz 1 , z 2 q ď 9 ÿ pP,P 1 qPP 0 pz,z 1 ,B,Z{nZq We consider P 0 pz, B, Z{nZq (respectively, P 0 pz, z 1 , B, Z{nZq) as a pk´2q-uniform (resp., p2k´4q-uniform) hypergraph on the vertex set Z{nZ. By Fact 12 we know that the maximum degree of the hypergraph is at most k 3 K (resp. 5k 5 K 2 ). By Fact 14 the probability that degpzq ą 10k 3 Kp k´2 n or codegpz, z 1 q ą 8 log n is at most 2k 3 Kn´4. Taking the union bound over all elements and all pairs of Z{nZ we obtain the desired property.
Proof of Lemma 10. For given k, c, K and α set L " 20c k´1 k 2 {α and α 1 " α{2pLKq L and let some linear order on Z{nZ be given. First we choose Y n so as to guarantee regularity of the triple pZ n,p , B, pZ{nZq Y n q. Note that there are two sources of irregularity: k-APs containing two elements from B`x for some x P Z{nZ and pairs of k-APs with one common element in Z n,p and each containing one element in B`x for some x P Z{nZ. These are ruled out by removing all x which are bad with respect to Z n,p and B. By Fact 13 a.a.s. the set Y n of bad elements has size at most n 1´1{pk´1q log n.
Further, we count the number of pk´1q-element sets in Z n,p which arise from k-APs with one element removed. The expected number of such sets is at most p k´1 kn 2 and the variance is of order at most p k´2 n 2 . Hence, by Chebyshev's inequality the number of such sets in Z n,p is at most 2c k´1 kn asymptotically almost surely.
Consider any set A Ă Z{nZ which posseses the two properties mentioned above: there is a set Y n of size at most n 1´1{pk´1q log n such that pA, B, pZ{nZq Y n q is regular and the number of pk´1q-element sets in A which arise from k-APs with one element removed is at most 2c k´1 kn. Let X Ă Z{nZ of size |X| ě αn be given. For every x P X Y n let x denote the size of M x " M pA, B, Xq. Then there are at least x {pk´1q sets of size pk´1q contained in M x each forming a k-AP with an element in B`x. Further, each such set is contained in B`x 1 for at most three x 1 P Z{nZ, hence, ř xPX Yn x {pk´1q ď 6c k´1 kn and we conclude that the number of x P X Y n such that x ą 20c k´1 k 2 {α " L is at most αn{3. Moreover, there are at most |B| distinct profiles of length , hence there is a profile π of length ď L and a set U Ă X Y n of size |U | ě αn{2K L such that pA, B, U q has profile π.
To obtain a set X 1 Ă U such that pA, B, X 1 q is index consistent we consider a random partition of A into classes pV 1 , . . . , V q. We say that an edge M x P HpA, B, U q with the elements z 1 ă¨¨¨ă z survives if z i P V i for all i P r s. The probability of survival is , hence there is a partition such that at least |U |{ edges survives. Choosing the corresponding set X 1 Ă U yields a set with the desired properties.

Proof of Lemma 8
In this section we prove Lemma 8. The proof relies crucially on a structural theorem of Balogh, Morris and Samotij [1] which we state in the following. Let H be a uniform hypergraph with vertex set V and let F be an increasing family of subsets of V and ε P p0, 1s. The hypergraph H is called pF, εq-dense if for every A P F epHrAsq ě εepHq.
Further, let IpHq denote the set of all independent sets of H. The so-called container theorem by Balogh, Morris and Samotij [1, Theorem 2.2] reads as follows.
Theorem 15 (Container theorem). For every P N and all positive c and ε, there exists a positive constant c 1 such that the following holds. Let H be an -uniform hypergraph and let F be an increasing family of subsets of V such that |A| ě εvpHq for all A P F. Suppose that H is pF, εq-dense and p P p0, 1q is such that for every t P r s the maximum t-degree ∆ t pHq of H satisfies Then there is a family S Ď`V pHq ďc 1 pvpHq˘a nd functions f : S Ñ F and g : IpHq Ñ S such that for every I P IpHq, gpIq Ď I and I gpIq Ď f pgpIqq.
Theorem 15 roughly says that if an uniform hypergraph H satisfies certain conditions then the set of independent sets IpHq of H can be "captured" by a family S consisting of small sets. Indeed, every independent set I P IpHq contains a (small) set gpIq P S and the remaining elements of I must come from a set determined by gpIq.
We are now in a position to derive Lemma 8 from Theorem 15.
We define p " m´1 {pk´2qp ´1q so that ∆ t pHq ď cp t´1 epHq vpHq for all t P r s. In fact, for t " 1 this follows directly from the bound ∆ 1 pHq ď C 1 m 1 k´2 given by the assumption of Lemma 8. For t " 2, . . . , ´1 we use ∆ t pHq ď ∆ 2 pHq and on ∆ 2 pHq given by the assumption of Lemma 8. Finally, for t " we note that ∆ pHq " 1 and the desired bound follows again from the choices of p and c.
Thus there exist a family S and functions f : S Ñ F and g : IpHq Ñ S with the properties described in Theorem 15. We define A " tS Y f pSq : S P Impgqu, where Impgq is the image of g. Our cores will be the complements of the elements of A, C " tV pHq A : A P Au.
Since |C| " |A| ď |S|, we infer (i ) of Lemma 8. Further, every A P A has size at most p1´2βqm`C 1 pm ď p1´βqm which yields the property (ii ) of Lemma 8.
Finally, by the properties of the functions f and g, every independent set I is contained in A " gpIq Y f pgpIqq, so, by taking complements, every hitting set contains an element of C which completes the property (iii ) of Lemma 8.

Proof of Lemma 11
In this section we prove Lemma 11 which relies on the following result by the last author [12] (see also [1,2,11]).
Theorem 16. For every integer k ě 3 and every γ P p0, 1q there exists C and ξ ą 0 such that for every sequence p " p n ě Cn´1 {pk´1q the following holds a.a.s. Every subset of Z n,p of size at least γpn contains at least ξp k n 2 arithmetic progression of length k.
With this result at hand we now prove Lemma 11.
Proof of Lemma 11. The upper bound on the size of Z n,p follows from Chernoff's bound (4). For the second property let k ě 3 and γ be given. For k ě 4 we apply Theorem 16 with k´1 and γ to obtain C and ξ. We may assume that ξ ď γ 2 {4 and we note that in the case k ě 4 we have p ě c 0 n´1 {pk´1q ą Cn´1 {pk´2q for sufficiently large n. We choose δ " ξ 2 {20.
Let S Ă Z n,p be a set of size at least γpn. For a given i P Z{nZ let degpiq denote the number of pk´1q-APs in S which form a k-AP with i. Note that i P F pSq if degpiq ‰ 0. Then a.a.s we have ÿ iPZ{nZ degpiq ě ξp k´1 n 2 which holds trivially for the case k " 3 due to ξ ď γ 2 {4 and which is a consequence of Theorem 16 for larger k. and we conclude that |F pSq| ě ξ 2 n{20 " δn.