
%root: main.tex


\begin{Theorem}\label{lem:const-p}
If we can compute $\rpoly_{G}^3(\vct{X})$ in T(\numedge) time for $X_1 =\cdots= X_\numvar = \prob$, then we can count the number of triangles, 3-paths, and 3-matchings in $G$ in $T(\numedge) + O(\numedge)$ time.
\end{Theorem}

Before moving on to prove ~\cref{lem:const-p}, let us state the lemmas and defintions that will be useful in the proof.
%Original lemma proving the exact coefficient terms in qE3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{Lemma}\label{lem:qE3-exp}
When we expand $\poly_{G}(\vct{X}) = \left(q_E(X_1,\ldots, X_\numvar)\right)^3$ out and assign all exponents $e \geq 1$ a value of $1$, we have the following,
	\begin{align}
		&\rpoly_{G}(\prob,\ldots, \prob) = \numocc{G}{\ed}\prob^2 + 6\numocc{G}{\twopath}\prob^3 + 6\numocc{G}{\twodis} + 6\numocc{G}{\tri}\prob^3\nonumber\\
		&+ 6\numocc{G}{\oneint}\prob^4 + 6\numocc{G}{\threepath}\prob^4 + 6\numocc{G}{\twopathdis}\prob^5 + 6\numocc{G}{\threedis}\prob^6.\label{claim:four-one}
	\end{align}
\end{Lemma}

\begin{proof}[Proof of \cref{lem:qE3-exp}]
By definition we have that
		\[\poly_{G}(\vct{X}) = \sum_{\substack{(i_1, j_1),\\ (i_2, j_2),\\ (i_3, j_3) \in E}} \prod_{\ell = 1}^{3}X_{i_\ell}X_{j_\ell}.\]
		Rather than list all the expressions in full detail, let us make some observations regarding the sum.  Let $e_1 = (i_1, j_1), e_2 = (i_2, j_2), e_3 = (i_3, j_3)$.  Notice that each expression in the sum consists of a triple $(e_1, e_2, e_3)$.  There are three forms the triple $(e_1, e_2, e_3)$ can take.

\textsc{case 1:} $e_1 = e_2 = e_3$, where all edges are the same.  There are exactly $\numedge$ such triples, each with a $\prob^2$ factor in $\rpoly_{G}\left(\prob_1,\ldots, \prob_\numvar\right)$.

\textsc{case 2:}  This case occurs when there are two distinct edges of the three, call them $e$ and $e'$.  When there are two distinct edges, there is then the occurence when $2$ variables in the triple $(e_1, e_2, e_3)$ are bound to $e$.  There are three combinations for this occurrence.  It is the analogue for when there is only one occurrence of $e$, i.e. $2$ of the variables in $(e_1, e_2, e_3)$ are $e'$.  Again, there are three combinations for this.  All $3 + 3 = 6$ combinations of two distinct values consist of the same monomial in $\rpoly$, i.e. $(e_1, e_1, e_2)$ is the same as $(e_2, e_1, e_2)$.  This case produces the following edge patterns: $\twopath, \twodis$.

\textsc{case 3:} $e_1 \neq e_2 \neq e_3$, i.e., when all edges are distinct.  For this case, we have $3! = 6$ permutations of $(e_1, e_2, e_3)$.  This case consists of the following edge patterns: $\tri, \oneint, \threepath, \twopathdis, \threedis$.
\end{proof}
\qed


\begin{proof}[Proof of \cref{lem:const-p}]

\begin{Definition}\label{def:Gk}
For $k > 1$, let graph $\graph{k}$ be a graph generated from an arbitrary graph $\graph{1}$, by replacing every edge $e$ of $\graph{1}$ with a $k$-path, such that all $k$-path replacement edges are disjoint in the sense that they only intersect at the original intersection endpoints as seen in $\graph{1}$.
\end{Definition}


\begin{Lemma}\label{lem:3m-G2}
The number of $3$-matchings in graph $\graph{2}$ satisfies the following identity,
\begin{align*}
\numocc{\graph{2}}{\threedis} &= 8 \cdot \numocc{\graph{1}}{\threedis} + 6 \cdot \numocc{\graph{1}}{\twopathdis}\\
&+ 4 \cdot \numocc{\graph{1}}{\oneint} + 4 \cdot \numocc{\graph{1}}{\threepath} + 2 \cdot \numocc{\graph{1}}{\tri}.
\end{align*}
\end{Lemma}

\begin{Lemma}\label{lem:3m-G3}
The number of 3-matchings in $\graph{3}$ satisfy the following identity, 
\begin{align*}
\numocc{\graph{3}}{\threedis} &= 4\numocc{\graph{1}}{\twopath} + 6\numocc{\graph{1}}{\twodis} + 18\numocc{\graph{1}}{\tri}\\
&+ 21\numocc{\graph{1}}{\threepath}+ 24\numocc{\graph{1}}{\twopathdis} + 20\numocc{\graph{1}}{\oneint}\\
&+ 27\numocc{\graph{1}}{\threedis}.
\end{align*}

\end{Lemma}

\begin{Lemma}\label{lem:3p-G2}
The number of $3$-paths in $\graph{2}$ satisfies the following identity,
\[\numocc{\graph{2}}{\threepath} = 2 \cdot \numocc{\graph{1}}{\twopath}.\]
\end{Lemma}

\begin{Lemma}\label{lem:3p-G3}
The number of $3$-paths in $\graph{3}$ satisfies the following identity,
\[\numocc{\graph{3}}{\threepath} = \numocc{\graph{1}}{\ed} + 2 \cdot \numocc{\graph{1}}{\twopath}.\]
\end{Lemma}

\begin{Lemma}\label{lem:tri}
For $k > 1$, any graph $\graph{k}$ has the property that $\numocc{\graph{k}}{\tri} = 0$.
\end{Lemma}

\begin{Lemma}\label{lem:lin-sys}
Using the identities of lemmas [\ref{lem:3m-G2}, \ref{lem:3m-G3}, \ref{lem:3p-G2}, \ref{lem:3p-G3}, \ref{lem:tri}] to compute $\numocc{G}{\threedis}, \numocc{G}{\threepath}, \numocc{G}{\tri}$ for $G \in \{\graph{2}, \graph{3}\}$, there exists a linear system $\mtrix{\rpoly}\cdot (x~y~z~)^T = \vct{b}$ which can then be solved to determine the unknown quantities of $\numocc{\graph{1}}{\threedis}, \numocc{\graph{1}}{\threepath}$, and $\numocc{\graph{1}}{\tri}$.
\end{Lemma}

\AH{I didn't think of a more appropriate name for $\vct{b}$, so I have just stuck with what Atri called it on chat.}

Using \cref{def:Gk} we construct graphs $\graph{2}$ and $\graph{3}$ from arbitrary graph $\graph{1}$.
We then show that for any of the patterns $\threedis, \threepath, \tri$ which are all known to be hard to compute, we can use linear combinations in terms of $\graph{1}$ from Lemmas \ref{lem:3m-G2}, \ref{lem:3m-G3}, \ref{lem:3p-G2}, \ref{lem:3p-G3}, \ref{lem:tri} to compute $\numocc{\graph{i}}{S}$, where $i$ in $\{2, 3\}$ and $S \in \{\threedis, \threepath, \tri\}$.  Then, using ~\cref{claim:four-two}, \cref{lem:qE3-exp} and \cref{lem:lin-sys}, we can combine all three linear combinations into a linear system, solving for $\numocc{\graph{1}}{S}$.
%$%^&*(


Before proceeding, let us introduce a few more helpful definitions.

\subsubsection{$f_k$ and $\graph{k}$}




\begin{Definition}\label{def:ed-nota}
For the set of edges in $\graph{k}$ we write $E_k$.  For any graph $\graph{k}$, its edges are denoted by the a pair $(e, b)$, such that $b \in \{0,\ldots, k-1\}$ and $e\in E_1$.
\end{Definition}

\begin{Definition}[$\eset{k}$]
Given an arbitrary subgraph $S\graph{1}$ of $\graph{1}$, let $\eset{1}$ denote the set of edges in $S\graph{1}$.  Define then $\eset{k}$ for $k > 1$ as the set of edges in the generated subgraph $S\graph{k}$.
\end{Definition}

For example, consider $S\graph{1}$ with edges $\eset{1} = \{e_1\}$.  Then the edges of $S\graph{2}$, $\eset{2} = \{(e_1, 0), (e_1, 1)\}$. 
\begin{Definition}\label{def:ed-sub}
Let $\binom{S}{t}$ denote the set of subsets in $S$ with exactly $t$ edges.  In a similar manner, $\binom{S}{\leq t}$ is used to mean the subsets of $S$ with $t$ or fewer edges.
\end{Definition}

The following function $f_k$  is a mapping from every $3$-edge shape in $\graph{k}$ to its `projection' in $\graph{1}$.
\begin{Definition}\label{def:fk}
Let $f_k: \binom{E_k}{3} \mapsto \binom{E_1}{\leq3}$ be defined as follows.  For any $S \in \binom{E_k}{3}$, such that $S = \pbrace{(e_1, b_1), (e_2, b_2), (e_3, b_3)}$, define:
\[ f_k\left(\pbrace{(e_1, b_1), (e_2, b_2), (e_3, b_3)}\right) = \pbrace{e_1, e_2, e_3}.\]
\end{Definition}

\AH{Just questioning if the notation is clear in the ~\cref{def:fk-inv}.  For more details, see the immediately following todo note which is commented out.}
%\AH{I found ~\cref{def:fk-inv} a bit imprecise and bulky and have attempted to refine it.
%\par Since this an inverse function, the signature is reversed, \vari{but},
%\par...the challenge is in quantifying the size of the set (of 3 edge subsets) that is returned...
%\par...where the main observation is that for an input edge of size $r$, a set of size $\leq \binom{r\cdot k}{3}$ is returned...
%\par...but the catch is that for $r \geq 3$, the set will be strictly less than $\binom{r\cdot k}{3}$ since $f_k$ does not map e.g. an input $\{(e_a, b_1), (e_a, b_2), (e_a, b_3)\}$ (where $a$ is constant and $b_1, b_2, b_3 \in \{0,\ldots, k -1\}$) to more than one edge, \textit{and} it is the case for $r \geq 3$ that $f_k^{-1}$ will not map such an input to its input of size $r$, meaning we must subtract off all such subsets of $\binom{E_k}{3}$.
%\par My fix was to use a variable in the exponent and explain in prose.  Perhaps there is a better, simpler notation/solution.}

\begin{Definition}[$f_k^{-1}$]\label{def:fk-inv}
The inverse function $f_k^{-1}: \binom{E_1}{\leq 3}\mapsto \left\{\binom{E_k}{3}\right\}^{h}$ takes an arbitrary $\eset{1}$ of at most $3$ edges and outputs the set of all subsets of $\binom{\eset{k}}{3}$ such that each subset $s^{(k)}$ of the output set is mapped to the input set $s^{(1)}$ by $f_k$, i.e. $f_k(s^{(k)}) = s^{(1)}$.  The set returned by $f_k^{-1}$ is of size $h$, where $h$ depends on $\abs{s^{(1)}}$, such that $h \leq \binom{\abs{s^{(1)}} \cdot k}{3}$.
\end{Definition}

Note, importantly, that when we discuss $f_k^{-1}$, that, although potentially counterintuitive, each \textit{edge} present in $s^{(1)}$ must have an edge in $s^{(k)}$ that `projects` down to it.  \textit{Meaning}, if $|s^{(1)}| = 3$, then it must be the case that each $s^{(k)}$ be a set $\{ (e_i, b), (e_j, b), e_\ell, b) \}$ where $i \neq j \neq \ell$.

\begin{Lemma}\label{lem:fk-func}
$f_k$ is a function.
\end{Lemma}
\begin{proof}[Proof of Lemma \ref{lem:fk-func}]
Note that $f_k$ is properly defined.  For any $S \in \binom{E_k}{3}$, $|f(S)| \leq 3$, since it has to be the case that any subset of $3$ edges in $E_k$ will map to at most 3 edges in $\graph{1}$.  All mappings are in the required range.  Then,  since for any $b \in \{0,\ldots, k-1\}$ the edge $(e, b) \mapsto e$ is a mapping for which $(e, b)$ maps to no other edge than $e$, and this implies that $f_k$ is a function.
\end{proof}
\qed   


\subsection{Three Matchings in $\graph{2}$}
\AR{TODO for {\em later}: I think the proof will be much easier to follow with figures: just drawing out $S\times \{0,1\}$ along with the $(e_i,b_i)$ explicity notated on the edges will make the proof much easier to follow.}
\begin{proof}[Proof of Lemma \ref{lem:3m-G2}]
For each edge pattern $S$, we count the number of $3$-matchings in the $3$-edge subgraphs of $\graph{2}$ in $f_2^{-1}(S)$.  We start with $S \in \binom{E_1}{3}$, where $S$ is composed of the edges $e_1, e_2, e_3$ and $f_2^{-1}(S)$ is the set of all $3$-edge subsets of the set 
\begin{equation*}
\{(e_1, 0), (e_1, 1), (e_2, 0), (e_2, 1), (e_3, 0), (e_3, 1)\}.
\end{equation*}

\begin{itemize}
	\item $3$-matching ($\threedis$)
\end{itemize}
Consider the $\eset{1} = \threedis$ pattern.  Note that edges in $\eset{2}$ are {\em not} disjoint only for the pairs $(e_i, 0), (e_i, 1)$ for $i\in \{1,2,3\}$.  All subsets for $b_1, b_2, b_3 \in \{0, 1\}$, $(e_1, b_1), (e_2, b_2), (e_3, b_3)$ will compose a 3-matching.  One can see that we have a total of two possible choices for each edge $e_i$ in $\graph{1}$ yielding $2^3 = 8$ possible 3-matchings in $f_2^{-1}(S)$.

\begin{itemize}
	\item Disjoint Two-Path ($\twopathdis$)
\end{itemize}
For $\eset{1} = \twopathdis$ edges $e_2, e_3$ form a $2$-path with $e_1$ being disjoint.  This means that $(e_2, 0), (e_2, 1), (e_3, 0), (e_3, 1)$ form a $4$-path while $(e_1, 0), (e_1, 1)$ is its own disjoint $2$-path.  We can only pick either $(e_1, 0)$ or $(e_1, 1)$ from $f_2^{-1}(S)$, and then we need to pick a $2$-matching from $e_2$ and $e_3$.  Note that a four path allows there to be 3 possible 2 matchings, specifically, $\pbrace{(e_2, 0), (e_3, 0)}, \pbrace{(e_2, 0), (e_3, 1)}, \pbrace{(e_2, 1), (e_3, 1)}$.  Since these two selections can be made independently, there are $2 \cdot 3 = 6$ choices for $3$-matchings in $f_2^{-1}(S)$.

\begin{itemize}
	\item $3$-star ($\oneint$)
\end{itemize}
When $\eset{1} = \oneint$, the inner edges $(e_i, 1)$ of $\eset{2}$ are all connected, and the outer edges $(e_i, 0)$ are all disjoint.  Note that for a valid 3 matching it must be the case that at most one inner edge can be part of the set of disjoint edges.  When exactly one inner edge is chosen, there are 3 such possibilities.  The remaining possible 3-matching occurs when all 3 outer edges are chosen.  Thus, there are $3 + 1 = 4$ 3-matchings in $f_2^{-1}(S)$. 

\begin{itemize}
	\item $3$-path ($\threepath$)
\end{itemize}
When $\eset{1} =\threepath$ it is the case that all edges beginning with $e_1$ and ending with $e_3$ are successively connected.  This means that the edges of $\eset{2}$ form a $6$-path in the edges of $f_2^{-1}(S)$, where all edges from $(e_1, 0),\ldots,(e_3, 1)$ are successively connected.  For a $3$-matching to exist, there must be at least one edge separating edges picked from a sequence.  There are four such possibilities: $\pbrace{(e_1, 0), (e_2, 0), (e_3, 0)}, \pbrace{(e_1, 0), (e_2, 0), (e_3, 1)},  \pbrace{(e_1, 0), (e_2, 1), (e_3, 1)},$\newline $\pbrace{(e_1, 1), (e_2, 1),  (e_3, 1)}$ . Thus, there are four possible 3-matchings in $f_2^{-1}(S)$.

\begin{itemize}
	\item Triangle ($\tri$)
\end{itemize}
For $\eset{1} = \tri$, note that it is the case that the edges in $\eset{2}$ are connected in a successive manner, but this time in a cycle, such that $(e_1, 0)$ and $(e_3, 1)$ are also connected.  While this is similar to the discussion of the three path above, the first and last edges are not disjoint, since they are connected.  This rules out both subsets of $(e_1, 0), (e_2, 0), (e_3, 1)$ and $(e_1, 0), (e_2, 1), (e_3, 1)$ leaving us with $2$ remaining edge combinations that produce a 3 matching.

\begin{itemize}
	\item $2$-matching ($\twodis$), $2$-path ($\twopath$), $1$ edge ($\ed$)
\end{itemize}
Let us also consider when $S \in \binom{E_1}{\leq 2}$.  When $|S| = 2$, we can only pick one from each of two pairs, $\pbrace{(e_1, 0), (e_1, 1)}$ and $\pbrace{(e_2, 0), (e_2, 1)}$.  This implies that a $3$-matching cannot exist in $f_2^{-1}(S)$.  The same argument holds for $|S| = 1$, where we can only pick one edge from the pair $\pbrace{(e_1, 0), (e_1, 1)}$, thus no $3$-matching exists in $f_2^{-1}(S)$.

Observe that all of the arguments above focused solely on the shape/pattern of $S$.  In other words, all $S$ of a given shape yield the same number of $3$-matchings, and this is why we get the required identity. 
\end{proof}
\qed

\subsection{Three matchings in $\graph{3}$}


\begin{proof}[Proof of Lemma \ref{lem:3m-G3}]
For any $S \in \binom{E_1}{\leq3}$, we again then count the number of $3$-matchings in $f_3^{-1}(S)$. 



\begin{itemize}
	\item $1$ edge ($\ed$)
\end{itemize}
When $\eset{1} = \ed$, $f_3^{-1}(\eset{1})$ has one subset, $(e_1, 0), (e_1, 1), (e_1, 2)$, which clearly does not contain a $3$-matching. Thus there are no $3$-matchings in $f_3^{-1}(\eset{1})$ for this case.

\begin{itemize}
	\item $2$-path ($\twopath$)
\end{itemize}
Fix then $\eset{1} = \twopath$ and now we have all edges in $\eset{3}$ form a $6$-path, and similar to the discussion in the proof of \cref{lem:3m-G2} (when $eset{1} = \threepath$ in $\graph{2}$), this leads to $4$ $3$-matchings in $f_3^{-1}(\eset{1})$.

\begin{itemize}
	\item $2$-matching ($\twodis$)
\end{itemize}
For $\eset{1} = \twodis$, all edges of $\eset{3}$ are predicated on the fact that $(e_i, b)$ is disjoint with $(e_j, b)$ for $i \neq j\in \{1,2\}$ and $b \in \{0, 1, 2\}$.  Pick an aribitrary $e_i$ and note, that $(e_i, 0), (e_i, 2)$ is a $2$-matching, which can combine with any of the $3$ edges in $(e_j, 0), (e_j, 1), (e_j, 2)$ again for $i \neq j$.  Since the selections are independent, it follows that there exist $2 \cdot 3 = 6$ $3$-matchings in $f_3^{-1}(\eset{1})$.

\begin{itemize}
	\item Triangle ($\tri$)
\end{itemize}
Now, we consider the 3-edge subgraphs of $\graph{1}$, starting with $\eset{1} = \tri$.   As discussed in proof of \cref{lem:3m-G2} for the case of $\tri$, the edges of $\eset{3}$ are a cyclic sequence, and we must be careful not to pair $(e_1, 0)$ with $(e_3, 2)$ in a $3$-matching.  For any $s \in f_3^{-1}(S)$, $s$ is a $3$-matching when we have that for the edges $(e_1, b_1), (e_2, b_2), (e_3, b_3)$ where $b_1, b_2, b_3 \in \{0, 1, 2\}$, such that, for all $i \in [3]$ it is the case that if $b_i = 2$ then $b_{i \mod{3} + 1} \neq 0$.  Iterating through all possible combinations, we have
\begin{itemize}
	\item \textsc{$(e_1, 0)$}
		\begin{itemize}
			\item $\pbrace{(e_1, 0), (e_2, 0), (e_3, 0)}$
			\item $\pbrace{(e_1, 0), (e_2, 0), (e_3, 1)}$
			\item $\pbrace{(e_1, 0), (e_2, 1), (e_3, 0)}$
			\item $\pbrace{(e_1, 0), (e_2, 1), (e_3, 1)}$
			\item $\pbrace{(e_1, 0), (e_2, 2), (e_3, 1)}$
		\end{itemize}
	\item \textsc{$(e_1, 1)$}
		\begin{itemize}
			\item $\pbrace{(e_1, 1), (e_2, 0), (e_3, 0)}, \ldots\pbrace{(e_1, 1), (e_2, 1), (e_3, 2)}$
			\item $\pbrace{(e_1, 1), (e_2, 2), (e_3, 1)}$
			\item $\pbrace{(e_1, 1), (e_2, 2), (e_3, 2)}$
		\end{itemize}
	\item \textsc{$(e_1, 2)$}
		\begin{itemize}
			\item $\pbrace{(e_1, 2), (e_2, 1), (e_3, 0)}$
			\item $\pbrace{(e_1, 2), (e_2, 1), (e_3, 1)}$
			\item $\pbrace{(e_1, 2), (e_2, 1), (e_3, 2)}$
			\item $\pbrace{(e_1, 2), (e_2, 2), (e_3, 1)}$
			\item $\pbrace{(e_1, 2), (e_2, 2), (e_3, 2)}$
		\end{itemize}
\end{itemize}
for a total of 18 3-matchings in $f_3^{-1}(\eset{1})$.

\begin{itemize}
	\item $3$-path ($\threepath$)
\end{itemize}
Consider when $\eset{1} = \threepath$ and all edges in $\eset{3}$ are successively connected to form a $9$-path.  Since $(e_1, 0)$ is disjoint to $(e_3, 2)$, both of these edges can exist in a $3$-matching.  This relaxation yields 3 other 3-matchings that couldn't be counted in the case of the $\eset{1} = \tri$, namely 
\begin{equation*}
\pbrace{(e_1, 0), (e_2, 0), (e_3, 2)},\pbrace{(e_1, 0), (e_2, 1), (e_3, 2)}, \pbrace{(e_1, 0), (e_2, 2), (e_3, 2)}.
\end{equation*}
There are therefore $18 + 3 = 21$ $3$-matchings in $f_3^{-1}(\eset{1})$.

\begin{itemize}
	\item Disjoint Two-Path ($\twopathdis$)
\end{itemize}
Assume $\eset{1} = \twopathdis$, then the edges of $\eset{3}$ have successive connectivity from $(e_1, 0)$ through $(e_1, 2)$, and successive connectivity from $(e_2, 0)$ through $(e_3, 2)$.  It is the case that the edges in $\eset{3}$ form a 6-path with a disjoint 3-path.  There exist $8$ distinct two matchings (with at least one $(e_2,\cdot)$ and at least one $(e_3,\cdot)$ edge) in the $6$-path $(e_2, 0),\ldots, (e_3, 2)$ of the form 
\begin{equation*}
\pbrace{(e_2, 0), (e_3, 0)},\ldots, \pbrace{(e_2, 1), (e_3, 2)}, \pbrace{(e_2, 2), (e_3, 1)}, \pbrace{(e_2, 2), (e_3, 2)}.
\end{equation*}
These matchings can be paired independently with either of the $3$ remaining edges of $(e_1, b)$, for a total of $8 \cdot 3 = 24$ 3-matchings in $f_3^{-1}(\eset{1})$.

\begin{itemize}
	\item $3$-star ($\oneint$)
\end{itemize}
Given $\eset{1} = \oneint$, the edges of $\eset{3}$ are restricted such that the outer edges $(e_i, 0)$ are disjoint from another, the middle edges $(e_i, 1)$ are also disjoint to each other, and only the inner edges $(e_i, 2)$ intersect with one another at exactly one common endpoint.  To be precise, any outer edge $(e_i, 0)$ is disjoint to every middle edge $(e_j, 1)$ for $i \neq j$.  As previously mentioned in the proof of \cref{lem:3m-G2}, at most one inner edge may appear in a $3$-matching.  For arbitrary inner edge $(e_i, 2)$, we have $4$ combinations of the middle and outer edges of $e_j, e_k$, where $i \neq j \neq k$.  These choices are independent and we have $4 \cdot 3 = 12$ 3-matchings.  We are not done yet, as we need to consider the middle and outer edge combinations.  Notice that for each $e_i$, we have $2$ choices, i.e. a middle or outer edge, contributing $2^3 = 8$ additional $3$-matchings, for a total of $8 + 12 = 20$ $3$-matchings in $f_3^{-1}(\eset{1})$.

\begin{itemize}
	\item $3$-matching ($\threedis$)
\end{itemize}
Given $\eset{1} = \threedis$ subgraph, we have the case that all edges in $\eset{3}$ have the property that $(e_i, b)$ is disjoint to $(e_j, b)$ for $i \neq j$.  For each $e_i$, there are then $3$ choices, independent of each other, and it results that there are $3^3 = 27$ 3-matchings in $f_3^{-1}(\eset{1})$.

All of the observations above focused only on the shape of $S$, and since we see that for fixed $S$, we have a fixed number of $3$-matchings, this implies the identity.
\end{proof}
\qed

\subsection{Three Paths}
Computing the number of 3-paths in $\graph{2}$ and $\graph{3}$ consists of much simpler linear combinations.
\subsubsection{$\graph{2}$}


\begin{proof}[Proof of Lemma \ref{lem:3p-G2}]
For $\mathcal{P} \subseteq \eset{2}$ such that $\mathcal{P} $ is a $3$-path, it \textit{must} be the case by definition of $f$ that all edges in $f_2(\mathcal{P} )$ have at least one mapping from an edge in $\mathcal{P} $ (and recall that $\mathcal{P} $ is connected).  This constraint rules out every pattern $\eset{1}$ consisting of $3$ edges, as well as when $\eset{1} = \twodis$. For $\eset{1} = \ed$, note that $\eset{1}$ doesn't have enough edges to have any output in $f_2^{-1}(\eset{1})$, i.e., there exists no $s \in \binom{E_2}{3}$ such that $f_2(\mathcal{P} ) = \eset{1}$.  The only surviving pattern is $\eset{1} = \twopath$, where the edges of $\eset{2}$ have successive connectivity from $(e_1, 0)$ to $(e_2, 1)$.  There are then $2$ $3$-paths sharing edges $e_1$ and $e_2$ in $f_2^{-1}(\eset{1}), \pbrace{(e_1, 0), (e_1, 1), (e_2, 0)} \text{ and }\pbrace{(e_1, 1), (e_2, 0), (e_2, 1)}$.
\end{proof}
\qed


\subsubsection{$\graph{3}$}


\begin{proof}[Proof of Lemma \ref{lem:3p-G3}]
The argument follows along the same lines as in the proof of \cref{lem:3p-G2}.  Given $\mathcal{P} \subseteq \eset{3}$, it \textit{must} be that every edge in $f_3(\mathcal{P})$ has at least one edge in $\mathcal{P}$ mapped to it (and $\mathcal{P}$ is connected).  Notice again that this cannot be the case for any $\eset{1} \in \binom{E_1}{3}$, nor is it the case when $\eset{1} = \twodis$.  This leaves us with two patterns, $\eset{1} = \twopath$ and $\eset{1} = \ed$.  For the former, it is the case that we have $2$ $3$-paths across $e_1$ and $e_2$, $\pbrace{(e_1, 1), (e_1, 2), (e_2, 0)}$ and $\pbrace{(e_1, 2), (e_2, 0), (e_2, 1)}$.  For the latter pattern $\ed$, it it trivial to see that an edge in $\graph{1}$ becomes a $3$-path in $\graph{3}$, and this proves the identity.  
\end{proof}
\qed



\subsection{Triangle}


\begin{proof}[Proof of Lemma \ref{lem:tri}]
The number of triangles in $\graph{k}$ for $k \geq 2$ will always be $0$ for the simple fact that all cycles in $\graph{k}$ will have at least six edges.
\end{proof}
\qed