automata and complexity theory Chapter 01
automata and complexity theory Chapter 01
2014 E.C
Course Contents
1. Theory of Computation 3. Introduction Turing Machine(TM)
Standard TM
Automata Theory
Construction of TM
Formal languages theory
TM Decidable and Acceptable
Complexity Theory
Undecidable Problems
Type of Finite Automata Undecidability
Conversion of Automata Turing Decidable
Turing Acceptable
2. Regular Languages, Expressions
Regular languages and grammars Undecidable Problems
Conversions of Res to FA 4. Computability Theory
Construction of FA from REs Recursive Functions
Context Free Languages, Grammars and Recursive Languages(RLs)
Simplifications Recursive Enumerable languages(RELs)
Type 2 Grammars, Closure properties
5. Computational complexity Theory
CFG Simplifications Big o Notation
Pushdown Automata(PDA) Class P vs NP
Construction of PDA for the given Languages NP-Complete Problems
PDA Acceptance Cook’s Theorem
Automata and Complexity Theory 2
Course Goals
• Theoretically explore the capabilities and limitations of computers
• Complexity of Algorithms
• How much resources are required to run the algorithms?
• Automata theory
• How can we mathematically model computation?
• Formal language Theory
• How a language defined, described, bounded & accepted?
• Complexity theory
• What makes some problems computationally hard and others easy?
• Computability theory
• What problems can be solved by a computer?
• Computational Complexity theory
• How the solution is efficient and effective enough?
• All Languages
Decidable
Languages
All
Languages
Decidable
Languages
O (n ) O (n 2 ) O (2n )
O ( n log n )
FA<PDA<LBA<TM
Generate
Languages(L) Language L generated by Grammar G
L(M)=L
Accept
Machines(M) Language L Accepted by Machine M
Input Tape
String
Output
“Accept”
Finite or
Automaton “Reject”
33
DFA…
• A Deterministic Finite Automata operates in the following manner
At the initial time, it is assumed to be in the initial state q0, with its input mechanism
on the leftmost symbol of the input string.
During each move of the automaton, the input mechanism advances one position to the
right(R), so each move consumes one input symbol.
When the end of the string is reached, the string is accepted if the automaton is in one
of its final states F. Otherwise the string is rejected.
The input mechanism can move only from left to right and reads exactly one symbol on
each step.
a a b • Each particular
input have only
b c a one state
• Can’t move via
c b c
a b b
1 a, b 1
Start 0 b a Start 0 a
a 2 b 2 a, b
The Execution of DFA for input string w A* begins at the start state and follows a path whose edges concatenate to w.
The DFA accepts w if the path ends in a final state. Otherwise the DFA rejects w. The language of a DFA is the set of
accepted strings.
Example. The example DFA accepts the strings
a, b, ab, bb, abb, bbb, …, abn, bbn, ….
So the language of the DFA is given by the regular expression (a + b)b*.
Automata and Complexity Theory 41
Languages and DFA …
• In the above figure, two labels were allowed on a single edge. Such multiple
labeled edges are short hand for two or more distinct transitions: the transition
is taken whenever the input symbol matches any of the edge labels.
• For example, the automaton in the above figure remains in its initial state q 0
until the first ‘b’ is encountered.
• If this is also the last symbol of the input, then the string is accepted.
• If not, the DFA goes into state q2, from which it can never escape. Such a state
is called a trap state.
• We can see clearly from the graph that the automaton accepts all strings which
have exactly one b, located at the rightmost position of the string.
• All other input strings are rejected. In set notation, the language accepted by
this automaton is
L = {an b| n ≥ 0}
Automata and Complexity Theory 42
Theorem
• Let M = (Q, Σ, δ, q0, F) be a deterministic finite acceptor, and let Gm be its
associated transition graph. Then for every q i, qj ∈ Q, and w ∈ Σ+, δ*(qi,w)=qj
if and only if there is in Gm a walk with label w from q i to qj.
qi
a
qo v
b
qj
45
Automata and Complexity Theory
Nondeterministic Finite Automata (NFA)
• Non-determinism means a choice of moves for an automaton.
• Rather than prescribing a unique move in each situation, we allow a set of possible moves.
• Formally, we achieve this by defining the transition function so that its range is a set of
possible states.
• A Nondeterministic Finite Automata or NFA is defined by the quintuple.
M = (Q, Σ, δ, q0, F)
where,
Q is a finite set of internal states
Σ is a finite set of symbols called the input alphabet
q0 ∈ Q is the initial state
F ⊆ Q is a set of final states
but,
δ: Q X (Σ ∪ {ε}) → 2Q
Automata and Complexity Theory 46
Graphical Representation of an NFA
• An NDFA is represented by digraphs called state diagram.
• The vertices represent the states.
• The arcs labeled with an input alphabet show the transitions.
• The initial state is denoted by an empty single incoming arc.
• The final state is indicated by double circles.
• Example 1: Let a non-deterministic finite automaton be →
Q = {a, b, c}
∑ = {0, 1}
q0 = {a}
F = {c}
States State 0 1
-At each state there are many next
states and many outputs(paths) at
a {a, b} {b} same time.
b {c} {a, c}
c {b, c} {c}
{} {q1, q2}
q1
{q2} {q2}
q2
49
Automata and Complexity Theory
NFA … Example …
• Example 3: The following NFA recognizes the language of a + aa*b + a*b.
A. State Diagram 1 a
L
a b
a
Start 0 2
T a b
start 0 {1, 2} {1}
1 {1} {2}
final 2
{} {q2}
q1
{q2} {q2}
q2
{q4} {}
q3
{q4} {q4}
q4
Automata and Complexity Theory 51
Differences between NFA and DFA
• Note that there are two major differences between the above NFA definition
and the definition of a DFA.
1. In a NFA, the range of δ is the power set 2Q, so that its value is not a single
element of Q, but a subset of it. This subset defines the set of all possible
states that can be reached by the transition. Example, δ(q1, a) = {q0, q2}.
2. Also we allow ε (null) as the second argument of δ. This means that the
NFA can make a transition without consuming an input symbol.
• It is nondeterministic not only because several edges with the same label
originate from one vertex, but also it has ε - transition.
DFA is understood as one machine. NFA is understood as multiple small machines computing at
the same time.
• Strings accepted by the above DFA: {0, 00, 11, 010, 101, ...........}
• Strings not accepted by the above DFA: {1, 011, 111, ........}
q δ(q,0) δ(q,1)
a {a,b,c,d,e} {d,e}
b {c} {e}
c ∅ {b}
d {e} ∅
e ∅ ∅
Automata and Complexity Theory 65
Conversion NFA to DFA
• Using the above algorithm, we find its equivalent DFA. The state table of the DFA is shown in
below.
q δ(q,0) δ(q,1)
[a] [a,b,c,d,e] [d,e]
[a,b,c,d,e] [a,b,c,d,e] [b,d,e]
[d,e] [e] ∅
[b,d,e] [c,e] [e]
[e] ∅ ∅
[c, e] ∅ [b]
[b] [c] [e]
[c] ∅ [b]