Theory of Computation & Computer Graphics β Turing Machine, NEC licence examination syllabus (Nepal Engineering Council).
TM as a Language Recognizer
The role that places Turing machines at the top of the Chomsky hierarchy.
π Where this lives: Every type checker is a language recogniser in this sense. When a compiler decides whether a program is well-typed, it is deciding membership in the language of well-typed programs β and for some languages that decision is genuinely hard. C++ template instantiation is Turing-complete, which means the compiler can be made to run an arbitrary computation at compile time, and in principle to never terminate. Compilers impose an arbitrary recursion depth limit precisely because the underlying problem is undecidable. Search "C++ templates Turing complete compile time computation".
ββ THE FULL PICTURE ββββββββββββββββββββββββββββββββββββββββ
CLASS MACHINE GRAMMAR
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
REGULAR finite automaton Type 3
CONTEXT FREE pushdown automaton Type 2
CONTEXT SENSITIVE LINEAR BOUNDED Type 1
AUTOMATON
RECURSIVE TM THAT ALWAYS (no grammar
(decidable) HALTS characterisation)
RECURSIVELY Turing machine Type 0
ENUMERABLE
NOT RE NO MACHINE AT ALL β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
THE SEPARATING LANGUAGES, each proved in its own topic:
aβΏbβΏ regular β context free
aβΏbβΏcβΏ context free β context sensitive
the HALTING PROBLEM recursive β RE
the COMPLEMENT of the halting problem RE β not RE
NOTE THAT THE LAST CLASS IS NOT EMPTY. THERE ARE LANGUAGES NO
MACHINE RECOGNISES AT ALL β not even one allowed to loop
forever on non-members. The complement of the halting problem
is the standard example, and its existence follows from the
complementation theorem of the previous topic.
ββ A COUNTING ARGUMENT FOR WHY MOST LANGUAGES ARE NOT RE βββ
A short and striking argument worth knowing:
Β· EVERY TURING MACHINE CAN BE ENCODED AS A FINITE STRING, so
there are COUNTABLY MANY Turing machines β the same
cardinality as the natural numbers.
Β· A LANGUAGE IS A SUBSET OF Ξ£*, and Ξ£* is countably
infinite, so there are UNCOUNTABLY MANY languages β the
cardinality of the power set of the naturals.
Β· THEREFORE THERE ARE STRICTLY MORE LANGUAGES THAN MACHINES.
SINCE EACH MACHINE RECOGNISES AT MOST ONE LANGUAGE, ALMOST
ALL LANGUAGES ARE RECOGNISED BY NO MACHINE.
THIS PROVES NON-RE LANGUAGES EXIST WITHOUT EXHIBITING ONE. It
is a pure counting argument, and it says something startling:
THE COMPUTABLE IS A VANISHINGLY SMALL FRAGMENT OF THE
MATHEMATICALLY DESCRIBABLE. The languages we can compute are
not merely a proper subset β they are a set of measure zero
among all languages.
ββ UNIVERSALITY AND TURING COMPLETENESS ββββββββββββββββββββ
A system is TURING COMPLETE if it can simulate a Turing
machine, and therefore compute anything computable.
THE SURPRISING MEMBERS OF THIS CLUB:
Β· every general-purpose programming language
Β· C++ TEMPLATE INSTANTIATION
Β· SQL with recursive common table expressions
Β· CONWAY'S GAME OF LIFE
Β· Minecraft redstone circuitry
Β· the x86 MOV instruction alone
Β· Magic: The Gathering, as a card game
THE LESSON IS THAT TURING COMPLETENESS IS EASY TO ACHIEVE
ACCIDENTALLY. A system needs only conditional branching and
unbounded storage, and those appear in places nobody
intended.
THE PRACTICAL CONSEQUENCE IS UNCOMFORTABLE: ONCE A
CONFIGURATION LANGUAGE OR TEMPLATE SYSTEM IS TURING
COMPLETE, EVERY INTERESTING QUESTION ABOUT IT BECOMES
UNDECIDABLE. You cannot in general determine whether a
configuration will terminate, whether two configurations are
equivalent, or whether a given rule can ever fire. This is
why security-sensitive formats deliberately AVOID Turing
completeness β and why some do not, to their cost.
The counting argument settles it without exhibiting a single example: there are countably many Turing machines and uncountably many languages, so almost every language is recognised by nothing at all. The computable is not merely a proper subset of the describable β it is a vanishingly small fragment of it.
π Go further: Turing completeness is easy to achieve accidentally, and that is a security problem rather than a curiosity. A system needs only conditional branching and unbounded storage β and those turn up in C++ templates, recursive SQL, Conway's Game of Life, Minecraft redstone, and even the x86 MOV instruction on its own. The moment a configuration format or template system becomes Turing complete, every interesting question about it becomes undecidable: you cannot determine whether a config terminates, whether two are equivalent, or whether a rule can ever fire. This is why security-conscious formats deliberately restrict themselves below Turing completeness. Search "accidentally Turing complete configuration language security".
π‘ Exam angle: be able to design a TM for aβΏbβΏcβΏ and explain why a PDA cannot do it β a stack is consumed as it is read, whereas a tape can be traversed repeatedly. Name the standard construction techniques, especially marking and shuttling. Know the LBA, that it recognises exactly the context-sensitive languages, and the configuration-counting argument |Q| Γ n Γ |Ξ|βΏ that makes context-sensitive membership decidable. Reproduce the full hierarchy with machines and separating languages, and be ready to give the countable-versus-uncountable argument for the existence of non-RE languages.
Syllabus points
Recursive & recursively enumerable languages
Designing a TM for a language
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.