study note of theory of computation
DESCRIPTION
DFA,NFA,PDA,CFL,TM,decidableTRANSCRIPT
Theory of Computation
Arik [email protected]
Automata and Language
Turing machineM=(Q,E,A,T,q0,qa,qr)Q: a set of stateE: input alphabet set.A: tape alphabet set, large than E.T: transition functionq0: start state qa: accept stateqr:reject state
GrammarG=(V,T,P,S)V is the alphabet;T is all the terminalS is a special non-terminal start symbole.g. cAd->aABd
R.E. recursive is a subset of R.E.if L is R.E, ~L may not R.E. If L is recursive, then ~L is also.L is recursive iff both ~L and L are R.E
PDAP=(Q,E,A,T,q0,F,) A: the stack alphabetT: transition relation ((state, tape, stack), (state', stack)) q0: the initial stateF: a set of final states,accept:(f,e,a) or (q, e, e)
CFGG=(V, T, P, S)P is the finite set of production.e.g. A->AB
CFLsome context free language is not regular ().
FAA={Q,E,T,q0,F}In DFA, T maps input (state, symbol) to one stateIn NFA, T maps input (state, symbol) to a set of states
regular expression regular languageall regular language are context free language.
Relation of Languages
Finite Automata
NFADFA
Finite AutomataNFA vs DFA
Theorem: for each NFA, there is and equivalent DFAthe key idea is to view a NFA as occupying not a single state but a set of state.
#state of DFA= 2#state of NFA (cause state explosion?)see proof by induction (P71)When state is considered, NFA is exponentially better than NFA
Regular Expression
regular expression to FA Theorem:the class of languages accepted by FA is closed under union, concatenation, * , complementary, intersection.
FA to regular expressionDFA to regular expression NFA to regular expressionproof: L(FA) is regular language
Theorem: Accept by FA <=> a language is regular.
State Minimization
remove unreachable statefind equivalent classes
Theorem: there is a DFA accepts L with the precious number of states as the equivalent classes of L .Theorem: L is regular <=> equivalent classes is finitefor example {anbn}, [e],[a],[aa]...
Extreme of FA/regularpumping lemma
if L is regular languagethen there exists a constant neach w longer than n in L can (exists y) break into three strings w=xyz and satisfy that
y is not empty|xy| is not longer than nxykz is also in L
when there are finite number of string in language L, pumping lemma is useless.
finite equivalent class if we want show a language L is not regular, you should prove that pumping lemma is not satisfied or the number of equivalent class is infinite.
Context Free Grammar
CFLChomsky Normal Form
All production of the form A->BC or A->astep 1: Eliminate nullable productionstep 2: Elimitnate unit productionconvert to production of length 2 or length 1
CFL closure propertyclose under union, concatenation, and starnot close under intersection or complementation(P147)intersection of CFL and regular language is CFL.
parse treeQ: Can we decide whether a language is CFL? CSL can not be decide but semi decide.
Push-Down Automata
NPDAthe idea is use stack to remember the first half for further check.
PDAFA vs PDA
every FA can be viewed as a PDA without operate the stack
PDA vs CFLEach CFL is accepted by some PDA.
map productions to transition relationif 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 TheoremG is a CFLAny string longer than Fanout|non-terminal|
can be (exist) rewritten as w=uvxyzeither v or y is nonemptyuvnxynz 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-terminalsymbol =>terminalarrow=>production
Right linear Grammar <=> regular language
every regular language can be accept by right linear GLanguage accept by right linear G is regular.proof by construct CFG<=>NFA
Grammar
The rules decide what L(language) is exactly generated.if not belong to this L, non-terminals can not be erased
L(G) iff L is REL(G)<=>L(M) (q, u1a1w1)|-M (q', u2a2w2) iff u2a2q'w2=>u1a1qw1
If a string can be generate by the grammar, then it can be searched by applying all the rules. If the string cannot, then the search will never stop.
What can/cannot be computed?
Algorithm device excludes non-halt TM.Church-Turing thesis: assert algorithm corresponds to a certain Turing machineTherefore, some computational problem cannot be solved. That is computation task that cannot be performed by Turing machines are impossible, hopeless, undecidable.
How to encoding Turing Machine?
if Turing Machine can receive encoding of Turing Machine then there would be interesting operations.
Universal Turing Machine
U('M', 'W')='M(W)'encode statesencode alphabetencode transition function
Implement with 3-tape machine
undecidable problem
halt problem
Does diagonal(diagonal) halt?d(d) halt when halt(d,d) return no which means d(d) not halt, a contradiction.That is to say, there can be no program halt(P,X) to solve this problem: to tell whether arbitrary program can halt or not
diagonal(x)a: if halt(x,x) then goto a else halt
Halt Problem
Exist M semi-decide W, which means halt("M","W") is semi-decided.
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 Mkthen use Mk to construnct Muk to solve unknown problem.1. encode(reduce, map) input of Muk to input of MK2. use Mk to work on the mapped input.
Undecidable Problem
show undecidablereduction
find a known problem to be hard (unsolvable)An unknown problem can be assumed decidable, decided by Muk1. 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?