4.6.17Theory of Computation

Decidability — decidable (recursive) and recognizable (recursively enumerable) languages

2,233 words10 min readdifficulty · medium

1. What are we even talking about?


2. The fundamental relationships (derive, don't memorize)

2.1 Every decidable language is recognizable

WHY: A decider already accepts members and rejects non-members. Accepting members is exactly the recognizer requirement; rejecting non-members is stronger than (and implies) the "may loop" condition. So: DecidableRecognizable.\text{Decidable} \subseteq \text{Recognizable}.

2.2 The complementation theorem — the crown jewel

Derivation of "decidable ⇒ closed under complement": Let MM decide LL. Build MM': run MM; if MM accepts, MM' rejects; if MM rejects, MM' accepts. Since MM always halts, MM' always halts and decides L\overline{L}. Swapping accept/reject only works because the machine halts. ∎

Derivation of the iff theorem (the famous "dovetailing" argument):

(\Rightarrow) If LL is decidable, then LL is recognizable (§2.1), and L\overline{L} is decidable (§2.2), hence recognizable.

(\Leftarrow) Suppose M1M_1 recognizes LL and M2M_2 recognizes L\overline{L}. Build decider DD on input ww:

  • Run M1M_1 and M2M_2 in parallel, step-by-step (one step of each, alternating). Why parallel? Because we can't fully run one first — it might loop.
  • Every ww is in exactly one of LL, L\overline{L}. So one of M1M_1, M2M_2 is guaranteed to accept ww in finite time.
    • If M1M_1 accepts → DD accepts.
    • If M2M_2 accepts → DD rejects.
  • DD always halts (one machine must accept), so DD decides LL. ∎
Figure — Decidability — decidable (recursive) and recognizable (recursively enumerable) languages

3. Worked examples


4. Common mistakes (Steel-manned)


5. Quick mental model

Recall Feynman: explain to a 12-year-old

Imagine a robot that checks if your guess is a hidden word.

  • A decider robot is honest both ways: it always beeps "YES, correct!" or "NO, wrong!" and then stops.
  • A recognizer robot only beeps "YES!" when you're right. When you're wrong, it just keeps thinking... and thinking... and never tells you "no." You'd sit there forever not knowing if it's almost done or stuck. So a decider always answers; a recognizer only confirms the good news. And here's the magic trick: if you have one robot that confirms "right" and another that confirms "wrong," you can run both at once and whichever beeps first tells you the real answer — turning two half-robots into one full decider!

6. Summary table (80/20 core)

Property Decidable (Recursive) Recognizable (RE)
Halts on members always (accept) always (accept)
Halts on non-members always (reject) may loop
Closed under complement? ✅ Yes ❌ No
Relationship Decidable ⊊ Recognizable superset
Key theorem LL decidable     \iff L,LL,\overline{L} both RE
Example ADFAA_{DFA} ATMA_{TM} (RE, undecidable)

Flashcards

What is a decider?
A TM that halts on every input, accepting members and rejecting non-members.
A language is decidable iff there exists what kind of TM?
A TM that halts on all inputs (a total decider / recursive).
A language is recognizable iff there exists what kind of TM?
A TM that accepts exactly the members; on non-members it may reject OR loop forever.
True/False: Every decidable language is recognizable.
True (a decider already satisfies the recognizer condition and more).
True/False: The recognizable languages are closed under complement.
False — e.g. ATMA_{TM} is RE but ATM\overline{A_{TM}} is not.
True/False: The decidable languages are closed under complement.
True — swap accept/reject; works because deciders always halt.
State the iff theorem linking decidable and recognizable.
LL is decidable iff both LL and L\overline{L} are recognizable.
In the iff-theorem proof, why run M1M_1 and M2M_2 in parallel?
Because running one fully may loop forever; dovetailing guarantees the halting one is reached.
Give a recognizable but undecidable language.
ATM={M,w:M accepts w}A_{TM} = \{\langle M,w\rangle : M \text{ accepts } w\}.
Why is ADFAA_{DFA} decidable?
A DFA halts in exactly w|w| steps, so simulation always terminates.
Why is ATM\overline{A_{TM}} not recognizable?
If it were, both ATMA_{TM} and its complement would be RE, making ATMA_{TM} decidable — contradiction.
What does "enumerable" mean here?
A TM can list (print) all and only the strings of the language; equivalent to being recognizable.

Connections

Concept Map

can

can

can

creates asymmetry

has

has

allowed only in

subset of

generates

closed under

NOT closed under

iff L and complement both

Turing Machine on input

Accept

Reject

Loop forever

Halt guarantee difference

Decidable / Recursive

Recognizable / RE

Decider always halts

Recognizer may loop

Complement

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek Turing Machine kisi input pe sirf teen cheezein kar sakti hai: accept, reject, ya phir hamesha ke liye loop mein fas jaana. Yahi teesra option pura khel badal deta hai. Agar koi machine har input pe rukti hai (halt hoti hai) aur saaf saaf yes/no deti hai, to wo language decidable (recursive) hai. Lekin agar machine members pe to "yes" bol deti hai, par non-members pe shayad loop maar de aur kabhi jawab na de, to wo sirf recognizable (RE) hai. Matlab decidable ek strong guarantee hai, recognizable ek weak guarantee.

Sabse important baat yaad rakhna: decidable languages complement ke under closed hain, par recognizable nahi. Kyun? Decider hamesha halt karta hai, to bas accept/reject swap karke complement bana lo. Lekin recognizer to non-member pe loop maar raha hai — usme swap karne ke liye kuch hai hi nahi. Isiliye ATMA_{TM} (TM accepts ww) recognizable hai par uska complement recognizable nahi hai.

Ek killer theorem hai: LL decidable hai agar aur sirf agar LL aur L\overline{L} dono recognizable hon. Iska proof "dovetailing" se hota hai — dono recognizers ko parallel mein, ek-ek step karke chalao. Har string ya to LL mein hogi ya L\overline{L} mein, to koi ek machine zaroor finite time mein accept karegi. Bas wahi tumhara real answer hai. Yahan trick yeh hai ki ek machine ko pura mat chalao (wo loop kar sakti hai), warna fas jaoge.

Exam ke liye 80/20: yaad rakho table — decidable always halts (dono taraf), RE sirf yes pe halt; decidable complement-closed, RE nahi; ADFAA_{DFA} decidable hai (DFA w|w| steps mein ruk jaati hai), ATMA_{TM} recognizable par undecidable hai. Bas yeh samajh gaye to decidability ka core clear hai.

Go deeper — visual, from zero

Test yourself — Theory of Computation

Connections