Anti-van der Waerden numbers of 3-term arithmetic progressions

The \emph{anti-van der Waerden number}, denoted by $aw([n],k)$, is the smallest $r$ such that every exact $r$-coloring of $[n]$ contains a rainbow $k$-term arithmetic progression. Butler et. al. showed that $\lceil \log_3 n \rceil + 2 \le aw([n],3) \le \lceil \log_2 n \rceil + 1$, and conjectured that there exists a constant $C$ such that $aw([n],3) \le \lceil \log_3 n \rceil + C$. In this paper, we show this conjecture is true by determining $aw([n],3)$ for all $n$. We prove that for $7\cdot 3^{m-2}+1 \leq n \leq 21 \cdot 3^{m-2}$, \[ aw([n],3)=\left\{\begin{array}{ll} m+2,&\mbox{if $n=3^m$}\\ m+3,&\mbox{otherwise}. \end{array}\right.\]

In this paper, we determine the exact value of aw ([n], 3), which answers questions posed in [4] and confirms the following conjecture: Conjecture 1. [4] There exists a constant C such that aw([n], 3) ≤ log 3 n + C, for all n ≥ 3.
Our main result, Theorem 2, also determines aw u ([n], 3) which shows the existence of extremal colorings of [n] that are unitary. In section 2, we provide lemmas that are useful in proving Theorem 2 and section 3 contains the proof of Theorem 2.

Lemmas
In [4,Theorem 1.6] it is shown that 3 ≤ aw(Z p , 3) ≤ 4 for every prime number p and that if aw(Z p , 3) = 4 then p ≥ 17. Furthermore, it is shown that the value of aw(Z n , 3) is determined by the values of aw(Z p , 3) for the prime factors p of n. We have included this theorem below with some notation change. 2e j , if n is even.
We use Theorem 3 to prove the following lemma.
Case 2. Suppose n is even, that is e 0 ≥ 1. Then aw(Z n , 3) = 3 + j=1 e j + s j= +1 2e j by Theorem 3. If n = 2 e 0 · 3 j for j ≥ 1, then by direct computation aw(Z n , 3) = 3 + j ≤ 2 + log 3 n , with equality if and only if e 0 = 1. So suppose there is i such that p i = 3, and let h = n If i ≤ then p i ≥ 5, and so 3 · 3 e i < 2 e 0 p e i i for all e 0 ≥ 1 and e i ≥ 1. Therefore, since h is odd, by the previous case 3 aw(Zn,3) = 3 · 3 e i · 3 aw(Z h ,3) ≤ 3 · 3 e i · 9h < 2 e 0 p e i i · 9h = 9n. If i ≥ + 1 then p i ≥ 17, and so 3 · 9 e i < 2 e 0 p e i i for all e 0 ≥ 1 and e i ≥ 1. Then by the previous case 3 aw(Zn,3) = 3 · 9 e i · 3 aw(Z h ,3) ≤ 3 · 9 e i · 9h < 2 e 0 p e i i · 9h = 9n. and c(N ) must be used in the subinterval I 2 . To see this, assume i is the missing color in I 2 distinct from c(1) and c(N ). Let x be the largest integer in c i (I 1 ). Since N is even, we have 2x − 1 ≤ 2 N/4 − 1 ≤ N/2, and so 2x − 1 ∈ I 2 and c(2x − 1) = i. Therefore the 3-AP {1, x, 2x − 1} is a rainbow. If there is no such integer x in I 1 , then the integers colored with i must be in the second half of the interval [N ], so we choose the smallest such integer y in Similarly, every color other than c(1) and c(N ) must be used in the subinterval I 3 .
Throughout the proof we mostly drop (mod 3) and just say congruent even though we mean congruent modulo 3. We consider the following three cases.
Case 1: N ≡ 0 (mod 3). Assume |{c(x) : x ≡ i (mod 3) and x ∈ [N ]}| < r−1 for both i = 1 and i = N . So there are two colors, say red and blue, such that no integer in [N ] colored with red is congruent to 1, and no integer in [N ] colored with blue is congruent to 0. We further partition the interval I 2 into subintervals I 2(i) and I 2(ii) so that (I 2(i) ) ≤ (I 2(ii) ) ≤ (I 2(i) ) + 1, and partition the interval I 3 into subintervals I 3(i) and I 3(ii) so that (I 3(ii) ) ≤ (I 3(i) ) ≤ (I 3(ii) ) + 1. Then we have the following observations: (i) x ≡ 0 for all x ∈ c red (I 3 ∪ I 4 ) and y ≡ 1 for all y ∈ c blue (I 1 ∪ I 2 ). If there is an integer r in I 3 ∪ I 4 colored with red and congruent to 2, then 2r − N ≡ 1, and so c(2r −N ) is not red by our assumption. Therefore the 3-AP {2r −N, r, N } is rainbow. Similarly, if there is an integer b in I 1 ∪ I 2 colored with blue and congruent to 2, then 2b − 1 ≡ 0, and so (ii) x ≡ 2 for all x ∈ c red (I 2 ) and y ≡ 2 for all y ∈ c blue (I 3 ). If there is an integer r in c red (I 2 ) congruent to 0, then 2r − 1 ≡ 2 and 2r − 1 ∈ I 3 ∪ I 4 since 2r − 1 ≥ N/2 + 1. Therefore, 2r − 1 is not colored with red by the previous observation, and so the 3-AP {1, r, 2r − 1} is a rainbow. Similarly, if there is an integer b in c blue (I 3 ) congruent to 1, then using N we obtain the rainbow 3-AP {2b−N, b, N }, because 2b−N ≡ 2 and 2b−N ≤ N/2.
(iv) c red (I 2(ii) ) = c blue (I 3(i) ) = ∅. Suppose there is an integer r in I 2(ii) colored with red. Since the coloring of I 2 contains both red and blue and there is no integer in I 2(i) colored with blue, by (iii), there must be an integer b in I 2(ii) colored with blue. By (i) and (ii), b ≡ 1 and r ≡ 2. Wlog, suppose b > r. Then 2r − b ≡ 0 and 2r − b ∈ I 2 since (I 2(ii) ) ≤ (I 2(i) ) + 1. So 2r − b is not colored red or blue and hence the 3-AP {2r − b, r, b} is rainbow. Therefore, there is no integer in I 2(ii) that is colored with red. Similarly, there is no integer in I 3(i) that is colored with blue.
Recall that every color other than c(1) and c(N ) is used in both intervals I 2 and I 3 . Therefore, sets c red (I 2(i) ), c blue (I 2(ii) ), c red (I 3(i) ), and c blue (I 3(ii) ) are nonempty. Using above observations we next show that in fact these integers colored with blue and red in each subinterval are unique. Let B = {b 1 , . . . , b 2 } be the shortest interval in I 2(ii) which contains all integers colored with blue and let R = {r 1 , . . . , r 2 } be the shortest interval in I 3(i) which contains all integers colored with red. Choose the largest integer x in c red (I 2(i) ) and consider two 3-APs {x, b 1 , 2b 1 − x} and {x, b 2 , 2b 2 − x}. Since x is congruent to 2 and both b 1 and b 2 are congruent to 1, we have that both 2b 1 − x and 2b 2 − x are congruent to 0 and are contained in I 3 , otherwise the 3-APs are rainbow. Since all integers colored with blue in I 3 are congruent to 2 by (ii), we have that 2b 1 −x and 2b 2 − x are both colored with red and so contained in R. Therefore, 2 (B) − 1 ≤ (R). Now using the smallest integer in c blue (I 3(ii) ), we similarly have that 2 (R) − 1 ≤ (B). Since (B) ≥ 1 and (R) ≥ 1, we have that (R) = (B) = 1, i.e. there are unique integers b in c blue (I 2(ii) ) and r in c red (I 3(i) ). Now for any integerr from c red (I 2(i) ) the integer 2r − 1 must be colored with red, otherwise the 3-AP {1,r, 2r − 1} is rainbow. Since 2r − 1 ∈ I 3 , it must be equal to the unique red colored integer r of I 3 . Therefore, there is exactly one suchr in I 2(i) , i.e. c red (I 2(i) ) = {r}. Similarly, using N there is a unique integerb in I 3(ii) colored with blue. Since {1,r, r}, {r, b, r}, {b, r,b}, and {b,b, N } are all 3-APs, N = 7( ({b, . . . , r}) − 1) + 1 = 7(r − b) + 1.
Observe that ifr is even, the integer (r + N )/2 in 3-AP {r, (r + N )/2, N } must be red and congruent to 1 sincer ≡ 2 by (ii), contradicting our assumption. Sor is odd, and hence the integer r = (r + 1)/2 in I 1 must be colored with red. Notice that there cannot be another integer x larger than r in c red (I 1 ), otherwise 2x − 1 will be another integer colored with red in I 2 distinct fromr. Now, since ({r , . . . ,r}) = ({b, . . . , r}) we have that {r , r, N } is a 3-AP, and so r must be even. Suppose there are integers smaller than r in c red (I 1 ), and let z be the largest of them. Then 2z − 1 is also in c red (I 1 ) and must be equal to or larger than r in I 1 . However, that is impossible because r is even and there is no integer in c red (I 1 ) larger than r . So r is a unique integer in I 1 colored with red. Similarly, there is a unique integer b in I 4 colored with blue. Therefore the 8-AP can be formed using integers 1, r ,r, b, r,b, b , N since In order for this coloring to be special, it remains to show that c blue (I 1 ) = c red (I 4 ) = ∅. If c blue (I 1 ) = ∅, then choose the largest integer y in it and consider the 3-AP {1, y, 2y − 1}. Since 2y − 1 must be in c blue (I 2 ) and the only integer in this set is b, we have 2y − 1 = b. However, we know that b is even because b = 2b − N , a contradiction. Similarly, if c red (I 4 ) = ∅ choose the smallest integer x in it and consider the 3-AP {2x − N, x, N }. Since 2x − N must be in c red (I 3 ) and the only integer in this set is r, we have 2x−N = r. However, we know that r is odd because r = 2r − 1, a contradiction. This implies that c red ([N ]) = {r ,r, r} and c blue ([N ]) = {b,b, b }, so the coloring is special.
Case 2: N ≡ 2 (mod 3). This case is analogous to Case 1. Case 3: N ≡ 1 (mod 3). Assume |{c(x) : x ≡ i (mod 3) and x ∈ [N ]}| < r − 1 i.e. there are two colors, say red and blue, such that no integer in [N ] colored with red or blue is congruent to 1. Recall that every color other than c(1) and c(N ) appears in I 2 and I 3 . First, notice that all integers colored with red or blue in I 2 must be congruent modulo 3. Otherwise, choosing a red colored integer and a blue colored integer, we obtain a 3-AP whose third term is colored with red or blue and is congruent to 1 contradicting our assumption. Similarly, this is also the case for I 3 . So suppose all integers in c red (I 2 ) ∪ c blue (I 2 ) and c red (I 3 ) ∪ c blue (I 3 ) are congruent modulo 3 to integers p ≡ 1 and q ≡ 1, respectively. Pick the largest integers from c red (I 2 ) and c blue (I 2 ) and form a 3-AP whose third term is in I 3 . Then the third term is colored with red or blue and is congruent to p. Therefore, p ≡ q ≡ 1.
We further partition the interval I 2 into subintervals I 2(i) and I 2(ii) , so that (I 2(i) ) ≤ (I 2(ii) ) ≤ (I 2(i) ) + 1. If there exists x ∈ c red (I 2(i) ) ∪ c blue (I 2(i) ), the integer 2x − 1 must be colored with c(x) and contained in I 3 , so 2x − 1 ≡ p while x ≡ p ≡ 1, a contradiction. So c red (I 2(i) ) ∪ c blue (I 2(i) ) = ∅. However, then the smallest integers of c red (I 2(ii) ) and c blue (I 2(ii) ) form a 3-AP whose first term is contained in I 2(i) and is colored with red or blue, a contradiction. This completes the proof of the lemma. Case 1. First suppose 7 · 3 m−2 + 1 ≤ n ≤ 3 m − 3 or 3 m ≤ n ≤ 21 · 3 m−2 . By the induction hypothesis and using the coloring c 1 , Case 2. Suppose n = 3 m − t where t ∈ {1, 2}. Notice that h = 3 m−1 , so by induction and using coloring c 2 , The upper bound, aw([n], 3) ≤ f (n), is also proved by induction on n. For small n, the result follows from Table 1. Assume the statement is true for all value less than n, and let 7 · 3 m−2 + 1 ≤ n ≤ 21 · 3 m−2 for some m. Let aw([n]) = r + 1, so there is an exact r-colorinĝ c of [n] with no rainbow 3-AP. We need to show that r ≤ f (n) − 1. Let [n 1 , n 2 , . . . , n N ] be the shortest interval in [n] containing all r colors underĉ. Define c to be an r-coloring of [N ] so that c(j) =ĉ(n j ) for j ∈ {1, . . . , N }. By minimality of N the colors of 1 and N are unique. If [N ] has at least r − 1 colors congruent to 1 or N , then [n] has at least r − 1 colors congruent to n 1 or n N , respectively, so r ≤ aw( n/3 ) and by induction r ≤ f ( n/3 ) ≤ f (n) − 1. So suppose that is not the case, then by Lemma 5 we have that the coloring c is special.
Let N = 7q+1 for some q ≥ 1, and let the 8-AP in this special coloring be {1, r 1 , r 2 , b 1 , r 3 , b 2 , b 3 , N }, where r 1 , r 2 , r 3 are the only integers colored red, b 1 , b 2 , b 3 are the only integers colored blue and q = r 1 −1. If n ≥ 9q, then the 8-AP can be extended to a 9-AP in n by adding the 9th element to either the beginning or the ending. Wlog, suppose {1, r 1 , r 2 , b 1 , r 3 , b 2 , b 3 , N, 2N − b 3 } correspond to a 9-AP in [n]. Since the coloring has no rainbow 3-AP, the color of 2N − b 3 is blue or c(N ), so we have a 4-coloring of this 9-AP. However, aw([9], 3) = 4 and hence there is a rainbow 3-AP in this 9-AP which is in turn a rainbow 3-AP in [n]. Therefore, n ≤ 9q − 1.