Date: 2020-06-21 (https://cs.stackexchange.com/a/127485/34520)
Update: 2020-10-28 (wrote this article)
This cs.stackexchange question from user326210 asks whether the acceptance problem for “leapfrog automata” is NP-complete. Recall: The acceptance problem asks, given an automaton $M$ and string $w$, “Does $M$ accept $w$?”.
Metaphor. Imagine a frog on a lily pad, determined to eat a gourmet, multi-course meal of flies. The meal is planned as a sequence of different types of flies. Flies are on nearby lily pads, which the frog can jump between, but it can only catch one before the rest fly away! Luckily for the frog, the uneaten flies will soon come back to a lily pad once it jumps to a different one. The frog needs proper nutrition to jump between so many lily pads, so it must catch a fly after each jump in order to have enough energy for its next jump. The problem is: Given a multi-course meal plan and a specific assortment of flies on lily pads, can the frog eat the entire meal?
It’s a cute metaphor, but let’s rephrase it as an automaton for the rest of this article. In short: (lily pad $\to$ register), (frog $\to$ active register), (flies $\to$ symbols), (meal plan $\to$ input string).
Defining leapfrog automata. A leapfrog automaton has a set of registers, each with a collection of symbols. It marks exactly one register as active at any time beginning with a unique “start” register. Its input string is accepted when all of its inputs symbols are consumed in order of appearance. To consume a symbol $\alpha$:
Note the nondeterministic choice. If there is no valid sequence of active registers that allows each input symbol to be consumed, then the input is rejected.
NP-completeness proof idea. So, is the acceptance problem for leapfrog automata NP-complete? For a reduction from 3-SAT, we could create registers $2i$ and $2i+1$ for each clause $C_i$ of the 3-SAT instance $\phi$. For each variable in $\phi$, we use the input string to guide execution:
This is the actual proof sketch, but I couldn’t manage to guarantee that an initial odd register choice would remain odd. That is, I couldn’t guarantee that variables stayed true while evaluating the 3CNF formula. I could however ensure that the registers (resp. variables) stay odd (resp. false). You’d think that a broken mapping like this, where the true variables could nondeterministally decay to false, would completely invalidate the NP-completeness proof. It turns out that a restricted version of 3-SAT is indifferent to whether decay can occur.
Let 3-SAT-REPEAT be a version of 3-SAT whose input is a 3CNF formula ANDed with itself at least as many times as it has variables (i.e., the 3CNF $\phi$ with $n$ variables is repeated at least $n+1$ times).
3-SAT-REPEAT is NP-complete by a polynomial-time mapping reduction from 3-SAT. In this mapping, let the instance of 3-SAT be a 3CNF formula $\phi$. The corresponding instance of 3-SAT-REPEAT is $\phi’=\phi\land\dots\land\phi$, where $\phi$ is repeated $n+1$ times. $\phi’$ can be constructed in a number of steps that is polynomial (quadratic) with respect to the size of $\phi$, therefore 3-SAT-REPEAT is in NP. Furthermore, $\phi’$ is satisfiable if and only if $\phi$ is satisfiable, therefore 3-SAT-REPEAT is NP-hard.
Notice that we only considered 3CNF formulas. A mapping reduction from A to B means that $\forall w: w\in \textbf{A} \iff f(w) \in \textbf{B}$. But from what universe is the problem instance $w$? It is often an implicit (though completely sound) assumption that each problem instance $w$ is a valid input (aka in the problem domain) of A. Therefore, a reduction from 3-SAT-REPEAT will only consider a 3CNF formula ANDed with itself at least $n+1$ times.
Let DECAY-3SAT be the problem of satisfying a 3CNF formula where variables can change their values to false (aka decay) during evaluation of subsequent clauses (but not back to true).
DECAY-3SAT is NP-complete by a trivial reduction from 3-SAT-REPEAT. Consider satisfiable instance of $\phi’=\phi\land\dots\land\phi$ of 3-SAT-REPEAT when decay can occur. $\phi$ appears $n+1$ times in $\phi’$, and $\phi’$ only has $n$ variables, therefore some $\phi$ must be evaluated without decay. This proves that decay cannot make $\phi’$ satisfiable. Furthermore, the nondeterminism of decay cannot make $\phi’$ unsatisfiable. Thus, any instance $\phi’$ of 3-SAT-REPEAT is satisfiable if and only if it satisfiable with decay, proving that DECAY-3SAT is NP-complete.
My original proof reduced DECAY-3SAT to leapfrog automaton acceptance, but I think it would have been better to reduce from 3-SAT-REPEAT. That way, the proof would be valid even if the leapfrog automaton construction didn’t have as much freedom to decay as DECAY-3SAT. It would cover the following cases:
The full proof lives at https://cs.stackexchange.com/a/127485/34520, with an excellent illustrative reply by user326210. However, I’m sure you’re wondering how to reduce 3-SAT-REPEAT instances to leapfrog automaton acceptance.
For each clause $C_i$ in the 3-SAT-REPEAT instance $\phi’$: