COMP272: Theory of Computation
Unit 1: Motivation and Overview
Theory of Computation
Mathematical study of computing machines, their
fundamental capabilities and their limitations.
Q1: What problems are solvable, in PRACTICE, by
computer and what problems
14: Pumping Theorem for CFLs
The idea behind the pumping theorem for CF languages
is similar to the pumping theorem for regular languages.
If the parse tree of a string is deep enough, then at least
one nonterminal must be repeated along a certain branch.
15. Turing Machines
(Deterministic) Turing Machines
How TMs work
How TMs are specied
Computations for TMs
Pushdown automata are too restrictive (uses stack) to serve
as models of general purpose computers.
TMs have unlimite
16. Turing Machines as Language Recognizers
Hereafter, we shall ssume that the initial conguration of M on
input w is (s, w).
Let M = (K, , , s, H ) be a Turing Machine such that
H = cfw_y, n
where y means yes, n means no.
0 cfw_ , is the input alphabet
17. Extensions of TM and Church-Turing Thesis
Extensions of TM
1. allow both write and move in one step
2. multiple tapes
3. two-way innite tape
Theorem 1 The operation of a machine allowing some or
all of the above extensions can be sim
Closure properties of recursive and r.e. languages
Theorem 1 The class of recursive languages is closed under
4. Kleene star (proof similar to (3)
5. intersection, (proof similar to (2)
Note: the set of context
18. Universal Turing Machines
So far, each Turing machine appears to be specialized at
solving one particular problem.
Can we program a Turing machine to obtain a generalpurpose programmable Turing machine?
Yes, such a machine is called a Universal Turi
19. Decidable problems
An example of decision problems:
Does a given polynomial p over variable x have an integral root?
The equivalent language membership problem:
D = cfw_p|p is a polynomial over x with an integral root
Is a given encoding of a polynomi
20. Undecidable problems
Reduction is the primary method for proving that a problem
is computationally undecidable.
Reducing a problem A to problem B means a solution for
problem B can be used to solve problem A.
To prove that a pr
8c: Decidable problems of regular languages
The following decision problems are decidable (solvable),
i.e., there exist algorithms for solving these problems.
1. Given a FA M and a string w, does M accept w?
2. Given a regular expression and a string w, d
14b: Decidable problems of context-free languages
The following decision problems about context-free grammar are decidable, i.e., there exist algorithms for solving
1. Given a CFG G and a string w, does G generate w?
2. Given a CFG G, is e L(G)?
13: Closure Properties of CFLs
Theorem 1 CFLs are closed under
3. Kleene Star.
Let G1 = (V1, 1, R1, S1 ), and G2 = (V2, 2, R2, S2 ) be the
two CFG generating the CFLs L1 and L2.
Rename the nonterminals, if necessary, so t
12: PA CFG
Theorem 1 If a language is context-free, then it is accepted
by a PA.
The proof is a constructive proof. We rst sketch the idea. We
construct a PA from the given CFG as follows:
1. Push the start nonterminal of the CFG onto the stack
Lecture 2: Sets, Relations, and Functions (a
A set is a collection of objects.
Example: L = cfw_a, b, c, d is a set of four elements.
a L denotes a is in L, and z L denotes z is not
The empty set, denoted by , contains no elements.
Lecture 3: Languages and Regular Expressions
Alphabet a nite set of symbols, .
word (or string) a nite sequence of symbols from
cfw_a, b, . . . , z man, abc, . . .
000, 010101, . . .
cfw_#, $, a, b, c
Lecture 4: Finite Automata
A nite automaton is a machine (controller) with only
a nite number of states.
It is the simplest and most restricted model of a computer.
Such a controller is used in many electromechanical devices, e.g., automatic door, lift, v
Lecture 5: Nondeterministic Finite Automata
In a DFA,
each symbol read causes a transition to the next
state, which is completely determined by the current state and current symbol (i.e., there is exactly one next state).
In an NFA,
some state may hav
Lecture 6: The fundamental theorem
Let L . Then the following three statements are equivalent.
1. L is accepted by some DFA.
2. L is accepted by some NFA.
3. L can be represented by a regular expression
Proof: We will prove the following: i) 1 2, ii) 2 3.
7: Properties of regular languages
Theorem 1 The set of regular languages are closed
1. Concatenation (L1 and L2 regular, then so is L1L2),
2. Union (L1 and L2 regular, then so is L1L2),
3. Kleene star (L regular, then so is L),
4. Complementation (
8: Proving that a language is not regular
Example: L = cfw_0n1n|n 0 is not a regular language.
Intuitively, this language L is not regular because any
machine that can recognize L must remember how many
0s have been seen so far (i.e. unlimited number of
Lecture 9: Countability and Uncountability
How do we measure the sizes of innite sets?
How can we compare their relative sizes?
The number of elements in a set A is called its cardinality, denoted |A|.
If |A| is nite, then A is a nite set.
10: Context-Free Languages
is a language generator that is more powerful than regular
important for parsing programs
= cfw_a, b
The language L represented by a(a b)b can be generated by
the following set of g
11: Pushdown Automata
Every regular language is a CFL.
But some CFLs are nonregular.
Since FA Regular languages, some CFLs cannot be recognized by any FA.
Examples of CFLs that are nonregular:
cfw_ a n b n : n 0
cfw_wwR : w cfw_a, b
We need to consider a
8b: State Minimization
One obvious way to reduce the number of states is to
eliminate any states that are not reachable from the start
Hereafter, we shall assume that all states in the given
DFA M are reachable from the start state.
Let M = (K., ,