TITLE: Strange factorial identity
QUESTION [8 upvotes]: The following appears to be true.
\begin{align*}
n! &= \sum_{k=0}^n \sum_{j=0}^{\lfloor\frac{k}{3}\rfloor}\sum_{i=0}^{k-3j}
(-1)^{i+j}\binom{k-2j}{i,j,k-i-3j}\frac{(n-i-2j)!}{(n-k)!}\\
&\qquad +\sum_{k=0}^n\sum_{j=1}^{\lfloor\frac{k+1}{3}\rfloor}\sum_{i=0}^{k+1-3j}
(-1)^{i+j}\binom{k-2j}{i,j-1,k+1-i-3j}\frac{(n-i-2j)!}{(n-k)!}
\end{align*}
I've verified it up to $n=100$.
In theory, it should succumb to a large enough Wilf-Zeilberger hammer, but I do not possess such a hammer.
I have attached a bijective proof of this (the writeup needs work, but I'm pretty sure that the underlying bijection is sound), but I would still very much like an algebraic proof.

REPLY [2 votes]: Combinatorial Definition
An $(n,k)$ partial permutation is a word of length $k$
made of the numbers in $[n]$ with no repetitions.  Alternatively
it is an injection $\sigma$ from $[k]$ to $[n]$.  We are interested
in the set $G_{n,k}$ of $(n,k)$ that satisfy the following condition.
If we set $\sigma(0)=n+1$ (prefix the word with $n+1$) then the following
two conditions hold.

For all $0\le i \le k-1$, $\sigma(i+1) \ne \sigma(i) - 1$
For all $0\le i \le k-2$, $\sigma(i+1) \ne \sigma(i) - 2$ or $\sigma(i+2) \ne \sigma(i) - 1$.

These are equivalent to saying that the partial permutation does not contain $a$ and $a-1$ consecutively
and does not contain $a$, $a-2$, and $a-1$ consecutively.
For example 
\begin{align*}
G_{3,0} &= \{\epsilon\}\\
G_{3,1} &= \{1, 2\}\\
G_{3,2} &= \{12, 13\}\\
G_{3,3} &= \{123\}
\end{align*}
and
\begin{align*}
G_{4,0} &= \{\epsilon\}\\
G_{4,1} &= \{1, 2, 3\}\\
G_{4,2} &= \{12, 13, 14, 23, 24, 31\}\\
G_{4,3} &= \{123, 124, 134, 142, 231, 234, 241, 314\}\\
G_{4,4} &= \{1234, 1342, 2314, 2341, 2413, 3142\}
\end{align*}
It turns out that the above conjecture is equivalent to
$$n! = \sum_{k=0}^n |G_{n,k}|$$
We will first show that the original question counts the elements in $\bigcup_{k=0}^n G_{n,k}$ by inclusion-exclusion, 
then we will exhibit a bijection between the permutations of $[n]$ and $\bigcup_{k=0}^n G_{n,k}$, thereby establishing
the result.  The bijection is more complicated than one might desire, and a direct algebraic proof would be quite welcome.
Counting with inclusion-exclusion
A partial permutation is excluded from $G_{n,k}$ if it has either $a$ and $a+1$ consecutively (we will call these two-blocks) or
it has $a$, $a-2$, $a-1$ consecutively (we will call these three-blocks).  Since each two block effectively assigns one symbol of
the word, and each three block effectively assigns two symbols, there are $(n-i-2j)!/(k-i-2j)!$ $(n,k)$ partial permutations with $i$
given two-blocks and $j$ given three-blocks as long as it is possible for a partial permutation to have that configuration.
Two two blocks can overlap in one position, and a two block can overlap the first cell of a three block but not the last.
We can represent the location of a two block by a one cell domino that represents the location of its first cell, and
the location of a three-block by a three cell domino.  So the number of admissible configurations of $i$ two-blocks and $j$ three-blocks
is the number of ways of placing $i$ one-cell dominos and $j$ three cell dominos on a $k+1\times 1$ cell board so that the last cell does not
contain a one-cell domino (since the one cell domino represents the first cell of a two block, a one cell domino in the last cell would
have the two-block fall off the edge of the partial permutation).
We can count these by considering the two cases
1. The last cell is empty this is just the number of ways of placing $i$ one cell   dominos and $j$ three cell dominos on a $k$ cell board. This is 
   $$\binom{k-2j}{i,j,k-i-3j}.$$
2. The last cell contains the end of a three cell domino, this is the number of ways of placing $i$ one cell dominos and $j-1$ three cell dominos on a $k-2$ cell board.  This is $$\binom{k-2j}{i,j-1,k+1-i-3j}.$$
So using inclusion-exclusion we can count the number of elements in $G_{n,k}$
\begin{align*}
|G_{n,k}| &= \sum_{j=0}^{\lfloor\frac{k}{3}\rfloor}\sum_{i=0}^{k-3j}
(-1)^{i+j}\binom{k-2j}{i,j,k-i-3j}\frac{(n-i-2j)!}{(n-k)!}\\
&\qquad +\sum_{j=1}^{\lfloor\frac{k+1}{3}\rfloor}\sum_{i=0}^{k+1-3j}
(-1)^{i+j}\binom{k-2j}{i,j-1,k+1-i-3j}\frac{(n-i-2j)!}{(n-k)!}
\end{align*}
Summing this over all values of $k$ gives us the original question.
A bijection with permutations
Let us define a two step recursive operation $\phi$ that takes an $(n,k)$ partial permutation $sigma$ and a position $i$ (an integer in [k]) and returns a modified partial permutation. 

If $\sigma(i + 1) = \sigma(i) - 1$ then swap the symbols $\sigma(i)$ and $\sigma(i+1)$ and return $\sigma$.
If $\sigma(i+1) = \sigma(i)-2$ and $\sigma(i+2) = \sigma(i) - 1$ then rotate the three 
  $\sigma(i)\leftarrow\sigma(i+1)\leftarrow\sigma(i+2)\leftarrow\sigma(i)$ and return $\phi(\sigma,i+2)$ 

Now we can define an operation $\pi$ that takes an $(n,k)$, $k<n$  partial permutation $\sigma$ to an $(n,k+1)$ partial permutation as follows
1. Let $a$ be the largest member of $[n]$ not in $\sigma$.
2. If $a=n$ then prefix $\sigma$ with $a$ (add it to the beginning), otherwise add $a$ to $\sigma$ immediately after $a+1$.
3. Let $i$ be the index of $a$.
4. Return $\phi(\sigma,i)$
Note that if $\sigma$ does not have a two-block or a three-block having members smaller than $a$ then the smallest block in $\pi(\sigma)$ is either
the two-block $a+1,a$ or the three block $a+1, a-1, a$ so we can identify which symbol was added by finding the block having the smallest right hand
element.
We can also define an operation $\zeta$ that takes an $(n,k)$ partial permutation containing a two-block or a three-block and returns an $(n,k-1)$ partial permutation.

Let $a$ be the smallest value occurring at the end of a two-block or a three-block 
If $a$ is immediately preceded by $a+1$ remove $a$ and return the resulting partial permutation.
Let $i$ be one less than the index of $a$
Remove $a$ from $\sigma$ and return $\phi(\sigma,i)$ 

Again note that the block containing $a$ has been disturbed
We can now describe our bijection:
To take a member of $G_{n,k}$ and create a permutation of $[n]$ apply $\pi$ $n-k$ times.
To take a permutation of $[n]$ and get a member of $G_{n,k}$ for some $k$ apply $\zeta$ until there are no more two-blocks or three-blocks.
For example for $n = 4$:
\begin{align*}
1234  &\Leftrightarrow  1234\\
1243  &\Leftrightarrow  124\\
1324  &\Leftrightarrow  134\\
1342  &\Leftrightarrow  1342\\
1423  &\Leftrightarrow  142\\
1432  &\Leftrightarrow  14\\
2134  &\Leftrightarrow  234\\
2143  &\Leftrightarrow  24\\
2314  &\Leftrightarrow  2314\\
2341  &\Leftrightarrow  2341\\
2413  &\Leftrightarrow  2413\\
2431  &\Leftrightarrow  241\\
3124  &\Leftrightarrow  314\\
3142  &\Leftrightarrow  3142\\
3214  &\Leftrightarrow  3\\
3241  &\Leftrightarrow  31\\
3412  &\Leftrightarrow  231\\
3421  &\Leftrightarrow  23\\
4123  &\Leftrightarrow  123\\
4132  &\Leftrightarrow  13\\
4213  &\Leftrightarrow  2\\
4231  &\Leftrightarrow  12\\
4312  &\Leftrightarrow  1\\
4321  &\Leftrightarrow  \epsilon 
\end{align*}
We need to show that if $\sigma$ is an $(n,k)$ partial permutation not containing $a$ but containing all of $a+1,\ldots,n$ that does not have any two-blocks or three-blocks containing values less than $a$ then $\zeta(\pi(\sigma))=\sigma$, as if each application of $\zeta$ undoes an application of $\pi$ we see that the two operations are inverses.
If after adding $a$, applying $\phi$ does nothing, then $a$ is preceded by $a+1$ so $\zeta$ just removes $a$ giving us back our original partial permutation.
If after adding $a$, $\phi$ swaps $a$ and $a-1$ then after removing $a$ we get our original permutation back, and applying $\phi$ does nothing (If it could, then our original partial permutation would have contained a block containing $a-1$ contradicting our assumption.)
So, we just need to consider the case that after adding $a$, $\phi$ rotates three elements more than once and then either swaps two elements and stops, or just stops. 
If after adding $a$, $\phi$ rotates $m$ triples and stops, then after adding $a$ we had
\begin{align*}
\sigma(i) &= a & \\
\sigma(i+2j-1) &= a-2j \qquad &\text{for $0<j\le m$ }\\
\sigma(i+2j) &= a + 1 - 2j \qquad  &\text{for $0<j\le m$ }
\end{align*} 
and $\sigma(i+2m+1)\ne a-2m-1$ and $\sigma(i+2m+1)\ne a-2m-2$ or $\sigma(i+2m+2)\ne a-2m-1$.
After applying $\phi$ we have
\begin{align*}
\sigma(i) &= a-1 & \\
\sigma(i+2j-1) &= a-2j+2 \qquad &\text{for $0<j\le m$ }\\
\sigma(i+2j) &= a - 1 - 2j \qquad  &\text{for $0<j\le m$ }
\end{align*} 
Now if we remove the a from position $i+1$ and perform $\phi$ starting at postion $i$ we perform $m-1$ rotations and a final swap.
The remaining case where $\pi$ performs $m$ rotations and one swap proceeds similarly and is undone by $m$ rotations.
Free partially commutative left regular bands
This identity was brought to my attention as a conjecture of Franco Saliola that the size
of a free partially commutative left regular band of an $n$ cycle for $n>3$ was $n!+1$.  As
a set, the free partially commutative left regular band of an $n$ cycle can be considered as the set
of equivalence classes of partial permutations of $[n]$ where two partial permutations are equvalent
if one can be reached from the other by swapping adjacent symbols if they differ by $i\bmod n$.
Setting aside the empty word,
it is easy to see that a given symbol can move at most two positions left or right, as it has only two neighbors in the cyclic graph, so for $n$ large enough (5 will do) each equivalence class has a lexicographically most counterclockwise element.  If we exploit the $n$-fold symmetry we can rotate the word so that the first letter is $n$. This word has no two-blocks or three-blocks, else it could be moved to a more ccw word (in one step for a two-block, or two steps for a three-block), and all such blocks are rotations of most ccw words.