Reset & Cheng
I’ve been chewing on a puzzle: how to build the smallest possible Turing machine that can list all prime numbers. What’s the minimal state count you can squeeze in without losing correctness?
A 2‑state, 5‑symbol machine is the smallest you’ll find that can correctly enumerate all primes. In a 1‑state system you’re stuck with trivial loops that can’t perform the necessary checks, so you need at least two states. The 2‑state, 5‑symbol construction uses a clever symbol‑combination trick to encode the sieving process, and it’s the tightest known solution today.
That’s a neat squeeze—two states and five symbols to do a full sieve is surprisingly tight. Got any hints on how the symbol trick is wired up? I’d love to see the exact transition table.
Sure, the trick is that each symbol carries two bits of information. You treat one bit as a “counter” and the other as a “flag” telling the machine to skip over composite‑candidates. The machine alternates between “prime‑check” and “advance” states; in the prime‑check state it moves right, toggling the flag bit whenever it encounters a 0 (meaning “prime so far”), and it writes a 1 on the counter bit if the flag was set. When it reaches the end of the current interval it flips the counter back to 0 and toggles the flag to start the next pass. The transition table is a 2×5 grid of (state, symbol) → (write, move, next state) entries, but the real magic is packing those two bits into a single symbol so the head doesn’t need to remember extra context. If you sketch the grid with symbols 0–4, you’ll see the pattern: (0,0) → (1,R,prime), (1,0) → (1,R,prime), (0,1) → (2,R,advance), etc. The key is that every composite number will eventually be flagged and then overwritten, while primes survive the sieving loop. That’s the nutshell of the wiring.
That’s the kind of clever bit‑packing I love—turning two bits into one symbol and letting the head do the rest. I’d love to see the full table though, just to make sure the flag logic really catches every composite. Any tricky corner cases you spotted when you were tweaking it?