Study Note of Theory of Computation
Study Note of Theory of Computation
Arik Chen
[email protected]
Turing machine Grammar R.E.
M=(Q,E,A,T,q0,qa,qr) G=(V,T,P,S) recursive is a subset of R.E.
Q: a set of state V is the alphabet; if L is R.E, ~L may not R.E.
E: input alphabet set. T is all the terminal If L is recursive, then ~L is also.
A: tape alphabet set, large than E. S is a special non-terminal start L is recursive iff both ~L and L are
T: transition function symbol R.E
q0: start state qa: accept state e.g. cAd->aABd
qr:reject state
NFA
DFA
Finite Automata
NFA vs DFA
Theorem: for each NFA, there is and equivalent DFA
the key idea is to view a NFA as occupying not a single
state but a set of state.
regular expression to FA
Theorem:the class of languages accepted by FA is
closed under union, concatenation, * , complementary,
intersection.
FA to regular expression
DFA to regular expression
NFA to regular expression
proof: L(FA) is regular language
Theorem: Accept by FA <=> a language is regular.
State Minimization
CFL
Chomsky Normal Form
All production of the form A->BC or A->a
step 1: Eliminate nullable production
step 2: Elimitnate unit production
convert to production of length 2 or length 1
CFL closure property
close under union, concatenation, and star
not close under intersection or complementation(P147)
intersection of CFL and regular language is CFL.
parse tree
Q: Can we decide whether a language is CFL? CSL can not
be decide but semi decide.
Push-Down Automata
NPDA
the idea is use stack to remember the first half for further
check.
PDA
FA vs PDA
every FA can be viewed as a PDA without operate the
stack
PDA vs CFL
Each CFL is accepted by some PDA.
map productions to transition relation
if a language is accept by a PDA, it is a CFL.
map transition relation to productions.
Q: non-deterministic PDA is powerful than deterministic PDA?
Extreme of CFL/PDA
Pumping Theorem
G is a CFL
Any string longer than Fanout|non-terminal|
can be (exist) rewritten as w=uvxyz
either v or y is nonempty
uvnxynz is also in L(G)
to prove not CFL, show non is exist.
{anbncn}
{an:n is a prime}
CFG vs regular
there are CFL not regular (anbn), but all regular language
are context free.
state => non-terminal
symbol =>terminal
arrow=>production
U('M', 'W')='M(W)'
encode states
encode alphabet
encode transition function
Implement with 3-tape machine
undecidable problem
halt problem
diagonal(x)
a: if halt(x,x)
then goto a
else halt
halt(M, W) recursive?
if yes. same contradiction may happen.
therefore NOT recursive
Decidable Problem
show decidable (recursive)
build a decider (TM)
reduction
know a solvable problem, and solved by Mk
then use Mk to construnct Muk to solve unknown
problem.
1. encode(reduce, map) input of Muk to input of MK
2. use Mk to work on the mapped input.
Undecidable Problem
show undecidable
reduction
find a known problem to be hard (unsolvable)
An unknown problem can be assumed decidable,
decided by Muk
1. encode instance (input) of known problem to input
of Muk
2. show that the problem is solved
however, known problem is unsolvable, so Muk is
impossible.
Does M halt on empty string?