Let $\mathcal{S}=[m]^*$ be the set of all strings on the alphabet $[m]=\{1, 2,\cdots, m\}$. Let $\Sigma\subset[m]^2$ be a set of strings of length $2$, and let $\overline{\Sigma}=[m]^2\backslash\Sigma$ be the complementary set. Let $\mathcal{G}$ (respectively $\overline{\mathcal{G}}$) be the set of all strings in $\mathcal{S}$ with the property that every substring of length $2$ belongs to $\Sigma$ (respectively $\overline{\Sigma}$). (Note that $\mathcal{G}$ and $\overline{\mathcal{G}}$ both include all strings of length $0$ or $1$.) Letting $\pi(\sigma)$ be the length of a string $\sigma\in\mathcal{S}$, define the two generating functions \begin{equation} G(x)=\sum_{\sigma\in\mathcal{G}}x^{\pi(\sigma)}\qquad\qquad \overline{G}(x)=\sum_{\sigma\in\overline{\mathcal{G}}}x^{\pi(\sigma)} \end{equation} The following identity holds: $G(x)=\overline{G}(-x)^{-1}$
A few years ago during my undergrad, I was asked to prove the above generating function identity in an assignment for a class on combinatorial enumeration. I have written out a proof of this identity below as an answer (I think that makes the most sense here, to keep this question concise). However, after I submitted this proof, I was informed that my proof was unexpected, and that there were other more intended methods to arrive at the identity.
Therefore I ask out of curiosity: What are some alternate methods of proving the above identity? (perhaps using more standard string counting generating function arguments, generalized inclusion exclusion, a combinatorial approach, or some more exotic method)
I would also be interested in seeing if/how different approaches to this problem allow for generalization of this identity. (perhaps a higher order identity of this sort exists, or perhaps one involving substrings of length greater than $2$, or one involving more general objects) I give mention one such small generalization in my answer.
Equivalently, we can prove that $$ G(x)\times \overline{G}(-x)=1 $$ Using the definition, we must show $$ \left(\sum_{\sigma\in \mathcal G}x^{\text{len}(\sigma)}\right) \left(\sum_{\tau\in \overline{\mathcal G}} (-x)^{\text{len}(\tau)}\right) = \sum_{\sigma\in \mathcal G} \sum_{\tau\in \overline{\mathcal G}} (-1)^{\text{len}(\tau)}x^{\text{len}(\sigma)+\text{len}(\tau)}=1 $$ We are effectively summing over ordered pairs $(\sigma,\tau)$, where $\sigma$ is a valid word for $\mathcal G$, and $\tau$ is valid word for $\newcommand\H{\overline{\mathcal G}}\H$. The contribution to $x^n$ is equal to the number of order pairs with total length $n$ for which $\newcommand\len{\text{len}}\len(\tau)$ is even, minus the number of ordered pairs for which $\len(\tau)$ is odd. We must show that this signed count of ordered pairs is zero, for all $n\ge 1$. To do this, we will use a sign-reversing involution. That is, we will divide the set of ordered pairs into pairs, where one contributes positively to the coefficient of $x^n$ and the other contributes negatively.
Specifically, I will define a function $f$, which takes as input an ordered pair $(\sigma,\tau)$ for which $\len(\sigma)+\len(\tau)=n$, and outputs a different order pair $(\sigma',\tau')$ for which $\len(\sigma')+\len(\tau')=n$. This function will have the property that $f\circ f$ is the identity, and $f$ has no fixed points, which means $f$ partitions the set of all order pairs into pairs of the form $\{(\sigma,\tau),(\sigma',\tau')\}$. Furthermore, $\len(\tau)$ will have the opposite parity of $\len(\tau')$, which means that the contributions of $(\sigma,\tau)$ and $(\sigma',\tau')$ to $x^n$ will cancel each other out. Since all pairs cancel, the coefficient of $x^n$ will be zero for all $n\ge 1$, as desired.
Suppose that $\sigma=\sigma_1\dots \sigma_s$ and $\tau=\tau_1\dots\tau_t$. We compute $f(\sigma,\tau)$ as follows:
If $\sigma_s\,\tau_1\in \Sigma$, then $\sigma'=(\sigma_1,\dots,\sigma_s,\tau_1)$ and $\tau'=(\tau_2,\dots,\tau_{t})$. That is, delete the first character of $\tau$, and append it to $\sigma$.
If $\sigma_s\,\tau_1\not\in \Sigma$, then $\sigma'=(\sigma_1,\dots,\sigma_{s-1})$ and $\tau'=(\sigma_s,\tau_1,\dots,\tau_{t})$. That is, delete the last character of $\sigma$, and prepend it to $\tau$.
I leave it to you to prove that $f$ has the properties I claimed; namely, that $(f\circ f)(\sigma,\tau)=(\sigma,\tau)$, and that $\len(\tau')$ always has the opposite parity as $\len(\tau)$.