Theory of Computation & Computer Graphics β Turing Machine, NEC licence examination syllabus (Nepal Engineering Council).
Acceptance of a String by a TM
Three outcomes, not two β and the third one changes everything.
π Where this lives: The three-outcome structure is why a program can hang. When an application stops responding, the operating system cannot tell you whether it is stuck forever or merely slow, so it offers to kill it and leaves the judgement to you. That is not a deficiency in the operating system; it is the halting problem appearing in a dialog box. No amount of engineering effort can produce a "this will never finish" detector, and this topic is where that limit is established. Search "halting problem application not responding undecidable".
The three outcomes
GIVEN A TURING MACHINE M AND AN INPUT w, EXACTLY ONE OF THREE
THINGS HAPPENS:
1. M ACCEPTS w β it reaches an accepting state and halts.
2. M REJECTS w β it halts in a non-accepting state, or with
no applicable transition.
3. M LOOPS ON w β it never halts.
THE LANGUAGE OF M is defined by the first outcome only:
L(M) = { w : M accepts w }
NOTE WHAT THIS DEFINITION DOES **NOT** SAY. It says nothing
about M's behaviour on strings outside L(M) β they may be
rejected or may cause an infinite loop, and the language is
the same either way.
THAT ASYMMETRY IS DELIBERATE AND IS THE SOURCE OF THE ENTIRE
THEORY THAT FOLLOWS.
ββ THE TWO CLASSES OF LANGUAGE βββββββββββββββββββββββββββββ
RECURSIVELY ENUMERABLE (RE), also TURING-RECOGNISABLE or
SEMI-DECIDABLE:
L is RE if SOME TM M has L(M) = L.
On w β L, M accepts (in finite time).
On w β L, M rejects OR LOOPS FOREVER.
RECURSIVE (R), also DECIDABLE:
L is recursive if some TM M has L(M) = L AND M HALTS ON
EVERY INPUT.
On w β L, M accepts. On w β L, M rejects. NEVER LOOPS.
SUCH A MACHINE IS CALLED A DECIDER, and it is what one
normally means by "an algorithm".
THE CONTAINMENT: RECURSIVE β RECURSIVELY ENUMERABLE
THE PRACTICAL MEANING OF THE DIFFERENCE, which is the point
worth grasping before any proof:
Β· A DECIDER always gives an answer. You can wait for it.
Β· A RECOGNISER gives a "yes" if the answer is yes, and MAY
GIVE NOTHING AT ALL if the answer is no.
IF A RECOGNISER HAS BEEN RUNNING FOR AN HOUR, YOU CANNOT
TELL WHETHER THE ANSWER IS "NO" OR WHETHER IT SIMPLY NEEDS
ANOTHER MINUTE. That is not ignorance about this particular
machine β it is provably impossible to determine in general.
ββ THE COMPLEMENTATION THEOREM βββββββββββββββββββββββββββββ
A result that pins the relationship down exactly:
IF L AND ITS COMPLEMENT LΜ ARE **BOTH** RECURSIVELY
ENUMERABLE, THEN L IS RECURSIVE.
THE PROOF IS A DOVETAILING ARGUMENT, and it is short enough
to reproduce:
Let Mβ recognise L and Mβ recognise LΜ. Build a decider D:
On input w, RUN Mβ AND Mβ IN PARALLEL β one step of each,
alternately.
Β· If Mβ accepts, ACCEPT.
Β· If Mβ accepts, REJECT.
EXACTLY ONE OF THEM MUST EVENTUALLY ACCEPT, because w is in
either L or LΜ. So D always halts, and D decides L. β
THE CONTRAPOSITIVE IS THE USEFUL FORM:
IF L IS RE BUT **NOT** RECURSIVE, THEN LΜ IS **NOT** RE.
This is the standard tool for proving a language is not
recursively enumerable, and it is used on the complement of
the halting problem.
THE PARALLEL SIMULATION IS ESSENTIAL. Running Mβ to
completion first would be useless β it might loop, and one
would never get to Mβ. DOVETAILING β interleaving the two
computations step by step β IS THE STANDARD TECHNIQUE FOR
RUNNING POSSIBLY-NON-HALTING MACHINES SAFELY, and it recurs
throughout computability theory.
ββ CLOSURE PROPERTIES ββββββββββββββββββββββββββββββββββββββ
RECURSIVE LANGUAGES are closed under:
UNION, INTERSECTION, COMPLEMENT, CONCATENATION, STAR,
DIFFERENCE
COMPLEMENT IS THE EASY ONE: run the decider and invert its
answer. This works ONLY because the decider is guaranteed to
halt.
RECURSIVELY ENUMERABLE LANGUAGES are closed under:
UNION, INTERSECTION, CONCATENATION, STAR
BUT **NOT** UNDER COMPLEMENT β which follows directly from
the theorem above, since closure under complement would make
every RE language recursive.
NOTE THE PATTERN ACROSS THE WHOLE SUBJECT:
REGULAR closed under complement
CONTEXT FREE NOT closed under complement
RECURSIVE closed under complement
RE NOT closed under complement
AND THE REASON IS THE SAME EACH TIME: complementation
requires a machine that always gives a definite answer.
DFAs and deciders do; PDAs and recognisers do not.
Multiple acceptance conventions, and why they agree
The definition of L(M) is deliberately asymmetric: it says what happens on strings in the language and nothing at all about strings outside it. A recogniser that has run for an hour gives you no way to distinguish "the answer is no" from "it needs another minute" β and that is provably impossible to fix, not merely unfixed.
π Go further: Notice where the recursive languages sit in the Chomsky hierarchy: strictly between context-sensitive and recursively enumerable, and not one of Chomsky's four classes. The hierarchy was built from restrictions on grammar productions, and no natural grammar restriction picks out exactly the recursive languages β the class is defined by a property of machines (always halting) rather than of grammars. This is a rare case where the machine view and the grammar view of language classes genuinely diverge, and it is why "decidable" is a computational notion rather than a linguistic one. Search "recursive languages not in Chomsky hierarchy decidable".
π‘ Exam angle: state the three outcomes and define L(M) by acceptance alone. Distinguish recursive (decidable) from recursively enumerable (semi-decidable) precisely, and give the strict containment. The complementation theorem β if L and LΜ are both RE then L is recursive β is a standard proof question: give the dovetailing argument and explain why parallel simulation is necessary. Know the closure properties, especially that recursive languages are closed under complement and RE languages are not. Place both classes in the Chomsky hierarchy and note that recursive is not one of the four types.
Syllabus points
Accepting/halting configuration
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.