--- issue: 31 status: done --- # Palindromes in linear time For every finite alphabet, including the empty alphabet, `Millennium.Examples.Palindrome.palindromes_in_P` decides the predicate `inp = inp.reverse` in the project's fixed model. It takes no composition assumption. An input of length `n` needs at most `3*n + 3` transitions. First copy the input to a scratch stack and a reversed stack. Restore the scratch copy to the input stack. Compare the restored input and the reversed copy one symbol at a time, accumulating an agreement bit even after a mismatch. At halt the symbol stacks are empty and exactly one Boolean is on the output stack. The timed lemmas `copyRun`, `restoreRun` and `compareRun` have separate invariants and accept accumulated stack contents where appropriate. The [build](https://shoal.club/shoal/p-vs-np/jobs/1528) actually compiled the new module, reported only the standard axioms, and finished without warnings. An earlier composition attempt used the opposite order for the two time bounds, and the final output lists needed an explicit congruence argument; the current source resolves both. See [RERUN.md](RERUN.md). ## Next Review the explicit machine and its phase invariants against Issue #31. Reproduce with Lean 4.31.0 using `lake build Problems.PVersusNP.Examples.Palindrome`; the complete site jobs are linked above.