{'fraction_non_alphanumeric': 0.06188397495407589, 'fraction_numerical': 0.015564817192407213, 'mean_word_length': 3.7712750918857787, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 31, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The Green-Tao theorem: an exposition

The celebrated Green-Tao theorem states that the prime numbers contain arbitrarily long arithmetic progressions. We give an exposition of the proof, incorporating several simplifications that have been discovered since the original paper.


Introduction
In 2004, Ben Green and Terence Tao [19] proved the following celebrated theorem, resolving a folklore conjecture about prime numbers. Theorem 1.1 (Green-Tao). The prime numbers contain arbitrarily long arithmetic progressions.
Our intention is to give a complete proof of this theorem. Although there have been numerous other expositions [17,18,24,25,36,38,40], we were prompted to write this note because of our recent work [5,44] simplifying one of the key technical ingredients in the proof. Together with work of Gowers [17], Reingold, Trevisan, Tulisiani, and Vadhan [28], and Tao [35], there have now been substantial simplifications to almost every aspect of the proof. We have chosen to collect these simplifications and present an up-to-date exposition in order to make the proof more accessible.
A key element in the proof of Theorem 1.1 is Szemerédi's theorem on arithmetic progressions in dense subsets of the integers. To state this theorem, we define the upper density of a set A ⊆ N to be lim sup Szemerédi's theorem is a deep and important result and the original proof is long and complex. It has had a huge impact on the subsequent development of combinatorics and, in particular, was responsible for the introduction of the regularity lemma, now a cornerstone of modern combinatorics. Numerous different proofs of Szemerédi's theorem have since been discovered and all of them have introduced important new ideas that grew into active areas of research. The three main modern approaches to Szemerédi's theorem are by ergodic theory [10,11], higher order Fourier analysis [13,14], and hypergraph regularity [16,26,29,30,39]. However, none of these approaches are easy. We shall therefore assume Szemerédi's theorem as a black box and explain how to derive the Green-Tao theorem using it.
As the set of primes has density zero, Szemerédi's theorem does not immediately imply the Green-Tao theorem. Nevertheless, Erdős famously conjectured that the density of the primes alone should guarantee the existence of long APs. 1 Specifically, he conjectured that any subset A of N The first author was supported by a Royal Society University Research Fellowship. The second author was supported by a Packard Fellowship, NSF grant DMS-1069197, an Alfred P. Sloan Fellowship, and an MIT NEC Corporation Award.
The third author was supported by a Microsoft Research PhD Fellowship. 1 For brevity, we will usually write AP for arithmetic progression and k-AP for a k-term AP.
with divergent harmonic sum, i.e., a∈A 1/a, must contain arbitrarily long APs. This conjecture is widely believed to be true, but it has yet to be proved even in the case of 3-term APs 2 .
If not by density considerations, how do Green and Tao prove their theorem? The answer is that they treat Szemerédi's theorem as a black box and show, through a transference principle, that a Szemerédi-type statement holds relative to sparse pseudorandom subsets of the integers, where a set is said to be pseudorandom if it resembles a random set of similar density in terms of certain statistics or properties. We refer to such a statement as a relative Szemerédi theorem. Given two sets A and S with A ⊆ S, we define the relative upper density of A in S to be lim sup N →∞ |A ∩ [N ]| / |S ∩ [N ]|.
Relative Szemerédi theorem. (Informally) If S is a (sparse) set of integers satisfying certain pseudorandomness conditions and A is a subset of S with positive relative density, then A contains arbitrarily long APs.
To prove the Green-Tao theorem, it therefore suffices to show that there is a set of "almost primes" containing, but not much larger than, the primes which satisfies the required pseudorandomness conditions. In the work of Green and Tao, there are two such conditions, known as the linear forms condition and the correlation condition.
The proof of the Green-Tao theorem therefore falls into two parts, the first part being the proof of the relative Szemerédi theorem and the second part being the construction of an appropriately pseudorandom superset of the primes. Green and Tao credit the contemporary work of Goldston and Yıldırım [12] for the construction and estimates used in the second half of the proof. Here we will follow a simpler approach discovered by Tao [35].
The proof of the relative Szemerédi theorem also splits into two parts, the dense model theorem and the counting lemma. Roughly speaking, the dense model theorem allows us to say that if S is a sufficiently pseudorandom set then any relatively dense subset A of S may be "approximated" by a dense subset A of N, while the counting lemma shows that the number of arithmetic progressions in A is close, up to a normalization factor, to the number of arithmetic progressions in A. Since A is a dense subset of N, Szemerédi's theorem implies that A contain arbitrarily long APs and this in turn implies that A contains arbitrarily long APs. This is also the outline we will follow in this paper, though for each part we will follow a different approach to the original paper. For the counting lemma, we will follow the recent approach taken by the authors in [5]. This approach has significant advantages over the original method of Green and Tao, not least of which is that a weakening of the linear forms condition is sufficient for the relative Szemerédi theorem to hold. This means that the estimates involved in verifying the correlation condition may now be omitted from the proof.
In [5], the dense model theorem was replaced with a certain sparse regularity lemma. However, as subsequently observed by Zhao [44], the original dense model theorem may also be used. To prove the dense model theorem, we will follow an elegant method developed independently by Gowers [17] and by Reingold, Trevisan, Tulsiani, and Vadhan [28].
The 3-AP case of Szemerédi's theorem was first proved by Roth [31] in the 1950s. While Roth's theorem, as this case is usually known, is already a very interesting and nontrivial result, the 3-AP case is substantially easier than the general result in all known approaches to Szemerédi's theorem. However, when proving a relative Szemerédi theorem by transferring Szemerédi's theorem down 2 A recent result of Sanders [33] is within a hair's breadth of verifying Erdős' conjecture for 3-APs. Sanders proved that every 3-AP-free subset of [N ] has size at most O(N (log log N ) 5 / log N ), which is just slightly shy of the logarithmic density barrier that one wishes to cross. In the other direction, Behrend [2] constructed a 3-AP-free subset of [N ] of size N e −O( √ log N ) . There is some evidence to suggest that Behrend's lower bound is closer to the truth (see [34]). For longer APs, the gap is much larger. The best upper bound, due to Gowers [14], is that every k-AP-free subset of [N ] has size at most N/(log log N ) c k for some c k > 0 (though for k = 4 there have been some improvements [20]). to the sparse setting, the general case is not mathematically more difficult than the 3-AP case. However, as one might expect, the notation for the general case can be rather cumbersome. For this reason, we explain various aspects of the proof first for 3-APs and only afterwards discuss how it can be adapted to the general case.
We begin, in Section 2, by presenting the Ruzsa-Szemerédi graph-theoretic approach to Roth's theorem. In particular, we present a graph-theoretic construction that will motivate the definition of the linear forms conditions, which we state in Sections 3 and 4, first for Roth's theorem, then for Szemerédi's theorem. The dense model theorem and the counting lemma are explained in Sections 5 and 6, respectively. We conclude the proof of the relative Szemerédi theorem in Section 7. In Sections 8 and 9, we will construct the relevant set of almost primes (or rather a majorizing measure for the primes) and show that it satisfies the linear forms condition. We conclude with some remarks about extensions of the Green-Tao theorem.

Roth's theorem via graph theory
One way to state Szemerédi's theorem is that for every fixed k every k-AP-free subset of [N ] has o(N ) elements. It is not hard to prove that this "finitary" version of Szemerédi's theorem is equivalent to the "infinitary" version stated as Theorem 1.2.
In fact, it will be more convenient to work in the setting of the abelian group Z N := Z/N Z as opposed to [N ]. These two settings are roughly equivalent for studying k-APs, assuming N is relatively prime to (k − 1)!, with the only difference being that Z N allows APs to wrap around 0. For example, N − 1, 0, 1 is a 3-AP in Z N , but not in [N ]. To deal with this issue, one simply embeds [N ] into a larger cyclic group so that no k-APs wrap around zero. Working in Z N , we will now show how Roth's theorem follows from a result in graph theory.
Consider the following graph construction (see Figure 1). Given A ⊆ Z N , we construct a tripartite graph G A whose vertex sets are X, Y , and Z, each with N vertices labeled by elements of Z N . The edges are constructed as follows (one may think of this as a variant of a Cayley graph for Z N generated by A): • (x, y) ∈ X × Y is an edge if and only if 2x + y ∈ A; • (x, z) ∈ X × Z is an edge if and only if x − z ∈ A; • (y, z) ∈ Y × Z is an edge if and only if −y − 2z ∈ A. Observe that (x, y, z) ∈ X × Y × Z forms a triangle if and only if all three of 2x + y, x − z, −y − 2z are in A. These numbers form a 3-AP with common difference −x − y − z, so we see that triangles in G A correspond to 3-APs in A.
e.g., Pseudorandomness hypothesis for S ⊆ Z N : G S has asymptotically the expected number of embeddings of However, we assumed that A is 3-AP-free. Does this mean that G A has no triangles? Not quite. There are still some triangles in G A , namely those that correspond to trivial 3-APs in A, i.e., 3-APs with common difference zero. So the triangles in G A are precisely those with x + y + z = 0. This easily implies that every edge in G A is contained in exactly one triangle, namely the one that completes the equation x + y + z = 0.
What can we say about a graph where every edge is contained in exactly one triangle? The following result of Ruzsa and Szemerédi [32] shows that it cannot have many edges.
Theorem 2.2 (Ruzsa-Szemerédi). If G is a graph on n vertices with every edge in exactly one triangle, then G has o(n 2 ) edges.
Our graph G A has 3N vertices and 3N |A| edges (for every x ∈ X, there are exactly |A| vertices y ∈ Y with 2x + y ∈ A and similarly for Y × Z and X × Z). So it follows by Theorem 2.2 that Theorem 2.2 easily follows from a result known as the triangle removal lemma, which says that if a graph on n vertices has o(n 3 ) triangles, then it can be made triangle-free by removing o(n 2 ) edges. Though both results look rather innocent, it is only recently [4,8] that a proof was found which avoids the use of Szemerédi's regularity lemma.
We will not include a proof of Theorem 2.2 here, since this would lead us too far down the route of proving Szemerédi's theorem. However, if our purpose was not to prove Roth's theorem, then why translate it into graph-theoretic language in the first place? The reason is that the counting lemma and pseudorandomness conditions used for transferring Roth's theorem to the sparse setting are most naturally phrased in terms of graph theory. 3 We will begin to make this explicit in the next section.

Relative Roth theorem
In this section, we describe the relative Roth theorem. We first give an informal statement. To state the pseudorandomness conditions, let p = |S| /N (which could decrease as a function of N ) and consider the graph G S . This is similar to G A , except that (x, y) ∈ X × Y is now made an edge if and only if 2x + y ∈ S, etc. The pseudorandomness hypothesis now asks that the number of embeddings of K 2,2,2 in G S (i.e., the number of tuples (x 1 , x 2 , y 1 , y 2 , z 1 , z 2 ) ∈ X ×X ×Y ×Y ×Z ×Z where x i y j , x i z j , y i z j are all edges for all i, j ∈ {1, 2}) be equal to (1 + o(1))p 12 N 6 , where o(1) indicates a quantity that tends to zero as N tends to infinity. This is asymptotically the same as the expected number of embeddings of K 2,2,2 in a random tripartite graph of density p or in the graph G S formed from a random set S of density p. Assuming that p does not decrease too rapidly with N , it is possible to show that with high probability the true K 2,2,2 -count in these random graphs is asymptotic to this expectation. It is therefore appropriate to think of our assumption as a pseudorandomness condition.
For technical reasons, it is necessary to assume that this property of having the "correct" count holds not only for K 2,2,2 but also for every subgraph H of K 2,2,2 . That is, we ask that the number of embeddings of H into G S (with vertices of H mapped into their assigned parts) be equal to (1 + o(1))p e(H) N v(H) . The full description is now summarized in Figure 2, although we will restate it in more formal terms later on.
We now sketch the idea behind the proof of the relative Roth theorem. We begin by noting that Roth's theorem can be rephrased as follows.
By a simple averaging argument (attributed to Varnavides [43]), this version of Roth's theorem is equivalent to the claim that A contains not just one, but many 3-APs.
To prove the relative Roth theorem from Roth's theorem, assume that A ⊆ S ⊆ Z N is such that |A| ≥ δ |S|. The first step is to show that there is a dense model A for A. This is a dense subset of Z N such that | A|/N ≈ |A|/|S| ≥ δ and A approximates A in the sense of a certain cut norm. The second step is to use this cut norm condition to prove a counting lemma, which says that A and A contain roughly the same number of 3-APs (after an appropriate normalization), i.e., (N/ |S|) 2 |{3-APs in A}| ≈ |{3-APs in A}|.
Since the counting version of Roth's theorem implies that |{3-APs in A}| ≥ cN 2 , the relative Roth theorem is proved.
This discussion is largely accurate, except for one white lie, which is that it is more correct to think of A as a weighted function from Z N to [0, 1] than as a subset of Z N . It will therefore be more convenient to work with the following weighted version of Roth's theorem. At this point, it is worth fixing some notation. We will write E x 1 ∈X 1 ,...,x k ∈X k as a shorthand for If the variables x 1 , . . . , x k or the sets X 1 , . . . , X k are understood, we will sometimes choose to omit them. We will also write o(1) to indicate a function that tends to zero as N tends to infinity, indicating further dependencies by subscripts when they are not understood.
Note that when f is {0, 1}-valued, i.e., f = 1 A is the indicator function of some set A, this reduces to the counting version of Roth's theorem. Up to a change of parameters, the counting version also implies the weighted version. Indeed, to deduce the weighted version from the counting version, let A = {x ∈ Z N | f (x) ≥ δ/2}. If Ef ≥ δ and 0 ≤ f ≤ 1, then |A| ≥ δN/2, so

Sets Functions
Dense setting By the counting version of Roth's theorem, this is bounded below by a positive constant when N is sufficiently large. When working in the functional setting, we also replace the set S by a function ν : Z N → [0, ∞). This function ν, which we call a majorizing measure, will be normalized to satisfy 4 The subset A ⊆ S will be replaced by some function f : for all x ∈ Z N (we write this as 0 ≤ f ≤ ν). The hypothesis |A| ≥ δ|S| will be replaced by Ef ≥ δ. Note that ν and f can be unbounded, which is a major source of difficulty. The main motivating example to bear in mind is that when A ⊆ S ⊆ Z N , we take ν(x) = N |S| 1 S (x) and f (x) = ν(x)1 A (x), noting that if |A| ≥ δ|S| then Ef ≥ δ. We refer the reader to Table 1 for a summary of this correspondence.
We can now state the pseudorandomness condition in a more formal way. We modify the graph G S to a weighted graph G ν , which, for brevity, we usually denote by ν. This is a weighted tripartite graph with vertex sets X = Y = Z = Z N and edge weights given by: • ν Y Z (y, z) = ν(−y − 2z) for all (y, z) ∈ Y × Z. We will omit the subscripts if there is no risk of confusion. The pseudorandomness condition then says that the weighted graph ν has asymptotically the expected H-density for any subgraph H of K 2,2,2 . For example, triangle density in ν is given by the expression E[ν(x, y)ν(x, z)ν(y, z)], where x, y, z vary independently and uniformly over X, Y , Z, respectively. The pseudorandomness assumption requires, amongst other things, that this triangle density be 1 + o(1), the normalization having accounted for the other factors. The full hypothesis, involving K 2,2,2 , is stated below.
and also (2) holds when one or more of the twelve ν factors in the expectation are erased.
Similarly, a function ν : and also (3) holds when one or more of the twelve ν factors in the expectation are erased. 4 We think of ν as a sequence of functions ν (N) , though we usually suppress the implicit dependence of ν on N . 5 We will assume that N is odd, which simplifies the proof of Theorem 3.5 without too much loss in generality.
Theorem 3.5 holds more generally without this additional assumption on N .
We can now state the relative Roth theorem in a more precise fashion.
. Moreover, c(δ) may be taken to be the same constant which appears in (1).
Remark. The rate at which the o(1) term in (3.5) goes to zero depends not only on δ but also on the rate of convergence in the 3-linear forms condition.

Relative Szemerédi theorem
As in the case of Roth's theorem, we first state an equivalent version of Szemerédi's theorem allowing weights.
The setup for the relative Szemerédi theorem is a natural extension of the previous section. Just as our pseudorandomness condition for 3-APs was related to the graph-theoretic approach to Roth's theorem, the pseudorandomness condition in the general case is informed by the hypergraph removal approach to Szemerédi's theorem [16,26,29,30,39].
Instead of constructing a weighted graph as we did for 3-APs, we now construct a weighted (k−1)uniform hypergraph corresponding to k-APs. For example, for 4-APs, the 3-uniform hypergraph corresponding to the majorizing measure ν : Z N → [0, ∞) is 4-partite, with vertex sets W, X, Y, Z, each with N vertices labeled by elements of Z N . The weighted edges are given by: The linear forms 3w + 2x + y, 2w + x − z, w − y − 2z, −x − 2y − 3z are chosen because they form a 4-AP with common difference −w − x − y − z and each linear form depends on exactly three of the four variables. The pseudorandomness condition then says that the weighted hypergraph ν contains asymptotically the expected count of H whenever H is a subgraph of the 2-blow-up of the simplex K and joining all those triples which correspond to edges in K For general k, we are concerned with K (k−1) k , the complete (k − 1)-uniform hypergraph on k vertices, while the pseudorandomness condition again asks that a certain weighted k-partite (k − 1)-uniform hypergraph contains asymptotically the expected count for every subgraph of the 2-blow-up of K For k-APs, the corresponding linear forms are given by the expressions k i=1 (j − i)x i , for each j = k, k − 1, . . . , 1. The condition (5) below is now the natural extension of the 3-linear forms condition (3). When viewed as a hypergraph condition, it asks that the count for any subgraph of the 2-blow-up of K (k−1) k be close to the expected count.
Now we are ready to state the main result in the proof of the Green-Tao theorem.
Moreover, c(k, δ) may be taken to be the same constant which appears in (4).
Remark. The rate at which the o(1) term in (6) goes to zero depends not only on k and δ but also on the rate of convergence in the k-linear forms condition for ν.
Now we outline the proof of the relative Szemerédi theorem. This is simply a rephrasing of the outline given after Theorem 3.2 for the unweighted version of the relative Roth theorem. We start with 0 ≤ f ≤ ν and Ef ≥ δ. In §5, we prove a dense model theorem which shows that there exists another functionf : Z N → [0, 1] which approximates f with respect to a certain cut norm 7 . Note thatf is bounded (hence "dense" model). In §6, we establish a counting lemma which says that the weighted k-AP counts in f andf are similar, that is, The right-hand side is at least c(k, δ) − o k,δ (1) by Szemerédi's theorem (Theorem 4.1). Thus the relative Szemerédi theorem follows. We now begin the proof proper.

Dense model theorem
Given g : X × Y → R, viewed as an edge-weighted bipartite graph with vertex set X ∪ Y , we define the cut norm of g to be For a weighted 3-uniform hypergraph g : (The more obvious alternative, where we range A, B, C over subsets of X, Y, Z, respectively, gives a weaker norm that is not sufficient to guarantee a counting lemma.) More generally, given a weighted r-uniform hypergraph g : where the supremum is taken over all choices of subsets , and we write As in the footnote to Definition 3.4, in our proof of Theorem 4.3 we will make the simplifying assumption that N is coprime to (k − 1)!. In the proof of the Green-Tao theorem, one can always take N coprime to (k − 1)!. 7 In the original Green-Tao approach, they requiredf and f to be close in a stronger sense related to the Gowers uniformity norm. The cut norm approach we present here requires less stringent pseudorandomness hypotheses for applying the dense model theorem, but at the cost of a more difficult counting lemma.
for each i. We extend this definition of cut norm to Z N : for any function f : where the supremum is taken over all A 1 , . . . , A r ⊆ Z r−1 N . It is easy to see that this is a norm. Equivalently, it is the hypergraph cut norm applied to the weighted r-uniform hypergraph g : The main result of this section is the following dense model theorem (in this form due to [44]). It says that it is possible to approximate an unbounded (or sparse) function f by a bounded (or dense) functionf .
Remark. One may take ǫ ′ = exp(−ǫ −C ) where C is some absolute constant (independent of r and, more importantly, N ).
A more involved dense model theorem (using a norm based on the Gowers uniformity norm rather than the cut norm) was used by Green and Tao in [19]. Its proof was subsequently simplified by Gowers [17] and, independently, Reingold, Trevisan, Tulsiani, and Vadhan [27]. Here we follow Gowers' approach, but specialized to · ,r , which simplifies the exposition.
It will be useful to rewrite where the convolution is defined by Let Φ 2 denote the set of all functions that can be written as a convex combination of convolutions More generally, given r functions h 1 , . . . , h r : For example, when r = 2, we recover the usual convolution (h 1 , h 2 ) * = h 1 * h 2 . We similarly have where Φ r is the set of all functions Z N → R that can be written as a convex combination of The next lemma establishes a key property of Φ r .
For the rest of this section, we fix the value of r and simply write · for · ,r and Φ for Φ r . We have f := sup ϕ∈Φ | f, ϕ |. Recall that the dual norm is defined for functions ψ : Z N → R by ψ * = sup f ≤1 | f, ψ |. In particular, one has f, ψ ≤ f ψ * for all f, ψ : Z N → R. Also note that · ≤ · 1 and · ∞ ≤ · * .
Proof. For any functions ϕ ∈ Φ and f : Z N → R, we have where the penultimate step uses that Φ is closed under multiplication. Thus, for any f, ψ : It follows that for any f, ψ, ψ ′ : Taking the supremum over all f with f ≤ 1, we see that ψψ ′ * ≤ ψ * ψ ′ * , as required.

Counting lemma
In this section, we prove the counting lemma. We will focus principally on the graph case, Theorem 6.2 below, since this case contains all the important ideas and is notationally simpler. The hypergraph generalization is then discussed towards the end of the section.
For graphs, the counting lemma says that if two weighted graphs are close in cut norm, then they have similar triangle densities. To be more specific, we consider weighted tripartite graphs on the vertex set X ∪ Y ∪ Z, where X, Y , and Z are finite sets. Such a weighted graph g is given by three functions g XY : X × Y → R, g XZ : X × Z → R, and g Y Z : Y × Z → R, although we often drop the subscripts if they are clear from context. We write g = max{ g XY , g XZ , g Y Z }. We first consider the easier case of counting in dense (i.e., bounded weight) graphs. Proposition 6.1 (Triangle counting lemma, dense setting). Let g andg be weighted tripartite graphs on X ∪ Y ∪ Z with weights in [0, 1]. If g −g ≤ ǫ, then |E x∈X,y∈Y,z∈Z [g(x, y)g(x, z)g(y, z) −g(x, y)g(x, z)g(y, z)]| ≤ 3ǫ.
Proof. Unless indicated otherwise, all expectations are taken over x ∈ X, y ∈ Y , z ∈ Z uniformly and independently. From the definition (7) of the cut norm, we have that for every function a : X → [0, 1] and b : Y → [0, 1] (since the expectation is bilinear in a and b, the extrema occur when a and b are {0, 1}-valued, so (10) is equivalent to (7)). It follows that |E[g(x, y)g(x, z)g(y, z) −g(x, y)g(x, z)g(y, z)]| ≤ ǫ, since the expectation has the form (10) if we fix any value of z. Similarly, we have |E[g(x, y)g(x, z)g(y, z) −g(x, y)g(x, z)g(y, z)]| ≤ ǫ and |E[g(x, y)g(x, z)g(y, z) −g(x, y)g(x, z)g(y, z)]| ≤ ǫ. The result then follows from telescoping and the triangle inequality.
This proof does not work in the sparse setting, when g is unbounded, since (10) requires a and b to be bounded. The main result of this section, stated next for graphs (the hypergraph version is stated towards the end of the section), gives a counting lemma assuming 0 ≤ g ≤ ν for some ν satisfying the linear forms condition. This is one of the main results in our paper [5].
The proof uses repeated application of the Cauchy-Schwarz inequality, a standard technique in this area, popularized by Gowers [13,14,15,16]. The key additional idea, introduced in [5,6], is densification. After several applications of the Cauchy-Schwarz inequality, it becomes necessary to analyze the 4-cycle density: E x,y,z,z ′ [g(x, z)g(x, z ′ )g(y, z)g(y, z ′ )]. To do this, one introduces an auxiliary weighted graph g ′ : X × Y → [0, ∞) defined by g ′ (x, y) := E z [g(x, z)g(y, z)] (this is basically the codegree function). Note that we benefit here from working with weighted graphs. The expression for the 4-cycle density now becomes E x,y,z [g ′ (x, y)g(x, z)g(y, z)].
At first glance, it seems that our reasoning is circular. Our aim was to estimate a certain triangle density expression but we have now returned to a triangle density expression. However, g ′ behaves much more like a dense weighted graph with bounded edge weights, so what we have accomplished is to replace one of the "sparse" g XY by a "dense" g ′ XY . If we do this two more times, replacing g Y Z and g XZ with dense counterparts, the problem reduces to the dense case, which we already know how to handle.
We begin with a warm-up showing how to apply the Cauchy-Schwarz inequality (there will be many more applications later on). The following lemma shows that the 3-linear forms condition on ν implies ν − 1 = o(1), which we need to apply the dense model theorem, Theorem 5.1.

Lemma 6.3. For any
Remark. The right-hand side expression is the Gowers uniformity norm of ν − 1.

Proof. By repeated applications of the Cauchy-Schwarz inequality, we have, for
The lemma then follows.
The next lemma is crucial to what follows. It shows that in certain expressions a factor ν can be deleted from an expectation while incurring only a o(1) loss. Lemma 6.4 (Strong linear forms). Let ν, g,g be weighted tripartite graphs on X ∪ Y ∪ Z. Assume that ν satisfies the 3-linear forms condition, 0 ≤ g ≤ ν, and 0 ≤g ≤ 1. Then (1) and the same statement holds if any subset of the four g factors are replaced byg.
Proof. We give the proof when none of the g factors are replaced. The other cases require only a simple modification. By the Cauchy-Schwarz inequality, we have E x,y,z,z ′ [(ν(x, y) − 1)g(x, z)g(x, z ′ )g(y, z)g(y, z ′ )] 2 ≤ E y,z,z ′ [(E x [(ν(x, y) − 1)g(x, z)g(x, z ′ )]) 2 g(y, z)g(y, z ′ )] E y,z,z ′ [g(y, z)g(y, z ′ )] The second factor is at most 1 + o(1) by the linear forms condition. So it remains to analyze the first factor. We have, by another application of the Cauchy-Schwarz inequality, Using the 3-linear forms condition, the second factor is 1 + o(1) and the first factor is o(1) (expand everything and notice that all the terms are 1 + o(1) and the signs make all the 1's cancel).
Proof of Theorem 6.2. If ν is identically 1, we are in the dense setting, in which case the theorem follows from Proposition 6.1. Now we apply induction on the number of ν XY , ν XZ , ν Y Z which are identically 1. By relabeling if necessary, we may assume without loss of generality that ν XY is not identically 1. We define auxiliary weighted graphs ν ′ , g ′ ,g ′ : We refer to this step as densification. The idea is that even though ν and g are possibly unbounded, the new weighted graphs ν ′ and g ′ behave like dense graphs. The weights on ν ′ and g ′ are not necessarily bounded by 1, but they almost are. To correct this, we will cap the weights by setting g ′ ∧1 := max{g ′ , 1} and ν ′ ∧1 := max{ν ′ , 1} and show that this capping operation has negligible effect. We have E[g(x, y)g(x, z)g(y, z) −g(x, y)g(x, z)g(y, z)] = E[gg ′ −gg ′ ] = E[g(g ′ −g ′ )] + E[(g −g)g ′ ], (11) where the first expectation is taken over x ∈ X, y ∈ Y, z ∈ Z and the other expectations are taken over X × Y (we will use these conventions unless otherwise specified). The second term on the right-hand side of (11) equals E[(g(x, y) −g(x, y))g(x, z)g(y, z)] and its absolute value is at most g −g = o(1) (here we use 0 ≤g ≤ 1 as in the proof of Proposition 6.1). So it remains to bound the first term on the right-hand side of (11). By the Cauchy-Schwarz inequality, we have The second factor is 1 + o(1) by the linear forms condition. By Lemma 6.4, the first factor differs from by o(1) (take the difference, expand the square, and then apply the lemma term-by-term). The 3-linear forms condition implies that E[ν ′ ] = 1 + o(1) and E[ν ′2 ] = 1 + o(1). Therefore, by the Cauchy-Schwarz inequality, we have We want to show that (12) is o(1). We have Since 0 ≤ g ′ ≤ ν ′ , we have Using (13) and (15), the absolute value of the first term on the right-hand side of (14) is at most Next, we claim that (15) and (13), the absolute value of the first term is at most E[|ν ′ − 1|] = o(1). The second term can be rewritten as which is o(1) by the induction hypothesis (replace ν XY , g XY ,g XY by 1, 1 A×B , 1 A×B , respectively, and note that this increases the number of {ν XY , ν XZ , ν Y Z } which are identically 1). This proves (16).
We now expand the second term on the right-hand side of (14) as We claim that each of the expectations on the right-hand side is , which is o(1) by the induction hypothesis (replace ν XY , g XY ,g XY by 1, g ′ ∧1 ,g ′ , respectively, which by (16) (1), and note that this increases the number of {ν XY , ν XZ , ν Y Z } which are identically 1). One can similarly show that the other expectations on the right-hand side of (17) are also E[(g ′ ) 2 ] + o(1). Thus (17) is o(1) and the theorem follows.
The appropriate generalization of the 3-linear forms condition involves counts for the 2-blow-up of the simplex K (k−1) k . We say that a weighted hypergraph ν satisfies the k-linear forms condition (the hypergraph version of Definition 4.2) if and also the same statement holds if any subset of the ν factors (there are k2 k−1 such factors) are deleted. Here x (ω) The following theorem generalizes Theorem 6.2.
Theorem 6.5 (Relative simplex counting lemma). Let ν, g,g be weighted (k − 1)-uniform k-partite weighted hypergraphs on X 1 ∪ · · · ∪ X k . Assume that ν satisfies the k-linear forms condition, 0 ≤ g ≤ ν and 0 ≤g ≤ 1. If g −g = o(1), then The proof of Theorem 6.5 is a straightforward generalization of the proof of Theorem 6.2. We simply point out the necessary modifications and leave the reader to figure out the details (a full proof can be found in our paper [5], but it is perhaps easier to reread the graph case and think about the small changes that need to be made).
The proof proceeds by induction on the number of ν −1 , . . . , ν −k which are not identically 1. When ν = 1, we are in the dense setting and the proof of Proposition 6.1 easily extends. Now assume that ν −1 is not identically 1. We have extensions of Lemmas 6.3 and 6.4, where in the proof we have to apply the Cauchy-Schwarz inequality k − 1 times in succession. For the densification step, we define ν ′ , g ′ ,g ′ : The rest of the proof works with minimal changes.

Proof of the relative Szemerédi theorem
We are now ready to prove the relative Szemerédi theorem using the dense model theorem and the counting lemma following the outline given in §4.
Proof of Theorem 4.3. The k-linear forms condition implies that ν − 1 ,k−1 = o(1) (by a sequence of k − 1 applications of the Cauchy-Schwarz inequality, following Lemma 6.3). By the dense model theorem, Theorem 5.1, we can findf : Construct (k − 1)-uniform k-partite weighted hypergraphs ν, g,g on X 1 ∪ · · · ∪ X k by setting (in the first definition, the left ν −j refers to the weighted hypergraph and the second ν refers to the given function on Z N ). We claim that and (18) and (19) the left-hand side refers to the hypergraph cut norm (8) while the right-hand side refers to the cut norm (9) for functions on Z N ). We illustrate (19) in the case when k = j = 4 (the full proof is straightforward). The left-hand side of (19) equals while the right-hand side of (19) equals These two expressions are equal 8 up to a change of variables 3x 1 ↔ x 1 and 2x 2 ↔ x 2 . 8 Here we use the assumption in the footnote to Definition 4.2 that N is coprime to (k − 1)!. Without this assumption, it can be shown that the two norms (20) and (21) differ by at most a constant factor depending on k, which suffices for what follows.
It follows from (19) that g −g = f −f ,k−1 = o(1). Moreover, the k-linear forms condition for ν : Z N → [0, ∞) translates to the k-linear forms condition for the weighted hypergraph ν. It follows from the counting lemma, Theorem 6.5, that The left-hand side is equal to which can be seen by setting x = ψ 1 (x −1 ) and d = −(x 1 + · · · + x k ) so that ψ j (x −j ) = x + (j − 1)d.
A similar statement holds for the right-hand side of (22). So (22) is equivalent to which is at least c(k, δ) − o k,δ (1) by Theorem 4.1, as desired.

Constructing the majorant
In this section, we use the relative Szemerédi theorem to prove the Green-Tao theorem. To do this, we must construct a majorizing measure for the primes that satisfies the linear forms condition.
Rather than considering the set of primes itself, we put weights on the primes, a common technique in analytic number theory. The weights we use will be related to the well-known von Mangoldt function Λ. This is defined by Λ(n) = log p if n = p k for some prime p and positive integer k and Λ(n) = 0 if n is not a power of a prime (actually, the higher powers p 2 , p 3 , . . . play no role here and we will soon discard them from Λ). That these are natural weights to consider follows from the observation that the Prime Number Theorem is equivalent to n≤N Λ(n) = (1 + o(1))N .
A difficulty with Λ is that it is biased on certain residue classes. For example, every prime other than 2 is odd. This prevents us from making any pseudorandomness claims unless we can somehow remove these biases. This is achieved using the W-trick. Let w = w(N ) be any function that tends to infinity slowly with N . Let W = p≤w p be the product of primes up to w. The trick for avoiding biases mod p for any p ≤ w is to consider only those primes which are congruent to 1 (mod W ). In keeping with this idea, we define the modified von Mangoldt function by Λ(n) := φ(W ) W log(W n + 1) when W n + 1 is prime, 0 otherwise.
The factor φ(W )/W is present since exactly φ(W ) of the W residue classes mod W have infinitely many primes and Dirichlet's theorem 9 tells us that the primes are equidistributed among these φ(W ) residue classes, i.e., n≤N Λ(n) = (1 + o(1))N as long as w grows slowly enough with N . From now on, we will work with Λ rather than Λ. Our main goal is to prove the following result, which says that there is a majorizing measure for Λ which satisfies the linear forms condition.
Proposition 8.1. For every k ≥ 3, there exists δ k > 0 such that for every sufficiently large N there exists a function ν : Z N → [0, ∞) satisfying the k-linear forms condition and ν(n) ≥ δ k Λ(n) for all N/2 ≤ n < N . 9 In fact, Dirichlet's theorem, or even the Prime Number Theorem, are not necessary to prove the Green-Tao theorem, though we assume them to simplify the exposition. Indeed, a weaker form of the Prime Number Theorem asserting that there are at least cN/ log N primes up to N for some c > 0 suffices for our needs (this bound was first proved by Chebyshev and a famous short proof was subsequently found by Erdős; see [1,Ch. 2]). Furthermore, in place of Dirichlet's theorem, a simple pigeonhole argument shows that for each W , some residue class b (mod W ) contains many primes (whereas we use Dirichlet's theorem to take b = 1). The proof presented here can easily be modified to deal with general b, though the notation gets a bit more cumbersome as b could vary with W . An analysis of this sort is necessary to prove a Szemerédi-type statement for the primes (see Section 10), since we do not then know how our subset of the primes is distributed on congruence classes.
Using this majorant with the relative Szemerédi theorem, we obtain the Green-Tao theorem.
How do we construct the majorant ν for Λ(n)? Recall that the Möbius function µ is defined by µ(n) = (−1) ω(n) when n is square-free, where ω(n) is the number of prime factors of n, and µ(n) = 0 when n is not square-free. The functions Λ and µ are related by the Möbius inversion formula Λ(n) = d|n µ(d) log(n/d).
In Green and Tao's original proof, the following truncated version of Λ (motivated by [12]) was used to construct the majorant. For any R > 0, define Observe that if n has no prime divisors less than or equal to R, then Λ R (n) = log R. Tao [35] later simplified the proof by using the following variant of Λ R , where the restriction d ≤ R is replaced by a smoother cutoff. In our application, χ will be supported on [−1, 1], so only divisors d which are at most R are considered in the sum. Note that Λ R above corresponds to χ(x) = max{1 − |x|, 0}, which is not smooth. The following proposition, which we will prove in the next section, gives a linear forms estimate for Λ χ,R .
where o(1) denotes a quantity tending to zero as N → ∞ (at a rate that may depend on χ, m, t, ψ 1 , . . . , ψ m , R, and w), and c χ is the normalizing factor Now we construct the majorizing measure ν and show that it satisfies the linear forms condition.
Then ν satisfies the k-linear forms condition.
Note that while Λ χ,R is not necessarily nonnegative, ν constructed in (24) is always nonnegative due to the square on Λ χ,R .
Proof of Proposition 8.1 assuming Proposition 8.4. Take δ k = k −1 2 −k−4 c −1 χ . It suffices to verify that for N sufficiently large we have δ k Λ(n) ≤ ν(n) for all N/2 ≤ n < N . We only need to check the inequality when W n + 1 is prime, since Λ(n) is zero otherwise. We have where the inequality holds for sufficiently large N provided w grows slowly enough. When W n + 1 is prime, we have Λ χ,R (W n + 1) = log R, so as claimed.
Proof of Proposition 8.4 assuming Proposition 8.3. We need to check that whenever ψ 1 , . . . , ψ m , m ≤ k2 k−1 , are the linear forms that appear in (5) or any subset thereof. Note that no two ψ i are multiples of each other.
To use the two-piece definition of ν, we divide the domain Z N into intervals. Let Q = Q(N ) be a slowly increasing function of N . Divide Z N into Q roughly equal intervals and form a partition of Z t N into Q t boxes, as follows: Then, up to a o(1) error (due to the fact that the boxes do not all have exactly equal sizes), the left-hand side of (25) equals We say that a box B u 1 ,...,ut is good if, for each j ∈ [m], the set {ψ j (x) : x ∈ B u 1 ,...,ut } either lies completely in the subset [N/2, N ) of Z N or completely outside this subset. Otherwise, we say that the box is bad. We may assume Q grows slowly enough that N/Q ≥ R 10m . From Proposition 8.3 and the definition of ν, we know that for good boxes, For bad boxes, we use the bound ν(n) . By expanding and applying (23) to each term, we find that E x∈Bu 1 ,...,u t [ν(ψ 1 (x)) · · · ν(ψ m (x))] = O(1) (it is bounded in absolute value by 2 m + o(1)). It remains to show that the proportion of boxes that are bad is o(1).
Suppose B u 1 ,...,ut is bad. Then there exists some i such that the image of the box under ψ i intersects both [N/2, N ) and its complement. This implies that there exists some (real-valued) x ∈ t j=1 [u j N/Q, (u j + 1)N/Q) ⊆ (R/N Z) t with ψ i (x) = 0 or N/2 (mod N ). Letting y = Qx/N , we see that y ∈ t j=1 [u j , u j + 1) ⊆ (R/QZ) t satisfies ψ i (y) = 0 or Q/2 (mod Q). This implies that ψ i (u 1 , . . . , u t ) is either O(1) or Q/2 + O(1) (mod Q). Since ψ i is a nonzero linear form, at most a O(1/Q) fraction of the tuples (u 1 , . . . , u t ) ∈ Z t Q have this property. Taking the union over all i, we see that the proportion of bad boxes is O(1/Q) = o(1).

Verifying the linear forms condition
In this section, we prove Proposition 8.3. There are numerous estimates along the way. To avoid getting bogged down with the rather technical error bounds, we first go through the proof while skipping some of these details (i.e., by only considering the "main term"). The approximations are then justified at the end, where we collect the error bound arguments. We note that all constants will depend implicitly on χ, m, t, ψ 1 , . . . , ψ m .
Expanding the definition of Λ χ,R , we rewrite the left-hand side of (23) as Since µ(d) = 0 unless d is square-free, we only need to consider square-free The width of the box B is at least R 10m in each dimension, so, by considering a slightly smaller box B ′ ⊆ B such that each dimension of B ′ is divisible by D ≤ R 2m , we obtain . Therefore, up to an additive error of O(R −6m log 2m R), we can approximate (26) by (log R) 2m Let ϕ be the Fourier transform of e x χ(x). That is, We have We wish to plug this integral into (27). It helps to first restrict the integral to a compact interval I = [− log 1/2 R, log 1/2 R]. By basic results in Fourier analysis, since χ is smooth and compactly supported, ϕ decays rapidly, that is, ϕ(ξ) ≪ A (1 + |ξ|) −A for any A > 0. It follows that for any A > 0, We write Using (28), we have (error bounds are deferred to the end) Using (29), we estimate (27) by (30) We are allowed to swap the summation and the integrals because I is compact and the sum can be shown to be absolutely convergent (the argument for absolute convergence is similar to the error bound for (30) included towards the end of the section). Splitting d 1 , d ′ 1 , . . . , d m , d ′ m in (30) into prime factors, we obtain where ξ = (ξ 1 , ξ ′ 1 , . . . , ξ m , ξ ′ m ) ∈ I 2m and E p (ξ) is the Euler factor We have E p (ξ) = 1 when p ≤ w (recall the W -trick, so p ∤ θ j (x) = W ψ j (x) + 1 for all j when p ≤ w). When p > w, the expectation in the summand equals 1 if all d j , d ′ j are 1, 1/p if d j d ′ j = 1 for all except exactly one j, and is at most 1/p 2 otherwise (here we assume that w is sufficiently large so that no two ψ i are multiples of each other mod p). It follows that for p > w, where, for any prime p,

It then follows that
Recall that the Riemann zeta function has a simple pole at s = 1 with residue 1 (a proof is included towards the end). This implies that Here we use Substituting (32), (33), and (34) into (31), we find that It remains to estimate the integral We can replace the domain of integration I = [− log 1/2 R, log 1/2 R] by R with a loss of O A (log −A R) for any A > 0 due to the rapid decay of ϕ, ϕ(ξ) = O A ((1 + |ξ|) −A ). We claim Using we can rewrite the left-hand side of (36) as The expression in parentheses is −χ ′ (x), so (36) follows. Substituting (36) into (35) we arrive at the desired conclusion, Proposition 8.3.
Error estimates. Now we bound the error terms in the above analysis. Estimate in (29). We have χ(log d/ log R) = O(d −1/ log R ) (we only need to check this for d ≤ R since χ is supported on [−1, 1]). Using (28), the difference between the two sides in (29) is Simple pole of Riemann zeta function. Here is the argument showing that ζ(s) = (s−1) −1 +O(1) whenever Re s > 1 and s − 1 = O(1). We have (s − 1) The n-th term on the right is bounded in magnitude by O(n −2 ) by the mean value theorem. So the sum is O(1).
Estimate (30). We want to bound the difference between (30) and (27). This means bounding the contribution to (27) from the error term (37) in (29). Taking absolute values everywhere, we bound these contributions by The expectation E x∈Z t p [1 d j ,d ′ j |θ j (x) ∀j ] is 1 if all d i and d ′ i are 1 and at most 1/p otherwise. We continue to bound the above by So the difference between (30) and (27) is , which is small as long as we take A to be sufficiently large.

Extensions of the Green-Tao theorem
We conclude by discussing a few extensions of the Green-Tao theorem.
Szemerédi's theorem in the primes. As noted already by Green and Tao [19], their method also implies a Szemerédi-type theorem for the primes. That is, every subset of the primes with positive relative upper density contains arbitrarily long arithmetic progressions.
One elegant corollary of this result is that there are arbitrarily long APs where every term is a sum of two squares. This result follows from a combination of the well-known fact that every prime of the form 4n + 1 is a sum of two squares with Dirichlet's theorem on primes in arithmetic progressions, which tells us that roughly half the primes are congruent to 1 (mod 4). Even this innocent-sounding corollary was open before Green and Tao's paper.
Gaussian primes contain arbitrarily shaped constellations. The Gaussian integers is the set of all numbers of the form a + bi, where a, b ∈ Z. This set is a ring under the usual definitions of addition and multiplication for complex numbers. It is also a unique factorization domain, so it is legitimate to talk about the set of Gaussian primes. It is natural to ask whether any analogue of the Green-Tao theorem holds for this set and a result of Tao [37] shows that this is indeed the case.
We say that A ⊆ Z d contains arbitrary constellations if, for every finite set F ⊆ Z d , there exist x ∈ Z d and t ∈ Z >0 such that x + tf ∈ A for every f ∈ F . Tao's theorem then states that the Gaussian primes, viewed as a subset of Z 2 , contain arbitrary constellations. Just as the Green-Tao theorem uses Szemerédi's theorem as a black box, this theorem uses the multidimensional analogue of Szemerédi's theorem, first proved by Furstenberg and Katznelson. This states that every subset of Z d with positive relative density 10 contains arbitrary constellations. The Furstenberg-Katznelson theorem also follows from the hypergraph removal lemma and the approach taken by Tao is to transfer this hypergraph removal proof to the sparse context. It may therefore be seen as a precursor to the approach taken here.
Multidimensional Szemerédi theorem in the primes. Let P denote the set of primes in Z. It was shown recently by Tao and Ziegler [41] and, independently, by Cook, Magyar, and Titichetrakun [7], that every subset of P d of positive relative upper density contains arbitrary constellations. A short proof was subsequently given in [9] (though, like [41], it assumes some difficult results of Green, Tao, and Ziegler that we will discuss later in this section).
Although both this result and Tao's result on the Gaussian primes are multidimensional analogues of the Green-Tao theorem, they are quite different in nature. Informally speaking, a key difficulty in the second result is that there is a strong correlation between coordinates in P d (namely, that all coordinates are simultaneously prime), whereas there is no significant correlation between the real and imaginary parts of a typical Gaussian prime (after applying an extension of the W -trick).
The primes contain arbitrary polynomial progressions. We say that A ⊆ Z contains arbitrary polynomial progressions if, whenever P 1 , . . . , P k ∈ Z[X] are polynomials in one variable with integer coefficients satisfying P 1 (0) = · · · = P k (0) = 0, there is some x ∈ Z and t ∈ Z >0 such that x + P j (t) ∈ A for each j = 1, . . . , m. A striking generalization of Szemerédi's theorem, due to Bergelson and Leibman [3] states that any subset of Z of positive upper density contains arbitrary polynomial progressions. To date, the only known proofs of this result use ergodic theory.
For primes, an analogue of the Bergelson-Leibman theorem was proved by Tao and Ziegler [42]. This result states that any subset of the primes with positive relative upper density contains arbitrary polynomial progressions. In particular, the primes themselves contain arbitrary polynomial progressions. It seems plausible that the simplifications outlined here could also be used to simplify the proof of this theorem.
The number of k-APs in the primes. The original approach of Green and Tao (and the approach outlined in this paper) implies that for any k the number of k-APs of primes with each term at most N is on the order of N 2 log k N . In subsequent work, Green, Tao, and Ziegler [21], [22], [23] showed how to determine the exact asymptotic. That is, they determine a constant c k such that the number of k-APs of primes with each term at most N is (c k + o(1)) N 2 log k N . More generally, they determine an asymptotic for the number of prime solutions to a broad range of linear systems of equations.
The proof of these results also draws on the transference technique discussed in this paper but a number of additional ingredients are needed, most notably an inverse theorem describing the structure of those sets which do not contain the expected number of solutions to certain linear systems of equations. It is this result which is transferred to the sparse setting when one wishes to determine the exact asymptotic.