0% found this document useful (0 votes)
12 views

Automata Unit1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Automata Unit1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Definition of an Automaton:-An Automaton is Description of a Finite Automata (Finite State

defined as a system that preforms certain Machine): A Finite automaton can be represented
functions without human intervention. it accepts by five-tuple structure M(Q,Σ, δ, q0, F), where
raw material and energy as input and converts 1. Q is a finite non empty set of states.
them into the final product under the guidance of 2. Σ is a finite non empty set of inputs called
control signals. or an automata is defined as a
the input alphabets.
system where energy, materials, and information
3. is a function which maps Q × Σ into Q
are transformed, transmitted and used for
performing some functions without direct and is called transmission function (next
involvement of man. Ex: Any automatic machine state function) (present state × input
like printing machine, washing machine etc. alphabet→ next state).
4. q0 ∈ Q is the initial state.

i1 5. F⊆ Q is the set of final states (may be more


AUTOMATON o1
i2 o2 than 1).
i3 Note: Q×Σ* into Q means Present state × String
...

q1, q2, … ,qn


...

oq of input symbols(including Λ ) → Next State.


ip
Model of a automaton String being processed
$ $ $ $ $ $
Characteristics of automaton: Reading Head Input Tape
1. Input: i1, i2,…,ip are the input of the model
each of which can take a finite number of Finite Control
fixed values from an input I. Block diagram of a finite automaton
2. Output: o1, o2,…,oq are the outputs of the
I) Input tape: The input tape is divided onto
model each of which can give the finite
squares, each square containing a single
number of fixed values to an output O.
symbol from the input alphabet Σ. The end
3. States: At any instant of time the automaton
squares of the tape contain the end marker
can be in one of the states q1, q2, … ,qn.
$. The absence of the end markers
4. States Relation: The next state of an
indicates that the tape is of infinite long.
automaton at any instant of time is determine
Input string is processed from left to right.
by the present state and present input.
II) Reading Head: The head examines only
5. Output relation: The output is related to
one square at a time and can move one
either state only or to both the input and the
square either to the left or to the right, we
state.
restrict the movement of reading head
Note: An automaton in which the output depends only to the right side.
only on the input is called an automaton without a III) Finite Control: The input to the finite
memory. Ex:- logic gate. An automaton in which control will usually be the ‘Symbol’ under
the output depends on the state and input is called the reading head and the ‘present state’ of
an automaton with a finite memory. Ex:- flip- the machine. Outputs will be A). A motion
flops, shift register, Mealy machine. An of R-head along the tape to the next
automaton in which the output depends only on square. B). The next state of the finite
the states of the machine is called Moore state machine given by δ(q,a).
Machine.
Transition system: A Transition system is a Determine the initial and final states.
finite directed labeled graph in which each q0 & q1 q3
vertex(node) represents a state and the directed
101011 will be accepted.
edge indicates the transmission of a state and
the edges are labeled with input/output. 111010 will be rejected.
Properties of Transition Functions:
0/0 1/1
1/0 Property 1: δ(q, ∧) = q is a finite automata, This
q0 q1 means that the state of the system can be changed
0/0 only by an input symbol.
Fig. A Transition System. Property 2:- for all strings w and input symbol a
In Figure, the initial state is represented by a δ(q,aw) = δ(δ (q,a)w)
circle with an arrow pointing toward it, the final δ(q,wa)= δ( δ(q,w),a)
state by two concentric circles and the other This property gives the state after the automaton
states are represented by a circle. The edges are consumes or reads the first symbol of a string aw.
labeled by input/output (eq. 1/0 or 1/1).
Ex: prove that for any input transition function δ
For example, if the system is in the state q0 & the and for any two input string x and y.
input is 1 is applied, the system moves to state q1
δ(q, xy) = δ(δ(q, x), y)
as there is a directed edge from q0 to q1 with
label1/0. It output 0. Proof: By method pf mathematical induction
Definition of Transition System: A transition 1. Basis: on |y| i.e. length of y when |y|=1,
System consist of 5-tuple (Q,Σ, δ, Q0, F). y=a∈Σ.
I. Here Q,∑ and F are finite non empty set of L.H.S= δ (q,xa)
states, the input alphabets, and set of final = δ( δ(q,x),a) (by using prop. 2)
states respectively, as in the case of FA. =R.H.S.
II. Q0 ⊆Q and Q0 is the non-empty set of initial 2. Induction Hypothesis: Assume the result
state. for all string x and string y with |y|=n.
III. δ is finite Q×Σ → Q . 3. Let y be a string of length n+1.
Write y=y1a, where |y1| = n.
In other words, if (q1, ω, q2) is in δ. It means that
L.H.S. = δ(q,xy1a) = δ (q,x1a) where
the graph starts at the vertex q1, goes along a set x1=xy1
of edges and reaches the vertex q2.
= δ( δ(q,x1)a) ( by using prop. 2).
A Transition system accepts a string w in Σ* if = δ( δ(q,xy1) a )
i). There exists a path which originates from = δ( δ( δ(q,x), y1 ) a ) by step 2.result
some initial state, goes along the arrows and = δ( δ(q,x)y1a)
terminates at some final state. = δ( δ(q,x)y) = R.H.S.
ii). The path value obtained by concatenation of By the principle of mathematical
all- edge-labels of the path is equal to w. induction, this is true for all strings.

1/0 Ex.:- prove that if δ(q,x) = δ(q,y), then


0/1 ^/0 δ(q,xz) = δ(q,yz) for all strings z in Σ+.
q0 q1 q3
Sol:- δ(q,xz) = δ( δ(q,x)z) by previous results.
^/0
0/0 1011/0 = δ( δ(q,y)z) (given)
q2
=(q,yz) (reverse the previous result)
Regular Languages: a regular language over an Acceptability of a string by a finite Automation:
alphabet Σ is one that can be obtained from these basic Definition: A string x is accepted by a finite automaton
languages using the operations Union, Concatenation M=(Q, Σ, δ, q0, F) if δ(q0, x)=q for some q∈ F.
and Kleene* (Kleene* operation arises from the
This is basically the acceptability of a string by
concatenation to produce infinite languages).
the final state,
A regular language can be described by explicit Example: The FSM is given below
formula { } by leaving out the set of { } or replacing Table: Input symbol
them with ( ) and replacing ∪ by +; the result is called State 0 1
a regular expression. q0 q2 q1
q1 q3 q0
Language Corresponding q2 q0 q3
Regular Expression q3 q1 q2
1. {^} ^
2. {0} 0
3. {001} or ({0},{0},{1}) 001 1 q1 0
4. {0,1} or ({0}∪{1}) 0+1
1
5. {0,10} or ({0} ∪ {10}) 0+10 0
6. {1,^}{001} (1+^)001 q0 q3
7. {110}*{10} (110)*(0+1) 0 1
8. {1}*{10} (1)*10 or 1*0 or 1+0 0 1
*
9. {10,111,11010} (10+111+11010)* q2
10. {0,10}*{{11}*U{001,^}) (0+10)*((11)*+001+^)
Here Q = { q0, q1, q2, q3 }
Definition: Regular Languages and Regular Σ = {0, 1 }
Expressions over Σ: The set R of regular languages F = { q0 }
over Σ and the corresponding regular expressions are Input String(x) = 110101
defined as follows:
1. Φ is an element of R, then the corresponding RE is Φ. δ( q0, 110101 ) ⟹ δ( q1, 10101 ) ⟹
2. {^} is an element of R, then corresponding RE is ^. δ( q0, 0101 ) ⟹ δ( q2, 101 ) ⟹ δ( q3, 01 ) ⟹
3. For each a∈Σ is an element of R, and the
corresponding RE is a. δ( q1, 1 ) ⟹ δ( q0, ∧ ) ⟹ q0
4. If L1 and L2 are any element of R and r1 and r2 are 1 1 q ⟶ 0 q ⟶1 0 1
Hence q0 ⟶ q1 ⟶ 0 2 q3 ⟶ q1 ⟶ q0
corresponding RE. This ↓ indicates that the current input symbol is
a. L1∪L2 are any element of R and the being processed by machine.
corresponding RE is (r1+r2).
Non-Deterministic FSM:
b. L1L2 is an elements of any element of R and The concept of non-determinism plays a central
the corresponding RE is (r1r2). role in both the theory of languages and the
c. L1* is an elements of R and the corresponding theory of computation, and it is useful to
RE is (r1*). understand this notion fully in a very simple
Note: Only those languages that can be obtained context initially. The finite automaton model
by using statements 1 to 4 are regular languages allows zero, one, or more transitions from a state
over Σ. on the same input symbol. This model is called a
nondeterministic finite automaton(NFA).
For one input there is one or more output states. a
a∗a(NFA) a
0 1 q0 F
0
q0 q1
a c
1 1 (a+b)(c+d) q0 q1 F
q2 b d
a ,b
Figure: Transition system representing NDA
(a + b)∗
If an automaton is in a state {q0} and the input F
symbol is 0, what will be the next state?, from
figre it is clear that next state will be either {q0} a ,b F
Φ q0
or {q1}. Some moves of the machine cannot be
determined uniquely by the input symbol and the Some regular Expression and their corresponding FA
present state. Such machines are called NDA.
Definition: A Non-Deterministic Finite Automata q0
∈, ∧
(NDFA) is a 5 tuple (Q, Σ, δ, q0, F), where
q0 0 F
I) Q is a finite non-empty set of states. 0
0 0
II) Σ is a finite non-empty set of inputs. 001 q0 q1 q2 1 F
III) δ is the transition function mapping from 0 ,1
0+1 q0 F
Q×∑ into 2Q which is the power set of Q,
the set of all subset of Q.
0
IV) q0 ∈ Q is the initial state; and 0 + 10 q0 F
V) F ⊆ Q is the set of final states. 1 q1 0
Some rules to generate FA ∧
(1 + ∧ ) 001 0 0
q0 q1 q2 q3 1 F
∈, ∧ q0 1

0 qf
(110)* (0+1)
a q0 a F q0 1 F
0 q1 1
b q0 b F 1
1+0
a q0 1 q1 0 F
a+b q0 F
b
a 1
c (10+111+11010)
(a+b)c q0 q1 F
b F 0 q1
a 1 1
a∗ 0 q2
F
q4 0
a 1
aa∗ a q3
q0 F
Difference between DFA and NDFA is only in δ. Example: Design a FA over alphabet Σ = {0, 1},
for DFA outcome is a state, i.e. an element of Q; which accepts the set of strings either start with
for NDFA, the outcome is a subset of Q. 01 and or end with 01.

Facts of designing Procedure of FA Solution: By the analysis of problem, it is clear


we can describe some facts or observation of FA that FA will accepts the strings such as 01,
a. In the designing of the FA, first of all we 01111, 010000, 000101, 0001101,….
have to analyze the set of strings i.e. 0, 1
language which is accepted by the FA.
0 1
b. Make sure that every state is check for the q0 q1 q2
output state for every input symbol of Σ.
1
c. Make sure that no state must have two
different output states for a single input q3 1
symbol. 0 0
0
d. Make sure that there is one initial state and
at least one final state in transition diagram 1 q4 0
of FA.
1
Example: Construct a FA that accepts set strings
q5
where the number of 0’s in every string is
multiple of three over alphabet Σ = {0, 1}. Example: Design a FA which accepts the
Solution: Multiple of three means number of 0’s language L= {w/ w has both an even number of
on the string may be 0, 3, 6, 9, 12, . . . 0’s and an even number of 1’s over alphabets Σ
1 = {0, 1}}.
Solution:
1 q1 1
0
q0 1 q1
q0
0 0 0 0
0 1
0
q2 q3
q2 1
1
Example: Design FA for the Language example:NFA
L ={(01)I 12j | i≥1, j≥1}. 0
0 ,1
Solution: By analysis Language L, it is clear that 1 1
q0 q1 q2
FA will accepts strings start with any number of
01(not empty) and end with even number of 1’s. 0
1 ∧
0 1
q3 0 q4
0 1 1 1 q4
q0 q1 q2 q3
w =0100
0 0 ,1
0
1 0 δ(q0, 0100) = { q0, q3, q4 }
q5
since q4 is an accepting state, the input string will
0, 1 be accepted by NDFA.
Example: NFA II. Any NDFA is a more general machine
without being more powerful.
0 ,1
q0
1 0 ,1 0 ,1 let M = ( Q, Σ, q0, δ, F ) is an NFA.
q1 q2 q3
M1= (Q1, Σ, q1, δ1, F1 ) is a DFA.
δ* (q0, 11) = ∪ δ ( r , 1 ) I) Q1 = 2Q
r ∈(q0,1) II) q1 = { q0 }
III) Σ =Σ
= ∪δ(r,1)
r∈(q0,q1) IV) F1 = { q ∈ Q1 and q ∩ F ≠ ∅ }
V) δ1 (q, a ) = ∪ δ ( r, a )
= δ(q0,1)∪δ(q1,1)
r∈q
{ q0, q1 } ∪ { q2 } δ1 ([q1, q2, … , qi] , a ) = δ(q1, a) ∪ δ(q2, a)
δ* ( q0 , 01 ) = ∪ δ ( r, 1 ) ∪…∪ δ(qi, a)
r ∈(q0,0) equivalently
= ∪ δ ( r, 1 ) δ1 ([q1, q2, … , qi] , a ) = [ p1, p2, . . ., pj]
r ∈ { q0 }
if and only if
= δ (q0, 1 )
δ1 ({q1, q2, … , qi} , a ) = {p1, p2, . . . , pj }
= {q0, q1 }
δ1 (q1, x ) = [q1, q2, … , qi]
δ* (q0, 111) = ∪ δ ( r, 1 )
if and only if
r ∈(q0,11)
δ (q0, x ) = {q1, q2, … , qi}
= ∪ δ ( r, 1 )
Prove by using Mathematical Induction
r ∈{q0, q1, q2}
= δ(q0, 1 ) ∪ δ(q1, 1 ) ∪ δ(q2, 1) 1. Basis: |x| = 0
δ (q0, ∧ ) = { q0 } and
= { q0, q1 } ∪ { q2 } ∪ { q3 }
= { q0, q1, q2, q3 } δ1 (q1, ∧) = q1 = {q0}
so the equation is true.
The Equivalence of DFA and NDFA: 2. Assume equation is true for all string y with
or Prove that for every NFA, there is an |y| = m
corresponding FA which simulate the behavior δ1 (q1, y) = δ (q0, y)
of NFA. for every string L. 3. let x be a string of length m+1.
Solution: Before describing the equivalence of x= ya
NFA and DFA, let us take a look at the term δ1 (q1, ya) = δ1 (δ1 (q1, y),a )
equivalence. The term equivalence means ‘equal = δ1 (δ (q0, y),a )
in some respect’. For example, a BA degree is
= ∪ δ ( r, a)
equivalent to an B.E. degree, as both are bachelor r ∈(q0,y)
degrees, and for appearing in the civil services = δ ( q0, ya )
examination, either of them is equally applicable.
However, both are not equal, as a person with a
Examples: Construct a deterministic automaton
BA degree cannot be appointed as engineer and a equivalent to M = ( [q0, q1], {0,1}, δ, q0 , {q0} )
person with a BA degree cannot be appointed as a where δ is
history teacher. state/ Σ 0 1
I. A DFA can simulate the behavior of NDFA ⟶q0 q0 q1
by increasing the number of states. q1 q1 q0q1
Solution: Sol: M1 = (2Q, {a,b}, δ, [q0], F )
i. The states are subset of {q0, q1} i.e. {Φ}, F = [q3], [q0. q3], [q1, q3], [q2, q3], [q0, q1, q3],
{q0}, {q1}, { q0, q1}. [q0, q2, q3], [q1, q2, q3] and [q0, q1, q2, q3]
ii. [q0] is initial state.
iii. [q0] and [q0, q1] are final states, both state/ Σ 0 1
⟶[q0] [q0, q1] [q0]
states contain q0.
[q0,q1] [q0,q1,q2] [q0, q1]
iv. Transition table for DFA [q0,q1,q2] [q0, q1, q2, q3] [q0,q1,q3]
state/ Σ 0 1 [q0,q1,q3] [q0,q1,q2] [q0,q1,q2]
Φ Φ Φ [q0, q1, q2, q3] [q0, q1, q2, q3] [q0, q1, q2, q3]
⟶[q0] [q0] [q1]
[q1] [q1] [q0, q1] Example: Convert he NFA given in Figure to
its equivalent DFA.
[q0, q1] [q0, q1] [q0, q1]
a,b
When M has n-states, the corresponding FA has
a b
2n states. However, we need not to construct δ q1 q2 qf
for all these 2n states. But only for those states
are reachable from {q0}, we halt on when no Transition table for the NFA in figure
more new states appear under the input. Current State Input Symbol
Example: Find a deterministic acceptor a b
equivalent to M = ( [q0, q1, q2 ], {a, b}, δ, q0, ⟶q1 q1, q2 q1
{q2} ) where δ is q2 __ qf
qf __ __
state/ Σ 0 1
⟶q0 q0, q1 q2 Transition Table for DFA corresponding to DFA
q1 q0 q1 Current State Input Symbol
q2 __ q0, q1 a b
⟶[q1] [q1, q2] [q1]
Solution: [q1, q2] [q1, q2] [q1, qf]
M = { 2Q, {a,b}, δ, [q0], F’ } [q1, qf] [q1, q2] [q1]
F’ = { [ q2], [q0, q2], [q1. q2], [q0, q1, q2] } Example: Convert the NFA given in Table to
state/ Σ 0 1 Corresponding DFA.
⟶[q0] [q0, q1] [q2] Transition Table for an NFA
[q2] __ [q0, q1] Current State Input Symbol
[q0, q1 ] [q0, q1 ] [ q1, q2] 0 1
[ q1, q2] [q0] [q0, q1] ⟶q1 q2 qf
q2 __ q3
Example: Find a deterministic acceptor q3 q4 q3
equivalent to q4 q3, qf __
M = ({q0, q1, q2, q3}, {a,b}, δ, q0, {q3} ) qf __ q1
where δ is

state/ Σ 0 1 Transition Table for DFA corresponding to DFA


⟶q0 q0, q1 q0 Current State Input Symbol
q1 q2 q1 0 1
q2 q3 q3 ⟶[q1] [q2] [qf]
__ q2 [q2] ϕ [q3]
q3 [q3] [q4] [q3]
[q4] [q3, qf] ϕ 1. ∈ - closure(q): Set of states which are
[qf] ϕ [q1] reachable from state q on ∈ - input including
[q3, qf] [q4] [q1, q3] state q. It is equivalent to one state of
[q1, q3] [q2, q4] [q3, qf] equivalent DFA.
[q2, q4] [q3, qf] [q3] 2. move(q,a) = set of reachable states on input a
Example: Convert the NFA fiven in table to its from state q.
corresponding DFA.
∈ - closure ( move ( q,a)): Next state from
Transition Table for an NFA state q on input a ( Note: ∈ - closure( ∅ ) = ∅ )
Current State Input Symbol
0 1 Initial state of equivalent DFA is ∈ - closure(),
⟶q0 q1 q0, q2 is the initial state of given NFA and final
q1 q2 q0 states are those sets, which have atleast one
q2 q0 __ final state of given NFA.
Example: Consider the NFA with ∧ - moves
Transition Table for DFA corresponding to DFA shown in figure.
Current State Input Symbol a
∧ q1 q3 ∧
0 1
⟶ [q0] [q1] [q0, q2] ∧ ∧
[q1] [q2] [q0] q0 q5 qf
∧ ∧
[q2] [q0] ϕ
[q0, q2] [q0, q1] [q0, q2] b
q2 q4
[q0, q1] [q1, q2] [q0, q2]
[q1, q2] [q0, q2] [q0] ∧
ϕ ϕ ϕ Fig: NFA with ∧ - moves.

NFA with ∧-moves : Find the equivalent DFA.


a Sol: M = ( Q, Σ, δ, S, F )
∧ S1 S3 ∧
S = ∈ - closure (initial state of NFA)
∧ ∧
S S5 S6 = ∈ - closure (q0) (state reachable from q0
∧ ∧ on input ∈ - including q0)
b
S2 S4 = { q0, q1, q2 }
∧ δ ( S , a ) = ∈ - closure ( move ({ q0, q1, q2 },
a ))
Fig:- NFA with ∧- moves = ∈ - closure (q3)
If there is a NFA M with ∧- moves, then there
= { q3, q5, qf} (next state)
exists an equivalent DFA M1 which has equal string
let A = { q3, q5, qf}.
recognizing power or if some NFA M with ∧-
moves accepts an input string w, then there exists where
an equivalent DFA M1 which also accepts w. δ ( S , b ) = ∈ - closure ( move ({ q0, q1, q2 },
b ))
Method for constructing equivalent DFA from = ∈ - closure (q4)
given NFA with ∧-moves. = {q4, q5, qf }
1. Using ∈ - closure Method let B = {q4, q5, qf }
we use two operations ∈ - closure and move().
Here we have two states A & B. so we have to let A = { q1, q2, q3, q4, q8},where
define possible transitions from these states and
δ ( S , b ) = ∈ - closure ( move ({P}, b ))
we continue the process until no next state remain
= ∈ - closure ( ϕ ) = ϕ.
to be considered.
δ ( A , a ) = ∈ - closure ( move ({ q1, q2, q3,
δ ( A , a ) = ∈ - closure ( move ({ q3, q5, qf}, a ))
q4, q8}, a )) = ∈ - closure (q5)
= ∈ - closure ( move ( ϕ ) ) = ϕ.
= {q2, q3, q4, q5, q7, q8} (next state)
δ ( A , b ) = ∈ - closure ( move ({ q3, q5, qf}, b )) let B ={q2, q3, q4, q5, q7, q8}
= ∈ - closure ( move ( ϕ ) ) = ϕ.
δ ( A , b ) = ∈ - closure ( move ({ q1, q2, q3,
δ ( B , a ) = ∈ - closure ( move ({q4, q5, qf }, a ))
q4, q8}, b )) = ∈ - closure (q6, qf)
= ∈ - closure ( move ( ϕ ) ) = ϕ.
= {q2, q3, q4, q6, q7, q8, qf} (next state)
δ ( B , b ) = ∈ - closure ( move ({q4, q5, qf }, b )) let C = {q2, q3, q4, q6, q7, q8, qf}
= ∈ - closure ( move ( ϕ ) ) = ϕ.
δ ( B , a ) = ∈ - closure ( move ({q2, q3, q4, q5,
Table for DFA q7, q8}, a )) = ∈ - closure(q5)
state/Σ a b ={q2, q3, q4, q5, q7, q8} =B
⟶S A B
A ϕ ϕ δ ( B , b ) = ∈ - closure ( move ({q2, q3, q4, q5,
B ϕ ϕ q7, q8}, b )) = ∈ - closure (q6, qf)
= {q2, q3, q4, q6, q7, q8, qf} = C.
Q = { S, A, B }
δ ( C , a ) = ∈ - closure ( move ({q2, q3, q4, q6,
Σ = { a, b}
q7, q8, qf}, a )) = ∈ - closure(q5)
F = { A, B } a A
={q2, q3, q4, q5, q7, q8}=B
S
δ ( C , b ) = ∈ - closure ( move ({q2, q3, q4, q6,
b B q7, q8, qf}, b )) = ∈ - closure (q6, qf)
= {q2, q3, q4, q6, q7, q8, qf} = C.
Example: Consider the following NFA with ∧ -
moves. Construct an equivalent DFA. state/Σ a b
a ⟶S A ∅
∧ q3 q5 ∧
A B C
a ∧ ∧ ∧ b B B C
P q1 q2 q7 q8 q9 C B C
∧ ∧ A b b
b a
q4 q6
S a C
∧ b
Figure: NFA having ∧ - moves B
let M = ( Q, Σ, δ, S, F ) is an equivalent DFA a
S = ∈ - closure (initial state of NFA) a
= ∈ - closure (P) (state reachable from P on
input ∈ - including P) 2. Removal of Null Moves
= { P } (next state) The basic Strategies for the removal of null
δ ( S , a ) = ∈ - closure ( move ({ P }, a )) string are as follows:
= ∈ - closure (q1) Let A and B be the two states connected by a
= { q1, q2, q3, q4, q8} (next state) null string ∧.
Strategy 1: If A is an initial state, then move A to b) Concatenation
overlap B with all its connected structures as
shown in figure. f1 f2

a a
∧ q0 = q1 q2
A B A ∧
f’1 f’2
Strategy 2: If B is a final state, then move B to
overlap A with all its connected structures as
Concatenation(PQ)
shown in figure.
a
a c) Kleene*

A B B ∧
f1
Strategy 3: If A is the initial state and B is the
final state, then move A to overlap B with all its ∧
qf q1 ∧
connected structures and make A the final state
as shown in figure. f’1
a ∧
a

B A
A Kleenee* P*
Strategy 4: If both A and B are normal states ( Equivalent of FA to a Regular Set: The method
neither final nor initial), either can be moved to going to give for constructing a finite automaton
overlap the other with all its connected equivalent to a given regular expression is called
structures. subset method which involves two steps.
Note: If there is confusion in removing the null Step 1: Construct a transition graph equivalent to
moves, remove them using ∈-closure as the regular expression using ∧- moves. This is
discussed earlier. done by kleene’s theorem.
Kleene’s Theorem: Step 2: Construct the transition table for the
transition graph obtained in step 1. Using the
method conversion of NFA to DFA & construct
(c) the equivalent DFA.
(a) (b)
Example:- Construct a finite automaton for the
a) Union regular language represented by the regular
f1 expression (a + b )*cd*e.
∧ Solution: The following steps details the
q1

f’1 ∧ creation of the finite automaton for the given
q8 expression:
q0 ∧
∧ Step 1: The regular expression (a + b)* means
f2 ∧
q2 the repetition of the symbol a and b any number
of times (including zero) and in any order. Thus,
f’2
the automaton for this part of the regular
expression is given by loop that repeats for both
Union(P + Q ) a and b at any state as shown in figure i.
0,1 0, 1
Step 2: The finite automaton corresponding to q7 1
0
the regular expression cd* consists of an arc with ∧ ∧ ∧ ∧
q0 q5 q1 q2 q6 qf
the c. this arc comes from the previous state of
1 0
the finite automaton from where cd* follows q8
sequentially. This arc ends on a state, say A, on (d)
which there is a loop to indicate the nuber of 0,1
0,1 q7 1
repetitions (including zero) of d. The part of the 0
finite automaton corresponding to the regular q2
q1
expression cd* is shown in figure 2.
1 0
Step 3: The finite automaton corresponding to q8
the regular expression e, consists of an arc with
(e)
label e coming from a previous state and ending
into some state, say F. since e is the last part of Example: Construct the FA equivalent to the
the total regular expression (a + b )*cd*e, F has regular expression 10 + ( 0 + 11) 0*1
to be a final state. The part of the finite Solution: (Construction of transition graph): First
automaton corresponding to the regular we construct the transition graph with ∧-moves
expression e is shown in figure 3. then eliminate ∧-moves.
Step 4: The complete finite automaton for the 10 + ( 0 + 11) 0*1
regular expression (a + b )*cd*e can be obtained q0 qf
by combining the finite automata in fig 1 -3 (a)
10
serially, as shown in figure 4.
d
a, b q0 qf
Previous c
A
S State ( 0 + 11) 0*1
Figure 2 (b)
Figure 1 q1
a, b d 0
1
Previous e c e
F S A F 0 qf
State q0
1
Figure 3 Figure 4 ∧
0+11
q2 q3
Example: Construct the FA equivalent to the RE
(0 + 1)*(00 + 11)(0 + 1)* (c)
q1 0
Solution: (Construction of transition graph): First
we construct the transition graph with ∧-moves 1
then eliminate ∧-moves. 0 qf
q0 0 1
(0 + 1)*(00 + 11)(0 + 1)* 1 ∧
q0 qf q2 q3
(a) q4
1 (d)
(0 + 1)* (00 + 11) (0 + 1)* q1 0
q0 q1 q2 qf 1
(b)
(0 + 1) (0 + 1) 0 qf
q0
(00 + 11) 0 1
∧ ∧ ∧ ∧ 1
q0 q5 q1 q2 q6 qf q2
1 d
(e)
Example: Design a grammar generating the Example: Design a grammar generating the
language L = { wcwR| w ∈ (a, b)+}. language L = { anbncn | n ≥ 1 }.
Solution: (a, b)+ indicates that w contain at Solution: Every string w belonging to the
least one symbol. The example strings are in language begins with a substring containing a
the language L are aca, abcba, bbcbb, aacaa, symbols. This follows a substring of equal
abbcbba, . . . Thus productions P are number of b symbols, which further follows
S ⟶ aSa | bSb | aXa| bXb the substring of same number of c symbols.
X⟶c The example strings in the language L are abc,
Example: Design a grammar generating the aaabbbccc, aabbcc, aaaabbbbcccc, . . . etc. Thus
language L = {anbn | n ≥ 1 }. the productions P are:
S ⟶ aSXc | abc
Solution: Every string contains equal number
cX ⟶ Xc
of a’s and b’s. Every string w in L contains a
bX ⟶ bb
substring of a’s followed by a substring of
equal number of b’s. The example strings in it can be seen that every string in the language
the language L are ab, aabb, aaaabbbb, aaabbb, L has the length 3n.
. . . . Thus productions P are Example: Design a grammar generating the
S ⟶ aSb | ab language L = { ww | w ∈ (a, b)+ }
Example: Design a grammar generating the Solution: we see that each string in the language
language L = { ancmbn | m, n ≥ 1 }. L is of the length 2n (n ≥ 1). The first substring
Solution: every string w belonging to the of length n is the same as that of the subsequent
language begins with a substring containing a substring of length n. The example strings in the
symbols. this follows a substring of c symbols. language L are aa, abab, bbbb, baba, bbabba,
the substring of c’s follows the substring of b babbab, . . . . thus productions P are :
symbols and the number of b’s is the same as S ⟶ XYZ
that of a’s. the example strings in the language XY ⟶ aXA | bXB
are acb, accb, aacccbbb, aaaccbbb, . . . . Thus, AZ ⟶ YaZ
we have the set of productions P as follows: BZ ⟶ YbZ
S ⟶ aSb | aXb Aa ⟶ aA
X⟶ cX | c. Ab ⟶ bA
Ba ⟶ aB
Example: Design a grammar generating the
Bb ⟶ bB
language L = { anbm |m, n ≥ 1 }.
aY ⟶ Ya
Solution: every string w belonging to the bY ⟶ Yb
language begins with a substring containing a
XY ⟶ ∧
symbols. This follows substring of b symbols
Z⟶∧
and the number of b’s are independent of a’s.
Example: Design a grammar for a language of
The example strings in the language L are ab,
all palindromes over {a, b}.
aab, abb, aabbbb, abbb, abbb, etc. Thus the
productions P are: Solution: The basis for our grammar is as
S ⟶ AB follows:
A ⟶ aA | a Note: Final state is also known as Accepting state.
B ⟶ bB | b
An alphabet a or b is a palindrome. If a string x 11. String of even length
is palindrome then the strings axa and bxb are - (aa + ab + ba + bb)*
also palindromes. thus the grammar can be 12. String with odd number of 1’s
designed as follows: - 0* ( 10*10* )* 10*
S ⟶ aSa | bSb | a | b | aa | bb. 13. String of length of 6 or less.
- (∧ + 0 + 1 )6
Example: Design a grammar for a language L 14. Strings ending with 1 and not containing 00
over {a, b} such that each string in L contains - ( 1 + 01 )+
equal number of a’s and b’s. 15. Language of C identifiers.
Solution: The string can start with either a or - ( l + _) ( l + d + _ )*
b. Thus, we have the production 16. Real Literals in Pascal
S ⟶ aX | bY - sd+(pd+ + pd+Esd+ + Esd+ )
17. Strings Containing exactly 2 0’s
Now the design of X should be such that it
- 1*01*01*
inserts one b more than a in the output string.
18. String containing atleast 2 0’s.
Similarly, design of Y should be such that it
- 1* 0 ( 1 + 0 ) * 0 ( 1 + 0 ) *
inserts one a more than b in the output string,
19. Strings that do not end with 01.
Thus, we have
- ∧ + 1 + (0 + 1 )*0 + ( 0 + 1 )*11
X ⟶ b | aXX | bS 20. Strings that begin or end with 00 or 11.
Y ⟶ a | bYY | aS - (00 + 11) (0 + 1 )* + ( 0 + 1 )* ( 00 + 11 )
Questions: Find the regular expression 21. Strings not containing the substring 00
corresponding to following: - ( ∧ + 0 ) ( 1 + 10 )* or ( 1 + 10 )* ( ∧ + 0 )
22. Strings in which the number of 0’s is even
1. a, b ∈ Σ starting from (abb) - 1* ( 01* 01* ) *
- abb ( a + b )* 23. Strings containing no more than one
2. a, b ∈ Σ ending with (baa) occurrence of the string 00.
- ( a + b )* baa - ( 1 + 01 )* ( ∧ + 0 + 00 ) ( 1 + 10 )*
3. a, b ∈ Σ ending with (baa) and starting 24. Strings in which every 0 is followed
with (abb). immediately by 11.
- abb ( a + b )* baa - 1* ( 011+ )*
4. a, b ∈ Σ containing exactly 2a’s 25. { 0, 1, 2}
- b*ab*ab* - 0+1+2
5. a, b ∈ Σ containing atmost 2a’s 26. { 1 2n + 1
|n>0}
- b* + b*ab* + b*ab*ab* - ( 11 )+ 1
6. a, b ∈ Σ containing atleast 2a’s 27. { w ∈ { a, b }* | w has only one a }
- b*a ( a + b)* a (a + b)* - b*ab*
7. a, b ∈ Σ containing abb as substring 28. Set of all strings over { 0, 1} which has
- ( a + b)* abb (a + b )* atmost 2 0’s.
8. String of length 2. - 1+ + 1*01* + 1*01*01*
- (a + b) (a + b) or ( a + b)2 29. { a2, a5, a8, . . . }
9. String of length 6. - (aaa)*aa
- (a+b)(a+b)(a+b)(a+b)(a+b)(a+b) 30. { an | n is divisible by 2 or 3 or n = 5 }
10. String of length 2 or less. - (aa)* + (aaa)* + aaaaa
- (∧+a+b)(∧+a+b) 31. Strings beginning and ending with a.
- a ( a + b )* a 2. Text Editor: smart and speedy text
32. Strings having atmost one pair 0’s or editors can be constructed using FA.
atmost one pair of 1’s. 3. Spell checkers: spell checkers can be
- ( 1 + 01)* + ( 1 + 01)* 00 ( 1 + 10)* + designed using FA. In our computer
( 0 + 10 )* + ( 0 + 10)*11(0 + 01 )* system, we have a dictionary, FA can
33. String in which number of occurrences of recognize the correctness of a word and
a is divisible by 3. can give the appropriate suggestion to the
- ( b* a b* a b* a b*)* users also.
34. String with 3 consecutive 4. Sequential Circuits: FA can also be used
- ( a + b )* bbb ( a + b )* to design sequential circuits.
35. Strings beginning with 00 5. Image Processing.
- 00 ( 0 + 1 )* 6. Natural Language Processing.
36. String ending with 00 and beginning with 1. 7. Internet Browsers: To scan large body of
- 1 ( 0 + 1 )* 00 information.
8. Communication: Designing of protocols
Difference between DFA and NDFA
for exchange of information.
Sr. DFA NDFA 9. Pattern matching.
1. Deterministic Non-Deterministic 10. Forensic Science
Finite Automata Finite Automata 11. Cellular machines uses cellular Automata
2. Every transition is Multiple transition for Limitations of Finite Automaton:
unique and an input on a state are
deterministic in possible, which means FA is most restricted model of automatic
nature. moves are non- machines. It is an abstract model of a computer
deterministic in nature. system. a FA has following limitations:
3. Null-transitions Null-transitions are 1. The memory is limited.
are not allowed allowed. 2. Memory is read-only memory.
4. Requires less Requires more 3. Memory is sequentially accessed.
memory as memory as transition 4. FA has only string recognizing power.
transition diagram diagrams needs more 5. Head movement is restricted in one
needs less number number of states. direction, either from left to right or from
of states.
right to left.
5. Range of Range of transition is 6. Limited Computability mean it can act
transition is δ:Q×Σ⟶2Q like a scanner FA are not computing
δ:Q×Σ⟶Q. devices but these act only as scanner.
6. All DFA’s are All DFA are NDFA. 7. Periodicity: FA cannot remember large
NDFA’s but vice amount of information or strings of large
versa is not true. size.
8. Impossibility of Multiplications: Full
Applications of Finite Automaton. length of multiplier and multiplicand
cannot be stored.
1. Lexical Analyzers: Lexical analysis is a
9. Binary Response: Response of FA is
part of compilation and used to recognize
binary either accepted or rejected after a
the validity of input programs. Whether
long sequence of moves.
the input program is grammatically
constructed or not.

You might also like