Automata Theory Chapter 2 PDF
Automata Theory Chapter 2 PDF
Automata Theory Chapter 2 PDF
In DFA, for each input symbol, one can determine the state to which the machine will move.
Hence, it is called Deterministic Automaton. As it has a finite number of states, the
machine is called Deterministic Finite Machine or Deterministic Finite Automaton.
1
Formal Languages and Automata Theory, chapter2
If q is a state and a is a symbol, then δ (q, a) is a state p (and in the graph that represents
the automaton there is an arc from q to p labeled a) Q x Σ ==> Q
4. A start state, one of the states in Q
5. A set of final or accepting states F (F ⊆ Q)
2
Formal Languages and Automata Theory, chapter2
q1 q1 q2
q2 q2 q2
The DFA define a language: the set of all strings that result in a sequence of state transitions
from the start state to an accepting state
Describes what happens when we start in any state and follow any sequence of inputs
If δ is our transition function, then the extended transition function is denoted by ˆδ
The extended transition function is a function that takes a state q and a string w and returns a
state p (the state that the automaton reaches when starting in state q and processing the
sequence of inputs w)
3
Formal Languages and Automata Theory, chapter2
4
Formal Languages and Automata Theory, chapter2
This ability is often expressed as an ability to “guess” something about its input
Each NFA accepts a language that is also accepted by some DFA
NFA are often more succinct and easier than DFAs
We can always convert an NFA to a DFA, but the latter may have exponentially more
states than the NFA (a rare case)
The difference between the DFA and the NFA is the type of transition function δ
o For a NFA δ is a function that takes a state and input symbol as arguments (like
the DFA transition function), but returns a set of zero or more states (rather than
returning exactly one state, as the DFA must)
A Non-deterministic Finite Automaton (NFA) consists of:
Q ==> a finite set of states
Σ ==> a finite set of input symbols (alphabet)
q0 ==> a start state
F ==> set of accepting states
δ ==> a transition function, which is a mapping between Q x Σ ==> subset of Q
An NFA is also defined by the 5-tuple: {Q, Σ, q0, F, δ }
Example
Let a deterministic finite automaton be →
Q = {q0,q1,q2},
Σ = {0, 1},
q0 = { q0},
F = { q2}, and
q1 ∅ {q2 }
q2 {q2} {q2}
5
Formal Languages and Automata Theory, chapter2
6
Formal Languages and Automata Theory, chapter2
DFA vs NDFA
The following table lists the differences between DFA and NDFA.
DFA NDFA
The transition from a state is to a single The transition from a state can be to multiple
particular next state for each input symbol. next states for each input symbol. Hence it is
Hence it is called deterministic. called non-deterministic.
Empty string transitions are not seen in DFA. NDFA permits empty string transitions.
For each state, transition on all possible Not all symbol transitions need to be defined
symbols (alphabet) should be defined explicitly
Backtracking is allowed in DFA In NDFA, backtracking is not always
possible.
Requires more space. Requires less space.
A string is accepted by a DFA, if it transits to A string is accepted by a NDFA, if at least
a final state. one of all possible transitions ends in a final
state.
7
Formal Languages and Automata Theory, chapter2
rephrasing…
Given any NFA N, we can construct a DFA D such that L(N)=L(D).
How to convert an NFA into a DFA?
Observation: In an NFA each transition maps to a subset of states.
Represent each “subset of NFA_states” as a single “DFA_state”.
We will call this process as Subset construction
We have a NFA N = (QN , Σ, δN, q0, FN )
The goal is the construction of a DFA D = (QD, Σ, δD, {q0}, FD) such that
L(D) = L(N).
Construction:
a. QD= all subsets of QN (i.e., power set)
b. FD=set of subsets S of QN s.t. S∩FN≠Φ
c. δD: for each subset S of QN and for each input symbol a in ∑:
δD(S, a) = U p in s δN (p, a)
Algorithm
Input − An NDFA
Step 2 − Create a blank state table under possible input alphabets for the equivalent DFA.
Step 3 − Mark the start state of the DFA by q0 (Same as the NDFA).
Step 4 − Find out the combination of States {Q0, Q1,... , Qn} for each possible input alphabet.
Step 5 − Each time we generate a new DFA state under the input alphabet columns, we have
to apply step 4 again, otherwise go to step 6.
8
Formal Languages and Automata Theory, chapter2
Step 6 − The states which contain any of the final states of the NDFA are the final states of
the equivalent DFA.
9
Formal Languages and Automata Theory, chapter2
The DFA is
10
Formal Languages and Automata Theory, chapter2
FA with Ԑ-Transitions
We allow now a transition on Ԑ, i.e., the empty string
A NFA is allowed to make a transition spontaneously, without receiving an input symbol
This capability does not expand the class of languages that can be accepted by finite
automata, but it does give us some added programming convenience.
Definition: Ԑ -NFAs are those NFAs with at least one explicit Ԑ-transition defined.
Ԑ -NFAs have one more column in their transition table
Example
L = {w | w is empty, or if non-empty will end in 01}
Ԑ-closure of a state q, ECLOSE (q), is the set of all states (including itself) that can be
reached from q by repeatedly making an arbitrary number of Ԑ- transitions.
An Ԑ-NFA A = (Q, Σ, δ, q0, F) where all components have their same interpretation as
for NFA, except that δ is now a function that takes arguments:
1. A state in Q and
2. A member of Σ ∪ {Ԑ}
11
Formal Languages and Automata Theory, chapter2
Eliminating Ԑ-Transitions
Let E = (QE, Σ, δE, q0, FE) be an Ԑ-NFA. Then the equivalent DFA
D = (QD, Σ, δD, qD, FD) is defined as follows:
1. QD is the set of subsets of QE
2. qD = ECLOSE(q0)
3. FD = {S | S is in QD and S ∩ FE ≠∅}
Those sets of states that contain at least one accepting state of E
4. δD (S, a) is computed, for all a in Σ and sets S in QD by:
o Let S = {p1, p2, . . . , pk}
o Compute U i=1 to k δE (pi, a); let this set be {r1, r2, . . . , rm}
o Then δD (S, a) = U j=1 to m ECLOSE(rj)
12