By the end of this chapter you'll be able to…

  • 1Describe the Turing machine model and its three possible outcomes
  • 2State why the unbounded tape is what separates it from weaker models
  • 3State that every standard variant has identical power
  • 4Explain why nondeterminism costs exponential simulation but adds no power
  • 5State the Church-Turing thesis and why it is not a theorem
  • 6Distinguish recursive from recursively enumerable precisely
  • 7Prove that a language is recursive exactly when it and its complement are both semi-decidable
  • 8Explain why recursively enumerable languages fail closure under complement
  • 9Prove the halting problem undecidable by diagonalisation
  • 10Identify the only assumption the diagonalisation argument uses
  • 11Define a reduction and state both directions of its consequence
  • 12Choose the correct reduction direction to prove undecidability
  • 13State Rice's theorem and both of its conditions
  • 14Distinguish a property of the language from a property of the machine
  • 15Explain why bounded-step questions escape Rice's theorem
  • 16Classify standard questions about a machine's language as decidable or not
  • 17State the role of Post's Correspondence Problem in reductions
  • 18Recall which context-free grammar questions are decidable
  • 19Explain why the complement of the halting language is not recursively enumerable
💡
Why this chapter matters in GATE
A Turing machine is not a model of a particular computer; it is the definition of what computation means, so every result here is a statement about the limits of computation itself rather than about any technology. The machine is deliberately minimal — a finite control, an unbounded tape, one cell at a time — because efficiency questions belong elsewhere and this chapter asks only what is possible at all. The central discovery is that some things are not possible, and the reason is always the same: a machine can be encoded as a string, so machines take other machines as input, and that self-reference makes diagonalisation available. So the diagnostic question for any decision problem is whether it can be turned against itself. The second organising fact is that almost every undecidability proof is a reduction rather than a fresh diagonalisation: prove halting undecidable once, then show a decider for the new problem would give a decider for halting.

Before you start — revise these

🔗
Regular & Context-Free Languages: Closure and the Pumping Lemma
The Chomsky hierarchy places Turing machines at the top, and the closure argument for recursively enumerable languages is developed there.
🔗
Context-Free Grammars & Pushdown Automata
The decidable and undecidable grammar questions listed here extend the decidability boundary established for context-free languages.
🔗
Discrete Mathematics
Diagonalisation, proof by contradiction and the notion of a computable function are the machinery every argument here relies on.

Turing Machines & Undecidability

A Turing machine is not a model of a particular computer. It is the definition of what computation means, and every result in this chapter is a statement about the limits of computation itself rather than about any technology.

The machine is deliberately minimal: a finite control, an infinite tape, and the ability to read, write and move one cell at a time. Nothing about it is efficient, and that is the point — efficiency questions belong elsewhere, while this chapter asks only what is possible at all.

The central discovery is that some things are not possible, and the reason is always the same. A Turing machine can be encoded as a string, so machines can take other machines as input. That self-reference is what makes diagonalisation available, and diagonalisation is what produces every undecidability result here.

So the diagnostic question for any decision problem is: can the problem be turned against itself? If a decider for the problem could be used to build a machine that contradicts its own behaviour, the problem is undecidable.

The second organising fact is that almost every undecidability proof is a reduction rather than a fresh diagonalisation. Prove the halting problem undecidable once, then show that a decider for the new problem would give a decider for halting.

1. The Machine

A Turing machine is a finite control plus an infinite tape divided into cells. A move reads the current cell, writes a symbol, moves the head one cell left or right, and changes state.

The tape is the machine's only memory, and it is unbounded. That single feature separates it from every weaker model: a finite automaton has no tape, and a pushdown automaton has one accessible only at the top.

A configuration is the complete state of a computation: the tape contents, the head position and the current state. A computation is a sequence of configurations, and the machine halts when it enters a halting state.

Three outcomes are possible on any input: halt and accept, halt and reject, or run forever. That third possibility is what makes the whole subject non-trivial.

2. Variants Are All Equivalent

Many variations on the model have been studied, and every one of them recognises exactly the same class of languages.

VariantPowerCost
Multi-tapeSamePolynomial simulation
Multi-trackSameNo overhead
Two-way infinite tapeSameConstant factor
NondeterministicSameExponential simulation
Multi-dimensional tapeSamePolynomial

Nondeterminism is the striking case. For finite automata it adds no power and costs an exponential state blow-up; for pushdown automata it adds power; for Turing machines it adds no power again, but the deterministic simulation takes exponential time.

The simulation explores the nondeterministic machine's computation tree breadth-first, which is why it costs so much. Whether that exponential cost is necessary is exactly the P versus NP question, unresolved and the most famous open problem in the subject.

The Church-Turing thesis states that any function computable by any effective procedure is computable by a Turing machine. It is not a theorem — "effective procedure" is informal — but every model ever proposed has turned out equivalent, which is strong evidence.

3. Recursive and Recursively Enumerable

Two classes must be distinguished precisely, because most exam errors here are confusions between them.

A language is recursive, or decidable, if some Turing machine halts on every input and correctly accepts or rejects.

A language is recursively enumerable, or semi-decidable, if some Turing machine halts and accepts on every member, and may run forever on non-members.

Every recursive language is recursively enumerable; the converse fails.

The relationship between the two is captured by one theorem. A language is recursive if and only if both it and its complement are recursively enumerable.

The proof is a parallel simulation. Run the semi-decider for and the semi-decider for its complement, interleaving steps. Every string is in exactly one of them, so exactly one machine halts, and its identity gives the answer.

The immediate consequence is that recursively enumerable languages are not closed under complement, since closure would make every semi-decidable language decidable.

ClassClosed under unionIntersectionComplement
RecursiveYesYesYes
Recursively enumerableYesYesNo

The complement of the halting language is the standard example of a language that is not even recursively enumerable.

4. The Halting Problem

The halting problem asks whether a given machine halts on a given input.

It is recursively enumerable, because a universal machine can simulate the encoded machine and accept if the simulation ever halts.

It is not recursive, and the proof is diagonalisation.

Suppose a machine decides it, answering yes when halts on and no otherwise. Build a machine that, on input , runs on the pair and then does the opposite: if says halts on itself, loops forever; if says it does not halt, halts.

Now run on itself.

If halts on input , then said so, and was built to loop in that case — a contradiction.

If does not halt on input , then said so, and was built to halt in that case — also a contradiction.

Both branches contradict, so cannot exist.

The argument depends on nothing but the ability to encode a machine as a string and feed it to itself. That self-reference is the whole mechanism, and it recurs in every undecidability result.

5. Reductions

Once one problem is known undecidable, others follow by reduction rather than by fresh diagonalisation.

A reduction from to is a computable function converting instances of into instances of with the same answer.

The logic then runs in two directions, and keeping them straight is essential.

If reduces to and is decidable, then is decidable: solve by converting and asking the -decider.

If reduces to and is undecidable, then is undecidable: a -decider would give an -decider, contradicting the assumption.

The direction that proves undecidability reduces the known-hard problem to the new one, never the reverse. Reducing the new problem to halting proves nothing about the new problem's difficulty.

The standard technique for showing a language property undecidable is to build, from an instance of halting, a machine whose language depends on whether the original halts.

6. Rice's Theorem

Rice's theorem generalises all of this into one statement.

Any non-trivial property of the language recognised by a Turing machine is undecidable.

A property is non-trivial if some recursively enumerable language has it and some does not. It must be a property of the language, not of the machine.

That second condition is where questions are built. "Does this machine have fewer than 50 states?" is decidable, because it is a property of the machine's description rather than of the language it recognises. "Is the language of this machine empty?" is undecidable, because it is a property of the language and is non-trivial.

Rice's theorem settles a large family of questions instantly.

Question about Decidable?
Is it empty?No
Is it finite?No
Is it regular?No
Does it contain a specific string?No
Is it equal to another machine's language?No
Does have 10 states?Yes
Does halt within 100 steps on input ?Yes

The last two escape Rice's theorem for different reasons. State counting is a syntactic property of the description. Bounded halting is decidable because simulating 100 steps always terminates — the bound removes the unbounded search that causes undecidability.

7. Other Undecidable Problems

Two further problems are examined by name.

Post's Correspondence Problem asks whether a sequence of domino-like tiles can be arranged so that the top string equals the bottom string. It is undecidable, and it is useful because reducing from it is often easier than reducing from halting when the target problem concerns strings rather than machines.

Many grammar questions are undecidable, and the boundary is worth holding exactly.

QuestionDecidable?
Is a string in for a context-free ?Yes
Is empty for a context-free ?Yes
Is finite for a context-free ?Yes
Is a context-free grammar ambiguous?No
Are two context-free grammars equivalent?No
Is empty for context-free grammars?No
Are two deterministic context-free languages equivalent?Yes

The pattern is that questions about one grammar's basic structure are decidable, while comparisons between grammars are not — with the deterministic equivalence result as the notable and deep exception.

8. Worked Examples

Example 1. Prove that the halting problem is undecidable.

Assume a decider exists, taking an encoded machine and an input , halting always, and answering yes exactly when halts on .

Construct as follows. On input , interpreted as an encoded machine, runs on the pair .

If answers yes, enters an infinite loop.

If answers no, halts immediately.

is a legitimate machine, since is assumed to exist and always halt, and looping is trivially implementable.

Now consider running on its own encoding.

Suppose halts on input . Then answered yes, and by construction loops forever. So does not halt — contradicting the supposition.

Suppose does not halt on input . Then answered no, and by construction halts immediately. So halts — again contradicting the supposition.

Both cases are impossible, so the assumption that exists must be false.

The only assumption used was that machines can be encoded as strings and fed to themselves. Nothing about tapes, states or transitions entered the argument, which is why the same technique applies far beyond Turing machines.

Example 2. Show that the problem "does machine accept the empty string" is undecidable.

Reduce from halting. Assume a decider for this problem exists.

Given an arbitrary instance of halting — a machine and an input — construct a new machine as follows.

ignores its own input entirely. It writes on its tape, simulates on , and if that simulation halts, accepts.

Now consider what 's language is.

If halts on , then accepts every input, including the empty string. So accepts the empty string.

If does not halt on , then never reaches its accepting step for any input, so its language is empty. It does not accept the empty string.

So accepts the empty string exactly when halts on .

Running on therefore answers the halting question for and . Since always halts by assumption, this would decide the halting problem.

The halting problem is undecidable, so cannot exist.

Note the direction of the reduction. The known-undecidable problem was converted into the new one, which is what proves the new one hard. Converting the new problem into halting would have proved nothing.

Example 3. Which of these are decidable: whether a Turing machine has an even number of states; whether it halts on all inputs; whether it halts within 50 steps on input ?

Even number of states: decidable. This is a property of the machine's description, not of the language it recognises. Count the states in the encoding and check parity. Rice's theorem does not apply, because Rice concerns properties of .

Halts on all inputs: undecidable. This is the totality problem. It is a non-trivial property — some machines halt on everything and some do not — and it depends only on the machine's behaviour rather than its syntax. It is undecidable, and in fact is not even recursively enumerable, since no finite amount of simulation can confirm that a machine halts on all of infinitely many inputs.

Halts within 50 steps: decidable. Simulate for exactly 50 steps and report whether the machine halted. The simulation always terminates because the step count is bounded, which removes the unbounded search entirely.

The general principle is that bounded questions are decidable and unbounded ones usually are not, and that syntactic properties of the description are always decidable however complicated they look.

Example 4. Apply Rice's theorem to decide whether "is regular" is decidable.

Check the two conditions Rice's theorem requires.

First, is it a property of the language rather than the machine? Yes. Whether is regular depends only on the set of strings accepted, not on how many states the machine has or how it is written. Two machines with the same language always agree on this property.

Second, is it non-trivial? A property is non-trivial if at least one recursively enumerable language has it and at least one does not.

Some machine recognises the empty language, which is regular, so the property is sometimes true.

Some machine recognises , which is recursively enumerable and not regular, so the property is sometimes false.

Both conditions hold, so Rice's theorem applies and the property is undecidable.

Notice how little work this required. Without Rice, proving it would need an explicit reduction from halting, constructing a machine whose language is regular exactly when some other machine halts. Rice packages that construction once and for all.

Example 5. Explain why the complement of the halting language is not recursively enumerable.

The halting language is recursively enumerable: a universal machine simulates the encoded machine and accepts if the simulation halts.

Suppose its complement were also recursively enumerable.

Then both the language and its complement would be semi-decidable, and by the parallel-simulation theorem the language would be recursive — that is, decidable.

But the halting language is undecidable, as diagonalisation established.

The contradiction shows the complement cannot be recursively enumerable.

Intuitively, the asymmetry is about what can be confirmed. Halting can be confirmed by observing it: simulate, and if the machine stops, you know. Not halting cannot be confirmed by any finite observation, because however long the simulation runs without stopping, it might stop on the next step.

That asymmetry between confirmable and unconfirmable is exactly the difference between recursively enumerable and its complement.

Example 6. Is the language of a Turing machine that accepts exactly the strings of length 5 decidable to recognise?

Read the question carefully: it asks whether the property " equals the set of strings of length 5" is decidable, given .

Apply Rice's theorem.

Is it a property of the language? Yes — it is a statement about which strings are accepted, and two machines with identical languages agree on it.

Is it non-trivial? Some machine has exactly that language, so the property is sometimes true. Some machine has the empty language, which is not the set of length-5 strings, so it is sometimes false.

Rice's theorem applies, so the property is undecidable.

Contrast this with a superficially similar question: "does accept the specific string within 100 steps?" That is decidable by bounded simulation.

The difference is the quantifier. Checking one string with a step bound is a finite computation. Determining the entire language requires reasoning about infinitely many inputs with no bound, and that is precisely what no decider can do.

Summary

A Turing machine is the definition of computation: a finite control and an unbounded tape, with three possible outcomes on any input, the third being that it never halts.

Every variant — multi-tape, multi-track, two-way, multi-dimensional, nondeterministic — recognises exactly the same languages. Nondeterminism costs exponential simulation time, and whether that cost is necessary is the P versus NP question.

Recursive means a machine always halts with a verdict; recursively enumerable means it halts on members and may loop on non-members. A language is recursive exactly when it and its complement are both recursively enumerable, which is why the recursively enumerable class fails closure under complement.

The halting problem is recursively enumerable and undecidable. The proof is diagonalisation and uses only the fact that a machine can be encoded and fed to itself.

Reductions transfer undecidability. To prove a new problem undecidable, reduce the known-hard problem to it, never the reverse.

Rice's theorem states that every non-trivial property of the language recognised by a machine is undecidable. Properties of the machine's description escape it, and so do questions with an explicit step bound, because bounded simulation always terminates.

Post's Correspondence Problem is undecidable and is often the easier source for reductions about strings.

For context-free grammars, membership, emptiness and finiteness are decidable, while ambiguity, equivalence and intersection emptiness are not — with deterministic equivalence as the deep exception.

The complement of the halting language is not even recursively enumerable, because halting can be confirmed by observation while non-halting cannot be confirmed by any finite computation.

Key formulas & results

Everything to memorise for the exam hall, in one card. Screenshot this for revision.

The organising tool
UNDECIDABILITY IS A STRUCTURAL CONSEQUENCE OF MACHINES BEING ABLE TO TAKE OTHER MACHINES AS INPUT. ASK WHETHER THE PROBLEM CAN BE TURNED AGAINST ITSELF.
IF A DECIDER FOR THE PROBLEM COULD BUILD A MACHINE THAT CONTRADICTS ITS OWN BEHAVIOUR, THE PROBLEM IS UNDECIDABLE.
The machine
A FINITE CONTROL PLUS AN UNBOUNDED TAPE. A MOVE READS THE CURRENT CELL, WRITES A SYMBOL, MOVES ONE CELL, AND CHANGES STATE.
THREE OUTCOMES ARE POSSIBLE: HALT AND ACCEPT, HALT AND REJECT, OR RUN FOREVER. THE THIRD IS WHAT MAKES THE WHOLE SUBJECT NON-TRIVIAL.
Variant equivalence
MULTI-TAPE, MULTI-TRACK, TWO-WAY INFINITE, MULTI-DIMENSIONAL AND NONDETERMINISTIC MACHINES ALL RECOGNISE EXACTLY THE SAME LANGUAGES.
MULTI-TAPE COSTS A POLYNOMIAL SIMULATION; NONDETERMINISM COSTS AN EXPONENTIAL ONE, BECAUSE THE SIMULATION EXPLORES A COMPUTATION TREE.
Nondeterminism across the models
FOR FINITE AUTOMATA IT ADDS NO POWER AND COSTS EXPONENTIAL STATES. FOR PUSHDOWN AUTOMATA IT ADDS POWER. FOR TURING MACHINES IT ADDS NO POWER AND COSTS EXPONENTIAL TIME.
WHETHER THAT EXPONENTIAL TIME COST IS NECESSARY IS EXACTLY THE P VERSUS NP QUESTION.
The Church-Turing thesis
ANY FUNCTION COMPUTABLE BY AN EFFECTIVE PROCEDURE IS COMPUTABLE BY A TURING MACHINE.
IT IS NOT A THEOREM, BECAUSE EFFECTIVE PROCEDURE IS INFORMAL, BUT EVERY MODEL EVER PROPOSED HAS PROVED EQUIVALENT.
Recursive versus recursively enumerable
RECURSIVE MEANS A MACHINE HALTS ON EVERY INPUT WITH A CORRECT VERDICT. RECURSIVELY ENUMERABLE MEANS IT HALTS AND ACCEPTS ON MEMBERS AND MAY RUN FOREVER ON NON-MEMBERS.
EVERY RECURSIVE LANGUAGE IS RECURSIVELY ENUMERABLE AND THE CONVERSE FAILS. MOST ERRORS IN THIS AREA ARE CONFUSIONS BETWEEN THE TWO.
The parallel-simulation theorem
A LANGUAGE IS RECURSIVE IF AND ONLY IF BOTH IT AND ITS COMPLEMENT ARE RECURSIVELY ENUMERABLE.
RUN BOTH SEMI-DECIDERS INTERLEAVED. EVERY STRING IS IN EXACTLY ONE OF THE TWO, SO EXACTLY ONE MACHINE HALTS AND ITS IDENTITY GIVES THE ANSWER.
Closure
RECURSIVE LANGUAGES ARE CLOSED UNDER UNION, INTERSECTION AND COMPLEMENT. RECURSIVELY ENUMERABLE LANGUAGES ARE CLOSED UNDER UNION AND INTERSECTION BUT NOT COMPLEMENT.
CLOSURE UNDER COMPLEMENT WOULD MAKE EVERY SEMI-DECIDABLE LANGUAGE DECIDABLE, WHICH THE HALTING LANGUAGE CONTRADICTS.
The halting problem
IT IS RECURSIVELY ENUMERABLE, SINCE A UNIVERSAL MACHINE CAN SIMULATE AND ACCEPT ON HALT, BUT IT IS NOT RECURSIVE.
THE DIAGONALISATION BUILDS A MACHINE THAT ASKS THE DECIDER ABOUT ITSELF AND THEN DOES THE OPPOSITE, WHICH CONTRADICTS IN BOTH BRANCHES.
What the diagonalisation uses
THE ONLY ASSUMPTION IS THAT A MACHINE CAN BE ENCODED AS A STRING AND FED TO ITSELF.
NOTHING ABOUT TAPES, STATES OR TRANSITIONS ENTERS THE ARGUMENT, WHICH IS WHY THE SAME TECHNIQUE APPLIES FAR BEYOND TURING MACHINES.
Reductions
A REDUCTION FROM A TO B IS A COMPUTABLE FUNCTION CONVERTING INSTANCES OF A INTO INSTANCES OF B WITH THE SAME ANSWER.
IF A REDUCES TO B AND B IS DECIDABLE THEN A IS DECIDABLE. IF A REDUCES TO B AND A IS UNDECIDABLE THEN B IS UNDECIDABLE.
The reduction direction
TO PROVE A NEW PROBLEM UNDECIDABLE, REDUCE THE KNOWN-HARD PROBLEM TO IT, NEVER THE REVERSE.
REDUCING THE NEW PROBLEM TO HALTING PROVES NOTHING ABOUT THE NEW PROBLEM'S DIFFICULTY, AND GETTING THIS BACKWARDS IS THE COMMONEST ERROR.
Rice's theorem
ANY NON-TRIVIAL PROPERTY OF THE LANGUAGE RECOGNISED BY A TURING MACHINE IS UNDECIDABLE.
NON-TRIVIAL MEANS SOME RECURSIVELY ENUMERABLE LANGUAGE HAS IT AND SOME DOES NOT. IT MUST BE A PROPERTY OF THE LANGUAGE, NOT OF THE MACHINE.
What escapes Rice's theorem
SYNTACTIC PROPERTIES OF THE MACHINE'S DESCRIPTION, SUCH AS ITS STATE COUNT, AND QUESTIONS WITH AN EXPLICIT STEP BOUND.
BOUNDED SIMULATION ALWAYS TERMINATES, WHICH REMOVES THE UNBOUNDED SEARCH THAT CAUSES UNDECIDABILITY. TWO MACHINES WITH THE SAME LANGUAGE MAY DIFFER SYNTACTICALLY.
Standard undecidable language properties
EMPTINESS, FINITENESS, REGULARITY, MEMBERSHIP OF A SPECIFIC STRING AND EQUIVALENCE TO ANOTHER MACHINE'S LANGUAGE ARE ALL UNDECIDABLE.
ALL FOLLOW IMMEDIATELY FROM RICE'S THEOREM, WHICH PACKAGES THE REDUCTION FROM HALTING ONCE AND FOR ALL.
Totality
WHETHER A MACHINE HALTS ON ALL INPUTS IS UNDECIDABLE AND NOT EVEN RECURSIVELY ENUMERABLE.
NO FINITE AMOUNT OF SIMULATION CAN CONFIRM HALTING ON INFINITELY MANY INPUTS, SO IT LIES OUTSIDE THE SEMI-DECIDABLE CLASS ENTIRELY.
Post's Correspondence Problem
GIVEN A SET OF TILES WITH A TOP AND BOTTOM STRING, DECIDE WHETHER SOME ARRANGEMENT MAKES THE CONCATENATED TOP EQUAL THE CONCATENATED BOTTOM. IT IS UNDECIDABLE.
IT IS OFTEN THE EASIER SOURCE FOR REDUCTIONS WHEN THE TARGET PROBLEM CONCERNS STRINGS OR GRAMMARS RATHER THAN MACHINES.
Decidability for grammars
MEMBERSHIP, EMPTINESS AND FINITENESS ARE DECIDABLE FOR CONTEXT-FREE GRAMMARS. AMBIGUITY, EQUIVALENCE AND INTERSECTION EMPTINESS ARE NOT.
EQUIVALENCE OF DETERMINISTIC CONTEXT-FREE LANGUAGES IS DECIDABLE, WHICH IS A DEEP RESULT AND THE STANDARD DISTRACTOR IN THIS QUESTION TYPE.
The complement of halting
IT IS NOT EVEN RECURSIVELY ENUMERABLE.
HALTING CAN BE CONFIRMED BY OBSERVATION, BUT NON-HALTING CANNOT BE CONFIRMED BY ANY FINITE COMPUTATION, AND THAT ASYMMETRY IS THE WHOLE REASON.
⚠️

Traps GATE sets — and how to dodge them

These are the exact option-traps and misreads that cost marks under negative marking.

WATCH OUT
Reducing the new problem to halting to prove it undecidable
The direction is backwards. Reducing the new problem to a known-hard one shows only that the new problem is no harder. To prove hardness, reduce the known-hard problem into the new one.
WATCH OUT
Confusing recursive with recursively enumerable
Recursive means the machine always halts with a verdict. Recursively enumerable means it halts on members and may loop forever on non-members, so it never reliably rejects.
WATCH OUT
Applying Rice's theorem to a property of the machine
Rice concerns properties of the language recognised. A state count, a transition count or any feature of the encoding is syntactic and decidable, however complicated it looks.
WATCH OUT
Applying Rice's theorem to a trivial property
The property must hold for some recursively enumerable language and fail for another. Properties true of every language, or of none, are decidable by answering the same way always.
WATCH OUT
Assuming a bounded-step question is undecidable
Simulating a fixed number of steps always terminates, so any question with an explicit step bound is decidable. The unbounded search is what causes undecidability, and the bound removes it.
WATCH OUT
Claiming recursively enumerable languages are closed under complement
They are not. Closure would make every semi-decidable language decidable by parallel simulation, contradicting the undecidability of the halting language.
WATCH OUT
Believing nondeterminism increases a Turing machine's power
It does not; the deterministic simulation recognises exactly the same languages. What it costs is exponential simulation time, and whether that cost is avoidable is the P versus NP question.
WATCH OUT
Treating the Church-Turing thesis as a proved theorem
It cannot be proved because the notion of an effective procedure is informal. It is a well-supported hypothesis, backed by every proposed model turning out equivalent.
WATCH OUT
Assuming totality is recursively enumerable
Whether a machine halts on all inputs is not even semi-decidable, because no finite simulation can confirm halting on infinitely many inputs. It sits strictly outside the recursively enumerable class.
WATCH OUT
Assuming all equivalence problems are undecidable
Equivalence of deterministic context-free languages is decidable, which is a deep result. The general context-free case and the Turing machine case are both undecidable.
WATCH OUT
Thinking undecidability depends on the machine model
The diagonalisation uses only the ability to encode a machine and feed it to itself. Any model rich enough to do that has the same limits, which is why the results are about computation rather than technology.
WATCH OUT
Assuming a semi-decider that has not halted proves non-membership
It proves nothing, because the machine may halt on the next step. That asymmetry between confirmable and unconfirmable is exactly what separates a language from its complement in the recursively enumerable class.

Exam-pattern practice

PYQ-style questions with full solutions. Work through them as a readiness check — mark yourself honestly and get your gap report at the end.

Readiness check

Are you exam-ready for Turing Machines & Undecidability?

9 problems from this chapter. Try each one, reveal the worked solution, mark yourself honestly — get your gap report at the end.

9 questions~6 min

5-minute revision

The whole chapter, distilled. Read this the night before the exam.

  • A Turing machine defines computation itself.
  • The unbounded tape is what separates it from weaker models.
  • Three outcomes: accept, reject, or run forever.
  • All standard variants have identical power.
  • Multi-tape costs polynomial simulation.
  • Nondeterminism costs exponential simulation.
  • Nondeterminism adds no power to Turing machines.
  • The P versus NP question asks whether that cost is necessary.
  • The Church-Turing thesis is a hypothesis, not a theorem.
  • Recursive means always halts with a verdict.
  • Recursively enumerable means halts on members only.
  • Recursive if and only if both it and the complement are RE.
  • RE languages fail closure under complement.
  • Recursive languages are closed under complement.
  • The halting problem is RE and undecidable.
  • Diagonalisation builds a machine that contradicts itself.
  • The only assumption is self-encoding.
  • A reduction converts instances preserving the answer.
  • Reduce the known-hard problem into the new one.
  • The reverse direction proves nothing.
  • Rice's theorem covers non-trivial language properties.
  • It requires a language property, not a machine property.
  • State counts and transition counts are decidable.
  • Bounded-step questions are decidable.
  • Emptiness, finiteness and regularity of L(M) are undecidable.
  • Totality is not even recursively enumerable.
  • Post's Correspondence Problem is undecidable.
  • It suits reductions about strings and grammars.
  • CFG membership, emptiness and finiteness are decidable.
  • CFG ambiguity and equivalence are not.
  • DCFL equivalence is decidable.
  • The complement of halting is not recursively enumerable.
  • Halting is confirmable; non-halting is not.

GATE question blueprint

How this topic is asked, tier by tier — so you can prep to the pattern.

Typical weightage: Theory of Computation contributes roughly 7-9 of the 72 core-CS marks; Turing machines and undecidability supply 2-3 of those across 2-3 questions

Question styleMarks eachTypical countWhat it tests
Decidability classification1~1Sorting standard problems into decidable and undecidable
Language classes2~1Placing a language as recursive, recursively enumerable, or neither
Machine variants1~1Equivalence of variants and the cost of each simulation
Diagonalisation2~1Reproducing the halting proof and identifying its single assumption
Reductions2~1Constructing a reduction and choosing the correct direction
Rice's theorem2~1Checking both conditions and identifying what escapes the theorem
Closure properties2~1Why recursive languages complement and recursively enumerable ones do not

Exam-hall strategy

Battle-tested tips from mentors and toppers for this topic under the sectional clock.

  1. Ask first whether the property concerns the language or the machine description.
  2. Check both Rice conditions before invoking the theorem.
  3. Treat any explicit step bound as a signal that the question is decidable.
  4. For reductions, always convert the known-hard problem into the new one.
  5. Distinguish recursive, recursively enumerable and neither before answering.
  6. Remember that totality and the complement of halting are outside the semi-decidable class.
  7. Decidability classification is commonly set as an MSQ, which carries no negative marking, so never leave one blank.
  8. For 1-mark and 2-mark MCQs, negative marking is -1/3 and -2/3, so guess only after eliminating an option.
  9. GATE gives a single freely-navigable 180-minute window, so flag a long reduction construction and return to it.

Beyond the exam

Where this skill shows up in the job you're competing for — and in life.

Why static analysers report 'unknown'

No tool can decide whether arbitrary code terminates, so analysers must be incomplete by design, and the third verdict is a mathematical necessity rather than a limitation of effort.

Why compilers cannot detect all dead code

Deciding whether a branch is ever taken is a language property of the program, so Rice's theorem makes exact dead-code elimination impossible and forces conservative approximation.

Timeouts in automated verification

Bounded model checking exists precisely because the unbounded question is undecidable while the bounded one is decidable by exhaustive simulation.

Reading an impossibility claim

Recognising that a specification asks for a decider for a non-trivial language property is what lets an engineer say a requirement cannot be met rather than merely being difficult.

Where else this topic is tested

Prepare once, score in every exam that asks it.

GATE DALow overlap — theory of computation is not a component of that paper
UGC NET Computer ScienceHigh overlap — decidability classification, Rice's theorem and the halting problem are examined as direct recall
ISRO / BARC / DRDO computer science papersVery high overlap — decidable versus undecidable classification and machine variant equivalence are recurring MCQ topics

Questions aspirants ask

Pulled from the Q&A community and mentor sessions.

Because the impossibility is logical rather than computational. A hard problem is one for which no efficient algorithm is known; an undecidable problem is one for which no algorithm exists at all, however much time it is given. The distinction matters because no advance in hardware, no cleverer heuristic and no quantum device changes the answer. The proof shows why. Assume a decider H for halting exists. Build a machine D that consults H about its own encoding and then deliberately does the opposite of what H predicts: loop if H says it halts, halt if H says it loops. Running D on itself produces a contradiction in both branches, so H cannot exist. Notice what the argument does not use. It says nothing about tapes, states, alphabets or transitions. The only capability it requires is that a machine can be encoded as a string and handed to another machine, including itself. Any computational framework rich enough to do that — and every general-purpose programming language is — inherits the same limitation. This is why the result is stated as a fact about computation rather than about Turing machines specifically. The practical consequence is that any tool claiming to determine whether arbitrary programs terminate must be either incomplete, unsound, or restricted to a language weaker than a Turing machine. Static analysers choose incompleteness: they report definitely-terminates, definitely-loops, or unknown, and the third category is unavoidable.

Whether the machine is guaranteed to give an answer. A recursive language has a machine that halts on every input, accepting members and rejecting non-members, so asking the question always yields a verdict. A recursively enumerable language has a machine that halts and accepts on every member, but on a non-member it may run forever without ever rejecting. The asymmetry is between confirmable and unconfirmable facts. Membership in a semi-decidable language can be witnessed by a finite computation: run the machine, and if the string is a member, it will eventually accept. Non-membership has no such witness, because however long the machine has run without accepting, it might accept on the next step. The halting language is the canonical illustration: simulate the encoded machine, and if it halts you know it halts, but no amount of simulation ever establishes that it will not. Two consequences are examined constantly. First, a language is recursive exactly when both it and its complement are recursively enumerable, proved by running the two semi-deciders in parallel and taking whichever halts. Second, and following immediately, the recursively enumerable class is not closed under complement, because closure would make every semi-decidable language decidable. The complement of the halting language is therefore the standard example of a language outside the recursively enumerable class entirely, and totality — halting on all inputs — is another.

Check two conditions in order, and reject the theorem if either fails. First, is the property about the language recognised, or about the machine? Rice applies only to language properties, meaning any two machines recognising the same set of strings must agree on it. Emptiness, finiteness, regularity, containing a specific string and equalling another machine's language are all language properties. Number of states, number of transitions, whether the machine ever moves left, and whether it halts within twenty steps are all machine properties, and all are decidable, however elaborate they look. Second, is the property non-trivial? It must hold for at least one recursively enumerable language and fail for at least one other. A property true of every such language, or of none, is decidable trivially by always giving the same answer. When both conditions hold, Rice settles the question instantly: the property is undecidable, with no reduction to construct. That is its value, since without it each case would need its own reduction from halting. Two traps recur. Questions phrased about the machine's behaviour sometimes sound like language properties but are not: halting within a step bound is behavioural, yet two machines with the same language can differ on it, so it fails the first condition and is decidable by bounded simulation. And questions about the language of a specific known machine, rather than about an arbitrary given machine, are not decision problems in Rice's sense at all.

Because the implication only flows in one direction, and reversing it produces a statement with a false antecedent that carries no information. A reduction from A to B is a computable conversion turning any instance of A into an instance of B with the same answer. It establishes that a decider for B would give a decider for A: convert, ask, return. Taking the contrapositive, if A has no decider then B has none either. So reducing a known-undecidable A into a new B proves B undecidable, which is exactly what is wanted. Run it the other way and the logic collapses. Reducing B into halting shows only that a halting-decider would solve B. Since no halting-decider exists, the conditional is vacuously true and says nothing about whether B is decidable. Many decidable problems reduce to halting; that is not evidence of their difficulty. An analogy helps. Showing you could win a race if you had a teleporter tells nobody how fast you are. Showing that a teleporter could be built if you could win the race tells them the race is unwinnable. The construction discipline follows directly. Begin with an arbitrary instance of the known-hard problem — a machine M and input w for halting. Build from it an instance of the new problem, typically a machine whose language or behaviour depends on whether M halts on w. Then show the two answers coincide, and observe that the hypothetical new decider would therefore settle halting.

It depends entirely on the model, and the three cases are genuinely different, which is why they are examined as a contrast. For finite automata, nondeterminism adds no power. The subset construction converts any nondeterministic automaton into a deterministic one recognising the same language, because the set of states the machine might occupy is itself finite and can be tracked as a single deterministic state. The cost is up to an exponential blow-up in the number of states, and that bound is tight, but the class of languages is unchanged. For pushdown automata, nondeterminism does add power. There is no analogue of the subset construction, because tracking the set of possible configurations would mean remembering unboundedly many distinct stacks at once, which one stack cannot do. The deterministic context-free languages are provably a strict subset, and the language of even-length palindromes separates them: the midpoint must be guessed, and no deterministic strategy can find it. For Turing machines, nondeterminism again adds no power. A deterministic machine simulates the nondeterministic one by exploring its computation tree breadth-first, accepting if any branch accepts. The simulation costs exponential time in general, because the tree branches at every choice point. Whether that exponential cost is necessary, or whether some cleverer deterministic simulation runs in polynomial time, is precisely the P versus NP question, and it remains open.
Header Logo