You are on page 1of 88

Theory of Computation

Lecture#03-08

1 9/8/2019 Unit-I
Computer ???
 What is a computer?
A computer is a machine that manipulates
data according to a list of instructions.
 What does the computer do?
 Any thing that can be expressed with that list
of instructions.

9/8/2019 Unit-I 2
Computer ??? (Cont.)
 Is there anything that a computer cannot
do?
 The efforts to answer to this question are
started even before the creation of the
computer !!
 The question leads us to the concept of
Automata theory.

9/8/2019 Unit-I 3
Automata theory
 The word “Automata“ is the plural of “automaton"
which simply means any machine.
 automata theory is the study of abstract
machines and problems they are able to solve.
 Automata theory is closely related to formal
language theory as the automata are often
classified by the class of formal languages they
are able to recognize.

9/8/2019 Unit-I 4
Abstract Machine
 An abstract machine, also called an abstract
computer, is a theoretical model of a computer
hardware or software system used in Automata
theory.
 Abstraction of computing processes is used in
both the computer science and computer
engineering disciplines and usually assumes
discrete time paradigm.
 abstract machines are often used in thought
experiments regarding computability or to
analyze the complexity of algorithms

9/8/2019 Unit-I 5
Finite Automata
( or Finite State Machines)

 This is the simplest kind of machine.


 We will study 3 types of Finite
Automata:
 DeterministicFinite Automata (DFA)
 Non-deterministic Finite Automata (NFA)
 Finite Automata with -transitions (-NFA)

6 9/8/2019
Deterministic Finite Automata
(DFA)
We have seen a simple example before:

start off on

There are some states and transitions (edges)


between the states. The edge labels tell when
we can move from one state to another.

7 9/8/2019
Definition of DFA

A DFA is a 5-tuple (Q, , , q0, F) where


Q is a finite set of states
 is a finite input alphabet
 is the transition function mapping Q  
to Q
q0 in Q is the initial state (only one)
F  Q is a set of final states (zero or more)

8 9/8/2019
Definition of DFA
For example:
1

start off on

Q is the set of states: {on, off}


 is the set of input symbols: {1}
 is the transitions: off  1  on; on  1  off
q0 is the initial state: off
F is the set of final states: {on}

9 9/8/2019
Definition of DFA
Another Example:
1 0 0

q1 q2
start q0
1 0

We use double circle to specify a final state.


What are Q, , , q0 and F in this DFA?

10 9/8/2019
Transition Table
We can also use a table to specify the
transitions.
For the previous example, the DFA is (Q,,,q0,F)
where Q = {q0,q1,q2},  = {0,1}, F = {q2} and  is
such that Inputs
States 0 1
q0 q1 q0
q1 q2 q0
q2 q1 q0

Note that there is one transition only for each input


symbol from each state.
11 9/8/2019
DFA Example
Consider the DFA M=(Q,,,q0,F) where Q
= {q0,q1,q2,q3},  = {0,1}, F = {q0} and  is:
Inputs
1
States 0 Start q0 q1
1 1
q0 q2 q1
q1 q3 q0 OR 0 0 0 0
q2 q0 q3 1
q2 q3
q3 q1 q2 1

We can use a transition table or a transition diagram to specify


the transitions. What input can take you to the final state in M?

12 9/8/2019
Language of a DFA
Given a DFA M, the language accepted
(or recognized) by M is the set of all
strings that, starting from the initial
state, will reach one of the final states
after the whole string is read.
For example, the language accepted by
the previous example is the set of all 0
and 1 strings with even number of 0’s
and 1’s.
13 9/8/2019
Class Discussion
0 0
1
Start q0 q1
1

0 1
1
Start q0 q1
0

0 1 0,1

q0 1 q1 0 q2
Start

What are the languages accepted by these DFA?

14 9/8/2019
Class Discussion

Construct a DFA that accepts a


language L over  = {0, 1} such that:
(a) L is the set of all strings which starts with
‘0’
and ends with 1’s.
(b) L is the set of all strings ending with
“101”.
(c) L is the set of all strings containing no
consecutive “1”s nor consecutive “0”s.
15 9/8/2019
“Yields” relation
 Indicates a transition from one configuration
of a DFA to the next configuration, which is
equivalent to one step in a computation
 notation: (q0, abba) |= (q1,bba)
 |=n denotes a transition from one
configuration of a DFA to another after n
steps
 |=* denotes the reflexive, transitive closure of
the relation |=, i.e., it denotes a transition from
one configuration of a DFA to another after
zero or more steps
9/8/2019 Unit-I 16
Extended transition function
 The extended transition function is
represented by:
δ* : Q  *  Q
 The * denotes a string instead of a
single character
 Q will represent the state the automaton
will be in after reading the entire string
instead of a single character

9/8/2019 Unit-I 17
Extended transition function
 Given:
a b c
q q1 q2 q3
0

What is δ* (q0, abc) ?

9/8/2019 Unit-I 18
Extended transition function
Let M = (Q, , q0, , A) be an FA. We can
define the function * : Q   *  Q as
follows:
 For any q  Q, * (q, ) = q
 For any y   * , a  , and q  Q,
* (q, ya) =  (* (q, y) , a)

9/8/2019 Unit-I 19
Computation
 Since a DFA is an abstract model of
computation, we can now define mathematically
what we mean by “computation”
 A computation is a sequence of transitions from
one configuration to another
 A computation proceeds according to a finite set
of rules or instructions -- the transition function
(or program) of the DFA

9/8/2019 Unit-I 20
Finite State Machines with output
 Moore Machine: Output depends on only
current state.

 Mealy Machine : Output depends on current


state as well as on input.

9/8/2019 Unit-I 21
Accepting
Let M = (Q, , q0, , F) be an FA.

 A string w  * is accepted by M if
*(q0, w)  F
 The language accepted (or recognized) by
M is the set of all strings on  that are
accepted by M
 Formally:
L(M) = {w  * : δ* (q0, w)  F}

9/8/2019 Unit-I 22
L = {awa : w  {a,b}*}

a a
q0 q1 q2

b
a,b
q3

This finite accepter accepts all and only the strings of the
language given above. But note that there are two arcs
out of q1 labeled a. How does the FA know which path to
take on an a? It doesn’t; it has to magically guess right.
Also, there are no arcs out of q2. So this FA is
nondeterministic.
9/8/2019 Unit-I 23
L = {awa : w  {a,b}*}
b a

a a
q0 q1 q2
b
b

q3

This finite accepter accepts all and only the strings of the
language given above. This FA is Deterministic.

9/8/2019 Unit-I 24
 The finite control can be described by a transition diagram:
 Example #1:

0
q0 q1 1
0

1 0 0 1 1
q0 q0 q1 q0 q0 q0

 One state is final/accepting, all others are rejecting.


 The above DFA accepts those strings that contain an even
number of 0’s

9/8/2019 Unit-I 25
 Example #2:

a a a/b/c

c c
q0 q1 q2

b b

a c c c b accepted
q0 q0 q1 q2 q2 q2

a a c rejected
q0 q0 q0 q1

 Accepts those strings that contain at least two c’s

9/8/2019 Unit-I 26
 For example #1:
1
Q = {q0, q1}
0
Σ = {0, 1}
q0 q1 1
Start state is q0
F = {q0} 0

δ:
0 1
q0 q1 q0

q1 q0 q1

9/8/2019 Unit-I 27
 For example #2:

a a a/b/c
Q = {q0, q1, q2}
Σ = {a, b, c} c c
q0 q1 q2
Start state is q0
F = {q2} b b

δ: a b c
q0 q0 q0 q1

q1 q1 q1 q2

q2 q2 q2 q2

 Since δ is a function, at each step M has exactly one option.


 It follows that for a given string, there is exactly one
computation.
9/8/2019 Unit-I 28
Extension of δ to Strings

δ^ : (Q x Σ*) –> Q

δ^(q,w) – The state entered after reading string w having started in


state q.

Formally:

1) δ^(q, ε) = q, and
2) For all w in Σ* and a in Σ
δ^(q,wa) = δ (δ^(q,w), a)

9/8/2019 Unit-I 29
 Recall Example #1: 1

0
q0 q1 1
0
 What is δ^(q0, 011)? Informally, it is the state entered by M after
processing 011 having started in state q0.
 Formally:
δ^(q0, 011) = δ (δ^(q0,01), 1)
= δ (δ ( δ(q0,0), 1), 1)
= δ (δ (q1, 1), 1)
= δ (q1, 1)
= q1

 Is 011 accepted? No, since δ^(q0, 011) = q1 is not a final state.

9/8/2019 Unit-I 30
Definitions for DFAs
 Let M = (Q, Σ, δ,q0,F) be a DFA and let w be in Σ*. Then w is
accepted by M iff δ^(q0,w) = p for some state p in F.

 Let M = (Q, Σ, δ,q0,F) be a DFA. Then the language accepted


by M is the set:
L(M) = {w | w is in Σ* and δ^(q0,w) is in F}

 Another equivalent definition:


L(M) = {w | w is in Σ* and w is accepted by M}

 Let L be a language. Then L is a regular language iff there


exists a DFA M such that L = L(M).

 Let M1 = (Q1, Σ1, δ1, q0, F1) and M2 = (Q2, Σ2, δ2, p0, F2) be
DFAs. Then M1 and M2 are equivalent iff L(M1) = L(M2).

9/8/2019 Unit-I 31
 Notes:
 A DFA M = (Q, Σ, δ,q0,F) partitions the set Σ* into two sets: L(M) and
Σ* - L(M).

 If L = L(M) then L is a subset of L(M) and L(M) is a subset of L.

 Similarly, if L(M1) = L(M2) then L(M1) is a subset of L(M2) and L(M2) is a


subset of L(M1).

 Some languages are regular, others are not. For example, if

L1 = {x | x is a string of 0's and 1's containing an even


number of 1's} and

L2 = {x | x = 0n1n for some n >= 0}

then L1 is regular but L2 is not.

 Questions:
 How do we determine whether or not a given language is regular?
 How could a program “simulate” a DFA?

9/8/2019 Unit-I 32
 Give a DFA M such that:

L(M) = {x | x is a string of 0’s and 1’s and |x| >= 2}

0/1

0/1 0/1
q0 q1 q2

9/8/2019 Unit-I 33
 Give a DFA M such that:

L(M) = {x | x is a string of (zero or more) a’s, b’s and c’s


such
that x does not contain the substring aa}

b/c a/b/c
a
a
q0 q1 q2
b/c

9/8/2019 Unit-I 34
 Give a DFA M such that:

L(M) = {x | x is a string of a’s, b’s and c’s such that x


contains the substring aba}

b/c a a/b/c
a a
b
q0 q1 q2 q3
c

b/c

9/8/2019 Unit-I 35
 Give a DFA M such that:

L(M) = {x | x is a string of a’s and b’s such that x


contains both aa and bb}

a
b
a
q1 q2 q3 b
a a/b
a

q0 a b q7
b
b a
b a
q4 q5 q6
b

9/8/2019 Unit-I 36
 Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+.

For {}: For {ε}:


0/1
0/1
0/1
q0 q0 q1

For Σ*: For Σ+:


0/1 0/1

0/1
q0 q0 q1

9/8/2019 Unit-I 37
Non-deterministic FA (NFA)
 For each state, zero, one or more
transitions are allowed on the same input
symbol.
 An input is accepted if there is a path
leading to a final state.
Nondeterministic Finite State
Automata (NFA)
 An NFA is a five-tuple:

M = (Q, Σ, δ, q0, F)

Q A finite set of states


Σ A finite input alphabet
q0 The initial/starting state, q0 is in Q
F A set of final/accepting states, which is a subset of Q
δ A transition function, which is a total function from Q x Σ to 2Q

δ: (Q x Σ) –> 2Q -2Q is the power set of Q, the set of all subsets of Q


δ(q,s) -The set of all states p such that there is a transition
labeled s from q to p

δ(q,s) is a function from Q x S to 2Q (but not to Q)

9/8/2019 Unit-I 39
 Example #1: some 0’s followed by some 1’s

0 1 0/1
Q = {q0, q1, q2}
Σ = {0, 1} 0 1
q0 q1 q2
Start state is q0
F = {q2}

δ: 0 1
q0 {q0, q1} {}

q1 {} {q1, q2}

q2 {q2} {q2}

9/8/2019 Unit-I 40
 Example #2: pair of 0’s or pair of 1’s

0/1 0/1
Q = {q0, q1, q2 , q3 , q4}
Σ = {0, 1} 0 0
q0 q3 q4
Start state is q0
F = {q2, q4} 1 0/1

1
δ: 0 1 q1 q2
q0 {q0, q3} {q0, q1}

q1 {} {q2}

{q2} {q2}
q2

q3 {q4} {}

q4 {q4} {q4}
9/8/2019 Unit-I 41
 Determining if a given NFA (example #2) accepts a given string
(001) can be done algorithmically:

0 0 1
q0 q0 q0 q0

q3 q3 q1

q4 q4 accepted

 Each level will have at most n states

9/8/2019 Unit-I 42
 Another example (010):

q0 0 q0 1 q0 0 q0

q3 q1 q3

not accepted

 All paths have been explored, and none lead to an accepting


state.

9/8/2019 Unit-I 43
An Example of NFA
In this NFA (Q,,,q0,F), Q = {q0,q1,q2},  = {0,1},
F = {q2} and  is:
Start 0
1
q1 Inputs
States 0 1
q0 1 OR q0  {q1,q2}
0 q1 {q1 } {q2 }
1 q2 {q0 } 
q2
Note that each transition can lead to a set of states,
which can be empty.
Language of an NFA
Given an NFA M, the language recognized by M is
the set of all strings that, starting from the initial
state, has at least one path reaching a final state
after the whole string is read.

Consider the previous example:


For input “101”, one path is q0q1q1q2 and
the other one is q0q2q0q1. Since q2 is a
final state, so “101” is accepted. For input “1010”,
none of its paths can reach a final state, so it is
rejected.
More Examples of NFA
a
b
Start q0 q1 q2 b
b

0-9 0-9 0-9

q1 0-9 q4 q6
0-9 . E
0-9
0-9
Start q0 q3 q5 0-9
0-9
+,-
+,-
q2 q7
0-9 0-9
Class Discussion
Consider the language L that consists of
all the strings over  = {0, 1} such that the
third last symbol is a “1”.
(a) Construct a DFA for L.
(b) Construct an NFA for L.

Is NFA more powerful than DFA?


 Let Σ = {a, b, c}. Give an NFA M that accepts:

L = {x | x is in Σ* and x contains ab}

a/b/c a/b/c

a b
q0 q1 q2

Is L a subset of L(M)?
Is L(M) a subset of L?

 Is an NFA necessary? Could a DFA accept L? Try and give an


equivalent DFA as an exercise.
 Designing NFAs is not a typical task.

9/8/2019 Unit-I 48
Nondeterminism

A finite automaton is deterministic if:


from every node there is exactly one arc
labeled for each character in the alphabet of
the language. But in case of Non –
deterministic from every node more that one
transition can take place.

9/8/2019 Unit-I 49
L = {ambn : m, n  0}
a

b a
q0 q1 q2

b a,b

Does this automaton correspond to (represent, accept) the


above language? Is it deterministic?

9/8/2019 Unit-I 50
Some exercises

a b a,b

q0 b q1 a q2

Use set notation to describe the language accepted by


the above DFA

9/8/2019 Unit-I 51
Some exercises

a b a,b

q0 b q1 a q2

L(M) = {anbm}, where n  0 and m  1

9/8/2019 Unit-I 52
Some exercises

A DFA that accepts the formal language


{ab}.
a b
q0 q1 q2

b a a,b

q3

a,b
9/8/2019 Unit-I 53
Some exercises
Use set notation to describe the language
accepted by the following DFA.
b
a b c
c a
b,c a a,b,c

Can you give a DFA that accepts the


complement of this language?

9/8/2019 Unit-I 54
NDFA
Differences between a DFA and an NDFA:
(1) in an NDFA, the range of  is in the powerset of
Q (instead of just Q), so that from the current
state, upon reading a symbol:
(a) more than one state might be the next state
of the NDFA, or
(b) no state may be defined as the next state of
the NDFA, and
(2) -moves are possible; that is, a transition from
one state to another may occur without reading
a symbol from the input string.
9/8/2019 Unit-I 55
NDFA = DFA
One kind of automaton is more powerful
than another if it can accept and reject
some kinds of languages that the other
cannot.
Two finite accepters are equivalent if both
accept the same language, that is,
L(M1) = L(M2)
As mentioned previously, we can always find
an equivalent DFA for any given NDFA.
Therefore, NDFA’s are no more powerful
than DFA’s.
9/8/2019 Unit-I 56
DFA and NFA
Is NFA more powerful than DFA?
NO! NFA is equivalent to DFA.

Trivial
DFA NFA

Constructive
Proof
Constructing DFA from NFA
Given any NFA M=(Q,,,q0,F) recognizing a
language L over , we can construct a DFA
N=(Q’, ,’,q0’,F’) which also recognizes L:
• Q’ = set of all subsets of Q
e.g., if Q = {q0, q1}, Q’ = {{}, {q0}, {q1}, {q0, q1}}
• q0’ = {q0}
• F’ = set of all states in Q’ containing a final state
of M
• ’({q1a,q 2, …
state
q }, a) = (q1,a) a(q
in N i
,a) ...  (qi,a)
state2 in M
NDFA  DFA

Example: Convert the following NDFA into an equivalent DFA


(Figure 2.12 in Linz.).

9/8/2019 Unit-I 59
NDFA  DFA

1. Create a graph GD with vertex {q0}. Identify this


vertex as the initial vertex.
OK; here it is:

{q0}

9/8/2019 Unit-I 60
NDFA  DFA

1. Repeat the following steps until no more edges are


missing:
a. Take any vertex {qi, qj, …, qk} of GD that has no
outgoing edge for some a  .
OK. Vertex q0 in our new DFA has no outgoing
edge for a yet.
b. Compute δ* (qi, a), δ* (qj, a), …, δ* (qk, a).
OK. From q0 in our NDFA, upon reading an a the
extended transition function leaves us in state
q1, or q2 via a “free” lambda-move.
9/8/2019 Unit-I 61
NDFA  DFA

c. Then form the union of all these δ*, yielding the set
{ql, qm, …, qn}.
So our new DFA will have a state labeled {q1, q2}.
d. Create a vertex for GD labeled {ql, qm, …, qn} if it
does not already exist.
So create a vertex for our new DFA and label it {q1,
q2}.
e. Add to GD an edge from {qi, qj, …, qk} to {ql, qm, …,
qn} and label it with a.
So add a transition labeled a to {q1, q2} from q0.
9/8/2019 Unit-I 62
NDFA  DFA
So now we have:

{q0} {q1, q2}

9/8/2019 Unit-I 63
NDFA  DFA

1. Repeat the following steps until no more edges are


missing:
a. Take any vertex {qi, qj, …, qk} of GD that has no
outgoing edge for some a  .
OK. Vertex q0 in our new DFA has no outgoing edge
for b yet.
b. Compute δ* (qi, b), δ* (qj, b), …, δ* (qk, b).
Well, there is no transition specified in our NDFA
from state q0 upon reading a b. Therefore, δ*
({q0}, b) = .
9/8/2019 Unit-I 64
NDFA  DFA

c. Then form the union of all these δ*, yielding the set
{ql, qm, …, qn}.
So our new DFA will have a state labeled .
d. Create a vertex for GD labeled {ql, qm, …, qn} if it
does not already exist.
So create a vertex for our new DFA and label it .
e. Add to GD an edge from {qi, qj, …, qk} to {ql, qm, …,
qn} and label it with a.
So add a transition labeled b to  from q0.
9/8/2019 Unit-I 65
NDFA  DFA
So now we have:

{q0} {q1, q2}

b a

 Any state labeled  represents an


impossible move and thus is a non-
final trap state.
a, b

9/8/2019 Unit-I 66
NDFA  DFA

1. Repeat the following steps until no more edges are


missing:
a. Take any vertex {qi, qj, …, qk} of GD that has no
outgoing edge for some a  .
OK. Vertex {q1, q2} in our new DFA has no outgoing
edge for a yet.
b. Compute δ* (qi, b), δ* (qj, b), …, δ* (qk, b).
OK. From q1 in our NDFA, upon reading an a the
extended transition function leaves us in state
q1, or q2 via a “free” lambda-move. From q2 in our
NDFA, upon reading an a there is no specified
9/8/2019 Unit-I 67
NDFA  DFA

c. Then form the union of all these δ*, yielding the set
{ql, qm, …, qn}.
The union is {q1, q2} .
d. Create a vertex for GD labeled {ql, qm, …, qn} if it
does not already exist.
It does.
e. Add to GD an edge from {qi, qj, …, qk} to {ql, qm, …,
qn} and label it with a.
So add a transition labeled a to {q1, q2} from {q1, q2}
.
9/8/2019 Unit-I 68
NDFA  DFA
So now we have:
a

{q0} {q1, q2}

b a

a, b

9/8/2019 Unit-I 69
NDFA  DFA

1. Repeat the following steps until no more edges are


missing:
a. Take any vertex {qi, qj, …, qk} of GD that has no
outgoing edge for some a  .
OK. Vertex {q1, q2} in our new DFA has no outgoing
edge for b yet.
b. Compute δ* (qi, b), δ* (qj, b), …, δ* (qk, b).
OK. From q2 in our NDFA, upon reading a b the
extended transition function leaves us in state
q0. From q1 in our NDFA, upon reading a b there
is no specified transition. However, we can
9/8/2019 Unit-I 70
NDFA  DFA

c. Then form the union of all these δ*, yielding the set
{ql, qm, …, qn}.
The union is {q1, q2} .
d. Create a vertex for GD labeled {ql, qm, …, qn} if it
does not already exist.
It does.
e. Add to GD an edge from {qi, qj, …, qk} to {ql, qm, …,
qn} and label it with a.
So add a transition labeled b to q0 from {q1, q2} .
9/8/2019 Unit-I 71
NDFA  DFA

2. Exit from loop.


3. Every state of GD whose label contains and qf  FN is
identified as a final vertex.
OK. State q1 in the NDFA is a final state, so state {q1,
q2} in the DFA will be a final state.

2. If MN accepts , the vertex q0 in GD is also made a final


vertex.

9/8/2019 Unit-I 72
NDFA  DFA
Here is the finished DFA (Figure 2.13 in Linz):

9/8/2019 Unit-I 73
An Example of NFA  DFA
Consider a simple NFA:
0 1
0
Start q0 1 q1
1

Construct a corresponding DFA:


1
Start {q0} {q1}
1
0 0

{q0, q1} {}
1,0 1,0
NDFA  DFA
Example: Convert this NDFA to a DFA.

9/8/2019 Unit-I 75
NDFA  DFA
Example:

9/8/2019 Unit-I 76
NDFA  DFA
Example:

9/8/2019 Unit-I 77
Minimal DFA’s
Two states p and q of a DFA are called
indistinguishable if
* (p, w)  F implies * (q, w)  F ,
and
* (p, w)  F implies * (q, w)  F ,
for all w  *.
If there exists some string w  * such that
* (p, w)  F
and
* (q, w)  F
or vice versa, then the states p and q are said to be
distinguishable by string w.
9/8/2019 Unit-I 78
The “Mark” procedure
This procedure marks all pairs of distinguishable
states.
1. Remove all inaccessible states.
2. Consider all pairs of states (p, q). If p  F and q 
F or vice versa, mark the pair (p, q) as
distinguishable.
3. Repeat the following step until no previously
unmarked pairs are marked:
For all pairs (p, q) and all a  , compute  (p,
a) = pa and  (q, a) = qa. If the pair (pa, qa) is marked
as distinguishable, mark (p,
9/8/2019 Unit-I
q) as distinguishable. 79
The “Reduce” procedure
Given a DFA M = (Q, , , q0, F), we construct a
reduced DFA M’ = (Q’, , ’, q0’, F’) as follows:
1. Use procedure Mark to find all pairs of
distinguishable states. Then from this find the sets
of indistinguishable states by partitioning the state
set Q of the DFA into disjoint subsets {qi, qj, …, qk},
{ql, qm, …, qn}, …, such that any q  Q occurs in
exactly one of these subsets, that elements in each
subset are indistinguishable, and that any two
elements from different subsets are distinguishable.

9/8/2019 Unit-I 80
The “Reduce” procedure, cont.
2. For each set {qi, qj, …, qk} of such
indistinguishable states, create a state labeled ij…k
for M.
3. For each transition rule of the form  (qr, a) = qp,
find the sets to which qr and qp belong. If qr  {qi, qj,
…, qk} and qp  {ql, qm, …, qn}, add to ’ a rule ’
(ij…k, a) = lm…n.
4. The initial state q0’ is that state of M’ whose label
includes the 0.
5. F’ is the set of all the states whose label contains
i such that qi  F.
9/8/2019 Unit-I 81
Theorem 2.4

Given any DFA M, application of the procedure


Reduce yields another DFA M’ such that
L(M) = L(M’)
Furthermore, M’ is minimal in the sense that there is
no other DFA with a smaller number of states which
also accepts L(M).

9/8/2019 Unit-I 82
Minimal DFA’s
Example: This DFA can be reduced to the DFA on the next
slide.

9/8/2019 Unit-I 83
Minimal DFA’s

What are the distinguishable pairs?


Mark step 2 gives (q0, q4), (q1, q4), (q2, q4) and (q3, q4).
Step 3 computes (q1, 1) = q4 and (q0, 1) = q3. Since (q3, q4)
is a distinguishable pair, (q0, q1) is also marked as a
distinguishable pair. Eventually the pairs (q0, q1), (q0, q2),
(q0, q3), (q0, q4), (q1, q4), (q2, q4) and (q3, q4) are marked as
distinguishable.
The remaining pairs, (q1, q2), (q1, q3), and (q2, q3) are
undistinguishable.
The states are partitioned into the sets {q0}, {q1, q2, q3}, and
{q4}.
9/8/2019 Unit-I 84
Minimal DFA’s
This is the reduced DFA resulting from the procedure.

9/8/2019 Unit-I 85
Minimum number of states in an
FA
If there are n distinguishable strings in a
language, then there must be at least n
states in the finite automata that accepts it.
The FA has no memory, other than the current
state.
This puts a lower bound on the number of
states in a FA recognizing a language.

9/8/2019 Unit-I 86
For
 Equivalence of DFA and NFA, refer page
no 33
 FA’s with ε-transitions, refer page no. 43
 Equivalence and minimization of DFA,
refer page no. 118
 All from Lecture Notes#01

9/8/2019 Unit-I 87
THANK YOU

88 9/8/2019 Unit-I

You might also like