4.6.13Theory of Computation

Turing machines — formal definition, computation, configurations

2,600 words12 min readdifficulty · medium6 backlinks

1. The formal definition

WHAT each piece does:

  • δ(q,a)=(r,b,D)\delta(q, a) = (r, b, D) means: in state qq reading symbol aa, switch to state rr, overwrite the cell with bb, then move the head one cell in direction DD (LL or RR).

2. Configurations — a snapshot of "where are we?"


3. How one configuration yields the next

Suppose δ(q,b)=(r,c,D)\delta(q, b) = (r, c, D), head reading symbol bb. Let aa be the symbol immediately left of the head, uu the rest of the left part, vv the rest of the right part.


Figure — Turing machines — formal definition, computation, configurations

4. Computation, acceptance, and the language


5. Worked examples


6. Common mistakes (Steel-man + fix)


Recall Feynman: explain to a 12-year-old

Imagine an endless strip of paper divided into boxes, and a little robot sitting on one box. The robot has a tiny notebook with a few "moods" (states). It looks at the letter in its box, then its rulebook says: "erase it, write this new letter, and shuffle one box left or right, and switch to that mood." It keeps doing this. Two special moods mean STOP-YES and STOP-NO. If it never reaches a STOP mood, it just keeps shuffling forever. That's a Turing machine — and amazingly, this dumb robot can compute anything any computer can.


Flashcards

What are the 7 components of a Turing machine?
(Q,Σ,Γ,δ,q0,qaccept,qreject)(Q,\Sigma,\Gamma,\delta,q_0,q_{\text{accept}},q_{\text{reject}}) — states, input alphabet, tape alphabet, transition function, start state, accept and reject states.
What is the type signature of the transition function δ\delta?
δ:Q×ΓQ×Γ×{L,R}\delta: Q\times\Gamma \to Q\times\Gamma\times\{L,R\}.
Why must ΣΓ\Sigma \subseteq \Gamma and Σ\sqcup \notin \Sigma?
Input lives on the tape (so ΣΓ\Sigma\subseteq\Gamma), but the blank marks "no input here" so it must never appear in the input itself.
What is a configuration uqvu\,q\,v?
A snapshot: state qq, tape content uu left of the head, content vv starting at the head (head on first symbol of vv), blanks beyond.
Yield rule for moving right: uaqbvu a q b v \vdash ? (given δ(q,b)=(r,c,R)\delta(q,b)=(r,c,R))
uacrvu a c r v — write cc, head steps right so cc joins the left part.
Yield rule for moving left: uaqbvu a q b v \vdash ? (given δ(q,b)=(r,c,L)\delta(q,b)=(r,c,L))
uracvu r a c v — write cc, head steps left onto aa.
What happens when the head tries to move left off cell 0?
It stays at cell 0 (left-edge convention); computation continues.
Difference between Turing-recognizable and Turing-decidable?
Recognizable: some TM accepts members (may loop on non-members). Decidable: a TM that always halts gives yes/no for every input.
What is a decider?
A TM that halts on every input (never loops).
What are the three outcomes of a TM running on input ww?
Accept, reject, or loop forever (never halt).
Why are there exactly two halting states?
So the machine can decide "yes" or "no" and stop immediately, without reading the whole input.
On which domain is δ\delta defined?
(Q{qaccept,qreject})×Γ(Q\setminus\{q_{\text{accept}},q_{\text{reject}}\})\times\Gamma — halting states have no outgoing transitions.

Connections

  • Finite Automata — TMs add a writable, infinite, two-way tape (FAs are read-only, one-way).
  • Pushdown Automata — PDAs have a stack; TMs generalize to full random-ish access via head movement.
  • Church-Turing Thesis — claims TMs capture all effective computation.
  • Halting Problem — the canonical undecidable language; lives in the recognizable-but-not-decidable gap.
  • Recursively Enumerable Languages / Recursive Languages — the language classes defined here.
  • Nondeterministic Turing Machines — same power, possibly faster; defined via a yield relation not function.
  • Multitape Turing Machines — equivalent in power, used for cleaner constructions.

Concept Map

leads to

formalized as

contains

contains

contains

reads writes moves L or R

extra work symbols and blank fill tape

bundles

special case

define

special case

Turing machine

Need model for all computation

7-tuple M

Transition function delta

Sigma vs Gamma with blank

Accept and reject states

Configuration u q v

State plus tape plus head

Start config q0 w

Halting configs

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Turing machine basically ek bahut hi simple "robot" hai jo ek infinite tape (kagaz ki endless patti, boxes mein divided) par baitha hai. Uske paas ek head hota hai jo ek box ko padh sakta hai aur usme likh bhi sakta hai. Robot ke paas thode se states (moods) hain, aur ek rulebook jise hum δ\delta (transition function) bolte hain. Rule kehta hai: "current state mein, jo symbol padha hai, uske hisaab se — naya symbol likho, ek box left ya right move karo, aur naye state mein jaao." Bas itna hi! Formally hum isse 7-tuple (Q,Σ,Γ,δ,q0,qaccept,qreject)(Q,\Sigma,\Gamma,\delta,q_0,q_{accept},q_{reject}) likhte hain.

Ab "configuration" ka matlab hai ek snapshot — yaani us moment pe machine ki poori state: kaunsa state, tape pe kya likha hai, aur head kahan hai. Hum isse uqvu\,q\,v likhte hain, jahan uu head ke left ka tape hai aur vv head se shuru hota hai. Jab ek configuration se doosri banti hai δ\delta apply karke, usse hum "yields" bolte hain (C1C2C_1 \vdash C_2). Right move pe likha hua symbol left part mein chala jaata hai, left move pe head left wale symbol pe aa jaata hai. Aur ek important convention — agar head cell 0 se aur left jaane ki koshish kare, toh wahi ruk jaata hai, crash nahi hota.

Sabse zaroori cheez yaad rakho: machine ke 3 anjaam ho sakte hain — accept, reject, ya loop (hamesha chalti rahe). Yahin se "recognizable" aur "decidable" ka farak aata hai. Agar TM members ko accept kar leti hai par non-members pe shaayad loop kar jaaye, toh language recognizable hai. Agar TM har input pe rukti hai (halt karti hai) aur saaf yes/no deti hai, toh wo decidable hai aur use decider bolte hain. Yeh loop wala gap hi aage chalke Halting Problem jaisi undecidable cheezon ki jadd hai — isiliye yeh chhota sa model itna important hai.

Go deeper — visual, from zero

Test yourself — Theory of Computation

Connections