# Separability Properties of Monadically Dependent Graph Classes

Édouard Bonnet

<figure><img src="image_1.png" /></figure>

ID

CNRS, ENS de Lyon, Université Claude Bernard Lyon 1, LIP UMR 5668, Lyon, France

Samuel Braunfeld

<figure><img src="image_2.png" /></figure>

ID

Computer Science Institute, Charles University, Prague, Czech Republic; and the Czech Academy of Sciences, Institute of Computer Science, Pod Vodárenskou věží 2, 182 00 Prague, Czech Republic

Ioannis Eleftheriadis

<figure><img src="image_3.png" /></figure>

ID

Department of Computer Science and Technology, University of Cambridge, UK

Colin Geniet

<figure><img src="image_4.png" /></figure>

ID

Discrete Mathematics Group, Institute for Basic Science (IBS), Daejeon, South Korea

Nikolas Mählmann

<figure><img src="image_5.png" /></figure>

ID

University of Bremen, Germany

Michał Pilipczuk

<figure><img src="image_6.png" /></figure>

ID

University of Warsaw, Poland

Wojciech Przybyszewski

<figure><img src="image_7.png" /></figure>

ID

University of Warsaw, Poland

Szymon Toruńczyk

<figure><img src="image_8.png" /></figure>

ID

University of Warsaw, Poland

## Abstract

A graph class $\mathcal{C}$ is monadically dependent if one cannot interpret all graphs in colored graphs from $\mathcal{C}$ using a fixed first-order interpretation. We prove that monadically dependent classes can be exactly characterized by the following property, which we call *flip-separability*: for every $r \in \mathbb{N}$, $\varepsilon > 0$, and every graph $G \in \mathcal{C}$ equipped with a weight function on vertices, one can apply a bounded (in terms of $\mathcal{C}$, $r$, $\varepsilon$) number of *flips* (complementations of the adjacency relation on a subset of vertices) to $G$ so that in the resulting graph, every radius-$r$ ball contains at most an $\varepsilon$-fraction of the total weight. On the way to this result, we introduce a robust toolbox for working with various notions of local separations in monadically dependent classes.

**2012 ACM Subject Classification** Mathematics of computing → Graph theory; Theory of computation → Finite Model Theory

**Keywords and phrases** Structural graph theory, Monadic dependence

**Category** Track B: Automata, Logic, Semantics, and Theory of Programming

**Funding** ÉB and CG were supported by the ANR projects TWIN-WIDTH (ANR-21-CE48-0014-01) and DIGRAPHS (ANR-19-CE48-0013-01). SB received funding from the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation programme (grant agreement No. 810115 - Dynasnet), and by Project 24-12591M of the Czech Science Foundation (GAČR), and supported partly by the long-term strategic development financing of the Institute of Computer Science (RVO: 67985807). IE was supported by a George and Marie Vergottis Scholarship awarded through Cambridge Trust, an Onassis Foundation Scholarship, and a Robert Sansom studentship. CG was further supported by the Institute for Basic Science (IBS-R029-C1). NM was supported by the German Research Foundation (DFG) with grant agreement No. 444419611. MP and WP were supported by the project BOBR that has received funding from ERC under the European Union's Horizon 2020 research and innovation programme, grant agreement No. 948057. SzT received funding from ERC grant BUKA (No. 101126229).
1 Introduction

In this work we study separability properties in well-structured dense graphs. To put our work in context, let us first review the setting of sparse graphs. An archetypal statement concerning separability is the following: Every *n*-vertex tree has a *centroid* — a vertex whose removal breaks the tree into subtrees with at most *n*/2 vertices each. This statement can be generalized to graphs of bounded treewidth: If an *n*-vertex graph *G* has treewidth *k*, then there is a set *S* of at most *k* + 1 vertices so that every connected component of *G* − *S* contains at most *n*/2 vertices. A set *S* with this property is called a *balanced vertex separator* of *G*.

One way to generalize this statement to graphs that are not necessarily tree-like is to
allow separators of larger cardinality. For instance, a classic result of Lipton and Tarjan [8]
states that every *n*-vertex planar graph has a balanced vertex separator of size *O*(√*n*).
Such *sublinear separators* are a fundamental tool in the algorithmic theory of graphs with
topological structure. In this work, we are interested in a different kind of separators, where
we still require the separator to be of bounded size, but we relax the separation requirement
to have a local, rather than a global character. The statement below represents the kind of
results we are interested in.

**► Theorem 1 ([12, Thm. 42]).** For every nowhere dense graph class *C*, *r* ∈ N, and *ε* > 0 there is some *k* ∈ N with the following property. For every *n*-vertex graph *G* ∈ *C* there is a set *S* consisting of at most *k* vertices of *G* such that every ball of radius *r* in *G* − *S* contains at most *ε* · *n* vertices.

Nowhere denseness is a very general notion of uniform, local sparseness [13]. Nowhere
dense classes include for example the class of planar graphs, all classes of bounded treewidth,
and all classes excluding a minor; see [11] for an introduction to the topic. Intuitively, the
separator *S* provided by Theorem 1 shatters the graph’s metric into small local “vicinities”,
but does not need to break the graph into components in any global sense. This way, even if
a graph does not admit any sublinear-size balanced separators in the global sense, it may
have a very small separator in the local sense; consider for instance subcubic expanders.

What would be an analogue of Theorem 1 in dense graphs? A recent line of work has
identified the model-theoretic notion of *monadic dependence* as a promising candidate for
the dense counterpart of nowhere denseness. Without going into technical details, a graph
class *C* is *monadically dependent* if there is no fixed one-dimensional first-order interpretation
that allows interpreting all graphs in vertex-colored graphs from *C*; see Section 2.3 for a
full definition. Apart from all nowhere dense classes, monadically dependent classes also
include all monadically stable classes and all classes of bounded clique- or twin-width. It
turns out that multiple characterizations of nowhere dense classes can be lifted to analogous
characterizations of monadically dependent classes (and related concepts), giving suitable
dense counterparts; see e.g. [3, 4, 7, 18] and an overview in a recent survey [15] and in
the thesis [9]. In this analogy, the concept of vertex deletion is replaced by the concept of
applying a *flip operation*: replacing all edges with non-edges and vice versa within some
subset of vertices. Note that a single flip operation can destroy multiple edges — for instance
turn a complete graph into an edgeless graph — hence this concept is well-suited to serve as
a notion of separation in the setting of dense graphs.

And indeed, it is not hard to prove that if an *n*-vertex graph *G* has cliquewidth at most *k* (cliquewidth is the dense counterpart of treewidth), then *O(*k*)* flip operations can be applied to *G* so that every component of the obtained graph has at most *n*/2 vertices. This is the dense counterpart of the aforementioned separability property of graphs of bounded treewidth. The main result of this work is the dense counterpart of Theorem 1. We phrase it
and prove it in the more general setting of vertex-weighted graphs. Here, a weighted graph is a graph $G$ equipped with a weight function $w: V(G) \to \mathbb{R}_{\ge 0}$; for $X \subseteq V(G)$, we denote $w(X) := \sum_{u \in X} w(u)$. Additionally, $\text{Ball}_G^r(v)$ denotes the set of vertices at distance at most $r$ from the vertex $v$ in the graph $G$.

**Definition 2.** A graph class $C$ is flip-separable if for every $r \in \mathbb{N}$ and $\varepsilon > 0$, there exists $k \in \mathbb{N}$ with the following property. For every graph $G \in C$ and weight function $w: V(G) \to \mathbb{R}_{\ge 0}$, there is a graph $G'$ that can be obtained by applying at most $k$ flip operations to $G$ so that

$$w(\text{Ball}_{G'}^r(v)) \le \varepsilon \cdot w(V(G)) \quad \text{for every } v \in V(G) \text{ with weight at most } \varepsilon \cdot w(V(G)).$$

**Theorem 3.** A graph class $C$ is monadically dependent if and only if it is flip-separable.

Together with the characterization of monadic dependence through flip-breakability (see Corollary 17), proposed by Dreier, Mählmann, and Toruńczyk [4], Theorem 3 corroborates the intuition that graphs from monadically dependent classes can be sparsified on a local level using few flips. In fact, we use flip-breakability in our proof, and flip-breakability can be easily derived from flip-separability (Lemma 24); so Theorem 3 can be seen as a strengthening of the result of [4]. In terms of applications, we believe that Theorem 3 will have direct consequences for the existence of modelling FO-limits for FO-convergent sequences of graphs from monadically dependent classes, similarly as is the case for Theorem 1 in the context of nowhere dense classes [10]. We defer working out this application to future work.

On our way to the proof of Theorem 3, we develop a versatile toolbox of *flip-metrics*: working with the local metric structure of a graph under various notions of flips. This toolbox is an equally important contribution of this work, and we now discuss it in more detail.

## Flip metrics and metric conversion

There are several, closely related variants of flips, and of the *metrics* they define, each of which has its advantage over the others. The emerging toolbox allows converting one variant into another, taking advantage of the benefits of each variant.

**Partition flips.** So far, we have only discussed the “operational” concept of flips, which boils down to applying a number of flip operations — complementing the adjacency relation within some set of vertices. It is equivalent, but more useful, to see this as a single operation consisting of taking a partition of the vertex set and complementing the adjacency relation within a selection of pairs of parts. Concretely, if $G$ is a graph and $\mathcal{P}$ is a partition of vertices of $G$, then a $\mathcal{P}$-flip of $G$ is any graph $G'$ that can be obtained from $G$ as follows: for every pair of parts $A, B \in \mathcal{P}$ (possibly $A = B$), either complement the adjacency relation within $A \times B$ or leave it intact. Further, call $G'$ a $k$-flip of $G$ if $G'$ is a $\mathcal{P}$-flip of $G$ for some partition $\mathcal{P}$ with $|\mathcal{P}| \le k$. It can be easily seen that if $G'$ is a $k$-flip of $G$, then $G'$ can be obtained from $G$ by applying $\mathcal{O}(k^2)$ single flip operations; and if $G'$ can be obtained from $G$ by applying $\ell$ single flip operations, then $G'$ is a $2^\ell$-flip of $G$. Hence, from now on we will use the definition of a $k$-flip of a graph as our basic notion of flips. In particular, in Definition 2 we can equivalently postulate that $G'$ is a $k$-flip of $G$.

**Definable flips.** The caveat of $k$-flips is that the definition considers an arbitrary partition $\mathcal{P}$ of the vertex set. In many arguments, particularly those concerning first-order logic, it is useful to restrict attention to some well-behaved partitions, for instance definable from a
handful of vertices. For this purpose, one considers *definable flips*, first used by Bonnet et al. [2], and then more explicitly by Gajarský et al. [7]. Concretely, if $S$ is a set of vertices of a graph $G$, then we consider the partition $\mathcal{P}_S$ in which every $s \in S$ is in its own singleton part, while the vertices $v \in V(G) \setminus S$ are partitioned according to their neighborhood in $S$, i.e. $u, v$ are in the same part if $N_G(u) \cap S = N_G(v) \cap S$, where $N_G(u)$ denotes the (open) neighborhood of $u$ in $G$. Then, $\mathcal{P}_S$-flips are called *S-definable flips*.

While definable flips are in general less powerful than classic flips, it turns out that in classes of bounded VC-dimension, every classic flip can be in some sense emulated by a definable flip. This observation is formalized in the lemma below, first proved by Bonnet et al. [2] (we use the formulation of Toruńczyk [18]). Recall that the *VC-dimension* of a graph $G$ is the maximum cardinality of a set $A \subseteq V(G)$ such that $\{N_G(v) \cap A \mid v \in V(G)\} = 2^A$; monadically dependent classes have bounded VC-dimension.

**Lemma 4 ([2, 18]).** Let $G$ be a graph of VC-dimension at most $d$ and let $G'$ be a $k$-flip of $G$. Then there is a set $S \subseteq V(G)$ with $|S| \le O(dk^2)$ and an $S$-definable flip $G''$ of $G$ so that for all $r \in \mathbb{N}$, we have

$$ \mathrm{Ball}_{G''}^r(v) \subseteq \mathrm{Ball}_{G'}^{5r}(v) \quad \text{for all } v \in V(G). $$

The right way of seeing the conclusion of Lemma 4 is that $G''$ sparsifies $G$ at least as well as $G'$, because bounded-radius balls in $G''$ are contained in bounded-radius balls in $G'$. Lemma 4 turned out to be an indispensable tool in the study of flips, see its applications in [2, 14, 18].

**Flip-metrics.** A fundamental property of vertex separators is that they are easily aggregable. For instance, let $G$ be a graph with some vertices colored red and some colored blue, and let $S_1, S_2$ be vertex sets such that every component of $G - S_1$ contains at most $p$ red vertices, and every component of $G - S_2$ contains at most $p$ blue vertices. Then, the union $S_1 \cup S_2$ is a separator achieving both properties: every component of $G - (S_1 \cup S_2)$ has at most $p$ red vertices and at most $p$ blue vertices. However, it is not obvious how to achieve this kind of aggregability in the context of flips: if $G_1, G_2$ are $k$-flips of $G$ so that every component of $G_1$ has at most $p$ red vertices and every component of $G_2$ has at most $p$ blue vertices, how do we construct a single flip $G'$ that satisfies both these properties?

A way of approaching this issue was proposed by Gajarský et al. [7] in the form of *flip-metrics*. In a nutshell, the idea is that given a set of vertices $S$, we consider all the $S$-definable flips at the same time. Concretely, for two vertices $u, v$, we define

$$ \mathrm{dist}_S(u, v) := \max\{\mathrm{dist}_{G'}(u, v) : G' \text{ is an } S\text{-definable flip of } G\}. $$

As observed in [7], this is a metric on the vertex set of $G$. Note that balls in this metric satisfy the following:

$$ \mathrm{Ball}_S^r(v) := \{u \in V(G) : \mathrm{dist}_S(u, v) \le r\} = \bigcap \{\mathrm{Ball}_{G'}^r(v) : G' \text{ is an } S\text{-definable flip of } G\}. $$

Crucially, the flip-metrics are aggregable in the following sense: for two vertex sets $S, T$ we always have $\mathrm{dist}_{S \cup T}(u, v) \ge \max(\mathrm{dist}_S(u, v), \mathrm{dist}_T(u, v))$, hence every $r$-ball in the metric $\mathrm{dist}_{S \cup T}$ is contained in the intersection of $r$-balls in the metrics $\mathrm{dist}_S$ and $\mathrm{dist}_T$.

The caveat of flip-metrics is that they no longer originate from a single graph on which one could work. Our main contribution to the theory of flips is the following lemma, which shows that in classes of bounded VC dimension, any flip-metric can be emulated by the usual distance metric in a single definable flip.
**► Lemma 5.** Let $G$ be a graph of VC-dimension at most $d$ and let $T$ be a set of vertices of $G$ of size at most $k$. Then there is a set of vertices $S$ with $|S| \le k^{\mathcal{O}(d^2)}$ and an $S$-definable flip $G'$ of $G$ such that

$$ \mathrm{Ball}_{G'}^r(v) \subseteq \mathrm{Ball}_T^{30r}(v) \quad \text{for all } v \in V(G) \text{ and } r \in \mathbb{N}. $$

Lemmas 4 and 5 show that in graph classes of bounded VC-dimension, all the discussed viewpoints — in the paragraphs *partition flips*, *definable flips*, and *flip-metrics* — are essentially equivalent, and one can easily move from one viewpoint to the other depending on specific properties that are useful in a context. We showcase this in the proof of Theorem 3, given is Section 4. However, we expect that the combination of Lemmas 4 and 5 will have further applications in the treatment of monadically dependent classes.

## Outline of the proof of Theorem 3.

Let us close this introduction by sketching the proof of our main result. We will present an incorrect proof attempt, and explain the changes needed to fix it.

We are given $G$ in the monadically dependent class $\mathcal{C}$ with weights $\mathbf{w}$, and search for a $k$-flip of $G$ in which all $r$-balls have at most an $\varepsilon$-proportion of the total weight. Using the metric conversion results, it is enough to find a bounded set $S$ for which the above holds in the flip metric $\mathrm{dist}_S$; we say that such an $S$ sparsifies $G$. We will start with $S = V(G)$ which trivially sparsifies $G$, and show that as long as $S$ is very large, it can be modified to reduce its size.

We first apply flip-breakability [4] to $S$: this states that in the very large set $S$, we can find large subsets $A_1, A_2$ with $\mathrm{dist}_F(A_1, A_2) > 2r'$ for some bounded flip $F$, and some fixed distance $r'$ we will choose later. By repeated application, we can instead find $p := \lceil \frac{1}{\varepsilon} \rceil$ (which is a constant) large subsets $A_1, \dots, A_p$ pairwise at distance $2r'$. Then the $r'$-balls around all the $A_i$s are pairwise disjoint, and one of them, say $\mathrm{Ball}_F^r(A_i)$, must have weight at most $\varepsilon \cdot \mathbf{w}(V(G))$.

We now want to modify $S$ by adding $F$ and removing all but a bounded subset $X$ of $A_i$. Since $F$ is bounded and $A_i$ is large, this will decrease the size of $S$. To show that the resulting set $S' = S - A_i + X + F$ still sparsifies $G$, we have to consider two cases:

1. If $v$ is close to $A_i$, meaning $\mathrm{dist}_F(v, A_i) \le r' - r$, then $F$ already is enough to sparsify the ball around $v$, as it is contained in $\mathrm{Ball}_F^r(A_i)$.

2. On the other hand, if $v$ at distance more than $r' - r$ from $A_i$ for an appropriately large choice of $r'$, then we would like to use a locality result to show that most of $A_i$ is irrelevant in sparsifying the ball around $v$: we can find a bounded set $X$ which emulates the behaviour of all vertices in $A_i$ and whose choice does not depend on $v$, allowing to delete $A_i - X$ from $S$.

The issue is of course that this supposed locality result needed in the second case of the proof fails. We are considering all $S$-flips for this unbounded set $S$, and this appears to be far too powerful for this kind of arguments to hold.

A similar and correct locality statement goes informally as follows: in a large collection $\mathcal{A}$ of sets of size $t$, there is some bounded subcollection $\mathcal{X} \subseteq \mathcal{A}$ such that if $u, v$ are far from all of $\mathcal{A}$, and $\mathrm{dist}_S(u, v) > r$ holds for some $S \in \mathcal{A}$, then it also holds for some $S \in \mathcal{X}$. This is a simple corollary of Gaifman's locality for first-order logic. Note that while $\mathcal{A}$ is unbounded, we only consider $S$-flips for sets $S \in \mathcal{A}$ of bounded size $t$.

This suggests a way to fix the proof: rather than having one large set $S$ and considering $S$-flips, we consider a large family $\mathcal{F}$ of sets of size $t$, and work with the metric $\mathrm{dist}_F(u, v) =$
$\max_{S \in \mathcal{F}} \mathrm{dist}_S(u, v)$ combining S-flips for all $S \in \mathcal{F}$. The previous sketch can be adjusted to this new setting without major changes if one picks $t$ to be the size of flips produced by flip-breakability, and once we reach the last case of the proof, the form of locality required is exactly the one stated above.

## 2 Preliminaries

For a nonnegative integer $p$, we denote $[p] := \{1, \dots, p\}$. If $\mathcal{X}$ is a set of sets, then $\bigcup \mathcal{X}$ is their union.

### 2.1 Standard graph-theoretic notation

We denote by $V(G)$ and $E(G)$ the sets of vertices and of edges of a graph $G$, respectively. A graph $H$ is a subgraph of a graph $G$ if $H$ can be obtained from $G$ by vertex and edge deletions. Graph $H$ is an induced subgraph of $G$ if $H$ is obtained from $G$ by vertex deletions only. For $S \subseteq V(G)$, the subgraph of $G$ induced by $S$, denoted $G[S]$, is obtained by removing from $G$ all the vertices that are not in $S$ (together with their incident edges). Then, $G-S$ is a shorthand for $G[V(G) \setminus S]$.

We denote the (open) neighborhood of a vertex $v$ in $G$ by $N_G(v)$ and by $\mathrm{Ball}_G^r(v)$ the set of vertices at distance at most $r$ from $v$ in $G$. We set $\mathrm{Ball}_G^r(S) := \bigcup_{v \in S} \mathrm{Ball}_G^r(v)$ for $S \subseteq V(G)$. The diameter of a graph $G$, denoted by $\mathrm{diam}(G)$, is defined as $\max_{u,v \in V(G)} \mathrm{dist}_G(u, v)$ where $\mathrm{dist}_G(u, v)$ is the shortest-path distance between $u$ and $v$. A biclique in $G$ is made of two non-empty disjoint sets $A, B \subseteq V(G)$ such that for every $a \in A$ and for every $b \in B$, $ab \in E(G)$. For any $A, B \subseteq V(G)$, we denote by $E_G(A, B)$ the edge set $\{uv \in E(G) \mid u \in A, v \in B\}$. If furthermore, $A$ and $B$ are disjoint, we denote by $G[A, B]$ the bipartite subgraph of $G$ with bipartition $(A, B)$ and edge set $E_G(A, B)$.

### 2.2 Flips

Given a graph $G$ and two not necessarily disjoint subsets $A, B \subseteq V(G)$, the $(A, B)$-flip of $G$ is the graph with vertex set $V(G)$ and edge set

$$E(G) \Delta \{ab : a \in A, b \in B, a \neq b\},$$

where $\Delta$ is the symmetric difference. A flip of a graph $G$ is any $(A, B)$-flip of $G$ for some $A, B \subseteq V(G)$.

Given a partition $\mathcal{P}$ of $V(G)$, a $\mathcal{P}$-flip of a graph $G$ is any graph obtained from $G$ by performing a sequence of flips, each of which is a $(P, P')$-flip for some (possibly equal) $P, P' \in \mathcal{P}$. Note that a $\mathcal{P}$-flip of $G$ is fully determined by specifying a graph on vertex set $\mathcal{P}$ with possible loops. In particular, there are at most $2^{|\mathcal{P}|^2}$ many $\mathcal{P}$-flips of $G$, and the sequence of flips can always be chosen to be of length at most $|\mathcal{P}|^2$. Then, for any positive integer $k$, a $k$-flip of $G$ is any $\mathcal{P}$-flip of $G$ with $|\mathcal{P}| \le k$, i.e., $\mathcal{P}$ comprises at most $k$ parts.

For any $S \subseteq V(G)$, the partition of $V(G)$ defined by $S$, denoted by $\mathcal{P}_S$, is

$$\{\{s\} : s \in S\} \cup \{\{v \in V(G - S) \mid N_G(v) \cap S = S'\} : S' \subseteq S\},$$

where empty sets are removed from the partition. Note that $\mathcal{P}_S$ is indeed a partition of $V(G)$, with at most $|S| + 2^{|S|}$ parts. An $S$-definable flip of $G$ is simply a $\mathcal{P}_S$-flip of $G$, and a $k$-definable flip is an $S$-definable flip for some $S \subseteq V(G)$ of size at most $k$.
We associate distances to flips. Recall that, given $u, v \in V(G)$, $\text{dist}_G(u, v)$ denotes the shortest-path distance between $u$ and $v$ in $G$. Then, for any $\mathcal{P}$ partition of $V(G)$, we define

$$ \text{dist}_{\mathcal{P}}^{G}(u, v) := \max \{ \text{dist}_{G'}(u, v) : G' \text{ is a } \mathcal{P}\text{-flip of } G \}; $$

and for $S \subseteq V(G)$,

$$ \text{dist}_{S}^{G}(u, v) := \max \{ \text{dist}_{G'}(u, v) : G' \text{ is an } S\text{-definable flip of } G \}. $$

We also define the corresponding balls

$$ \text{Ball}_{\mathcal{P}}^{r}(v) := \{u \in V(G) : \text{dist}_{\mathcal{P}}^{G}(u, v) \le r\} \quad \text{and} \quad \text{Ball}_{S}^{r}(v) := \{u \in V(G) : \text{dist}_{S}^{G}(u, v) \le r\}, $$

where the graph $G$ will always be clear from the context. In these cases we may also omit $G$ from sub- or superscripts.

## 2.3 VC-dimension, transductions, and monadic dependence

We recall the standard terminology of VC-theory in the context of graphs. Given a graph $G$ and a set of vertices $A$, we say that $G$ shatters $A$ if for each $B \subseteq A$ there exists a vertex $u_B$ such that $N(u_B) \cap A = B$. We define the VC-dimension of $G$, denoted as $\text{VCdim}(G)$, as the maximum size of a set $A \subseteq V(G)$ shattered by $G$. For a graph class $\mathcal{C}$ we write $\text{VCdim}(\mathcal{C}) := \sup \{ \text{VCdim}(G) : G \in \mathcal{C} \}$; note that it may happen that $\text{VCdim}(\mathcal{C}) = \infty$ in case graphs from $\mathcal{C}$ contain arbitrarily large shattered sets. We additionally define the growth function, or shatter function, of $G$ as the map $\pi_G : \mathbb{N} \to \mathbb{N}$ given by

$$ \pi_G(n) := \max_{A \subseteq V(G), |A|=n} |\{ N_G(v) \cap A : v \in V(G) \}|. $$

Evidently $\pi_G(n) \le 2^n$, while $\text{VCdim}(G) < n \iff \pi_G(m) < 2^m$ for every $m \ge n$. However, a bound on the VC-dimension implies a much stronger bound on the shatter function.

**Fact 6 (Sauer-Shelah Lemma, [16, 17]).** Let $G$ be a graph with $k := \text{VCdim}(G)$. Then for all $n \ge k$, we have

$$ \pi_G(n) \le \sum_{i=0}^{k} \binom{n}{i}. $$

In particular, $\pi_G(n) \le \mathcal{O}(n^k)$.

We now recall the definition of first-order transductions, or transductions for short, in the special case of languages over (vertex-colored) graphs; see also the discussion in [15] for a broader introduction. A (vertex-colored) graph is here seen as a relational structure consisting of the vertex set equipped with one binary relation $E(\cdot, \cdot)$ signifying adjacency, and one unary relation per color. Given a non-negative integer $k$, a transduction $\mathcal{T}$ is specified by a set of colors $\Sigma$ and a first-order formula $\varphi(x, y)$ with two free variables in the language of $\Sigma$-colored graphs. For every (uncolored) graph $G$, we denote by $\mathcal{T}(G)$ the family of all induced subgraphs of graphs $H$ with $V(H) = V(G)$ satisfying the following: there are subsets $\{U_C : C \in \Sigma\}$ of $V(G)$ such that for all distinct $u, v \in V(H)$, we have $uv \in E(H)$ if and only if $\varphi(u, v)$ holds in $G$ with vertices of $U_C$ marked as of color $C$, for each $C \in \Sigma$.

Given a graph class $\mathcal{C}$, we denote by $\mathcal{T}(\mathcal{C})$ the class $\bigcup_{G \in \mathcal{C}} \mathcal{T}(G)$. We say that a graph class $\mathcal{C}$ transduces a class $\mathcal{D}$ if there is a transduction $\mathcal{T}$ such that $\mathcal{D} \subseteq \mathcal{T}(\mathcal{C})$. Finally, a characterization of Baldwin and Shelah [1] states that a graph class is monadically dependent (or monadically NIP) if it does not transduce the class of all graphs. We take it as our definition of monadic dependence.

The quantifier rank of a (first-order) formula $\varphi$, denoted by $\text{qr}(\varphi)$, is the maximum number of nested quantifiers in $\varphi$.
## 3 Metric conversion

In this section we prove Lemma 5. In fact, we shall establish the following stronger result that more generally shows that the metric arising from an arbitrary partition can be approximated by that coming from a definable flip.

**Theorem 7.** For every graph $G$ of VC-dimension $d$ and a partition $\mathcal{P}$ of $V(G)$, there is a set of vertices $S$ of size $\mathcal{O}(d \cdot |\mathcal{P}|^{2d+2})$ and an $S$-definable flip $G'$ of $G$ such that for every $r \in \mathbb{N}$, $v \in V(G)$, and $\mathcal{P}$-flip $H$ of $G$

$$ \mathrm{Ball}_{G'}^r(v) \subseteq \mathrm{Ball}_H^{30r}(v). $$

Note that Lemma 5 follows immediately from Theorem 7. This is because for any vertex set $T$ of size $k$, the partition $\mathcal{P}_T$ has size $\mathcal{O}(k^d)$ where $d$ is the VC-dimension, by the Sauer-Shelah Lemma (Fact 6); and the definition of the metric $\mathrm{dist}_T$ considers all $\mathcal{P}_T$-flips.

Towards Theorem 7, we argue that the partition metric can be approximated by the distance metric of a concrete, not necessarily definable, flip.

**Lemma 8.** Let $G$ be a graph and $\mathcal{P}$ a partition of the vertex set of $G$. Then there exists a refinement $\mathcal{P}'$ of $\mathcal{P}$ and a $\mathcal{P}'$-flip $G'$ of $G$ such that for all $v \in V(G)$,

$$ \mathrm{Ball}_{G'}^r(v) \subseteq \mathrm{Ball}_{\mathcal{P}}^{6r}(v). $$

Furthermore, we have $|\mathcal{P}'| \le |\mathcal{P}| \cdot 2^{|\mathcal{P}|}$, and if $G$ has VC-dimension at most $d$, then $|\mathcal{P}'| = \mathcal{O}(|\mathcal{P}|^{d+1})$. Moreover, $G'$ and $\mathcal{P}'$ can be computed from $G$ and $\mathcal{P}$ in time $\mathcal{O}(|\mathcal{P}|^2 \cdot |V(G)|^2)$.

Evidently, this result together with Lemma 4, which allows to approximate the metric of an arbitrary flip by that of a definable flip, imply Theorem 7. We now turn to the proof of Lemma 8. For this, we first use some folklore results. Let $\bar{G}$ denote the complement of a graph $G$, i.e., the graph obtained from $G$ by replacing all edges with non-edges and vice versa.

**Lemma 9.** For any graph $G$, we have $\mathrm{diam}(G) \le 3$ or $\mathrm{diam}(\bar{G}) \le 3$.

**Proof.** Assume that $\mathrm{diam}(G) > 3$, i.e., there are vertices $u, v$ with $\mathrm{dist}_G(u, v) > 3$ (possibly $u, v$ are in distinct connected components). Then there is no common neighbor of $u, v$. Thus, in the complement $\bar{G}$, all vertices are neighbors of either $u$ or $v$, and $uv$ is an edge. This implies that $\mathrm{diam}(\bar{G}) \le 3$. $\blacksquare$

Observe that Lemma 9 proves Lemma 8 in the case where the partition $\mathcal{P} = \{V(G)\}$ is trivial. Indeed, suppose first that $\mathrm{diam}(G) \le 3$. We then let $\mathcal{P}' = \mathcal{P}$ and $G' = \bar{G}$, which is a $\mathcal{P}$-flip of $G$. Thus, for every edge $uv \in E(G')$, we have that the edge $uv$ is a path of length 1 connecting $u$ and $v$ in $\bar{G}$, and there is always a path connecting $u$ and $v$ of length 3 in $G$. Consequently $\mathrm{dist}_{\mathcal{P}}(u, v) \le 3$ and, more generally, $\mathrm{dist}_{\mathcal{P}}(u, v) \le 3 \cdot \mathrm{dist}_{G'}(u, v)$. The case when $\mathrm{diam}(\bar{G}) \le 3$ can be handled by a symmetric argument.

To generalize this, we need a variant of Lemma 9 for bipartite graphs. Let $B = (U, V, E)$ be a bipartite graph, where $U, V$ are the two sides of the bipartition. We consider the choice of bipartition (which is not necessarily unique) to be a part of $B$. The bipartite complement $\bar{B}$ of $B$ is the bipartite graph with edge set $\{uv : u \in U, v \in V \text{ and } uv \notin E(B)\}$. A degenerate case appears in this bipartite setting: it is possible for both $B$ and $\bar{B}$ to be disconnected (which is impossible for the usual notion of complement).

**Lemma 10.** For any bipartite graph $B$, either $\mathrm{diam}(B) \le 6$, $\mathrm{diam}(\bar{B}) \le 6$, or both $B$ and $\bar{B}$ are disconnected.
**Proof.** See Figure 1 for an illustration. Assume that one of $B, \bar{B}$ is connected, say $B$. Suppose furthermore that $\text{diam}(B) > 6$. We must then show $\text{diam}(\bar{B}) \le 6$. Using that $B$ is connected, we can pick vertices $x, y$ at distance exactly 6, and a shortest path $x = x_0, \dots, x_6 = y$ between them. This path alternates between the sides $U, V$ of the bipartition, say $x_i \in U$ for even $i$ and $x_i \in V$ for odd $i$.

<figure><img src="image_9.png" /><figcaption>Figure 1 A bipartite graph $B$ with a shortest path $x_1, \dots, x_6$ of length 6. Note that the neighborhoods of $x_0, x_1, x_5, x_6$ must be disjoint. The set $R$ denotes what remains outside these neighborhoods. The red-dashed edges form a path $P$ of length 4 in the bipartite complement $\bar{B}$ which dominates all of $\bar{B}$, i.e., no vertex of $B$ is adjacent to all of $P$. This ensures $\text{diam}(\bar{B}) \le 6$.</figcaption></figure>

Now a vertex $u \in U$ cannot be adjacent to both $x_1$ and $x_5$, as these vertices are at distance 4. Similarly, a vertex $v \in V$ cannot be adjacent to both $x_0$ and $x_6$. It follows that in $\bar{B}$, all vertices are adjacent to one of $x_0, x_1, x_5, x_6$, and the latter are connected by the following path of length 4: $(x_5, x_0, x_3, x_6, x_1)$. It follows that $\text{diam}(\bar{B}) \le 6$. ◀

The degenerate cases of Lemma 10 have a simple classification.

**▶ Lemma 11.** Let $B = (U, V, E)$ be a bipartite graph such that both $B$ and $\bar{B}$ are disconnected. Then

1. either $B$ is the disjoint union of two bicliques, or

2. up to swapping $U$ and $V$, there are vertices $v^-, v^+ \in V$ such that $v^-$ is isolated and $v^+$ is adjacent to all of $U$.

<figure><img src="image_10.png" /><figcaption>Figure 2 The two types of bipartite graphs $B$ with both $B$ and $\bar{B}$ disconnected (Lemma 11).</figcaption></figure>

**Proof.** Assume first that $B$ contains an isolated vertex $v^-$, which without loss of generality is in $V$. Thus in $\bar{B}$, $U \cup \{v^-\}$ is connected. If all vertices of $V$ had a non-neighbor in $U$, then $\bar{B}$ would be connected, see Figure 3a. Hence, there must be some $v^+ \in V$ connected to all of $U$, and case 2 of the lemma holds.

Otherwise, every connected component of $B$ has at least two vertices. Let $C_1, \dots, C_k$ be the components of $B$, where $k \ge 2$, for we assume that $B$ is disconnected. Call $U_i = U \cap C_i$ and $V_i = V \cap C_i$ the two sides of component $C_i$; they are non-empty since $C_i$ has more than one vertex. Note that for all $i \ne j$, $(U_i, V_j)$ is a biclique in $\bar{B}$. If there are at least 3 components $C_i$, it is then simple to check that $\bar{B}$ is connected, a contradiction (see Figure 3b).
We finally assume that there are only two components $C_1, C_2$, each with at least two vertices. Once again, $(U_1, V_2)$ and $(U_2, V_1)$ are bicliques in $\bar{B}$. If in either $C_1$ or $C_2$ there is some non-edge between $U$ and $V$, then the corresponding edge in $\bar{B}$ connects these two bicliques, and thus all of $\bar{B}$, a contradiction (see Figure 3c). Therefore, $C_1$ and $C_2$ are themselves bicliques in $B$, so case 1 of the lemma holds. ◀

<figure><img src="image_11.png" /><figcaption>(a) Vertex $v^- \in V$ is isolated, and $v \in V$ dominates $U$, i.e., all of them have a non-edge to $U$.</figcaption></figure>

<caption>(b) There are at least 3 non-trivial connected components $C_1, C_2, C_3$.</caption>

<caption>(c) The graph has exactly 2 non-trivial components, with at least one non-edge in one of them.</caption>

■ **Figure 3** Impossible situations in the proof of Lemma 11, in which enough non-edges (drawn with dashes) are found for $\bar{B}$ to be connected.

Next, we prove Lemma 8 for bipartite graphs when the partition $\mathcal{P}$ is trivial. In this context, a flip of a bipartite graph $B = (U, V, E)$ should preserve the fixed bipartition $(U, V)$, i.e., we only consider flips between some subset of $U$ and some subset of $V$. We call this a bipartite flip.

**Lemma 12.** For every bipartite graph $B = (U, V, E)$, there are partitions $(U_1, U_2)$ of $U$ and $(V_1, V_2)$ of $V_2$, and a $\{U_1, U_2, V_1, V_2\}$-bipartite flip $B'$ such that if $uv \in E(B')$, then $\text{dist}_B(u, v) \le 6$ and $\text{dist}_{\bar{B}}(u, v) \le 6$. Furthermore, we either have $U_2 = \emptyset$ or $U_1 = N(v)$ for some $v \in V$; and similarly, either $V_2 = \emptyset$ or $V_1 = N(u)$ for some $u \in U$.

*Proof.* We apply Lemma 11 to choose the appropriate partition:

1. If $B$ or $\bar{B}$ is connected, then the partition is trivial: $U_1 = U, U_2 = \emptyset, V_1 = V, V_2 = \emptyset$.

2. If $B$ is the disjoint union of two bicliques, then we partition accordingly so that the bicliques are $(U_1, V_1)$ and $(U_2, V_2)$.

3. If $v^-, v^+ \in V$ are isolated and fully adjacent to $U$ respectively, then we pick $u \in U$ arbitrarily and let $V_1 = N(u)$ and $V_2 = V \setminus V_1$. The partition of $U$ remains trivial: $U_1 = U$ and $U_2 = \emptyset$.

In all three cases, for each nonempty $U_i, V_j$ the bipartite graph $B[U_i, V_j]$ or its complement is connected. Furthermore, the partitions $(U_1, U_2)$ and $(V_1, V_2)$ are of the required form.

For all nonempty $U_i, V_j$, Lemma 10 gives that either $B[U_i, V_j]$ or its complement has diameter at most 6. In the former case, we flip the adjacency relation between $U_i$ and $V_j$, and the flip $B'$ is the one obtained by doing so for each pair $U_i, V_j$. By construction, $\overline{B'}[U_i, V_j]$ has diameter at most 6 for all nonempty $U_i, V_j$. Thus, if $uv \in E(B')$ with $u \in U_i, v \in V_j$, then $u, v$ are at distance at most 6 in both $B'[U_i, V_j]$ and its complement. Finally, $B$ contains either $B'[U_i, V_j]$ or $\overline{B'}[U_i, V_j]$ as an induced subgraph, hence such $u, v$ are also at distance at most 6 in both $B$ and $\bar{B}$.

Having established the above, we proceed with the proof of Lemma 8.

**Proof of Lemma 8.** Let $G$ be a graph and $\mathcal{P}$ a partition of $V(G)$. We construct a flip $G'$ of $G$ as follows:
- For each part $X \in \mathcal{P}$, we flip $(X, X)$ if necessary to ensure that $\text{diam}(\overline{G'[X]}) \le 3$ has diameter at most 3, using Lemma 9.

- For each pair of distinct parts $X, Y \in \mathcal{P}$, we apply Lemma 12 to the bipartite graph $G[X, Y]$. This gives partitions $\mathcal{P}_{X,Y}$ of $X$ and $\mathcal{P}_{Y,X}$ of $Y$ into at most two parts each, and a $(\mathcal{P}_{X,Y} \cup \mathcal{P}_{Y,X})$ bipartite flip $G'_{XY}$ of $G[X, Y]$, ensuring the following: whenever $uv$ is an edge in $G'_{XY}$, then $u, v$ are at distance at most 6 in both $G[X, Y]$ and $\overline{G[X, Y]}$. We apply the same flip in $G$ to obtain $G'$.

Define $\mathcal{P}'$ to be the partition of $V(G)$ whose parts are of the form $\bigcap_{Y \in \mathcal{P}} P_{X,Y}$ for all possible choices of $X \in \mathcal{P}$ and $\{P_{X,Y} \in \mathcal{P}_{X,Y}\}_{Y \in \mathcal{P}}$. Clearly, the partition $\mathcal{P}'$ refines both $\mathcal{P}$ and all $\mathcal{P}_{X,Y}$, i.e., any part of the latters can be obtained as union of parts of $\mathcal{P}'$. It follows that $G'$ is a $\mathcal{P}'$-flip of $G$.

Consider an edge $uv \in E(G')$, and let $X, Y$ be the parts of $\mathcal{P}$ containing $u$ and $v$, respectively (possibly $X = Y$). Further, consider an arbitrary $\mathcal{P}$-flip $G''$ of $G$. If $X \ne Y$, notice that $G'[X, Y]$ is equal to the flip $G'_{XY}$ provided by Lemma 12. Thus, $uv$ is an edge in $G'_{XY}$, which implies that $u, v$ are at distance at most 6 in both $G[X, Y]$ and $\overline{G[X, Y]}$. Since $G''$ is a $\mathcal{P}$-flip of $G$ and $X, Y \in \mathcal{P}$, the restriction $G''[X, Y]$ coincides with either $G[X, Y]$ or $\overline{G[X, Y]}$, hence $\text{dist}_{G''[X,Y]}(u, v) \le 6$, and a fortiori $\text{dist}_{G''}(u, v) \le 6$. And in the case $X = Y$, we have $\text{dist}_{G'[X]}(u, v) = 1$ and $\text{dist}_{\overline{G'[X]}}(u, v) \le 3$ due to $\text{diam}(\overline{G'[X]}) \le 3$, hence also $\text{dist}_{G''}(u, v) \le 3$ because $G''[X]$ is equal to $G'[X]$ or its complement. Since $G''$ was chosen arbitrarily as a $\mathcal{P}$-flip of $G$, this proves that $\text{dist}_{\mathcal{P}}(u, v) \le 6$ holds for any edge $uv \in E(G')$. So we have more generally $\text{dist}_{\mathcal{P}}(u, v) \le 6 \cdot \text{dist}_{G'}(u, v)$ for every pair of vertices $u, v$, which in terms of balls is equivalent to $\text{Ball}_{\mathcal{P}}^{\text{tr}}(v) \subseteq \text{Ball}_{\mathcal{P}}^{\text{br}}(v)$ for all vertices $v$ and radius $r$.

Consider now the partition $\mathcal{P}'$ used to obtain the flip $G'$. Recall that its part are of the form $\bigcap_{Y \in \mathcal{P}} P_{X,Y}$ for all $|\mathcal{P}|$ choices of $X \in \mathcal{P}$, and all $2^{|\mathcal{P}|}$ choices of $\{P_{X,Y} \in \mathcal{P}_{X,Y}\}_{Y \in \mathcal{P}}$. This immediately gives the general bound $|\mathcal{P}'| \le |\mathcal{P}| \cdot 2^{|\mathcal{P}|}$. Assuming now that $G$ has VC-dimension at most $d$, we will improve this bound using the additional restriction on $\mathcal{P}_{X,Y}$ ensured by Lemma 12: either $\mathcal{P}_{X,Y} = \{X\}$ is trivial, or there is some vertex $v_{X,Y} \in Y$ such that $\mathcal{P}_{X,Y} = \{X \cap N(v_Y), X \setminus N(v_Y)\}$ is the partition into neighbours and non-neighbours of $v_Y$. Call $A$ the collection of these vertices $v_Y$. The above implies that $\mathcal{P}'$ partitions $X$ into neighbourhood types over $A$, that is parts of the form $\{x \in X : N(x) \cap A = B\}$ for all choices of $B \subseteq A$. By the Sauer–Shelah lemma (see Fact 6), if $G$ has VC-dimension at most $d$, then at most $\mathcal{O}(|A|^d) = \mathcal{O}(|\mathcal{P}|^d)$ of these neighbourhood types are non-empty. Summing over all choices of $X$, this gives $|\mathcal{P}'| = \mathcal{O}(|\mathcal{P}|^{d+1})$.

We finally compute the running time of this procedure. For each part $X \in \mathcal{P}$, the algorithm checks if $\text{diam}(G[X]) \le 3$ and either complements or keeps $G[X]$ as is; evidently, this can be achieved in time $\mathcal{O}(|\mathcal{P}| \cdot |V(G)|^2)$. Additionally, for each distinct pair of parts $X, Y \in \mathcal{P}$, the algorithm checks if $\text{diam}(G[X, Y]) \le 6$ or $\text{diam}(\overline{G[X, Y]}) \le 6$; if neither holds, then $G[X, Y]$ and $\overline{G[X, Y]}$ are necessarily both disconnected by Lemma 10, and so the algorithm checks if $G[X, Y]$ is the disjoint union of two bicliques. This may be achieved in time $\mathcal{O}(|\mathcal{P}|^2 \cdot |V(G)|^2)$. In any one of these outcomes, the flips and the refinement of the partition are directly obtainable by Lemma 12. ◀

We remark that an inspection of the proof of Lemma 4 yields a polynomial-time algorithm for converting arbitrary flips into definable ones. The combination of this fact together with Lemma 8 gives an effective lemma for translating the partition metric into the metric induced by a definable flip, i.e., an effective version of Theorem 7.
4 Flip-separability

The starting point to our proof of separability is the recent characterization of monadic dependence via flip-breakability [4], a combinatorial property that allows to find large sets that are pairwise far apart after a bounded number of flips. To make use of this property, we require some additional tools which we believe will be very useful in the analysis of monadically dependent classes. The first is a locality property of the partition metric.

4.1 Locality for various metrics

Evidently, for every graph G and its k-flip G', we may definably recover the structure of G in G' by expanding the language with k unary predicates that account for the flip. As such, the metric induced by a concrete flip may be used in a variant of Gaifman's locality theorem [6]. Interestingly, this idea also applies to any partition metric as these can be approximated by concrete flips due to Lemma 8. This idea is crucially used in our proof of separability; we make this precise below. Recall the following standard corollary of Gaifman's locality theorem [6], see e.g. [2]. Here, by a k-colored graph we mean a graph with k unary predicates (colors) on it, and the distance between tuples $\bar{u}$ and $\bar{v}$ is defined as the minimum distance between any vertex present in $\bar{u}$ and any vertex present in $\bar{v}$.

**Theorem 13.** For every $k \in \mathbb{N}$ and every first-order formula $\varphi(\bar{x}, \bar{y})$ in the language of k-colored graphs, there exist numbers $r = r(\mathrm{qr}(\varphi))$ and $t = t(\mathrm{qr}(\varphi), |\bar{x}|, |\bar{y}|, k)$ such that for every k-colored graph G, there are colorings $\mathrm{col}_1: V(G)^{\bar{x}} \to [t]$ and $\mathrm{col}_2: V(G)^{\bar{y}} \to [t]$ satisfying the property that for any two tuples $\bar{u} \in V(G)^{\bar{x}}, \bar{v} \in V(G)^{\bar{y}}$ with $\mathrm{dist}_G(\bar{u}, \bar{v}) > r$, whether $\varphi(\bar{u}, \bar{v})$ holds in G depends only on $\mathrm{col}_1(\bar{u})$ and $\mathrm{col}_2(\bar{v})$.

We argue that a variant of the above is true if we replace $\mathrm{dist}_G(\bar{u}, \bar{v})$ by $\mathrm{dist}_P(\bar{u}, \bar{v})$.

**Lemma 14.** For every $p \in \mathbb{N}$ and every first-order formula $\varphi(\bar{x}, \bar{y})$ in the language of graphs there exist numbers $\rho = \rho(\mathrm{qr}(\varphi))$ and $\ell = \ell(\mathrm{qr}(\varphi), |\bar{x}|, |\bar{y}|, p)$ such that for every graph G and every partition $\mathcal{P}$ of $V(G)$ with at most $p$ parts, there are colorings $\mathrm{col}_1: V(G)^{\bar{x}} \to [\ell]$ and $\mathrm{col}_2: V(G)^{\bar{y}} \to [\ell]$ satisfying the property that for any $\bar{u} \in V(G)^{\bar{x}}, \bar{v} \in V(G)^{\bar{y}}$ with $\mathrm{dist}_{\mathcal{P}}(\bar{u}, \bar{v}) > \rho$, whether $\varphi(\bar{u}, \bar{v})$ holds in G depends only on $\mathrm{col}_1(\bar{u})$ and $\mathrm{col}_2(\bar{v})$.

**Proof.** Let $k := p \cdot 2^p$, $r := r(\mathrm{qr}(\varphi))$ and $t := t(\mathrm{qr}(\varphi), |\bar{x}|, |\bar{y}|, k)$ from Theorem 13, and set $\rho := 6r$, $\ell := t$. Consider a graph G and a partition $\mathcal{P}$ of G into p parts. By Lemma 8 it follows that there is a k-flip $G'$ of G such that

$$ \mathrm{dist}_{\mathcal{P}}(u, v) \le 6 \cdot \mathrm{dist}_{G'}(u, v), \quad \text{for all } u, v \in V(G). \quad (*) $$

Consider an expansion $\hat{G}'$ of $G'$ with k unary predicates, interpreted as the parts defining this flip. It follows that the edge relation of G can be defined in $\hat{G}'$ by a quantifier-free formula, and consequently, we may rewrite $\varphi(\bar{x}, \bar{y})$ into a formula $\varphi'(\bar{x}, \bar{y})$ in the language of k-colored graphs and with the same quantifier rank as $\varphi$, that satisfies

$$ G \models \varphi(\bar{u}, \bar{v}) \iff \hat{G}' \models \varphi'(\bar{u}, \bar{v}), \quad \text{for all } \bar{u} \in V(G)^{\bar{x}}, \bar{v} \in V(G)^{\bar{y}}. \quad (\star\star) $$

Applying Theorem 13, we obtain colorings $\mathrm{col}_1: V(G)^{\bar{x}} \to [\ell]$ and in $\mathrm{col}_2: V(G)^{\bar{y}} \to [\ell]$ satisfying the property that for any $\bar{u} \in V(G)^{\bar{x}}, \bar{v} \in V(G)^{\bar{y}}$ with $\mathrm{dist}_{G'}(\bar{u}, \bar{v}) > r$, whether $\varphi'(\bar{u}, \bar{v})$ holds in $\hat{G}'$ only depends on $\mathrm{col}_1(\bar{u})$ and $\mathrm{col}_2(\bar{v})$. It thus follows by (⋆) and (⋆⋆) that for any tuples $\bar{u} \in V(G)^{\bar{x}}, \bar{v} \in V(G)^{\bar{y}}$ with $\mathrm{dist}_{\mathcal{P}}(\bar{u}, \bar{v}) > \rho$, whether $\varphi(\bar{u}, \bar{v})$ holds in G only depends on $\mathrm{col}_1(\bar{u})$ and $\mathrm{col}_2(\bar{v})$, as required. ◀
## 4.2 Flip-breakability

We will rely on the notion of flip-breakability, introduced in [4].

**Definition 15.** A graph class $\mathcal{C}$ is flip-breakable if for every radius $r \in \mathbb{N}$, there is a $t := t(\mathcal{C}, r)$ and a function $M_r : \mathbb{N} \to \mathbb{N}$, such that the following holds. For every graph $G \in \mathcal{C}$, $m \in \mathbb{N}$, and set $W \subseteq V(G)$ of size at least $M_r(m)$, there are disjoint subsets $A_1, A_2 \subseteq W$ each of size at least $m$ and a t-flip $H$ of $G$ such that $\mathrm{Ball}_H^r(A_1) \cap \mathrm{Ball}_H^r(A_2) = \emptyset$.

**Theorem 16 ([4]).** A graph class is monadically dependent if and only if it is flip-breakable.

A natural two-set variant of this property also holds, in which two large sets $W_1, W_2$ both of size $M_r(m)$ are given, and one finds the distant subsets $A_1, A_2$ of size $m$ with $A_i \subseteq W_i$, see [4, full version, Theorem 19.14]. Combined with Lemma 4 which allows to replace t-flips with t-definable flips, we obtain the following statement which we use in the proof.

**Corollary 17.** For every monadically dependent graph class $\mathcal{C}$ and radius $r \in \mathbb{N}$, there is a $t := t(\mathcal{C}, r)$ and a function $M_r : \mathbb{N} \to \mathbb{N}$, such that the following holds. For every graph $G \in \mathcal{C}$, $m \in \mathbb{N}$, and sets $W_1, W_2 \subseteq V(G)$ each of size at least $M_r(m)$, there are disjoint subsets $A_1 \subseteq W_1, A_2 \subseteq W_2$ each of size at least $m$ and a t-definable flip $H$ of $G$ such that $\mathrm{Ball}_H^r(A_1) \cap \mathrm{Ball}_H^r(A_2) = \emptyset$.

A simple application of flip-breakability is the following: in a graph $G$ from a monadically dependent class with weights $w$, given a very large set of vertices $W$, there is a large subset $A \subseteq W$ and a bounded set $S$ satisfying $w(\mathrm{Ball}_S^r(A)) \le \varepsilon \cdot w(V(G))$. Indeed, for $p := \lceil \frac{1}{\varepsilon} \rceil$, by applying $p-1$ times flip-breakability with radius $2r$ to $W$, we obtain $p$ large subsets $A_1, \dots, A_p$ of $W$ pairwise at distance more than $2r$ in some flip metric $\mathrm{dist}_S$ with bounded $|S|$. Then, the $r$-balls $\mathrm{Ball}_S^r(A_i)$ are all disjoint, and one of them must have only an $\varepsilon$-proportion of the total weight.

The main technical result of this section (Lemma 19 below) is a variant of this statement in which the sets $W$ and $S$ of vertices are replaced by a families $\mathcal{F}$ and $\mathcal{Y}$ of $t$-tuples of vertices. To state this result, we need to define the flip-metric associated with $\mathcal{Y}$, which combines the flip metric $\mathrm{dist}_S$ for all $S \in \mathcal{Y}$. For a graph $G$ and a family $\mathcal{Y} \subseteq 2^{V(G)}$, we define for all $u, v \in V(G)$, and $A, B \subseteq V(G)$,

$$ \mathrm{dist}_{\mathcal{Y}}(u, v) := \max_{S \in \mathcal{Y}} \mathrm{dist}_{S}(u, v) \quad \text{and} \quad \mathrm{dist}_{\mathcal{Y}}(A, B) := \min_{a \in A, b \in B} \mathrm{dist}_{\mathcal{Y}}(a, b). $$

Thus, we also have

$$ \mathrm{Ball}_{\mathcal{Y}}^r(v) := \bigcap_{S \in \mathcal{Y}} \mathrm{Ball}_S^r(v) \quad \text{and} \quad \mathrm{Ball}_{\mathcal{Y}}^r(A) = \bigcup_{v \in A} \mathrm{Ball}_{\mathcal{Y}}^r(v). $$

We call $\mathcal{F}$ $t$-uniform if every set in $\mathcal{F}$ has size exactly $t$. We will use the sunflower lemma:

**Theorem 18 ([5]).** For every $t \in \mathbb{N}$ there is a function $f : \mathbb{N} \to \mathbb{N}$ satisfying the following. For every $m \in \mathbb{N}$ and in any $t$-uniform family $\mathcal{F}$ of size $f(m)$, there is a subfamily $\mathcal{F}' \subseteq \mathcal{F}$ of size $m$ and a set $Y$ such that for all $A \ne B$ in $\mathcal{F}'$, $A \cap B = Y$. The subfamily $\mathcal{F}'$ is called a sunflower, and $Y$ its core.

We proceed with the main technical lemma of this section.
**► Lemma 19.** For every monadically dependent graph class $\mathcal{C}$, radius $r \in \mathbb{N}$, and $\varepsilon > 0$, there are numbers $t := t(\mathcal{C}, r)$ and $k := k(\mathcal{C}, r, \varepsilon)$ and a function $M := M(\mathcal{C}, r, \varepsilon) : \mathbb{N} \to \mathbb{N}$ satisfying the following. Given a graph $G \in \mathcal{C}$ with weights $\mathbf{w}$ and a $t$-uniform family $\mathcal{F} \subseteq 2^{V(G)}$ of size $|\mathcal{F}| \ge M(m)$, there exist two $t$-uniform families $\mathcal{F}' \subseteq \mathcal{F}$ and $\mathcal{Y} \subseteq 2^{V(G)}$ of size $|\mathcal{F}'| \ge m$ and $|\mathcal{Y}| \le k$, such that for each $S \in \mathcal{F}'$, we have

$$ \mathbf{w}(\mathrm{Ball}_{\mathcal{Y}}^r(S - \bigcup \mathcal{Y})) \le \varepsilon \cdot \mathbf{w}(V(G)). $$

The proof follows the previously sketched argument, replacing vertices with $t$-tuples. We repetitively apply flip-breakability to $\mathcal{F}$, considering each coordinate of $t$-tuples one after the other, until $\mathcal{F}$ is broken into $[\frac{1}{\varepsilon}]$ subsets with pairwise disjoint $r$-neighbourhoods. One of these subsets has a $r$-neighbourhood with only an $\varepsilon$-fraction of the total weight, and satisfies the desired condition. The sunflower lemma is used as a preprocessing step to reduce the problem to the case where tuples in $\mathcal{F}$ are pairwise disjoint.

**Proof of Lemma 19.** Fix $\mathcal{C}, r, \varepsilon$ as in the statement, choose $t := t(\mathcal{C}, r)$ as given by flip-breakability (Corollary 17), and fix $p := [\frac{1}{\varepsilon}]$, $\ell := (\frac{p}{2})t^2$, and $k := k(\mathcal{C}, r, \varepsilon) = \ell + 1$. Further, call $M_{\mathrm{brk}} : \mathbb{N} \to \mathbb{N}$ the function given by Corollary 17 (depending on $\mathcal{C}, r$), and define

$$ M(m) := f(p \cdot M_{\mathrm{brk}}^{(\ell)}(m)), $$

where $f$ is the bound in the sunflower lemma (Theorem 18), and $M_{\mathrm{brk}}^{(\ell)}$ is the $\ell$-fold composition of $M_{\mathrm{brk}}$.

Consider now $G \in \mathcal{C}$ with weights $\mathbf{w}$ and a $t$-uniform family $\mathcal{F}$ of size $M(m)$. Applying Theorem 18 to $\mathcal{F}$, we obtain a subfamily $\mathcal{S} \subseteq \mathcal{F}$ of size $p \cdot M_{\mathrm{brk}}^{(\ell)}(m)$ and a core $Y$ such that for all $A \ne B \in \mathcal{S}$, $A \cap B = Y$. Define $\mathcal{S}' = \{S \setminus Y : S \in \mathcal{S}\}$ the collection of petals of the sunflower $\mathcal{S}$. By construction, it is $t'$-uniform for $t' := t - |Y|$, and no two sets in $\mathcal{S}'$ share a vertex. We arbitrarily partition $\mathcal{S}'$ into $p$ subfamilies $\mathcal{F}_1, \dots, \mathcal{F}_p$, each of equal size $M_{\mathrm{brk}}^{(\ell)}(m)$.

We now write each set in each $\mathcal{F}_q$ as a $t'$-tuple $\bar{s} = (s_1, \dots, s_{t'})$. Our goal, using Corollary 17, is to restrict each $\mathcal{F}_q$ to some subfamily of size $m$, so that $\bigcup \mathcal{F}_q$ and $\bigcup \mathcal{F}_{q'}$ are far apart in some appropriate flip metric for $q \ne q'$. Note here that we allow ourselves to discard entire tuples from the family $\mathcal{F}_q$, but we cannot discard individual vertices from a kept tuple $\bar{s} \in \mathcal{F}_q$.

We proceed as follows for every $q < q'$ and every $i, j \in [t']$: define $W_1 = \{s_i : \bar{s} \in \mathcal{F}_q\}$ the set of $i$th vertices in tuples of $\mathcal{F}_q$, and similarly $W_2 = \{s_j : \bar{s} \in \mathcal{F}_{q'}\}$. Since the sunflower lemma ensures that no two tuples of $\mathcal{F}_q$ share a vertex, we have $|W_1| = |\mathcal{F}_q|$ and $|W_2| = |\mathcal{F}_{q'}|$, which at the start of the procedure are equal to $M_{\mathrm{brk}}^{(\ell)}(m)$. Flip-breakability (Corollary 17) applied to $W_1, W_2$ then gives subsets $A_1 \subseteq W_1$, $A_2 \subseteq W_2$ of size $M_{\mathrm{brk}}^{(\ell-1)}(m)$ each, and a set $Y_1$ of size $t$ such that $\mathrm{Ball}_{Y_1}^r(A_1) \cap \mathrm{Ball}_{Y_1}^r(A_2) = \emptyset$, or equivalently $\mathrm{dist}_{Y_1}(A_1, A_2) > 2r$. We then restrict $\mathcal{F}_q$ to the $M_{\mathrm{brk}}^{(\ell-1)}(m)$ tuples whose $i$th element belongs to $A_1$, and $\mathcal{F}_{q'}$ to the $M_{\mathrm{brk}}^{(\ell-1)}(m)$ tuples whose $j$th element belongs to $A_2$. For simplicity, we also restrict every remaining $\mathcal{F}_{q''}$, $q'' \notin \{q, q'\}$ to an arbitrary subfamily of size $M_{\mathrm{brk}}^{(\ell-1)}(m)$. We then continue with the next choice of $q, q', i, j$, yielding the next set $Y_2$ of size $t$, and further restricting the families $\mathcal{F}_s$ to size $M_{\mathrm{brk}}^{(\ell-2)}(m)$.

After $\ell = (\frac{p}{2})t^2$ steps, $m$ tuples remain in each $\mathcal{F}_q$, and we have accumulated flip-defining sets $Y_1, \dots, Y_\ell$, each of size $t$. Adding the sunflower core, define $\mathcal{Y} = \{Y, Y_1, \dots, Y_\ell\}$ (here $|Y| < t$, but we can add arbitrary elements to $Y$ to make $\mathcal{Y}$ $t$-uniform: this only helps to reach the conclusion of the lemma). By construction, for all $q \ne q'$ and all $i, j \in [t']$, the $i$th elements of tuples of $\mathcal{F}_q$ are at distance more than $2r$ from the $j$th elements of
tuples of $\mathcal{F}_{q'}$ in the flip metric $\text{dist}_{Y_{\ell'}}$ for some $\ell' \in [\ell]$. A fortiori, the same holds in the metric $\text{dist}_Y$. Therefore, $\text{dist}_Y(\bigcup \mathcal{F}_q, \bigcup \mathcal{F}_{q'}) > 2r$ for all $q \neq q'$, or equivalently $\text{Ball}_Y^r(\bigcup \mathcal{F}_q)$ and $\text{Ball}_Y^r(\bigcup \mathcal{F}_{q'})$ are disjoint. Since these $p = \lceil \frac{1}{\epsilon} \rceil$ balls are disjoint, the one with minimum weight, say around $\mathcal{F}_q$, will satisfy

$$ \mathbf{w}(\text{Ball}_Y^r(\bigcup \mathcal{F}_q)) \le \epsilon \cdot \mathbf{w}(V(G)). \qquad (1) $$

Finally, we construct $\mathcal{F}'$ by adding back the core $Y$ to each tuple of $\mathcal{F}_q$, so that they are once again $t$-tuples. Since $Y \in \mathcal{Y}$, we clearly have for any $S \in \mathcal{F}'$ that $S - \bigcup \mathcal{Y} \subseteq \bigcup \mathcal{F}_q$, and thus the conclusion follows directly from (1). ◀

## 4.3 Monadic dependence implies flip-separability

We are now ready to prove our main result: any monadically dependent (or equivalently flip-breakable) class $\mathcal{C}$ is flip-separable. The core of the proof is the following lemma, in which flip-separability is modified to use the metric $\text{dist}_{\mathcal{F}}$ for a $t$-uniform family $\mathcal{F}$, as defined in the previous section. For simplicity, we assume that no vertex has large weight: a weight function $\mathbf{w}: V(G) \to \mathbb{R}_{\ge 0}$ of a graph $G$ is called $\epsilon$-balanced if no vertex $v \in V(G)$ has weight larger than $\epsilon \cdot \mathbf{w}(V(G))$. Vertices with large weight will be added back afterwards.

**Lemma 20.** For every monadically dependent graph class $\mathcal{C}$, $r \in \mathbb{N}$, and $\epsilon > 0$, there are $t, k \in \mathbb{N}$ with the following property. For every $G \in \mathcal{C}$ with an $\epsilon$-balanced weight function $\mathbf{w}$, there exists a family $\mathcal{F} \subseteq 2^{V(G)}$ of at most $k$ many sets each of size at most $t$, such that for every vertex $v \in V(G)$, we have

$$ \mathbf{w}(\text{Ball}_{\mathcal{F}}^r(v)) \le \epsilon \cdot \mathbf{w}(V(G)). $$

We will call a $t$-uniform family $\mathcal{F} \subseteq 2^{V(G)}$ a sparsifying family if it satisfies the conclusion of Lemma 20, i.e. for every vertex $v \in V(G)$,

$$ \mathbf{w}(\text{Ball}_{\mathcal{F}}^r(v)) \le \epsilon \cdot \mathbf{w}(V(G)). $$

The proof of Lemma 20 follows the sketch given at the end of Section 1. The goal is to find a small sparsifying family $\mathcal{F}$. We start with a very large $\mathcal{F}$: for instance any $\mathcal{F}$ satisfying $\bigcup \mathcal{F} = V(G)$ is trivially sparsifying. As long as $\mathcal{F}$ is very large, we shrink it as follows. Applying Lemma 19 gives a large subfamily $\mathcal{F}' \subseteq \mathcal{F}$ and a $t$-uniform family $\mathcal{Y}$ of bounded size which sparsifies $\mathcal{F}'$. This ensures that any vertex close to $\mathcal{F}'$ is sparsified by $\mathcal{Y}$ itself. For vertices which are far from $\mathcal{F}'$, we use locality (Lemma 14) to show that a bounded subfamily $\bar{\mathcal{X}} \subseteq \mathcal{F}'$ is enough to replicate the sparsifying power of $\mathcal{F}'$. Then, tuples in $\mathcal{X} := \mathcal{F}' \setminus \bar{\mathcal{X}}$ are redundant, and $(\mathcal{F} - \mathcal{X}) \cup \mathcal{Y}$ is a sparsifying family. Since $|\mathcal{F}'|$ is unbounded (function of $|\mathcal{F}|$) and $|\bar{\mathcal{X}}|, |\mathcal{Y}|$ are bounded, this new sparsifying family is smaller than $\mathcal{F}$.

**Proof of Lemma 20.** Fix $\mathcal{C}$, $r$, $\epsilon$ as in the statement. Let $r' > r$ be the distance given by Lemma 14 for formulas with quantifier rank at most $r$. Let $t := t(\mathcal{C}, 3r', \epsilon)$, $\lambda := k(\mathcal{C}, 3r', \epsilon)$, and $M := M(\mathcal{C}, r, \epsilon)$ be defined as in Lemma 19. All defined quantities so far depend only on $\mathcal{C}$, $r$, $\epsilon$.

Fix a graph $G \in \mathcal{C}$ with $\epsilon$-balanced weights $\mathbf{w}$. We may assume that $G$ has at least $t$ vertices, as otherwise $\epsilon$-balancedness lets us conclude with $\mathcal{F} := \{V(G)\}$. Since the weights $\mathbf{w}$ are $\epsilon$-balanced, there exists a (large) sparsifying family $\mathcal{F} := \{S_v : v \in V(G)\}$ where we can choose $S_v$ to be any set of size $t$ that contains $v$. We will show that there is a $k \in \mathbb{N}$, which only depends on $\mathcal{C}$, $r$, $\epsilon$, such that whenever we have a sparsifying family $\mathcal{F}$ of size at least $k$,
we can also find a sparsifying family $\mathcal{F}^*$ of strictly smaller size $|\mathcal{F}^*| < |\mathcal{F}|$. This will prove the lemma by induction.

We will specify the value of $k$ later, and now assume that we are given a sparsifying family $\mathcal{F}$ of size at least $k$ that we want to compress. We first apply Lemma 19 with radius $3r'$ and $\varepsilon$ to $\mathcal{F}$ which yields $t$-uniform families $\mathcal{F}' \subseteq \mathcal{F}$ and $\mathcal{Y}$ with $|\mathcal{F}'| \ge M^{-1}(k)$ and $|\mathcal{Y}| \le \lambda$ such that for each $S \in \mathcal{F}'$,

$$ \mathbf{w}(\mathrm{Ball}_{\mathcal{Y}}^{3r'}(S - \bigcup \mathcal{Y})) \le \varepsilon \cdot \mathbf{w}(V(G)). \quad (*) $$

We will next show the existence of a family $\mathcal{X} \subseteq \mathcal{F}'$ such that

$$ \mathcal{F}^* := (\mathcal{F} - \mathcal{X}) \cup \mathcal{Y} $$

is a sparsifying family that is smaller than $\mathcal{F}$. We first show that vertices $v$ close to $\mathcal{F}'$ already define balls of small-enough weight, regardless of $\mathcal{X}$. This is made formal with the following claim.

### ▷ Claim 21. 
For every $v \in \mathrm{Ball}_{\mathcal{Y}}^{2r'}(\bigcup \mathcal{F}')$ we have $\mathbf{w}(\mathrm{Ball}_{\mathcal{Y}}^r(v)) \le \varepsilon \cdot \mathbf{w}(V(G))$.

**Proof.** Consider a vertex $v$ as in the claim, i.e. $v \in \mathrm{Ball}_{\mathcal{Y}}^{2r'}(S)$ for some $S \in \mathcal{F}'$. By definition, every $y \in \bigcup \mathcal{Y}$ satisfies $\mathrm{Ball}_{\mathcal{Y}}^{2r'}(y) = \mathrm{Ball}_{\mathcal{Y}}^r(y) = \{y\}$. This means if $v \in \mathrm{Ball}_{\mathcal{Y}}^{2r'}(\bigcup \mathcal{Y})$ then actually $v \in \bigcup \mathcal{Y}$ and $\mathrm{Ball}_{\mathcal{Y}}^r(v) = \{v\}$ has small weight by $\varepsilon$-balancedness. Otherwise, we must have $v \in \mathrm{Ball}_{\mathcal{Y}}^{2r'}(S - \bigcup \mathcal{Y})$. Then by the triangle inequality

$$ \mathrm{Ball}_{\mathcal{Y}}^r(v) \subseteq \mathrm{Ball}_{\mathcal{Y}}^{r'}(v) \subseteq \mathrm{Ball}_{\mathcal{Y}}^{3r'}(S - \bigcup \mathcal{Y}) $$

and $\mathrm{Ball}_{\mathcal{Y}}^r(v)$ has small weight by $(*)$.

### △

We will next use the locality of first order logic, to show that we can handle the vertices far from $\mathcal{F}'$, by only keeping few representatives from $\mathcal{F}'$. We define the family $\mathcal{X}$ containing the “redundant” sets from $\mathcal{F}'$. In order to build $\mathcal{X}$, consider the first-order formula $\varphi(vw, \bar{s})$ with quantifier rank at most $r$ that asserts $\mathrm{dist}_S(v, w) > r$ for every two vertices $v, w \in V(G)$, set $S$ of size $t$, and $t$-tuple $\bar{s}$ that enumerates $S$. Moreover, let $\mathcal{P}$ be the coarsest simultaneous refinement of every partition $\mathcal{P}_S$ with $S \in \mathcal{Y}$. Each $\mathcal{P}_S$ has size at most $(t + 2^t)$, hence the size of $\mathcal{P}$ is bounded by $p := (t + 2^t)^\lambda$, and $\mathrm{dist}_\mathcal{P}(u, v) \ge \mathrm{dist}_\mathcal{Y}(u, v)$ holds for all vertices $u, v \in V(G)$.

Applying Lemma 14 to $\varphi$ and $p$ yields a number $\ell := \ell(r, 2, t, p)$ that only depends on $\mathcal{C}, r, \varepsilon$, and two $\ell$-colorings $\mathrm{col}_1 : V(G)^2 \to [\ell]$ and $\mathrm{col}_2 : V(G)^t \to [\ell]$ of the 2-tuples and $t$-tuples of $V(G)$ such that for all $uv \in V(G)^2$ and $\bar{s} \in V(G)^t$ with $\mathrm{dist}_\mathcal{P}(uv, \bar{s}) > r'$, whether or not $G \models \varphi(uv, \bar{s})$ holds only depends on $\mathrm{col}_1(uv)$ and $\mathrm{col}_2(\bar{s})$. By our choice of $\varphi$, whether or not $\mathrm{dist}_S(u, v) > r$ holds for $S := \{s : s \in \bar{s}\}$ depends only on these colors, too. Since $\mathrm{dist}_\mathcal{P}(uv, \bar{s}) \ge \mathrm{dist}_\mathcal{Y}(uv, \bar{s})$, the above in particular holds when $\mathrm{dist}_\mathcal{Y}(uv, \bar{s}) > r'$.

Let $\bar{\mathcal{X}} \subseteq \mathcal{F}'$ be a subfamily constructed by picking for every color $K \in [\ell]$ a set $S \in \mathcal{F}'$ such that $\mathrm{col}_2(\bar{s}) = K$ holds for some enumeration $\bar{s}$ of $S$ (when such a set $S$ exists for $K$). We set $\mathcal{X} := \mathcal{F}' - \bar{\mathcal{X}}$, which completes the definition of $\mathcal{F}^*$. Let us now show that $\mathcal{F}^*$ is a sparsifying family. We have already argued in Claim 21 that vertices close to some set $S \subseteq \mathcal{F}'$ have balls of sufficiently small weight. It remains to argue that the same holds for vertices far from $\mathcal{F}'$.

### ▷ Claim 22. 
For every $v \in V(G)$ with $v \notin \mathrm{Ball}_{\mathcal{Y}}^{2r'}(\bigcup \mathcal{F}')$, we have $\mathrm{Ball}_{\mathcal{F}^*}^r(v) \subseteq \mathrm{Ball}_{\mathcal{F}^*}^r(v)$.
Proof. Let $v$ be as in the statement of the claim. Let $w \notin \text{Ball}_{\mathcal{F}}^r(v)$. We want to show that $w \notin \text{Ball}_{\mathcal{F}^*}^r(v)$, too. By assumption, there exists a set $S \in \mathcal{F}$ such that $\text{dist}_S(v, w) > r$. If $S$ is also contained in $\mathcal{F}^*$, then we are done. Otherwise, $S \in \mathcal{X} \subseteq \mathcal{F}'$. Let $\bar{s}$ be a $t$-tuple that enumerates $S$. We know that $G \models \varphi(vw, \bar{s})$. Since $S \in \mathcal{X} \subseteq \mathcal{F}'$, we know that $\text{dist}_Y(v, \bar{s}) > 2r'$ by assumption. Now if $\text{dist}_Y(v, w) > r$, then we are also done. Otherwise, we have $\text{dist}_Y(v, w) \le r$ and by the triangle inequality $\text{dist}_Y(vw, \bar{s}) > r'$. By construction of $\mathcal{X}$ there is another $S' \in \mathcal{F}^*$ that has an enumeration $\bar{s}'$ such that $\text{col}_2(\bar{s}) = \text{col}_2(\bar{s}') = K$. By the same argument as before, also $\text{dist}_Y(vw, \bar{s}') > r'$. As $\bar{s}$ and $\bar{s}'$ have the same color and are both far from $vw$, Lemma 14 gives us that also $G \models \varphi(vw, \bar{s}')$ and $\text{dist}_{\mathcal{F}^*}(v, w) > r$, as desired.

$\triangleleft$

It follows by Claim 21, Claim 22, and $\mathcal{F}$ being a sparsifying family, that also $\mathcal{F}^*$ is a sparsifying family. It finally remains to analyze the size of $\mathcal{F}^*$. We have

$$|\mathcal{F}^*| \le |\mathcal{F}| - |\mathcal{X}| + |\mathcal{Y}|,$$

where $\mathcal{F}$ has size at least $k$, $\mathcal{Y}$ has size at most $\lambda$, and $\mathcal{X}$ has size at least $M^{-1}(k) - \ell$. This means

$$|\mathcal{F}^*| \le |\mathcal{F}| - M^{-1}(k) + \ell + \lambda.$$

Setting $k := M(\ell + \lambda + 1)$ yields $|\mathcal{F}^*| < |\mathcal{F}|$ as desired.

<figure><img src="image_12.png" /></figure>

We can now wrap things up in the main result of this section.

**► Lemma 23.** Every monadically dependent graph class is flip-separable.

**Proof.** Let $\mathcal{C}$ be monadically dependent and fix $r \in \mathbb{N}$ and $\varepsilon > 0$. Consider the graph class

$$\mathcal{C}^+ := \{G + I_n : G \in \mathcal{C}, n \in \mathbb{N}\}$$

where $I_n$ denotes an independent set of size $n$, and $+$ denotes disjoint union of graphs. Evidently, $\mathcal{C}^+$ is still monadically dependent. Let $t, k_0 \in \mathbb{N}$ be the constants obtained by applying Lemma 20 on $\mathcal{C}^+$ with $r' := 6r$ and $\varepsilon' := \varepsilon$. We fix $k_1 := (k_0t + 2^{k_0t})$, $k_2 := k_1 \cdot 2^{k_1}$, and $k := k_2 \cdot (\lfloor \frac{1}{\varepsilon} \rfloor + 2^{\lfloor \frac{1}{\varepsilon} \rfloor})$. Take $G \in \mathcal{C}$ and weights $\mathbf{w} : V(G) \to \mathbb{R}_{\ge 0}$, and let $W := \{v \in V(G) : \mathbf{w}(v) > \varepsilon \cdot \mathbf{w}(V(G))\}$ be the set of vertices of $\varepsilon$-large weight. Evidently, $|W| \le \lfloor \frac{1}{\varepsilon} \rfloor$. By assigning $\varepsilon$-small weights to vertices in the independent set we obtain some $c \in \mathbb{N}$, a graph $G^+ := G + I_c \in \mathcal{C}^+$, and a weight function $\mathbf{w}^+ : V(G^+) \to \mathbb{R}_{\ge 0}$ with the following properties:

1. $\mathbf{w}^+(v) = \mathbf{w}(v)$ for all $v \in V(G) \setminus W$;

2. $\mathbf{w}^+(v) = 0$ for all $v \in W$;

3. $\mathbf{w}^+(V(G^+)) = \mathbf{w}(V(G))$;

4. $\mathbf{w}^+$ is $\varepsilon$-balanced.

It follows by Lemma 20 that there is a collection $\mathcal{F} \subseteq 2^{V(G)}$ of at most $k_0$ many sets of size at most $t$ such that for every vertex $v \in V(G^+)$

$$\mathbf{w}^+(\text{Ball}_{\mathcal{F}}^{6r}(v)) \le \varepsilon \cdot \mathbf{w}^+(V(G^+)).$$

Let $\mathcal{S} = \bigcup \mathcal{F} \subseteq V(G)$; clearly $|\mathcal{S}| \le k_0t$. Consider the partition $\mathcal{P}$ of size $k_1$ into $\mathcal{S}$-classes. By Lemma 8 we obtain a $k_2$-flip $G_0^+$ of $G^+$ such that for all $v \in V(G)$

$$\text{Ball}_{G_0^+}^r(v) \subseteq \text{Ball}_{\mathcal{P}}^{6r}(v) = \text{Ball}_{\mathcal{S}}^{6r}(v) \subseteq \text{Ball}_{\mathcal{F}}^{6r}(v).$$
Finally, consider the k-flip $G_1^+$ of $G^+$ obtained from $G_0^+$ by isolating the vertices in $V(G) \setminus W$, and let $G' := G_1^+[V(G)];$ this is a k-flip of $G$. It follows that for every $v \in V(G)$ of $\epsilon$-small weight,

$$ 
\begin{aligned}
\mathbf{w}(\mathrm{Ball}_{G'}^r(v)) &= \mathbf{w}(\mathrm{Ball}_{G_1^+}^r(v)) = \mathbf{w}^+(\mathrm{Ball}_{G_0^+}^r(v)) \le \mathbf{w}^+(\mathrm{Ball}_{\mathcal{F}}^{6r}(v)) \\
&\le \epsilon \cdot \mathbf{w}^+(V(G^+)) = \epsilon \cdot \mathbf{w}(V(G)).
\end{aligned}
$$

Hence, $\mathcal{C}$ is flip-separable as claimed.

<figure><img src="image_13.png" /></figure>

## 4.4 Flip-separability implies monadic dependence

We finally show that flip-separability implies flip-breakability, which is known to be equivalent to monadic dependence [4].

**Lemma 24.** Every flip-separable graph class is flip-breakable, and hence monadically dependent.

**Proof.** For every integer $r \ge 0$ and for $\epsilon = 1/2$, let $k$ satisfy the definition of flip-separability of $\mathcal{C}$ for the parameters $4r$ and $\epsilon$. We show that we can take $t = t(r, \mathcal{C}) := k$ and $M_r(m) = 4m^2$, in Definition 15, to witness that $\mathcal{C}$ is flip-breakable.

Fix $G \in \mathcal{C}$, $m \in \mathbb{N}$, and $W \subseteq V(G)$ of size at least $M_r(m) = 4m^2$. We can assume without loss of generality that $W$ has size exactly $4m^2$. Define the weights $\mathbf{w}: V(G) \to \mathbb{R}_{\ge 0}$ by $\mathbf{w}(v) = 1$ for every $v \in W$, and $\mathbf{w}(v) = 0$ otherwise. The flip-separability of $\mathcal{C}$ with radius $4r$, $\epsilon = 1/2$, and this weight function yields a k-flip $H$ of $G$ such that

$$ \mathbf{w}(\mathrm{Ball}_{H}^{4r}(v)) = |\mathrm{Ball}_{H}^{4r}(v) \cap W| \le \epsilon \cdot \mathbf{w}(V(G)) = |W|/2 $$

for every $v \in V(G)$ of weight at most $|W|/2$. We can of course assume $m > 0$ (there is nothing to prove otherwise), thus $|W| \ge 4$, and every vertex of $G$ has weight at most $|W|/2$. We distinguish two covering cases.

**Case 1:** There is a vertex $v \in V(G)$ such that $|\mathrm{Ball}_{H}^{2r}(v) \cap W| \ge \sqrt{|W|}$.

On the one hand, $A_1 := \mathrm{Ball}_{H}^{2r}(v) \cap W$ has size at least $\sqrt{4m^2} = 2m > m$. From the flip-separability, we also know that $A' := \mathrm{Ball}_{H}^{4r}(v) \cap W$ has size at most $|W|/2$. Therefore, on the other hand, $A_2 := W \setminus A'$ has size at least $|W|/2 = 2m^2 \ge m$. In $H$, no vertex of $A_1$ is at distance at most $2r$ of a vertex $w$ of $A_2$, as that would put $w$ in $\mathrm{Ball}_{H}^{4r}(v)$. Thus, $A_1, A_2$ satisfy the conclusion of Definition 15.

**Case 2:** For every $v \in V(G)$, it holds that $|\mathrm{Ball}_{H}^{2r}(v) \cap W| < \sqrt{|W|}$.

Let $\{v_1, v_2, \dots, v_h\}$ be a maximal (greedily-constructed) subset of $W$ such that for every $i \ne j \in [h]$, $v_i$ and $v_j$ are at distance larger than $2r$ from each other in $H$. By assumption, we have that $h \ge |W|/\sqrt{|W|} = \sqrt{|W|} = 2m$. Therefore, $A_1 := \{v_1, v_2, \dots, v_m\}$ and $A_2 := \{v_{m+1}, v_{m+2}, \dots, v_{2m}\}$ satisfy the conclusion of Definition 15.

<figure><img src="image_14.png" /></figure>

Lemmas 23 and 24 jointly establish Theorem 3. We remark that the flip-breakability margins $M_r(m) = 4m^2$ obtained in Lemma 24 are polynomial in $m$ and depend on neither $\mathcal{C}$ nor $r$. This is a strengthening of the original bounds obtained in [4], where $M_r$ was established as a fast-growing function with dependence on both $\mathcal{C}$ and $r$. This means our proof of Theorem 3 can also be seen as a boosting argument for flip-breakability.
References

1 J.T. Baldwin and S. Shelah. Second-order quantifiers and the complexity of theories. *Notre Dame Journal of Formal Logic*, 26(3):229–303, 1985.

2 Édouard Bonnet, Jan Dreier, Jakub Gajarský, Stephan Kreutzer, Nikolas Mählmann, Pierre Simon, and Szymon Torunczyk. Model checking on interpretations of classes of bounded local cliquewidth. In Christel Baier and Dana Fisman, editors, *LICS '22: 37th Annual ACM/IEEE Symposium on Logic in Computer Science, Haifa, Israel, August 2 - 5, 2022*, pages 54:1–54:13. ACM, 2022. doi:10.1145/3531130.3533367.

3 Jan Dreier, Nikolas Mählmann, Sebastian Siebertz, and Szymon Toruńczyk. Indiscernibles and Flatness in Monadically Stable and Monadically NIP Classes. In *50th International Colloquium on Automata, Languages, and Programming, ICALP 2023*, volume 261 of LIPIcs, pages 125:1–125:18, Dagstuhl, Germany, 2023. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. URL: https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ICALP.2023.125, doi:10.4230/LIPIcs.ICALP.2023.125.

4 Jan Dreier, Nikolas Mählmann, and Szymon Toruńczyk. Flip-breakability: A combinatorial dichotomy for monadically dependent graph classes. In *56th Annual ACM Symposium on Theory of Computing, STOC 2024*, pages 1550–1560. ACM, 2024. full version: arXiv:2403.15201. doi:10.1145/3618260.3649739.

5 Paul Erdős and Richard Rado. Intersection theorems for systems of sets. *Journal of the London Mathematical Society*, s1-35(1):85–90, 1960. URL: https://londmathsoc.onlinelibrary.wiley.com/doi/abs/10.1112/jlms/s1-35.1.85, doi:https://doi.org/10.1112/jlms/s1-35.1.85.

6 Haim Gaifman. On local and non-local properties. In J. Stern, editor, *Proceedings of the Herbrand Symposium*, volume 107 of *Studies in Logic and the Foundations of Mathematics*, pages 105–135. Elsevier, 1982. URL: https://www.sciencedirect.com/science/article/pii/S0049237X08718792, doi:https://doi.org/10.1016/S0049-237X(08)71879-2.

7 Jakub Gajarský, Nikolas Mählmann, Rose McCarty, Pierre Ohlmann, Michał Pilipczuk, Wojciech Przybyszewski, Sebastian Siebertz, Marek Sokołowski, and Szymon Toruńczyk. Flipper Games for Monadically Stable Graph Classes. In *50th International Colloquium on Automata, Languages, and Programming, ICALP 2023*, volume 261 of LIPIcs, pages 128:1–128:16, Dagstuhl, Germany, 2023. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. URL: https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ICALP.2023.128, doi:10.4230/LIPIcs.ICALP.2023.128.

8 Richard J. Lipton and Robert Endre Tarjan. Applications of a planar separator theorem. *SIAM Journal on Computing*, 9(3):615–627, 1980. doi:10.1137/0209046.

9 Nikolas Mählmann. *Monadically Stable and Monadically Dependent Graph Classes: Characterizations and Algorithmic Meta-Theorems*. PhD thesis, University of Bremen, 2024.

10 Jaroslav Nešetřil and Patrice Ossona de Mendez. Existence of modeling limits for sequences of sparse structures. *The Journal of Symbolic Logic*, 84(2):452–472, 2019. doi:10.1017/jsl.2018.32.

11 Jaroslav Nešetřil and Patrice Ossona de Mendez. *Sparsity - Graphs, Structures, and Algorithms*, volume 28 of *Algorithms and Combinatorics*. Springer, 2012. doi:10.1007/978-3-642-27875-4.

12 Jaroslav Nešetřil and Patrice Ossona de Mendez. Structural sparsity. *Russian Mathematical Surveys*, 71(1):79, feb 2016. doi:10.1070/RM9688.

13 Jaroslav Nešetřil and Patrice Ossona de Mendez. On nowhere dense graphs. *Eur. J. Comb.*, 32(4):600–617, 2011. doi:10.1016/j.ejc.2011.01.006.

14 Pierre Ohlmann, Michał Pilipczuk, Wojciech Przybyszewski, and Szymon Toruńczyk. Canonical Decompositions in Monadically Stable and Bounded Shrubdepth Graph Classes. In *50th International Colloquium on Automata, Languages, and Programming, ICALP 2023*, volume
261 of LIPIcs, pages 135:1–135:17, Dagstuhl, Germany, 2023. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. URL: https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ICALP.2023.135, doi:10.4230/LIPIcs.ICALP.2023.135.

15 Michał Pilipczuk. Graph classes through the lens of logic. ArXiv preprint, abs/2501.04166, 2025. arXiv:2501.04166.

16 Norbert Sauer. On the density of families of sets. Journal of Combinatorial Theory, Series A, 13(1):145–147, 1972. doi:10.1016/0097-3165(72)90019-2.

17 Saharon Shelah. A combinatorial problem; stability and order for models and theories in infinitary languages. Pacific Journal of Mathematics, 41(1):247–261, 1972.

18 Szymon Toruńczyk. Flip-width: Cops and robber on dense graphs. In 64th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2023, pages 663–700. IEEE, 2023. doi:10.1109/FOCS57990.2023.00045.