A Turing Machine in SQL
using the with recursive construct, very similar in structure to
the Cyclic Tag System
by Andrew Gierth.
Query initially published on this
blog post
by Fabien Coelho.
Note: actually running this query with PostgreSQL 8.4 may require minor
syntactic changes.
See also
another version
using a recursive SQL function.