Structure and regularity for subsets of groups with finite VC-dimension

Suppose $G$ is a finite group and $A\subseteq G$ is such that $\{gA:g\in G\}$ has VC-dimension strictly less than $k$. We find algebraically well-structured sets in $G$ which, up to a chosen $\epsilon>0$, describe the structure of $A$ and behave regularly with respect to translates of $A$. For the subclass of groups with uniformly fixed finite exponent $r$, these algebraic objects are normal subgroups with index bounded in terms of $k$, $r$, and $\epsilon$. For arbitrary groups, we use Bohr neighborhoods of bounded rank and width inside normal subgroups of bounded index. Our proofs are largely model theoretic, and heavily rely on a structural analysis of compactifications of pseudofinite groups as inverse limits of Lie groups. The introduction of Bohr neighborhoods into the nonabelian setting uses model theoretic methods related to the work of Breuillard, Green, and Tao and Hrushovski on approximate groups, as well as a result of Alekseev, Glebskii, and Gordon on approximate homomorphisms.


Introduction and statement of results
Szemerédi's Regularity Lemma [50] is a fundamental result about graphs, which has found broad applications in graph theory, computer science, and arithmetic combinatorics. Roughly speaking, the regularity lemma partitions large graphs into few pieces so that almost all pairs of pieces have uniform edge density. In 2005, Green [24] proved the first arithmetic regularity lemma, which uses discrete Fourier analysis to define arithmetic notions of regularity for subsets of finite abelian groups. For groups of the form F n p , Green's result states that given A ⊆ F n p , there is H ≤ F n p of bounded index such that A is uniformly distributed in almost all cosets of H (as quantified by Fourier analytic methods; see [24,Theorem 2.1]). Arithmetic regularity lemmas, and their higher order analogues (see [23,25]), are now important tools in arithmetic combinatorics. From a general perspective, one can view regularity lemmas as tools for decomposing mathematical objects into ingredients that are easier to study because they are either highly structured (e.g., the cosets of a subgroup) or highly random (e.g., uniformly distributed).
Recently, a large body of work has developed around strengthened regularity lemmas for classes of graphs which forbid some particular bipartite configuration. This setting is fundamental in both combinatorics and model theory, although often for very different reasons. In combinatorics, forbidden configurations can lead to significant quantitative improvements in results about graphs, and several wellknown open problems arise in this pursuit (e.g., the Erdős-Hajnal conjecture; see 1.4 of [17], and also [20]). In model theory, the focus is usually on infinite objects, and forbidden configurations are used to obtain qualitative results about definable sets in mathematical structures. Indeed, much of modern model theory emerged from the study of mathematical structures in which every definable bipartite graph omits a finite "half-graph" as an induced subgraph (such structures are called stable).
In combinatorics and model theory, the practice of forbidding finite bipartite configurations is rigorously formulated using VC-dimension. By definition, the VCdimension of a bipartite graph (V, W ; E) is the supremum of all k ∈ Z + such that (V, W ; E) contains ([k], P([k]); ∈) as an induced subgraph (where [k] = {1, . . . , k}). We call (V, W ; E) k-NIP if it has VC-dimension at most k−1. 1 While this definition is based on omitting one specific bipartite graph, an illuminating exercise is that if (V, W ; E) omits some finite bipartite graph (V ′ , W ′ , E ′ ) as an induced subgraph, then (V, W ; E) is k-NIP for some k ≤ |V ′ | + ⌈log 2 |W ′ |⌉. Therefore, having finite VC-dimension is equivalent to omitting some finite bipartite configuration.
In [2, Lemma 1.6], Alon, Fischer, and Newman proved a strengthened regularity lemma for finite graphs of bounded VC-dimension 2 , in which the bound on the size of the partition is polynomial in the degree of irregularity (in contrast to Szemerédi's original work, where these bounds are necessarily tower-type [21]), and the edge density in any regular pair is close to 0 or 1. This latter condition says that, as a bipartite graph, each regular pair is almost empty or complete, and so the normally "random" ingredients of Szemerédi regularity are in fact highly structured. Graph regularity with bounded VC-dimension was also developed by Lovász and Szegedy in [35], and similar results have been found for hypergraphs (e.g., [18,19,20]), as well as for various model theoretic settings inside NIP (see [5,10,11,37]). The strongest conclusion is for stable graphs 3 , where Malliaris and Shelah prove the existence of regular partitions with polynomial bounds, no irregular pairs, and the same "0-1" behavior of edge densities in regular pairs (see [37,Theorem 5.18]).
The goal of this article is to develop arithmetic regularity for arbitrary finite groups in the context of forbidden bipartite configurations, as quantified by VCdimension. In analogy to the case of graphs, we show that by forbidding finite bipartite configurations, one obtains a strengthened version of arithmetic regularity in which the normally random ingredients are instead highly structured. Moreover, our proof methods deepen the connection between model theory and arithmetic combinatorics, in that we use pseudofinite methods to extend combinatorial results for finite abelian groups to the nonabelian setting. This is in the same vein as Hrushovski's [28] celebrated work on approximate groups, and the subsequent structure theory proved by Breuillard, Green, and Tao [8]. We will use similar techniques in order to formulate arithmetic regularity in nonabelian groups using Bohr neighborhoods, which are fundamental objects from arithmetic combinatorics in abelian groups. Finally, our results show that arithmetic regularity for NIP sets in finite groups coincides with a certain model theoretic phenomenon called "compact domination". This notion was first isolated by Hrushovski, Peterzil, and the second author [29] in their proof of the so-called "Pillay conjectures" for groups definable in o-minimal theories, and later played an important role in the study of definably amenable groups definable in NIP theories [9,29,31,32].
Before stating the main results of this paper, we briefly recall previous work on stable arithmetic regularity, as it provides a template for the "structure and regularity" statements we will obtain in the NIP setting. Given a group G and a subset A ⊆ G, we define the bipartite graph Γ G (A) = (V, W ; E) where V = W = G and E = {(x, y) ∈ G 2 : yx ∈ A}. 4 Given k ≥ 1, we say that a subset A of a group G is k-NIP (respectively, k-stable) if Γ G (A) is k-NIP (respectively, k-stable), as defined above. In [52], the third author and Wolf developed arithmetic regularity for k-stable subsets of F n p . They proved that such sets satisfy a strengthened version of Green's arithmetic regularity lemma above, in which there is an efficient bound on the index of H and A is uniformly distributed in all cosets of H. They also show that a k-stable subset of F n p is approximately a union of cosets of a subgroup of small index, which is an arithmetic analogue of "0-1 density" in regular pairs. In [15,Theorem 1.2], we generalized and strengthened the results from [52] on F n p to the setting of arbitrary finite groups, but without explicit bounds. 5 Theorem 1.1. [15] For any k ≥ 1 and ǫ > 0, there is n = n(k, ǫ) such that the following holds. Suppose G is a finite group and A ⊆ G is k-stable. Then there is a normal subgroup H ≤ G, of index at most n, satisfying the following properties.
(i) (structure) There is a set D ⊆ G, which is a union of cosets of H, such that |A △ D| < ǫ|H|.
Our first result on arithmetic regularity in the setting of bounded VC-dimension is for k-NIP subsets of finite groups with uniformly bounded exponent.
Theorem 3.2. For any k, r ≥ 1 and ǫ > 0, there is n = n(k, r, ǫ) such that the following holds. Suppose G is a finite group of exponent r, and A ⊆ G is k-NIP. Then there are * a normal subgroup H ≤ G of index at most n, and * a set Z ⊆ G, which is a union of cosets of H with |Z| < ǫ|G|, satisfying the following properties.
(i) (structure) There is a set D ⊆ G, which is a union of cosets of H, such that |(A\Z) △ D| < ǫ|H|.
Thus the behavior of NIP sets in bounded exponent groups is almost identical to that of stable sets in arbitrary finite groups, where the only difference is the error set Z. This reflects similar behavior in graph regularity, where the main difference between the stable and NIP cases is the need for irregular pairs. Theorem 3.2 also qualitatively generalizes and strengthens a recent quantitative result of Alon, Fox, groups. The reason we use yx ∈ A rather than xy ∈ A is due to the model theoretic preference for "left-invariant" formulas (see Section 2.4 for details). 5 Quantitative results for stable sets in finite abelian groups were later proved by the third author and Wolf (see [53,Theorem 4]), and more recently for arbitrary finite groups by the first author (see Theorems 1.3 and 1.4 of [13]). and Zhao [3, Theorem 1.1] on k-NIP subsets of finite abelian groups of uniformly bounded exponent. A version of Theorem 3.2 with polynomial bounds (in ǫ -1 ), but weaker qualitative ingredients, is conjectured in [3]. 6 We then turn to k-NIP sets in arbitrary finite groups. In this case, one cannot expect a statement involving only subgroups, as in Theorem 3.2. Indeed, as noted in [3,Section 5], if p ≥ 3 is prime and A = {1, 2, . . . , ⌊ p 2 ⌋}, then A is 4-NIP as a subset of Z/pZ, but A cannot be approximated as in Theorem 3.2 for arbitrarily small ǫ. This example illustrates a common obstacle faced in arithmetic combinatorics when working in abelian groups with very few subgroups. In situations like this, one often works instead with certain well-structured subsets of groups called Bohr neighborhoods. Bohr neighborhoods in cyclic groups were used in Bourgain's improvement of Roth's Theorem [7, (0.11)], and also form the basis of Green's arithmetic regularity lemma for finite abelian groups [24,Theorem 5.2]. Results related to ours involving Bohr neighborhoods, with quantitative bounds but for abelian groups, were independently obtained by Sisask [49,Theorem 1.4].
Given a group H, an integer r ≥ 0, and some δ > 0, we define a (δ, r)-Bohr neighborhood in H to be a set of the form B r τ,δ := {x ∈ H : d(τ (x), 0) < δ}, where τ : H → T r is a group homomorphism and d is a fixed invariant metric on the r-dimensional torus T r (see Remark 4.6 and Definition 4.7). Our main structure and regularity result for NIP sets in finite groups is as follows.
Theorem 5.7. For any k ≥ 1 and ǫ > 0 there is n = n(k, ǫ) such that the following holds. Suppose G is a finite group and A ⊆ G is k-NIP. Then there are * a normal subgroup H ≤ G of index m ≤ n, * a (δ, r)-Bohr neighborhood B in H, where 0 ≤ r ≤ n and 1 n ≤ δ ≤ 1, and * a subset Z ⊆ G, with |Z| < ǫ|G|, satisfying the following properties.
(i) (structure) There is a set D ⊆ G, which is a union of at most m( 2 δ ) r translates of B, such that |(A △ D)\Z| < ǫ|B|. (ii) (regularity) For any g ∈ G\Z, either |gB ∩ A| < ǫ|B| or |gB\A| < ǫ|B|. Moreover, H and Z are in the Boolean algebra generated by {gAh : g, h ∈ G}, and if G is abelian then we may assume H = G.
In order to prove Theorems 3.2 and 5.7, we will first prove companion theorems for these results involving definable sets in infinite pseudofinite groups (Theorems 3.1 and 5.5, respectively). We then prove the theorems about finite groups by taking ultraproducts of counterexamples in order to obtain infinite pseudofinite groups contradicting the companion theorems. To prove the companion theorems, we work with a saturated pseudofinite group G, and an invariant NIP formula θ(x;ȳ) (see Definitions 2.1 and 2.10). In [14], the first two authors proved "generic compact domination" for the quotient group G/G 00 θ r , where θ r (x;ȳ, u) := θ(x · u;ȳ) and G 00 θ r is the intersection of all θ r -type-definable bounded-index subgroups of G (see Definition 2.12). In this case, G/G 00 θ r is a compact Hausdorff group, and generic compact domination roughly states that if A ⊆ G is θ r -definable, then the set of cosets of G 00 θ r , which intersect both A and G\A in "large" sets with respect to the pseudofinite counting measure, has Haar measure 0 (see Theorem 2.14). This is essentially a regularity statement for A with respect to the subgroup G 00 θ r , which is rather remarkable as generic compact domination originated in [29] toward proving conjectures of the second author on the Lie structure of groups definable in o-minimal theories [41, Conjecture 1.1].
For G and θ(x;ȳ) as above, the regularity provided by generic compact domination for θ r -definable sets in G cannot be transferred directly to finite groups, as the statement depends entirely on type-definable data (such as G 00 θ r ). Thus, much of the work in this paper focuses on obtaining definable approximations to G 00 θ r and the other objects involved in generic compact domination. We first investigate the situation when G/G 00 θ r is a profinite group, in which case G 00 θ r can be approximated by definable finite-index subgroups of G. Using this, we prove Theorem 3.1 (the pseudofinite companion to Theorem 3.2 above). The connection to Theorem 3.2 is that if G is elementarily equivalent to an ultraproduct of groups of uniformly bounded exponent, then G/G 00 θ r is a compact Hausdorff group of finite exponent, hence is profinite (see Fact 2.3(d)).
When G/G 00 θ r is not profinite, there are not enough definable finite-index subgroups available to describe G 00 θ r , and it is for this reason that we turn to Bohr neighborhoods. This is somewhat surprising, as Bohr neighborhoods are fundamentally linked to abelian groups, and we do not make any assumptions of commutativity. However, by a general result of the second author on "definable" compactifications of pseudofinite groups, we in fact have that the connected component of G/G 00 θ r is abelian (see Theorem 2.7). It is at this point that we see the beautiful partnership between pseudofinite groups and NIP formulas. Specifically, we have generic compact domination of θ r -definable sets by the abelian-by-profinite group G/G 00 θ r , which allows us to analyze θ r -definable sets in G using Bohr neighborhoods in definable finite-index subgroups. In order to obtain a statement involving only definable objects, we use approximate homomorphisms to formulate a notion of approximate Bohr neighborhoods. This leads to Theorem 5.5 (the pseudofinite companion of Theorem 5.7 above). We then apply a result of Alekseev, Glebskiǐ, and Gordon [1, Theorem 5.13] on approximate homomorphisms to find actual Bohr neighborhoods inside approximate Bohr neighborhoods and, ultimately, prove Theorem 5.7.
In Section 6, we prove similar results for fsg groups definable in distal NIP theories (see Theorems 6.8 and 6.7). This follows our theme, as such groups satisfy a strong form of compact domination (see Lemma 6.6). In Section 7, we discuss compact p-adic analytic groups as one concrete example of the distal fsg setting.
Acknowledgements. Much of the work in this paper was carried out during the 2018 Model Theory, Combinatorics and Valued Fields trimester program at Institut Henri Poincaré. We thank IHP for their hospitality. We also thank Julia Wolf for helpful conversations, and the anonymous referee for their careful reading and for providing many valuable revisions, corrections, and suggestions.

Preliminaries
2.1. First-order structures and definability. We start by establishing the setting involving first-order structures. See [38] for an introduction to first-order logic and model theory.
Let L be a first-order language. Following model-theoretic convention, we will say that an L-structure M * is sufficiently saturated if M * is κ-saturated and strongly κ-homogeneous for some large (e.g., strongly inaccessible) cardinal κ. Let M * be a fixed sufficiently saturated L-structure. We say that a set is bounded if its cardinality is strictly less than the saturation cardinal κ of M * . 7 When L and M * are fixed, we will refer to an L-formula with parameters from M * as simply a formula. We also call an elementary substructure M ≺ M * small if its universe is bounded. As usual, a subset X ⊆ (M * ) n is definable if there is a formula φ(x 1 , . . . , x n ) such that X = φ(M * ) := {ā ∈ (M * ) n : M * |= φ(ā)}; and X ⊆ (M * ) n is type-definable if it is an intersection of a bounded number of definable subsets of (M * ) n . We will further say that X ⊆ (M * ) n is countably-definable if it is an intersection of countably many definable subsets of (M * ) n .
Many of our results will operate in a "local" model-theoretic setting, which is to say that we focus on a single formula θ(x;ȳ) whose free variables are partitioned into a singleton x and a finite tupleȳ.
if it is an intersection of a bounded (respectively, countable) number of θdefinable subsets of M * .
Note that if θ(x;ȳ) is a formula, and X ⊆ M * is a set that is both countablydefinable and θ-type-definable, then X is θ-countably-definable by an easy saturation argument.
We end this subsection with some discussion on our conventions regarding definable groups. In general, we will work with a sufficiently saturated structure M * and consider a group G definable in M * . (For example, this will be the setting for the results in Sections 6 and 7.) Thus most of the preliminaries below will take place in this context. On the other hand, the results in Sections 3 and 5 are in the "local setting" discussed above, and thus we will work in the situation where L is an expansion of the group language 8 and M * expands a group. So in this case, we use G in place of M * , and we just say that G is a sufficiently saturated expansion of a group.
In some situations, we may start by working in the setting of groups definable in M * and then, for certain results, move to the latter setting where M * is itself an expansion of a group. To clarify this, we adopt the following convention. Given a sufficiently saturated structure M * and a group G definable in M * , we will write G = M * to signify the additional assumption that L contains the language of groups, M * is an expansion of a group, and G is defined by x = x. In other words, this assumption moves us to the setting where we work with a sufficiently saturated expansion of a group (as discussed above). This will be done primarily for the sake of convenience, and in order to avoid introducing further terminology and notation. 7 This is not to be confused with later uses of the phrase "uniformly bounded" in the context of theorems about finite groups. 8 In fact, the group language expanded by a single unary relation symbol A suffices for our main results on finite groups (Theorems 3.2 and 5.7).
Definition 2.2. Let G be a sufficiently saturated expansion of a group. A formula θ(x;ȳ) is (left) invariant if, for any a ∈ G andb ∈ G |ȳ| , there isc ∈ G |ȳ| such that θ(a · x;b) and θ(x;c) define the same subset of G.
The typical example of an invariant formula is something of the form θ(x; y) := φ(y · x), where φ(x) is a formula in one variable. Note also that if θ(x;ȳ) is an invariant formula then any θ -formula is invariant as well.
2.2. Compact quotients. By convention, when we say that a topological space is compact, we mean compact and Hausdorff. We will frequently use the fact that a compact space is second-countable if and only if it is separable and metrizable (e.g., by Urysohn's Metrization Theorem). Given a topological group K, we let K 0 denote the connected component of the identity in K, which is a closed normal subgroup of K. A topological group is called profinite if it is a projective limit of finite groups. By a Lie group, we mean a finite-dimensional real Lie group. For n ∈ N, let T n denote the n-dimensional torus, where T = R/Z (so T 0 is the trivial group). We view T n as a compact topological group (with the product of the quotient topology on R/Z). We use ∼ = for isomorphism of topological groups.
The structure theory for compact groups as projective limits of compact Lie groups will play a significant role in this paper. We refer the reader to [43, Section 1.1] for details on projective limits of topological spaces. Each projective limit below will be indexed by a join semilattice (jsl ), i.e., a poset I = (I, ≤) such that any finite set F ⊆ I has a least upper bound (denoted sup F ). When we refer to N as a jsl, we always use the usual ordering.
The following are several important facts about compact groups that we will need at various points throughout the paper. (f ) Any compact group K admits a unique left-invariant regular Borel probability measure η K (called the normalized Haar measure on K). 9 (g) If K is a compact abelian Lie group, then K ∼ = T n × F for some finite group F and some n ∈ N. (h) If K is a compact group then there is a jsl I and a projective system (L i ) i∈I of compact Lie groups such that K ∼ = lim ← − L i . Moreover, the projection maps are surjective, and if K is second-countable then we may assume I = N.
Proof. Part (a). This is a straightforward consequence of the Open Mapping Theorem for compact groups [27, p. 704]. See also [26,Theorem 7.12] for a more general result in the locally compact setting.
Part (b). This follows from the fact that a topological group is profinite if and only if it is compact and totally disconnected (see [43,Theorem 2 Part (c). This follows from parts (a) and (b). 9 In fact, η K is also right-invariant and is the unique right-invariant regular Borel probability measure on K. We now return to model theory. Let L be a first-order language. Given a sufficiently saturated L-structure M * , a type-definable set X ⊆ (M * ) n , and a complete n-type p ∈ S n (M * ), we say p concentrates on X, written p |= X, if p contains a bounded set {φ i (x)} i∈I of formulas such that X = i∈I φ i (M * ) (note that, by saturation and since p is a complete type, we have p |= X if and only if φ(x) ∈ p for any formula φ(x) such that X ⊆ φ(M * )).
Fact 2.4. Let G be a group definable in a sufficiently saturated L-structure M * . Suppose Γ ≤ G is a type-definable normal subgroup of bounded index, and let π : G → G/Γ be the canonical homomorphism.
Then X ⊆ G/Γ is closed if and only if π -1 (X) is θ-type-definable. (e) Suppose µ is a left-invariant finitely additive probability measure on the Boolean algebra B of definable subsets of G, and X is a closed subset of G/Γ. Then η G/Γ (X) = inf{µ(Z) : Z ∈ B and π -1 (X) ⊆ Z}. ] for the right-to-left direction. Conversely, suppose G/Γ is second-countable and let {U n : n ∈ N} be a neighborhood basis of the identity in G/Γ. For any n ∈ N, π -1 (U n ) is co-type-definable and contains Γ. By saturation, there is some definable set D n ⊆ G such that Γ ⊆ D n ⊆ π -1 (U n ). It follows that Γ = is the unique coset aΓ such that p |= aΓ. It is straightforward to show that f -1 (X) = {p ∈ S G (M * ) : p |= π -1 (X)} for any closed X ⊆ G/Γ. It follows that f is continuous and that µ(f -1 (X)) = inf{µ(Z) : Z ∈ B and π -1 (X) ⊆ Z} for any closed X ⊆ G/Γ. Finally, one checks that µ • f -1 is a left-invariant regular Borel probability measure on G/Γ, and thus must be η G/Γ by Fact 2.3(f ).
The topology defined on G/Γ in the previous fact is called the logic topology, and the canonical homomorphism from G to G/Γ connects topological structure in G/Γ to definable sets in G. This is a special case of the following notion.
is finite then the fibers of f partition X into finitely many type-definable sets which, by saturation, implies that each fiber of f is definable. Suppose further that X and f are θ-definable for some fixed formula θ(x;ȳ). Then in part (a) we may assume D is θ-definable, and so if C ⊆ Y is clopen then Recall that a first-order structure is pseudofinite if it is elementarily equivalent to an ultraproduct of finite structures. We now recall a result of the second author on definable compactifications of pseudofinite groups, which will be the key ingredient that allows us to introduce Bohr neighborhoods into the setting of possibly nonabelian finite groups.
Theorem 2.7. [42] Suppose G is a sufficiently saturated pseudofinite expansion of a group, and Γ ≤ G is normal and type-definable of bounded index. Then (G/Γ) 0 is abelian.
Proof. Suppose M ≺ G is a small substructure such that Γ is type-definable over M . Then G 00 M ≤ Γ, where G 00 M denotes the intersection of all bounded-index subgroups of G that are type-definable over M . By [42, Theorem 2.2], (G/G 00 M ) 0 is abelian, and so (G/Γ) 0 is abelian by Fact 2.3(a) and since the canonical homomorphism from G/G 00 M to G/Γ is surjective and continuous. Remark 2.8. The proof of [42, Theorem 2.2] uses the classification of approximate groups due to Breuillard, Green, and Tao [8]. This theorem was later generalized by Nikolov, Schneider, and Thom [39,Theorem 8], who showed that the connected component of any compactification of an (abstract) pseudofinite group is abelian. Their proof uses the classification of finite simple groups.
We are now ready to collect all of the previous facts and prove the main result of this subsection. In particular, let G be a group definable in a sufficiently saturated structure M * , and let Γ ≤ G be type-definable and normal of bounded index. Since G/Γ is a compact group, and the topology on G/Γ is controlled by type-definable objects in G, we can analyze Γ using the structure theory for compact Lie groups. The next lemma describes the main ingredients of this analysis. Given a poset I, we say that a net (X i ) i∈I of subsets of some fixed set X is decreasing if X j ⊆ X i for any i, j ∈ I such that i ≤ j. Lemma 2.9. Let G be a group definable in a sufficiently saturated L-structure M * . Suppose Γ ≤ G is type-definable and normal of bounded index. Then there is a bounded jsl I, a decreasing net (Γ i ) i∈I of countably-definable bounded-index normal subgroups of G, and decreasing net (H i ) i∈I of definable finite-index normal subgroups of G, such that the following properties are satisfied. Moreover: (a) If Γ is countably-definable then we may assume I = N.
If G is abelian then we may assume that, for all i ∈ I, there is some n i ∈ N and some finite group Then for any i ∈ I, H i /Γ i is a clopen finite-index normal subgroup of G/Γ i . 11 So each H i is a finite-index normal subgroup of G and, since G → G/Γ i is definable, H i is definable by Remark 2.6(a). If i, j ∈ I and i ≤ j, then the pullback of H i /Γ i to G/Γ j is a clopen finite-index normal subgroup, and thus contains  3(b, c). Finally, for claim (d), assume G = M * and suppose G is pseudofinite. Then (G/Γ) 0 is abelian by Theorem 2.7. So, for any i ∈ I, H i /Γ i is a compact connected abelian Lie group, and thus H i /Γ i ∼ = T ni for some n i ∈ N by Fact 2.3(g). 10 Here we view (G/Γ i ) i∈I and (H i /Γ i ) i∈I as projective systems using (i) and the assumption that (H i ) i∈I and (Γ i ) i∈I are decreasing. 11 If K is a Lie group then it is locally connected, and so K 0 is clopen. Thus, if K is also compact, then K 0 has finite index.

NIP formulas in pseudofinite groups.
In this subsection, we assume that L expands the group language. Let G be a sufficiently saturated expansion of a group. [46,Section 6.1] for details on set systems and VC-dimension).
Next, we summarize several main results from [14], which will form the basis for our work on NIP sets in finite and pseudofinite groups. We say that a set A ⊆ G is generic if G is covered by finitely many left translates of A; and a formula φ(x) is generic if φ(G) is generic. Given a formula θ(x;ȳ), let S θ (G) denote the space of complete θ-types over G (i.e., ultrafilters over the Boolean algebra of θ-formulas). A type p ∈ S θ (G) is generic if every formula in p is generic.
Note that if θ(x;ȳ) is invariant, then so is θ r (x;ȳ, u). One can also show that if θ(x;ȳ) is invariant and NIP, and φ(x) is a θ r -formula, then φ(y · x) is NIP. 12 We now focus on the case when G is pseudofinite which, by saturation, implies that G is an elementary extension of an ultraproduct U G i , where each G i is a finite L-structure expanding a group and U is a (nonprincipal) ultrafilter on some index set I. In this case, µ will always denote the pseudofinite counting measure on G, which is obtained by lifting (e.g., as in [29, Section 2]) the ultralimit measure lim U µ i on U G i , where µ i is the normalized counting measure on G i . Remark 2.13. In several proofs, we will apply Loś's Theorem to properties of µ, which requires an expanded language L + containing a sort for the ordered interval [0, 1] with a distance function, and functions from the G-sort to [0, 1] giving the measures of L-formulas. There are many accounts of this kind of formalism, and so we will omit further details and refer the reader to similar treatments in the literature, for example [ Before stating the next theorem, we "localize" the notation given before Fact 2.4. Given a formula θ(x;ȳ), a θ-type-definable set X ⊆ G, and a complete θ-type Theorem 2.14. [14] Let G be a sufficiently saturated pseudofinite expansion of a group, and suppose θ(x;ȳ) is an invariant NIP formula.
Remark 2.15. In the setting of the previous fact, part (a) implies that if X ⊆ G is θ r -type-definable, then p |= X for some generic p ∈ S θ r (G) if and only if µ(W ) > 0 for any definable (equivalently, any θ r -definable) set W ⊆ G containing X.
We now prove the main result of this subsection.
Lemma 2.16. Let G be a sufficiently saturated pseudofinite expansion of a group. Suppose θ(x;ȳ) is an invariant NIP formula, and let (W i ) ∞ i=0 be a decreasing sequence of definable sets such that G 00 Then, for any ǫ > 0, there is a θ r -definable set Z ⊆ G and some i ∈ N such that µ(Z) < ǫ and, for any g ∈ G\Z, either µ(gW i ∩ A) = 0 or µ(gW i \A) = 0. Proof. To ease notation, let Γ = G 00 θ r and K = G/Γ, and let π : G → K be the canonical homomorphism. Let E be as in Theorem 2.14(d) (with respect to the fixed θ r -definable set A). So E is closed and η K (E) = 0.
Fix ǫ > 0. By Fact 2.4(e), we may fix a definable set Z ′ ⊆ G such that µ(Z ′ ) < ǫ and π -1 (E) ⊆ Z ′ . By saturation and Fact 2.4(d), there a s θ r -definable set Z ⊆ G such that π -1 (E) ⊆ Z ⊆ Z ′ . In particular, we still have µ(Z) < ǫ. We show that Z satisfies the conclusion of the lemma. To motivate the argument, we first make a side remark. By saturation and Remark 2.15, we immediately have that for any g ∈ G\Z, there is some i ∈ N such that µ(gW i ∩ A) = 0 or µ(gW i \A) = 0. Thus the content of the following argument is to show that we can pick one i ∈ N that works for every g ∈ G\Z.
Toward a contradiction, suppose that for all i ∈ N there is some Since U is open and K is compact and second-countable (by Fact 2.4(c) and Theorem 2.14(c)), we may pass to a subsequence and assume that (a i Γ) ∞ i=0 converges to some aΓ ∈ K\U . In particular, aΓ ∈ E. Claim: it follows from saturation that any definable set containing aΓ ∩ A (respectively, aΓ\A) contains aW i ∩ A (respectively, aW i \A) for some i ∈ N. So aΓ ∈ E by the claim (and Remark 2.15), which is a contradiction.
Note that Lemma 2.16 provides a "regularity" statement for invariant NIP formulas in pseudofinite groups. However, it does not provide any information about the shape of the definable sets W i , other than that they approximate the subgroup G 00 θ r . Indeed, most of the remaining work in this paper is toward replacing these definable sets with ones that enjoy meaningful algebraic properties.
Remark 2.17. Except for Sections 6 and 7, our use of finite VC-dimension is based entirely on applications of Lemma 2.16. So it is worth emphasizing that the proof of Theorem 2.14 in [14] heavily uses fundamental results about VC-dimension such as the Sauer-Shelah Lemma and the VC-Theorem (see [46,Chapter 6]), as well as work of Simon [47,48] on NIP formulas, which builds on a large body of research on NIP theories and groups definable in such theories (e.g., [9,29,31]).
2.4. NIP subsets of groups. In this subsection, we briefly recall the notion of an NIP subset of an arbitrary group, and clarify the relationship to VC-dimension and NIP formulas. Recall from the introduction that if G is a group and A ⊆ G, then we have the bipartite graph Γ G (A) = (G, G; E) where E = {(x, y) ∈ G 2 : yx ∈ A}.  (1) If Γ G (A) omits some finite bipartite graph (V, W, E) as an induced subgraph, then A is k-NIP for some k ≤ |V | + ⌈log 2 |W |⌉.
(2) Given k ≥ 1, A is k-NIP if and only if the formula θ(x; y) := A(y · x) is k-NIP (here we view G as a structure in the group language expanded by a predicate for A). Note that the formula θ(x; y) defined in the second remark is invariant. This is the main reason we define Γ G (A) in terms of the edge relation yx ∈ A and not xy ∈ A. However, an important fact is that if a bipartite graph (V, W ; E) is k-NIP then the "opposite graph" (W, V ; {(w, v) : E(v, w)}) is 2 k -NIP (see [46,Lemma 6.3]). 13 So the order of the group operation when defining k-NIP sets only affects the precise value of k, and not whether the set is NIP overall.

Structure and regularity: the profinite case
In this section, we prove a structure and regularity theorem for θ r -definable sets in a sufficiently saturated pseudofinite group G, where θ(x;ȳ) is an invariant NIP formula and G/G 00 θ r is profinite (Theorem 3.1 below). As an application, we obtain a structure and regularity theorem for NIP sets in finite groups of uniformly bounded exponent. We also view Theorem 3.1 as a warm-up to the general case. Indeed, this theorem follows almost immediately from Lemma 2.16 and the fact that profinite quotients correspond to type-definable subgroups that are intersections of definable subgroups (via Lemma 2.9(c)).
Theorem 3.1. Let G be a sufficiently saturated pseudofinite expansion of a group, and suppose θ(x;ȳ) is an invariant NIP formula. Assume G/G 00 θ r is profinite. Fix a θ r -definable set A ⊆ G and some ǫ > 0. Then there are * a θ r -definable finite-index normal subgroup H ≤ G, and * a set Z ⊆ G, which is a union of cosets of H with µ(Z) < ǫ, 13 On the other hand, if a bipartite graph is k-stable (as defined in the introduction) then one can easily check that the opposite graph is as well. This reconciles our definitions with those in [15], where we defined k-stable subsets of groups using the relation xy ∈ A.
satisfying the following properties.
(i) (structure) There is a set D ⊆ G, which is a union of cosets of H, such that µ((A\Z) △ D) = 0.
Proof. By Theorem 2.14(c) and Lemma 2.9(a, c), there is a decreasing sequence 16, there is a θ r -definable set Z ′ ⊆ G and some i ∈ N such that µ(Z ′ ) < ǫ and, if H := H i , then for any g ∈ G\Z ′ , either µ(gH ∩ A) = 0 or µ(gH\A) = 0. Let Z = {g ∈ G : gH ⊆ Z ′ }. Then Z is a union of cosets of H, and thus is θ r -definable since [G : H] is finite. Note that µ(Z) < ǫ since Z ⊆ Z ′ . Moreover, if g ∈ G\Z then gH = g ′ H for some g ′ ∈ G\Z ′ , and so we have condition (ii). Now let D = {gH : g ∈ G\Z and µ(gH ∩ A) > 0}. Then D is θ r -definable since [G : H] is finite. Moreover, µ((A\Z) △ D) = 0 by condition (ii) and since [G : H] is finite. So we have condition (i).
We now prove structure and regularity for NIP sets in finite groups of uniformly bounded exponent. In this case, we obtain the optimal situation where NIP sets are entirely controlled by finite-index subgroups up to small error. This is related to a similar result of Alon, Fox, and Zhao [3, Theorem 1.1] on finite abelian groups of bounded exponent. Our result is stronger in the sense that the abelian assumption is removed and the structural conclusions are improved, but also weaker in the sense that we do not obtain explicit bounds. This is analogous to the comparison of our stable arithmetic regularity lemma in [15] (Theorem 1.1 above) to the work of the third author and Wolf [52] on stable sets in F n p . Theorem 3.2. For any k, r ≥ 1 and ǫ > 0, there is n = n(k, r, ǫ) such that the following holds. Suppose G is a finite group of exponent r and A ⊆ G is k-NIP. Then there are * a normal subgroup H ≤ G of index at most n, and * a set Z ⊆ G, which is a union of cosets of H with |Z| < ǫ|G|, satisfying the following properties.
(i) (structure) There is a set D ⊆ G, which is a union of cosets of H, such that |(A\Z) △ D| < ǫ|H|.
Proof. Note that condition (ii) follows immediately from condition (i). So suppose condition (i) is false. Then we have some fixed k, r ≥ 1 and ǫ > 0 such that, for all i ∈ N, there is a finite group G i of exponent r, which is a counterexample.
Let L be the group language with a new predicate A, and consider (G i , A i ) as a finite L-structure. Let U be a nonprincipal ultrafilter on Z + , and let G be a sufficiently saturated elementary extension of M := U (G i , A i ). Let θ(x; y) be the formula A(y · x). Note that θ(x; y) is invariant. Moreover, by Loś's Theorem and since M ≺ G, θ(x; y) is k-NIP (in G) and G has exponent r. So G/G 00 θ r is a compact torsion group, and thus is profinite by Fact 2.3(d). By Theorem 3.1, there is a θ r -definable finite-index normal subgroup H ≤ G and sets D, Z ⊆ G, which are unions of cosets of H, such that µ(Z) < ǫ and µ((A\Z) △ D) = 0. Let n = [G : H], and fix θ r -formulas φ(x;ȳ), ψ(x;z), and ζ(x;ū) such that H, D, and Z are defined by instances of φ(x;ȳ), ψ(x;z), and ζ(x;ū), respectively. Given i ∈ Z + , let µ i be the normalized counting measure on G i . Let I be the set of i ∈ Z + such that, for some tuplesā n . Then I ∈ U by Loś's Theorem and since M ≺ G. So there is some i ∈ I such that i ≥ n, which contradicts the choice of (G i , A i ).
The statement of the previous result is almost identical to our result from [15] on stable arithmetic regularity in arbitrary finite groups (Theorem 1.1 above), except for the presence of the error set Z. As in [15,Corollary 3.5], we can use this result to deduce a very strong graph regularity statement for bipartite graphs defined by NIP subsets of finite groups of uniformly bounded exponent.
One can show that if (X, Y ) is uniformly ǫ 2 -good then it is ǫ-regular, and either δ Γ (X, Y ) ≤ ǫ or δ Γ (X, Y ) ≥ 1−ǫ. In fact, a stronger property holds: if X 0 ⊆ X and Y 0 ⊆ Y are nonempty and either |X 0 | ≥ ǫ|X| or |Y 0 | ≥ ǫ|Y |, then δ Γ (X 0 , Y 0 ) ≤ ǫ or δ Γ (X 0 , Y 0 ) ≥ 1 − ǫ (see [15,Proposition 3.4]). Now suppose G is a finite group and A is a subset of G. Let Γ G (A) = (G, G; E) where E = {(x, y) ∈ G 2 : yx ∈ A}. Given X ⊆ G and g ∈ G, note that deg ΓG(A) (g, X) = |A ∩ Xg| and deg ΓG(A) (X, g) = |A ∩ gX|. We now observe that Theorem 3.2 implies a graph regularity statement for NIP subsets of finite groups of uniformly bounded exponent, in which the partition is given by cosets of a normal subgroup and almost all pairs are uniformly good (and thus regular up to a change in ǫ). Given a group G, a normal subgroup H ≤ G, and C, D ∈ G/H, let C · D denote the product of C and D in the quotient group G/H. Corollary 3.3. For any k, r ≥ 1 and ǫ > 0 there is n(k, r, ǫ) such that the following holds. Suppose G is a finite group of exponent r and A ⊆ G is k-NIP. Then there is a normal subgroup H of index n ≤ n(k, r, ǫ), and set Σ ⊆ (G/H) 2 , with |Σ| ≤ ǫn 2 , such that any (C, D) ∈ Σ is uniformly ǫ-good for Γ G (A).
Proof. Fix k, r ≥ 1 and ǫ > 0 and let n(k, r, ǫ) be as in Theorem 3.2. Fix a finite group G and a k-NIP set A ⊆ G. Then there is a normal subgroup H ≤ G of index n ≤ n(k, r, ǫ), and a set I ⊆ G/H with |I| ≤ ǫn, such that for any C ∈ I, either Remark 3.4. In Theorem 3.2, the assumption of uniformly bounded exponent was used to obtain a certain profinite quotient, and so it is worth reviewing this argument from a more general perspective. Specifically, fix k ≥ 1 and consider the following property of a class G of finite groups: ( * ) k For any sequences ( and for any ultrafilter U on N, if G is a sufficiently saturated elementary extension of U (G i , A i ), then G/G 00 θ r is profinite, where θ(x; y) := A(y · x). Then, for any G satisfying ( * ) k and any ǫ > 0, there is some n = n(k, ǫ, G) such that any group G ∈ G and k-NIP set A ⊆ G satisfy the conclusions of Theorem 3.2 using n. Indeed, Theorem 3.2 only uses that for any k, r ≥ 1, the class G r of finite groups of exponent r satisfies ( * ) k , for the rather heavy-handed reason that compact torsion groups are profinite.
Profinite quotients also arise in the stable setting (recall that A ⊆ G is k-stable if Γ G (A) omits ([k], [k]; ≤) as an induced subgraph). In fact, if G is pseudofinite and saturated, and θ(x;ȳ) is a stable invariant formula, then the group G/G 00 θ r is finite (see [14,Corollary 3.17]). Therefore, in this case, the set E in Theorem 2.14(d) is empty since it is a Haar null set in a finite group. So, if one replaces "NIP" with "stable" in Lemma 2.16 and Theorem 3.1, then one can choose the error set Z = ∅, and a similar ultraproduct argument as in Theorem 3.2 yields Theorem 1.1 (structure and regularity for stable subsets of finite groups). 14

Bohr neighborhoods
In this section, we recall some basic definitions and facts concerning Bohr neighborhoods, and define an approximate version of Bohr neighborhoods, which we will need for later arguments involving ultraproducts.
Given a group G, 1 G denotes the identity (if G is abelian we use 0 G ). We say that the pair (L, d) is a compact metric group if L is a compact metrizable group and d is a bi-invariant metric on L compatible with the topology. By Fact 2.3(e), if L is any compact second-countable group then there is a (not necessarily unique) bi-invariant metric d on L such that (L, d) is a compact metric group.
Our ultimate goal is to transfer Bohr neighborhoods in pseudofinite groups to Bohr neighborhoods in finite groups. To do this, we will need to approximate Bohr neighborhoods by definable objects. This necessitates an approximate notion of a Bohr neighborhood, which involves approximate homomorphisms of groups.
14 It is worth noting that this explanation of Theorem 1.1 is not a faster proof than what is done in [15]. In particular, [14, Corollary 3.17] relies on the same results from [30] used in [15] to directly prove Theorem 1.1. Also, pseudofiniteness is not needed to prove that G/G 00 θ r is finite.

Definition 4.2.
Let H be a group and let (L, d) be a compact metric group.
Approximate homomorphisms have been studied extensively in the literature, with a special focus on the question of when an approximate homomorphism is "close" to an actual homomorphism. For our purposes, this is what is needed to replace approximate Bohr neighborhoods with actual Bohr neighborhoods. More precisely, we will start with a definable approximate Bohr neighborhood in a pseudofinite group, and transfer this to find an approximate Bohr neighborhood in a finite group. At this point, we will be working with an approximate homomorphism from a finite group to a compact Lie group, which is a setting where one can always find a genuine Bohr neighborhood inside an approximate Bohr neighborhood, with a negligible loss in size.
An easy consequence is that in the setting of compact Lie groups, Bohr neighborhoods can be found inside approximate Bohr neighborhoods. Given a compact metric group (L, d) and n ≥ 1, note that we have a compact metric group (L n , d n ), where L n is endowed the product topology and d n (x,ȳ) = max 1≤i≤n d(x i , y i ). Proof. Fix α L > 0 from Theorem 4.3. Suppose H is a compact group, and Y ⊆ H is a δ-approximate (3δ, L n )-Bohr neighborhood in H, for some n ∈ N and 0 < δ < α L , witnessed by a δ-homomorphism f : H → L n . We may assume n ≥ 1. For 1 ≤ i ≤ n, let f i : H → L be given by f i (x) = f (x) i . Then each f i is a δ-homomorphism. Given 1 ≤ i ≤ n, Theorem 4.3 provides a homomorphism τ i : H → L such that d(f i (x), τ i (x)) < 2δ for all x ∈ H. Let τ : H → L n be such that τ (x) = (τ 1 (x), . . . , τ n (x)). Then τ is a homomorphism and d n (f (x), τ (x)) < 2δ for all x ∈ H. Now we have B L n τ,δ ⊆ Y by the triangle inequality. The next result provides a lower bound on the size of Bohr neighborhoods in finite groups. The proof is a standard averaging argument (adapted from the abelian case; see [51,Lemma 4.20] and/or [24, Lemma 4.1]). We include the details for the sake of clarity and to observe that the method works for Bohr neighborhoods in nonabelian finite groups defined using compact metric groups. Then So there must be some t ∈ L such that x∈H f x (t) ≥ ℓ δ |H|. In other words, if S = {x ∈ H : d(τ (x), t) < δ} then |S| ≥ ℓ δ |H|. Fix a ∈ S. For any x ∈ S, we have Therefore Sa -1 ⊆ B L τ,2δ , and so |B L τ,2δ | ≥ |Sa -1 | = |S| ≥ ℓ δ |H|.
Remark 4.6. As we have seen in previous results (e.g., Lemma 2.9), real tori of the form T r have a distinguished role in the study of compact abelian groups. Moreover, in the setting of finite abelian groups, Bohr neighborhoods are usually defined using homomorphisms to the torus (see, e.g., [7], [24]). Thus, in order to match these definitions more explicitly, we define the metric d T 1 (x, y) = min{|x − y|, 1 − |x − y|} on T 1 (identified with [0, 1)) and the product metric d T r := d r T 1 on T r for r ∈ N. Throughout the rest of the paper, when we speak of T r as a compact metric group, will always work with this choice of metric.
Definition 4.7. Given a finite group H, a homomorphism τ : H → T r , and some δ > 0, we let B r τ,δ denote B T r τ,δ . We call B ⊆ H a (δ, r)-Bohr neighborhood in H if B = B r τ,δ for some τ . 15 In Theorem 3.2, we showed that NIP sets in finite groups of uniformly bounded exponent are approximated by normal subgroups of uniformly bounded index. As noted in the introduction, we cannot expect such a result for NIP sets in finite groups G of unrestricted exponent. So instead of subgroups of G, we will consider pairs (B, H), where H is a normal subgroup of G and B is a (δ, r)-Bohr neighborhood in H. Thus, in Proposition 4.9 below, we point out some ways in which Bohr neighborhoods behave like normal subgroups of "small" index. We will need the following minor generalization of a well-known exercise, namely, if G is an amenable group and A ⊆ G has positive upper density then AA -1 is generic. Proposition 4.8. Suppose G is a group, B is a left-invariant Boolean algebra of subsets of G, and ν is a left-invariant finitely additive probability measure on B. Suppose A ∈ B is such that ν(A) > 0. Then, for any X ⊆ G, there is a finite set F ⊆ X such that |F | ≤ 1 ν(A) and X ⊆ F AA -1 . Proof. We say that Y ⊆ G separates A if xA ∩ yA = ∅ for all distinct x, y ∈ Y . By the assumptions on ν, if Y ⊆ G separates A then |Y | ≤ 1 ν(A) . Choose a finite set F ⊆ X with maximal size among subsets of X that separate A. Fix x ∈ X. Then there is y ∈ F such that xA ∩ yA = ∅, and so we may fix z ∈ xA ∩ yA. Then y -1 z ∈ A and z -1 x ∈ A -1 , which means y -1 x ∈ AA -1 , and so x ∈ F AA -1 . Proposition 4.9. Let G be a finite group and H ≤ G be a normal subgroup of index n. Suppose B is a (δ, r)-Bohr neighborhood in H, where r ∈ N and 0 < δ ≤ 2. (a) B = B -1 , 1 G ∈ B, and gB = Bg for any g ∈ G.
(b) For any X ⊆ G there is F ⊆ X such that |F | ≤ n( 2 δ ) r and X ⊆ F B. Thus G is covered by at most n( 2 δ ) r translates of B.
Proof. Part (a). We have B = B -1 by bi-invariance of d T r , and clearly 1 G ∈ B. If g ∈ G and x ∈ B then gxg -1 ∈ H (since H is normal), and so gxg -1 ∈ B by bi-invariance of d T r . It follows that gB = Bg for any g ∈ G.
Part (b). Suppose B = B r τ,δ for some τ : H → T r , and let B 0 = B r τ,δ/2 . Note that η T r ({t ∈ T r : d T r (t, 0 T r ) < δ 4 }) = ( δ 2 ) r , and so |B 0 | ≥ ( δ 2 ) r |H| = n -1 ( δ 2 ) r |G| by Proposition 4.5. Now fix X ⊆ G. By Proposition 4.8 (with ν the normalized counting measure on G), we have So B 0 B -1 0 ⊆ B, and we have X ⊆ F B. Note that part (a) of the previous fact holds for any compact metric group (L, d) in place of T r (and does not use that G is finite); and the analogue of part (b) holds for any (L, d) with ( δ 2 ) r replaced by ℓ δ/4 (from Proposition 4.5). We refer the reader to [51,Section 4.4] and [24,Sections 3 & 4] for more on the role of Bohr neighborhoods in arithmetic combinatorics and discrete Fourier analysis.

Structure and regularity: the general case
The next goal is a result analogous to Theorem 3.1, but without the assumption that G/G 00 θ r is profinite. For this, we need to understand more about descriptions of G 00 θ r as an intersection of definable subsets of G. The goal is to find properties of definable sets which are both interesting algebraically, and also sufficiently first-order so that they can be transferred to finite groups in arguments with ultraproducts. In particular, we will use approximate Bohr neighborhoods.
Suppose G is a group definable in a sufficiently saturated structure, and Γ ≤ G is a type-definable normal subgroup of bounded index. By Lemma 2.9, Γ is an intersection of a bounded number of definable finite-index normal subgroups of G whenever G/Γ is profinite. The next result shows that in general, we can write Γ = i∈I W i where each W i is a definable subset of a definable finite-index normal subgroup H i ≤ G, and there is a Bohr neighborhood B i in H i such that Γ ⊆ B i ⊆ W i . Moreover, B i is obtained from a definable homomorphism to a compact connected Lie group (so, in particular, B i is co-type-definable).
Proposition 5.1. Let G be a group definable in a sufficiently saturated structure M * . Suppose Γ ≤ G is type-definable and normal of bounded index. Then there is a bounded jsl I and a decreasing net (W i ) i∈I of definable subsets of G such that Γ = i∈I W i and, for all i ∈ I, there are * a definable finite-index normal subgroup is a compact connected metric Lie group, and * a real number δ i > 0, such that Γ ⊆ ker π i ⊆ B Li πi,δi ⊆ W i ⊆ H i . Moreover: (a) If Γ is countably-definable then we may assume I = N. (b) If G = M * and Γ is θ-type-definable for some invariant formula θ(x;ȳ), then we may assume W i , H i , and π i are θ-definable. (c) If G = M * and G is pseudofinite, then we may assume L i = T ni for some n i ∈ N. (d) If G/Γ is abelian then we may assume H i = G and L i = T ni for some n i ∈ N.
Proof. Let (Γ i ) i∈I0 and (H i ) i∈I0 be as in Lemma 2.9, where I 0 is a small jsl. For each i ∈ I 0 , let L i = H i /Γ i and equip L i with some bi-invariant metric d i (by Fact 2.3(e)). Let π i : H i → L i be the canonical homomorphism. Then π i is definable since G → G/Γ i is definable.
For each i ∈ I 0 , let (W i n ) ∞ n=0 be a decreasing sequence of definable subsets of G such that Γ i = ∞ n=0 W i n . Let I be the set of all finite subsets of I 0 × N, and view I as a jsl under the subset ordering. Given σ = {(i 1 , n 1 ), . . . , (i k , n k )} ∈ I, let i σ = sup{i 1 , . . . , i k }, and set H σ := H iσ , W σ := H σ ∩ k t=1 W it nt , Γ σ := Γ iσ , L σ = L iσ , and π σ = π iσ . Note that Γ σ ⊆ W σ ⊆ H σ for all σ ∈ I, and σ∈I W σ = Γ. By choice of i σ , we also have that (W σ ) σ∈I is decreasing. Now, given σ ∈ I, the set U σ = {aΓ σ ∈ G/Γ σ : aΓ σ ⊆ W σ } is an identity neighborhood in L σ (by Fact 2.4(b)) and, by construction, π -1 σ (U σ ) ⊆ W σ . So choose δ σ > 0 such that U σ contains the open ball of radius δ σ around 1 Lσ . Note that Γ ⊆ Γ σ = ker π σ ⊆ B Lσ πσ,δσ ⊆ W σ . This finishes the proof of the main statement. We now deal with the remaining claims. Claims (b) and (c) follow by applying Lemma 2.9(b, d) in the above construction. For claim (a), suppose Γ is countablydefinable. Then, by Lemma 2.9(a), we may assume I 0 = N. So I is the jsl of finite subsets of N × N under the subset ordering, which contains a cofinal sub-jsl isomorphic to N.
Finally, for claim (d), suppose G/Γ is abelian. Then G/Γ i is a compact abelian Lie group for any i ∈ I 0 , and thus isomorphically embeds in T ni for some n i ∈ N by Fact 2.3(g). So in the argument above, we can replace each H i and π i with G and G → G/Γ i ⊆ T ni , respectively.
Note that in the previous result, the homomorphism π i : H i → L i is also surjective, except in part (d) where we can replace H i with G when G/Γ is abelian. The purpose of part (d) is to note that if G is already abelian then one can obtain Bohr neighborhoods defined by tori without first passing to a subgroup H i , and without Theorem 2.7 or an extra pseudofiniteness assumption.
One drawback of Proposition 5.1 is that the Bohr neighborhood B Li πi,δi is not necessarily definable. In order to work with definable objects, we will have to consider approximate Bohr neighborhoods.
Definition 5.2. Let G be a group definable in a sufficiently saturated structure M * . Suppose H ≤ G is definable and π : H → L is a definable homomorphism to a compact metric group (L, d). Given t ≥ 1, we say that a sequence ( Moreover, if G = M * and H, π, and f m are all θ-definable, for some fixed formula θ(x;ȳ), then we say "θ-definable" in place of "definable".
m=0 is a definable (respectively, θ-definable) (t, π)approximate Bohr chain in H ≤ G, as in Definition 5.2. Then each set Y m is a δ m -approximate (tδ m , L)-Bohr neighborhood in H, and a definable (respectively, θ-definable) subset of G. 16 Proof. The first claim is obvious. For definability, note that for any m ∈ N, H is partitioned into finitely many fibers f -1 m (λ) for λ ∈ f m (H), each of which is definable (respectively, θ-definable) by Remark 2.6. Now Y m is a union of the (finitely many) fibers f -1 m (λ) where λ ∈ f (H) is such that d(λ, 1 L ) < ǫ. The parameter t in Definition 5.2 is introduced in order to control the "width" ǫ and the "error" δ in a δ-approximate (ǫ, L)-Bohr neighborhood. Specifically, it is desirable to have ǫ be some constant multiple t of δ, and in the following results we will choose t arbitrarily. This will eventually be used to find actual Bohr neighborhoods inside approximate Bohr neighborhoods, with L = T n for some n ∈ N, in which case setting t = 3 will suffice (via Corollary 4.4).
Lemma 5.4. Let G be a group definable in a sufficiently saturated structure M * . Suppose H is a definable subgroup of G and π : H → L is a definable homomorphism to a compact metric group (L, d). Then, for any t ≥ 1, there is a definable (t, π)approximate Bohr chain (Y m ) ∞ m=0 in H. Moreover, if G = M * and H and π are θ-definable for some invariant formula θ(x;ȳ), then (Y m ) ∞ m=0 is a θ-definable (t, π)-approximate Bohr chain.
thinning the sequence, we may assume Y m+1 ⊆ Y m for all m ∈ N. Altogether, if δ m = 3 m , then (δ m ) ∞ m=1 and (f m ) ∞ m=1 witness that (Y m ) ∞ m=1 is a definable (t, π)approximate Bohr chain in H.
For the "moreover" statement, suppose G = M * , and H and π are θ-definable for some formula θ(x;ȳ). Then one can choose each D λ to be θ-definable (by Remark 2.6). So each f m is θ-definable by construction, and (Y m ) ∞ m=1 is a θ-definable (t, π)approximate Bohr chain.
We now combine the above ingredients to prove a structure and regularity theorem for θ r -definable sets in a sufficiently saturated pseudofinite group G, where θ(x;ȳ) is an arbitrary invariant NIP formula. Recall that we use µ for the pseudofinite counting measure.
Theorem 5.5. Let G be a sufficiently saturated pseudofinite expansion of a group, and suppose θ(x;ȳ) is an invariant NIP formula. Fix a θ r -definable set A ⊆ G and some ǫ > 0. Then there are * a θ r -definable finite-index normal subgroup H ≤ G, * a θ r -definable homomorphism π : H → T n , for some n ∈ N, and * a θ r -definable set Z ⊆ G, with µ(Z) < ǫ, such that, for any integer t ≥ 1, there is * a θ r -definable (t, π)-approximate Bohr chain (Y m ) ∞ m=0 in H satisfying the following properties, for any m ∈ N. Moreover, if G/G 00 θ r is abelian then we may assume H = G.
Proof. Let (W i ) ∞ i=0 be a sequence of θ r -definable sets in G satisfying the conditions of Proposition 5.1 with Γ = G 00 θ r . By Lemma 2.16, there is a θ r -definable set Z ⊆ G and some i ∈ N such that µ(Z) < ǫ and, if W := W i , then for all g ∈ G\Z, we have µ(gW ∩ A) = 0 or µ(gW \A) = 0. Proposition 5.1 associates to W a θ r -definable homomorphism π : H → T n , where H is a θ r -definable finite-index normal subgroup of G. If G/G 00 θ r is abelian then we may further assume H = G. Fix t ≥ 1. By Lemma 5.4, there is a θ r -definable (t, π)-approximate Bohr chain (Y m ) ∞ m=0 in H. Recall that each Y m is definable by Proposition 5.3. Since ker π is type-definable and contained in the definable set W , it follows from saturation that Y m ⊆ W for sufficiently large m. So for sufficiently large m we have that, for any g ∈ G\Z, either µ(gY m ∩ A) = 0 or µ(gY m \A) = 0. Thus, after removing finitely many sets Y m from the sequence, we have condition (ii).
Toward proving condition (i), fix m ∈ N. Since ker π is a subgroup of H, we may use saturation (similar to as in the proof of Lemma 2.16), to find some r ≥ m such that Y r Y -1 r ⊆ Y m . Since Y r contains a type-definable bounded-index subgroup of G (namely, ker π), it follows that Y r is generic and so µ(Y r ) > 0. By Proposition 4.8, there is a finite set F ⊆ G\Z such that G\Z ⊆ F Y m . Let I be the set of g ∈ F such that µ(gY m \A) = 0, and note that if g ∈ F \I then µ(gY m ∩ A) = 0. Let The next goal is our main result for NIP sets in arbitrary finite groups (see Theorem 5.7). Roughly speaking, we will show that if A is a k-NIP set in a finite group G, then there is a normal subgroup H ≤ G, and Bohr neighborhood B in H, such that almost all translates of B are almost contained in A or almost disjoint from A (up to some error ǫ > 0). Moreover, A is approximately a union of translates of B, and the index of H and complexity of B are bounded in terms of k and ǫ.
The proof of Theorem 5.7 from Theorem 5.5 is of course in analogy to the proof of Theorem 3.2 from Theorem 3.1. However, the argument is significantly more complicated, due to certain crucial differences between Bohr neighborhoods and subgroups. Specifically, Bohr neighborhoods are not closed under the group operation and, moreover, distinct translates of a Bohr neighborhood need not be disjoint. 17 Thus, when using Theorem 5.5 to obtain results for finite groups, we will focus solely on the regularity statement. In order to then deduce structure from regularity in finite groups, we will need to argue similarly as in the end of the proof of Theorem 5.5, while also taking into account the quantitative behavior of Bohr neighborhoods described in Propositions 4.5 and 4.9. So we first prove a lemma, which gives a rather flexible version of the regularity statement, and also contains the ultraproduct argument necessary to prove Theorem 5.7.
Lemma 5.6. For any k ≥ 1 and ǫ > 0, and any function γ : (Z + ) 2 × (0, 1] → R + , there is n = n(k, ǫ, γ) such that the following holds. Suppose G is a finite group and A ⊆ G is k-NIP. Then there are * a normal subgroup H ≤ G of index m ≤ n, * a (δ, r)-Bohr neighborhood B in H and a δ-approximate (3δ, r)-Bohr neighborhood Y in H, where r ≤ n and 1 n ≤ δ ≤ 1, and * a set Z ⊆ G, with |Z| < ǫ|G|, such that B ⊆ Y ⊆ H and, for any g ∈ G\Z, either |gY ∩ A| < γ(m, r, δ)|B| or |gY \A| < γ(m, r, δ)|B|. Moreover, H, Y , and Z are in the Boolean algebra generated by {gAh : g, h ∈ G}, and if G is abelian then we may assume H = G.
Proof. Suppose not. Then we have k ≥ 1, ǫ > 0, and γ : (Z + ) 2 × (0, 1] → R + witnessing this. In particular, for any n ≥ 1, there is a finite group G n and a k-NIP subset A n ⊆ G n such that, for any H, B, Y, Z ⊆ G n , if * H is a normal subgroup of G n of index m ≤ n, and H = G n if G n is abelian, * H, Y , and Z are in the Boolean algebra generated by {gA n h : g, h ∈ G n }, * B is a (δ, r)-Bohr neighborhood in H and Y is a δ-approximate (3δ, r)-Bohr neighborhood in H, where r ≤ n and 1 n ≤ δ ≤ 1, * |Z| < ǫ|G n |, and B ⊆ Y ⊆ H, then there is some g ∈ G n \Z such that |gY ∩ A n | ≥ γ(m, r, δ)|B| and |gY \A n | ≥ γ(m, r, δ)|B|.
Let L be the group language together with an extra predicate A, and consider each (G n , A n ) as a finite L-structure. Let U be a nonprincipal ultrafilter on Z + , and let G be a sufficiently saturated elementary extension of M := U (G n , A n ). We identify A = A(G). Let θ(x; y) be the formula A(y · x). Note that θ(x; y) is invariant, and k-NIP (in G) by Loś's Theorem and since M ≺ G. Finally, let α := min{α T 1 , 1}, where α T 1 > 0 is as in Corollary 4.4. By Theorem 5.5 (with t = 3), there are θ r -definable sets Y, Z ⊆ G (for Y we obtain θ r -definability via Proposition 5.3), a θ r -definable finite-index normal subgroup H ≤ G, and a θ rdefinable δ-homomorphism f : H → T r , for some r ∈ N and 0 < δ < α, such that: Fix θ r -formulas φ(x;ȳ), ψ(x;z), ζ(x;ū), and ξ λ (x;v λ ) for λ ∈ Λ (without parameters) such that H, Y , Z, and F (λ) for λ ∈ Λ are defined by instances of φ(x;ȳ), ψ(x;z), ζ(x;ū), and ξ λ (x;v λ ), respectively. Given n ∈ N, let µ n denote the normalized counting measure on G n . Let d denote d T r . Define I ⊆ Z + to be the set of n ∈ Z + such that, for some tuplesā n ,b n ,c n , andd n,λ for λ ∈ Λ, (i) φ(x;ā n ) defines a normal subgroup H n of G n of index m, and if G is abelian then so is H n = G n , (ii) ζ(x;c n ) defines a subset Z n with µ n (Z n ) < ǫ, (iii) for each λ ∈ Λ, ξ λ (x;d n,λ ) defines a subset F n (λ) of H n , and (F n (λ)) λ∈Λ forms a partition of H n , (iv) if f n : H n → Λ is defined so that f n (x) = λ if and only if x ∈ F n (λ), then f n is a δ-homomorphism from H n to T r , (v) ψ(x;b n ) defines the set Y n = {x ∈ H n : d(f n (x), 0 T r ) < 3δ}, and (vi) for all g ∈ G n \Z n , either µ n (gY n ∩ A n ) < ǫ * or µ n (gY n \A n ) < ǫ * . We claim that I ∈ U by Loś's Theorem and since M ≺ G. In other words, the claim is that conditions (i) through (vi) are first-order expressible (possibly using the expanded language discussed in Remark 2.13). This is clear for (i), (ii), (iii), and (vi), and the only subtleties lie in (iv) and (v). In both cases, the crucial point is that Λ is finite, and so these conditions can be described by first-order sentences (using similar ideas as in Proposition 5.3). For instance, to express condition (iv), fix λ ∈ Λ, and let P λ = {(λ 1 , λ 2 ) ∈ Λ 2 : d(λ, λ 1 + λ 2 ) < δ}. Let σ λ be a sentence expressing that for any x, y, if x · y ∈ F (λ) then x ∈ F (λ 1 ) and y ∈ F (λ 2 ) for some (λ 1 , λ 2 ) ∈ P (λ). Then the conjunction λ∈Λ σ λ expresses precisely that f is a δ-homomorphism. The details for condition (v) are similar and left to the reader.
We now prove the main result for NIP subsets of arbitrary finite groups.
Theorem 5.7. For any k ≥ 1 and ǫ > 0 there is n = n(k, ǫ) such that the following holds. Suppose G is a finite group and A ⊆ G is k-NIP. Then there are * a normal subgroup H ≤ G of index m ≤ n, * a (δ, r)-Bohr neighborhood B in H, where r ≤ n and 1 n ≤ δ ≤ 1, and * a subset Z ⊆ G, with |Z| < ǫ|G|, satisfying the following properties.
(i) (structure) There is a set D ⊆ G, which is a union of at most m( 2 δ ) r translates of B, such that |(A △ D)\Z| < ǫ|B|.
(ii) (regularity) For any g ∈ G\Z, either |gB ∩ A| < ǫ|B| or |gB\A| < ǫ|B|. Moreover, H and Z are in the Boolean algebra generated by {gAh : g, h ∈ G}, and if G is abelian then we may assume H = G.
For condition (i), we argue as in the proof of Theorem 5.5. First, by Proposition 4.9(b), there is a set F ⊆ G\Z such that |F | ≤ m( 2 δ ) r and G\Z ⊆ F B. Let I = {g ∈ F : |gB\A| < γ(m, r, δ)|B|}, and note that if g ∈ F \I then |gB ∩A| < γ(m, r, δ)|B|. Let D = IB. Since G\Z ⊆ F B, we have We end this section with some remarks on NIP subsets of finite simple groups. To motivate this, we first consider the stable case. In particular, given k ≥ 1 and ǫ > 0, it follows immediately from Theorem 1.1 that if G is a sufficiently large (depending on k and ǫ) finite simple group, and A ⊆ G is k-stable, then |A| < ǫ|G| or |A| > (1 − ǫ)|G|. On the other hand, this conclusion fails for NIP subsets of abelian finite simple groups (e.g., by the examples of NIP sets in Z/pZ mentioned in the introduction). So it is interesting to observe that for nonabelian finite simple groups, one recovers the same "triviality" for NIP sets.
Proof. Let m = n(k, ǫ 2 ) be as in Theorem 5.7. Suppose G is a nonabelian finite simple group, with |G| > m, and A ⊆ G is k-NIP. Then we have a normal subgroup H ≤ G of index at most m, a (δ, r)-Bohr neighborhood B in H (for some δ and r), a set Z ⊆ G with |Z| < ǫ 2 |G|, and a union D of translates of B such that |(A △ D)\Z| < ǫ 2 |B|. So |A △ D| ≤ |(A △ D)\Z| + |Z| < ǫ|G|. Since G is simple and |G| > m, we have H = G. Now B contains the kernel K of a homomorphism from G to T r . So G/K is abelian, which implies K = B = G since G is simple and nonabelian. Now D is either ∅ or G, and the result follows.
The previous proof highlights the significance of obtaining Bohr neighborhoods defined from abelian compact Lie groups, which is ultimately possible thanks to Theorem 2.7.
Remark 5.9. Corollary 5.8 is one of the few results on NIP sets in nonabelian finite groups for which we know an explicit bound. Specifically, in [12], the first author used techniques of Alon, Fox, and Zhao [3] and a result of Gowers [22] on "quasirandom" groups to obtain the bound m = exp(c(90/ǫ) 6k−6 ) in Corollary 5.8, where c is an absolute constant (see [12,Remark 8.7]).
As for stable sets, the proofs of Corollaries 1 and 3 in [53] yield an explicit lower bound of the form |G| ≥ exp(c k (ǫ -d k )) for the analogue of Corollary 5.8 in which A is k-stable and G is an abelian finite simple group (i.e., a cyclic group of prime order). The work in [13] removes the exponential and yields improved values for the constants c k , d k (see [13,Theorem 1.3]).

Distal arithmetic regularity
In this section, we adapt the preceding results to the case of NIP fsg groups with smooth left-invariant measures (e.g., fsg groups definable in distal theories). In contrast to previous results, where we focused on a single NIP formula, here we will operate in the setting of groups definable in an NIP theory.
In this section, we let T be a complete theory and we work in a saturated model M * . Given M M * and an M -definable set X in M * , a Keisler measure on X over M is a finitely additive probability measure defined on the Boolean algebra of M -definable subsets of X. If M * = M then µ is a global Keisler measure on X. If T is NIP, then a global Keisler measure µ on a definable set X is generically stable if there is a small model M ≺ M * such that X is M -definable, µ is Mdefinable (i.e., for any formula φ(x;ȳ) with x in the same sort as X, We note that this is not the original definition of fsg (which is given in [29]), but rather the right characterization (in NIP theories) for our purposes (see [29,Proposition 6.2] and [32,Remark 4.2]). The significance of this notion in the context of our work is illustrated by the following example.
Example 6.2. If T is NIP and G is a definable pseudofinite group, then G is fsg since the pseudofinite counting measure on G is generically stable. This follows directly from the VC-Theorem (see, e.g., [46,Example 7.32], [14,Section 2]).
The fsg property for a definable group in an NIP theory has strong consequences. For example, we will use the following result from [31]. [31,Theorem 7.7]). An fsg group definable in an NIP theory admits a unique left-invariant Keisler measure µ, which is also the unique right-invariant Keisler measure.
In NIP theories, definable fsg groups also satisfy a generic compact domination statement similar to Theorem 2.14(d) (see [48,Corollary 4.9]). However, in this section, we focus on a certain strengthening of generic compact domination for definable fsg groups in NIP theories whose unique left-invariant Keisler measure is smooth. If T is NIP, then any smooth measure is generically stable (see Proposition 7.10 and Theorem 7.29 in [46]), and so any definable group with a smooth left-invariant Keisler measure is fsg. A place to find smooth measures is in the setting of distal theories, which were introduced by Simon in [45]. For our purposes we will take the following characterization as a definition of distality (see [45,  So, in particular, if T is distal and G is a definable fsg group, then the unique leftinvariant Keisler measure on G is smooth. In [46,Proposition 8.41], Simon shows that if T is countable and NIP, and G is a definable group with a smooth leftinvariant Keisler measure, then generic compact domination for G can be strengthened to outright "compact domination". We give a formulation of this result suitable for our applications. First, recall that if T is NIP and G is a definable group, then G has a smallest type-definable subgroup of bounded index, denoted G 00 , which is an intersection of at most |T | definable sets (see [44] and/or [29, Proposition 6.1]). The reader should compare the following result to Lemma 2.16. Lemma 6.6. Assume T is countable and NIP, and G is a definable fsg group. Let µ be the unique left-invariant Keisler measure on G, and assume µ is smooth. Let i=0 be a decreasing sequence of definable sets such that G 00 = ∞ i=0 W i . Fix a definable set A ⊆ G. Then, for any ǫ > 0, there is a definable set Z ⊆ G and some i ∈ N such that µ(Z) < ǫ and, for any g ∈ G\Z, either gW i ∩ A = ∅ or gW i ⊆ A.
Proof. Let F = {C ∈ G/G 00 : C ∩ A = ∅ and C ∩ (G\A) = ∅}. Then F is closed by Fact 2.4(b), and η G/G 00 (F ) = 0 by [46,Proposition 8.41]. Now fix ǫ > 0. By Fact 2.4(e), there is a definable set Z ⊆ G such that µ(Z) < ǫ and {a ∈ G : aG 00 ∈ F } ⊆ Z. By saturation of G and since (W i ) ∞ i=0 is decreasing, there is some i ∈ N such that for any g ∈ G\Z, either gW i ∩ A = ∅ or gW i ⊆ A.
We now prove analogues of Theorems 3.1 and 5.5 for an fsg group G, definable in an NIP theory, such that the unique left-invariant Keisler measure on G is smooth. In these results, the assumptions are stronger in the sense that the whole theory is assumed to be NIP. Moreover, in the conclusions we have definability of the data, but no claims about definability in a certain Boolean fragment (see Remark 6.9).
On the other hand, we have outright inclusion or disjointness, rather than up to ǫ, which yields stronger structure and regularity statements. Theorem 6.7. Assume T is NIP. Let G be a definable fsg group, and let µ be the unique left-invariant Keisler measure on G. Suppose µ is smooth (e.g., if T is distal) and G/G 00 is profinite. Fix a definable set A ⊆ G and some ǫ > 0. Then there are * a definable finite-index normal subgroup H of G, and * a set Z ⊆ G, which is a union of cosets of H with µ(Z) < ǫ, satisfying the following properties.
(i) (structure) A\Z is a union of cosets of H.
Proof. The proof is similar to that of Theorem 3.1. First, we may restrict to a countable language in which G and A are definable and µ is still smooth (see [46,Lemma 7.8] and subsequent remarks). By Fact 2.3(c), we also preserve the hypothesis that G/G 00 is profinite. By Lemma 2.9, we may fix a decreasing sequence (H i ) ∞ i=0 of definable finiteindex normal subgroups of G such that G 00 = ∞ i=0 H i . By Lemma 6.6, we have a definable set Z and some H = H i satisfying condition (ii). As in the proof of Theorem 3.1, we may assume Z is a union of cosets of H. For condition (i), set D = {g ∈ G : gH ⊆ A and gH ∩ Z = ∅}. Then D is a union of cosets of H, and D ⊆ A ⊆ D ∪ Z. Since D ∩ Z = ∅, we have A\Z = D. Now we prove the general statement. Theorem 6.8. Assume T is NIP. Let G be a definable fsg group, and let µ be the unique left-invariant Keisler measure on G. Suppose µ is smooth (e.g., if T is distal). Fix a definable set A ⊆ G and some ǫ > 0. Then there are * a definable finite-index normal subgroup H of G, * a compact connected metric Lie group (L, d), * a definable homomorphism π : H → L, and * a definable set Z ⊆ G, with µ(Z) < ǫ, such that, for any integer t ≥ 1, there is * a definable (t, π)-approximate Bohr chain (Y m ) ∞ m=0 in H, satisfying the following properties, for any m ∈ N.
(i) (structure) There is D m ⊆ G, which is a union of finitely many left translates of Y m , such that D m ⊆ A ⊆ D m ∪ Z. (ii) (regularity) For any g ∈ G\Z, either gY m ∩ A = ∅ or gY m ⊆ A. Moreover, if G is pseudofinite then we may assume L = T n for some n ∈ N; and if G/G 00 is abelian then we may assume L = T n for some n ∈ N and H = G.
Proof. The proof is similar to that of Theorem 5.5. First, as in the proof of Theorem 6.7, we may assume T is in a countable language. Let (W i ) ∞ i=0 be a decreasing sequence of definable subsets of G satisfying the conditions of Proposition 5.1, with Γ = G 00 . By Lemma 6.6, there is a definable set Z ⊆ G and some i ∈ N such that µ(Z) < ǫ and, if W := W i , then for all g ∈ G\Z, either gW ∩ A = ∅ or gW ⊆ A. Proposition 5.1 associates to W a definable homomorphism π : H → L, with ker π ⊆ W , where H is a definable finite-index normal subgroup of G and (L, d) is compact connected metric Lie group. Note also that the "moreover" statement is given by Proposition 5.1. By Lemma 5.4, there is a definable (t, π)-approximate Bohr chain (Y m ) ∞ m=0 in H. By saturation, if m is sufficiently large then Y m ⊆ W and so if g ∈ G\Z then either gY m ∩ A = ∅ or gY m ⊆ A. This yields condition (ii). For condition (i), mimic the end of the proof of Theorem 5.5 to find D m ⊆ G, which is a union of finitely many left translates of Y m , such that D m ⊆ A ⊆ D m ∪ Z (replace each occurrence of µ(A ∩ gY m ) = 0 with A ∩ gY m = ∅, and each occurrence of µ(A\gY m ) = 0 with gY m ⊆ A).
Since Theorems 6.7 and 6.8 use global assumptions on the theory, a fully general statement for applications to finite groups would be rather cumbersome to state. However, one concludes, in a routine fashion, structure and regularity for suitable families of finite groups, for example a collection G of finite L-structures expanding groups, such that any completion of Th(G) is distal. In the next section, we will discuss an application to the family of finite groups obtained as quotients of a compact p-adic Lie group by its open normal subgroups. Remark 6.9. Results along the lines of Theorems 3.1 and 5.5 can also be shown for fsg groups definable in NIP theories, but without the smoothness assumption. Indeed, such groups satisfy generic compact domination just as in Theorem 2.14(d), but with G 00 θ r replaced by G 00 (see [48,Corollary 4.9]). However, as discussed in [14, Remark 1.3], since the unique left-invariant measure on an NIP fsg group G is generically stable, one could fix an invariant formula θ(x;ȳ) and construct G 00 θ r as in Theorem 2.14. This yields structure and regularity theorems as before with additional information about the definability of the data. Precisely: Assume T is NIP. Suppose G is definable and fsg, and let µ be the unique leftinvariant Keisler measure on G. Without loss of generality, assume G = M * . Fix an invariant formula θ(x;ȳ). Then, for any θ r -definable A ⊆ G and any ǫ > 0, we have the conclusion of Theorem 5.5, except with T n replaced by some compact connected metric Lie group (L, d). If G/G 00 θ r is profinite, then the conclusion of Theorem 3.1 holds exactly as stated.
It would be interesting to pursue notions of smoothness for local measures, or "local distality" for formulas, and recover local versions of Theorems 6.8 and 6.7. For instance, one might consider an NIP formula θ(x,ȳ) such that every generically stable global Keisler measure on the Boolean algebra of θ-formulas is smooth.

Compact p-adic analytic groups
In this section, we apply Theorem 6.7 to the setting of compact p-adic analytic groups (see Theorems 7.3 and 7.5). We assume some familiarity with the p-adic field Q p and p-adic model theory. See [6] for further reading. The topology on Q p is given by the valuation v where open neighborhoods of a point a are defined by v(x − a) ≥ n for n ∈ Z. The topology on Q n p is the product topology. A p-adic analytic function is a function f , from some open V ⊆ Q n p to Q p , such that for every a ∈ V , there is an open neighborhood of a ∈ V in which f is given by a convergent power series. We obtain the notions of a p-adic analytic manifold and a p-adic analytic (or Lie) group. Recall that any compact p-adic analytic group is profinite (see also [43,Section 2.12.1]).
We let Q an p denote the expansion of the field (Q p , +, ·) by symbols for all convergent (in Z p ) power series in Z p [[X 1 , . . . , X n ]] for all n. Then any compact p-adic analytic manifold or group is seen to be naturally definable in the structure Q an ( * ) For someb ∈ (M * )ȳ, H := φ(M * ;b) is a normal subgroup of G = K(M * )/U i * of index n, and there is Z ⊆ G, which is a union of m cosets of H such that (A(M * )/U i * )\Z is a union of r cosets of H.
In particular, ( * ) is a property of i * that can be expressed using a formula ζ(t) over Q p . So there is n ′ ≥ n such that Q an p |= ζ(i n ′ ), which is a contradiction.
Remark 7.6. Suppose K is a compact p-adic analytic group such that the family of open normal subgroups is (eventually) linearly ordered by inclusion (e.g., K = Z p ). In this case, Theorem 7.5 can be deduced easily from Theorem 7.3. Indeed, given a definable set A ⊆ G and some ǫ > 0, let H ≤ K and Z ⊆ K be as in It is not clear whether such an argument can be given for arbitrary K (or if there is a proof of Theorem 7.5 not relying on Lemma 7.1). Note that the above assumption does not hold for every compact p-adic analytic group; for example (Z 2 p , +) does not have eventually linearly ordered open (normal) subgroups.