%! TEX root = PC.tex
% vim: tw=80 ft=tex
% 05/11/2025 09AM

\begin{proof}[Proof of \cref{lemma:grrgreedy}]
  Greedily embed $H$ into $G$.
  This is possible, because when we embed $x_{i + 1}$, there are at least
  \[
    n
    \ub{- \frac{n}{4d} - \frac{n}{4d} - \cdots - \frac{n}{4d}}_{\text{$d$
    times}}
  \]
  many possible options (a lot!).
\end{proof}

\begin{fclemma}[]
  \label{lemma:grrmaxdegfinding}
  Assuming:
  - $p, \eps \in (0, 1)$, $t \in \Nbb \cup \{0\}$
  - $G$ a graph with no \gls{pepsdense} subgraph on $\ge \left( \frac{\eps}{4}
  \right)^t \cdot n$ vertices
  Then:
  there exists $A \subset V(G)$ with $|A| \ge \left( \frac{\eps}{4} \right)^t
  \cdot n$ and
  \[
    \Delta(G[A])
    \le (32p + 2^{-t}) |A|
  .\]
\end{fclemma}

We will apply this Lemma with $t \sim \log d$ and $p \sim \frac{1}{d}$, so that
we get a subgraph $G[A]$ satisfying the assumptions of the greedy embedding
algorithm (\cref{lemma:grrgreedy}).

\begin{proof}
  We work by induction on $t$.

  For $t = 0$: trivial, can just take $A = G$, since $2^{-t} = 1$.

  Assume holds for $t - 1$.
  Let $X, Y \subset V(G)$ such that
  \[
    e(X, Y)
    \le p|X||Y|
  ,\]
  where $|X|, |Y| = \lceil \eps n \rceil$, because $G$ is not \gls{pepsdense}.

  If $|X \cap Y| \ge \frac{\eps n}{2}$ then let $A' = X \cap Y$, so
  \[
    e(A', A')
    \le e(X, Y)
    \le p|X||Y|
    \le 4p|A'|^2
  .\]
  Throw away vertices of degree $\ge 16p|A'|$ and we delete at most $\le \half$
  of $A'$.
  Call the resulting set $A$, which is our desired set.

  So we can assume that $|X \cap Y| \le \frac{\eps n}{2}$.
  So we work with $X \setminus Y$ and $Y \setminus X$.

  \textbf{Fact:} If I have a bipartite graph $G$ with bipartition $A \cup B$ and
  $e(G) \le p|A||B|$, then there exists $A_0 \subset A$ with $|A_0| \ge
  \frac{|A|}{2}$ so that
  \[
    |N(x) \cap B|
    \le 2p|B|
  ,\]
  for all $x \in A_0$.

  Proof: Let $x \in A$ chosen uniformly at random.
  Then
  \[
    \Pbb_x(|N(x) \cap B| \ge 2p|B|)
    \le \frac{\frac{1}{|A|} \sum_{x \in A} d(x)}{2p|B|}
    = \frac{p|A||B|}{2p|B||A|}
    = \half
  .\]
  So if we let $A_0$ be the set of vertices satisfying the desired condition,
  then we have $\frac{|A \setminus A_0|}{|A|} \le \half$ as desired.

  Using this fact, we put
  \[
    A_0
    = \{x \in A : |N(x) \cap B| \le 2p|B|\}
  .\]
  
  Let $X_0 \subset X \setminus Y$ be such that
  \[
    |N(x) \cap (Y \setminus X)|
    \le 2p|Y \setminus X|
  \]
  and $|X_0| \ge \frac{|X \setminus Y|}{2} \ge \frac{\eps}{4}n$.

  Now apply induction inside of $X_0$ to find $X_A \subset X_0$ with
  \[
    |X_A|
    \ge \left( \frac{\eps}{4} \right)^{t - 1} \left( \frac{\eps n}{4} \right)
    = \left( \frac{\eps}{4} \right)^t n
  \]
  and
  \[
    \Delta(G[X_A])
    \le (64p + 2^{-t})|X_A|
  .\]
  Now consider the bipartite graph between $X_A$ and $Y \setminus X$.
  Note
  \begin{align*}
    e(X_A, Y \setminus X)
    &= \sum_{x \in X_A} |N(x) \cap Y \setminus X| \\
    &\le 2p|N(x) \cap Y \setminus X| |X_A|
  \end{align*}
  So apply fact to find $Y_0 \subset Y \setminus X$ with $|Y_0| \ge |Y \setminus
  X|$ and $|N(x) \cap X_A| \le 4p |X_A|$.
  Now apply induction inside of $Y_0$ to get $Y_A \subset Y_0$ satisfying the
  induction hypothesis.

  Set $A = Y_A \cup X_A$.
  We now check the max degree condition.
  Let $x \in A$ and without loss of generality assume $x \in Y_A$.
  \[
    |N(x) \cap A|
    \le (64p + 2^{-t + 1})|Y_A|
    + 4p|X_A|
  .\]
  Then
  \begin{align*}
    \frac{|N(x) \cap A|}{|A|}
    &\le \left( 64p + 2^{-t + 1} \right) \half
    + \frac{4p}{2} \\
    &\le (64p + 2^{-t})
  \end{align*}
  as desired.
\end{proof}

This proof had some lies.
At the end, we actually need to perform another step where we delete high degree
vertices.
Also, for some of the inequalities, we treated them as equality so that we
can divide by them nicely.
This can be fixed by passing down to a subgraph, because an average subgraph has
the same density as the original graph.

The proof is probably simpler if we instead make our inductive claim be about
the density of $G[A]$, and then delete high degree vertices at the end to get a
maximum degree condition.

\begin{proof}[Proof of \nameref{thm:grr}]
  Let $n > 2^{Cd(\log d)^2} \cdot k$.
  Let $\chi$ be a 2-colouring of $K_n$.
  Set $p = \frac{1}{4d}$ and $\eps = \frac{p^d}{4d}$, let $t = 2\log_2 d$.

  Either there is a subset of $V(G)$ that is \gls{pepsdense} with $\ge \left(
  \frac{\eps}{4} \right)^t n$ vertices, in which case I apply
  \nameref{lemma:grrembedding} to find $H$.
  Otherwise find a very dense subgraph in the other colour
  (\cref{lemma:grrmaxdegfinding}) and apply the greedy embedding algorithm
  (\cref{lemma:grrgreedy}).
\end{proof}
