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

Cse303 Elements of The Theory of Computation: Professor Anita Wasilewska

This document provides an overview of deterministic finite automata (DFA) including: 1. The components and operation of a DFA model including the input string, finite control states, reading head, transition function, initial and final states. 2. The formal definition of a DFA as a 5-tuple (K, Σ, δ, s, F) where K is states, Σ is the alphabet, δ is the transition function, s is the initial state, and F are the final states. 3. How a DFA accepts or rejects strings based on whether there is a computation path from the initial to a final state with the entire input string read.

Uploaded by

Anonymous G0oZQa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Cse303 Elements of The Theory of Computation: Professor Anita Wasilewska

This document provides an overview of deterministic finite automata (DFA) including: 1. The components and operation of a DFA model including the input string, finite control states, reading head, transition function, initial and final states. 2. The formal definition of a DFA as a 5-tuple (K, Σ, δ, s, F) where K is states, Σ is the alphabet, δ is the transition function, s is the initial state, and F are the final states. 3. How a DFA accepts or rejects strings based on whether there is a computation path from the initial to a final state with the entire input string read.

Uploaded by

Anonymous G0oZQa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 91

cse303

ELEMENTS OF THE THEORY OF


COMPUTATION
Professor Anita Wasilewska

LECTURE 5

CHAPTER 2
FINITE AUTOMATA
1. Deterministic Finite Automata DFA
2. Nondeterministic Finite Automata NDFA
3. Finite Automata and Regular Expressions
4. Languages that are Not Regular
5. State Minimization
6. Algorithmic Aspects of Finite Automata

CHAPTER 2
PART 1: Deterministic Finite Automata DFA

Deterministic Finite Automata DFA


Simple Computational Model
Here is a picture

Here are the components of the model


C1: Input string on an input tape written at the beginning of
the tape
The input tape is divided into squares, with one symbol
inscribed in each tape square

DFA - A Simple Computational Model


Here is a picture

C2: Black Box - called Finite Control


It can be in any specific time in one of the finite number of
states {q1 , . . . , qn }
C3: a movable reading head
It can sense what symbol is written in any position on the
input tape and moves only one square to the right

DFA - A Simple Computational Model


Here are the assumptions for the model
A1: There is no output at all;
A2: DFA indicates whether the input is acceptable or not
acceptable
A3:

DFA is a language recognition device

DFA - A Simple Computational Model


Operation of DFA
O1 Initially the reading head is placed at left most square
at the beginning of the tape and
O2

finite control is set on the initial state

O3 After reading on the input symbol the reading head


moves one square to the right and enters a new state
O4

The process is repeated

O5 The process ends when the reading head reaches the


end of the tape

DFA - A Simple Computational Model


The general rules of the operation of DFA are
R1 At regular intervals DFA reads only one symbol at the
time from the input tape and enters a new state
R2: The move of DFA depends only on the current state
and the symbol just read

DFA - A Simple Computational Model

Operation of DFA
O6 When the process stops the DFA indicates its approval
or disapproval of the string by means of the final state
O7 If the process stops while being in the final state, the
string is accepted
O8 If the process stops while not being in the final state,
the string is not accepted

Language Accepted by DFA


Informal Definition
Language accepted by a Deterministic Finite Automata is
equal to the set of strings accepted by it

DFA - Mathematical Model


To build a mathematical model for DFA we need to include
and define the following components
FINITE set of STATES
ALPHABET
INITIAL state
FINAL state
Description of the MOVE of the reading head that follows
R1 At regular intervals DFA reads only one symbol at the
time from the input tape and enters a new state
R2: The move of DFA depends only on the current state and
the symbol just read

DFA - Mathematical Model


Definition
A Deterministic Finite Automata is a quintuple
M = (K , , , s , F )
where
K is a finite set of states

as an alphabet
s K is the initial state
F K is the set of final states
is a function
: K K
called the transition function
We usually use different symbols for K , , i.e. we have that
K =

DFA Definition
Definition revisited
A Deterministic Finite Automata is a quintuple
M = (K , , , s , F )
where
K is a finite set of states
K , because s K
as an alphabet
can be - case to consider
s K is the initial state
F K is the set of final states
F can be - case to consider
is a function
: K K
called the transition function

Transition Function
Given DFA
M = (K , , , s , F )
where

: K K
Let

(q, ) = q0 for q, q0 K ,
means: the automaton M in the state q reads and
moves to a state q0 K , which is uniquely determined by
state q and just read

Configuration
In order to define a notion of computation of M on an input
string w we introduce first a notion of a configuration
Definition
A configuration is any tuple

(q, w ) K
where q K represents a current state of M and w is
unread part of the input
Picture

Transition Relation
Definition
The set of all possible configurations of M = (K , , , s , F )
is just
K = {(q, w ) : q K , w }
We define move of an automaton M i in terms of a transition
relation

`M
The transition relation acts between two configurations
and hence `M is a certain binary relation defined on
K , i.e.
`M (K )2
Formal definition follows

Transition Relation
Definition
Given M = (K , , , s , F )
A binary relation

`M (K )2
is called a transition relation when for any
q, q0 K , w1 , w2 the following holds

(q, w1 ) `M (q0 , w2 )
if and only if
1. w1 = w2 , for some (M looks at )
2. (q, ) = q0 (M moves from q to q reading in w1 )

Transition Relation
Definition Transition relation short definition
Given M = (K , , , s , F )
For any q, q0 K ,

, w
(q, w ) `M (q0 , w )
if and only if

(q, ) = q0

Idea of Computation
We use the transition relation to define a move of M along a
given input, i.e. a given w
Such a move is called a computation
Example
Given M such that K = {s , q} and let `M be a transition
relation such that

(s , aab )`M (q, ab )`M (s , b )`M (q, e )


We call a sequence of configurations

(s , aab ), (q, ab ), (s , b ), (q, e )


a computation from (s , aab ) to (q, e ) in automaton M

Idea of Computation
Given a a computaion

(s , aab ), (q, ab ), (s , b ), (q, e )


We write this computation in a more general form as

(q1 , aab ), (q2 , ab ), (q3 , b ), (q4 , e )


for q1 , q2 , q3 , q4 being a specific sequence of states from
K = {s , q}, namely q1 = s , q2 =, q3 = s , q4 = q and say
that the length of this computation is 4
In general we write any computation of length 4 as

(q1 , w1 ), (q2 , w2 ), (q3 , w3 ), (q4 , w4 )


for any sequence q1 , q2 , q3 , q4 of states from K and words
wi

Idea of the Computation


Example
Given M and the computation

(s , aab ), (q, ab ), (sb ), (q, e )


We say that the word w= aab is accepted by M if and only if
1. the computation starts when M is in the initial state true here as s denotes the initial state
2. the whole word w has been read, i.e. the last configuration
of the computation is (q, e ) for certain state in K, true as
K = {s , q}
3. the computation ends when M is in the final state - true
only if we have that q F
Otherwise the word w is not accepted by M

Definition of the Computation


Definition
Given M = (K , , , s , F )
A sequence of configurations

(q1 , w1 ), (q2 , w2 ), . . . , (qn , wn ),

n1

is a computation of the length n in M from (q, w ) to (q0 , w 0 )


if and only if

(q1 , w1 ) = (q, w ),

(qn , wn ) = (q0 , w 0 ) and

(qi , wi ) `M (qi +1 , wi +1 )

for

i = 1, 2, . . . n 1

Observe that when n = 1 the computation (q1 , w1 ) always


exists and is called a computation of the length one called
also a trivial computation
We also write sometimes the computations as
(q1 , w1 ) `M (q2 , w2 ) `M . . . `M (qn , wn ) for n 1

Words Accepted by M
Definition
A word w is accepted by M = (K , , , s , F )
if and only if there is computation

(q1 , w1 ), (q2 , w2 ), . . . , (qn , wn )


such that q1 = s , w1 = w , wn = e and qn = q F
We re-write it as
A word w is accepted by M = (K , , , s , F )
if and only if there is computation

(s , w ), (q2 , w2 ), . . . , (q, e )

and q F

When the computation is such that q < F we say that w is


not accepted (rejected) by M

Words Accepted by M
In Plain Words:
A word w is accepted by M = (K , , , s , F )
if and only if
there is a computation such that
1. starts with the word w and M in the initial state ,
2. ends when M is in a final state, and
3. the whole word w has been read

Language Accepted by M
Definition
We define the language accepted by M as follows
L (M ) = {w :

w is accepted by M }

i.e.
L (M ) = {w : (s , w ) `M . . . `M (q, e ) for some q F }

Examples
Example 1
Let M = (K , , , s , F )
where
K = {q0 , q1 },

= {a , b },

s = q0 ,

F = {q0 }

and the transition function : K K is defined as


follows

Question Determine whether ababb L (M ) or


ababb < L (M )

Examples
Solution
We must evaluate computation that starts with the
configuration (q0 , ababb ) as q0 = s

(q0 , ababb ) `M
(q0 , babb ) `M
(q1 , abb ) `M
(q1 , bb ) `M

use (q0 , a ) = q0
use (q0 , b ) = q1
use (q1 , a ) = q1

use (q1 , b ) = q0

(q0 , b ) `M

use (q0 , b ) = q1

(q1 , e ) `M

end of computation and q1 < F = {q0 }

We proved that ababb < L (M )


Observe that we always get unique computations, as is a
function, hence he name Deterministic Finite Automaton
(DFA)

Examples
Example 2
Let M1 = (K , , , s , F ) for all components defined as in
M from Example 1, except that we take now F = {q0 , q1 }
We remind that

Exercise Show that now ababb L (M1 )

Language Accepted by M Revisited


We have defined the language accepted by M as
L (M ) = {w : (s , w ) `M . . . `M (q, e ) for some q F }
The question is now- how to write it in a more concise and
elegant way
Answer: use the notion (Chapter 1, Lecture 3) of reflexive,
transitive closure of `M denoted by `M and now we write
Definition
L (M ) = {w : (s , w ) `M (q, e ) for some q F }
We write it also using the existential quantifier symbol as
L (M ) = {w : qF ((s , w ) `M (q, e ))

Language Accepted by M Revisited

Definition
L (M ) = {w : (s , w ) `M (q, e ) for some q F }
We now bring back the general notion of a path in a binary
relation R (Lecture 2) and its reflexive, transitive closure R
(Lecture 3)
It follows directly from these definitions that `M is just a
shorthand notation for the computation

(s , w ), (q2 , w2 ), . . . , (qn , e )

and qn = q F, i.e. that

L (M ) = {w : (s , w ) `M . . . `M (q, e ) for some q F }


Hence the book definition represents just a more concise and
elegant way of expressing the same language

Definitions: Path in R and of R


Definition:

Path in R

A path in the binary relation R is a finite sequence


a1 , . . . , an , such that (ai , ai +1 ) R, for i = 1, 2, . . . n 1
and n 1
The path a1 , . . . , an is said to be from a1 to an
Observe that the path a1 (case when n = 1) always exist
and is called a trivial path from a1 to a1
Definition:

Let R be a binary relation on a set A


The reflexive, transitive closure of R is the relation
R = {(a , b ) A A :

there is a path from a to b in R}

Example
Example
Let M = (K , , , s , F ) be automaton from our Example
1, i.e. we have
K = {q0 , q1 },

= {a , b },

s = q0 ,

F = {q0 }

and the transition function : K K is defined as


follows

Question Show that aabba L (M )

Example
We evaluate

(q0 , aabba ) `M (q0 , abba ) `M (q0 , bba ) `M


(q1 , ba ) `M (q0 , a ) `M (q0 , e ) and q0 = s , q0 F = {q0 }
This proves that

(s , aabba ) `M (q0 , e ) for q0 F


as we have the following path (computation) in M

(s , aabba ), (q0 , abba ), (q0 , bba ), (q1 , ba ), (q0 , a ), (q0 , e ) and q0 F


By definition
aabba L (M )

General remark
To define or to give an example of
M = (K , , , s , F )
means that one has to specify all its components
K , , , s , F
We usually use different symbols for K , , i.e. we have that
K =
Exercise
Given = {a , b } and K == {q0 , q1 }
1. Define 3 automata M
2. Define an automaton M, such that L (M ) =
3. How many automata M can one define?

Exercise
1. Here are 3 automata M1 M3
M1 : M1 = ( K = {q0 , q1 }, = {a , b }, , s = q0 , F = {q0 })

(q0 , a ) = q0 , (q0 , b ) = q0 , (q1 , a ) = q0 , (q1 , b ) = q0


M2 : M2 = ( K = {q0 , q1 }, = {a , b }, , s = q0 , F = {q1 })

(q0 , a ) = q0 , (q0 , b ) = q0 , (q1 , a ) = q0 , (q1 , b ) = q1


M3 : M3 = ( K = {q0 , q1 }, = {a , b }, , s = q0 , F = {q1 })

(q0 , a ) = q0 , (q0 , b ) = q1 , (q1 , a ) = q1 , (q1 , b ) = q0

Exercise
2. Define an automaton M, such that L (M ) =
Answer: The automata M2 is such that L (M2 ) = as there
is no computation that would start at initial state q0 and
end in the final state q1 as in M2 we have that
(q0 , a ) = q0 , (q0 , b ) = q0 , so we will never reach the final
state q1
Here is another example:
Let M4 be defined as follows
M4 = ( K = {q0 , q1 }, = {a , b }, , s = q0 , F = )

(q0 , a ) = q0 , (q0 , b ) = q0 , (q1 , a ) = q0 , (q1 , b ) = q0


L (M4 ) = as there is no computation that would start at
initial state q0 and end in the final state as there is no final
state

Exercise
3. How many automata M can one define?
Observe that all of M must have = {a , b } and
K == {q0 , q1 } so they differ on the choices of
: K K
By Counting Functions Theorem we have 24 possible
choices for
They also can differ on the choices of final states F
There as many choices for final states as subsets of
K == {q0 , q1 }, i.e. 22 = 4
Additionally we have to count all combinations of choices of
with choices of F

Challenge
1. Define an automata M with , such that L (M ) =
2. Define an automata M with , such that L (M ) =
3. Define an automata M with = such that L (M ) ,
4. Define an automata M with , such that L (M ) =
5. Prove that there always exist an automata M such that
L (M ) =

DFA State Diagram


As we could see the transition functions can be defined in
many ways but it is difficult to decipher the workings of the
automata they define from their mathematical definition
We usually use a much more clear graphical representation of
the transition functions that is called a state diagram
Definition
The state diagram is a directed graph, with certain additional
information as shown at the picture on next slide

DFA State Diagram


PICTURE 1

States are represented by the nodes


Initial state is shown by a >
Final states are indicated by a dot in a circle

Initial state that is also a final state is pictured as >

DFA State Diagram


PICTURE 2

States are represented by the nodes


There is an arrow labelled a from node q1 to q2 whenever
(q1 , a ) = q2

A Simple Problem
Problem
Given M = (K , , , s , F )
diagram

described by the following

1. List all components of M


2. Describe L (M ) as a regular expression

A Simple Problem
Given the diagram

Components are: M = (K , , , s , F )
= {a , b }, K = {q0 , q1 , q2 },

for

s = q0 , F = {q0 , q1 } and the transition function is given


by following table

A Simple Problem
2. Describe L (M ) as a regular expression, where
L (M ) = {w : (s , w ) `M (q, e ) for q F }
Lets look again at the diagram of M

Observe that the state q2 does not influence the language


L(M ). We call such state a trap state and say:
The state q2 is a trap state
We read from the diagram that
L (M ) = a (a b ) e as a regular expression
L (M ) = {a } {a , b } {e } as a set

DFA Theorem
DFA Theorem
For any DFA M = (K , , , s , F ),
e L (M )

if and only if

sF

where we defined L (M ) as follows


L (M ) = {w : (s , w ) `M (q, e ) for some q F }
Proof
Let e L (M ), then by definition (s , e ) `M (q, e ) and q F
This is possible only when the computation is of the length
one (case n = 1), i.e when it is (s , e ) and s = q, hence s F
Suppose now that s F
We know that `M is reflexive, so (s , e ) `M (s , e ) and as
s F, we get e L (M )

Definition of TRAP States of M


Definition
A trap state of a DFA automaton M is any of its states that
does not influence the language L(M ) of M
Example

L (M ) = b written in shorthand notation, L (M ) = {b }, or


L (M ) = L(b ) = {b }
States q2 , q3 are trap states

TRAP States of M
Given a diagram of M

The state q2 is the trap state and we can write a short


diagram of M as follows

Remember that if you use the short diagram you must add
statement: plus trap states

Short and Pattern Diagrams of M


Definition
A diagram of M with some or all of its trap states removed is
called a short diagram
Our M becomes

We can shorten the diagram even more by removing the


names of the states

Such diagram, with names of the states removed is called a


pattern diagram

Pattern Diagrams
Pattern Diagrams are very useful when we want to read
the language M directly out of the diagram
Lets look at M1 given by a diagram

It is obvious that (we write a shorthand notion!)


L (M1 ) = (a b ) =
Remark that the regular expression that defines the
language L (M1 ) is = (a b )
We add the description L (M1 ) = as yet another useful
informal shorthand notation notation

Pattern Diagrams
The pattern diagram for our M is

It is obvious that (we write a shorthand notion!) - must add:


plus trap states
L (M ) = aL (M1 ) e
We must add e to the language by DFA Theorem, as we have
that s F
Finally we obtain the following regular expression that defines
the language and write it as
L (M ) = a (a b ) e
We can also write L(M ) in an informal way ( is not a
regular expression) as

Trap States
Why do we need trap states?
Lets take = {a , b } and let M be defined by a diagram

Obviously, the diagram means that M is such that its language


is L (M ) = aa
But by definition, : K K and we get from the
diagram

We must complete definition of by making it a function


(still preserving the language)
To do so introduce a new state q2 and make it a trap state by
defining (q0 , b ) = q2 , (q1 , b ) = q2

Short Problems
For all short problems presented here (and given on Quizzes
and Tests) you have to do the following
1. Decide and explain whether the diagram represents a
DFA or does not
2. List all components of M when it represents DFA
3. Describe L (M ) as a regular expression when it
represents DFA

Short Problems
Consider a diagram M1

1. Yes, it represents a DFA; is a function on {q0 , q1 } {a }


and initial state s = q0 exists
2. K = {q0 , q1 }, = {a }, s = q0 , F = {q1 },

(q0 , a ) = q1 , (q1 , a ) = q1
3. L (M1) = aa

Short Problems
Consider a diagram M2

1. Yes, it represents a DFA; is a function on {q0 } {a } and


initial state s = q0 exists
2. K = {q0 }, = {a }, s = q0 , F = , (q0 , a ) = q0
3. L (M2) =

Short Problems
Consider a diagram M3

1. Yes, it represents a DFA; initial state s = q0 exists


2. K = {q0 }, = , s = q0 , F = , =
3. L (M3) =

Short Problems
Consider a diagram M4

1. Yes, it represents a DFA; initial state s = q0 exists


2. K = {q0 }, = {a }, s = q0 , F = {q0 }, (q0 , a ) = q0
3. L (M4) = a
Remark e L (M4) by DFA Theorem, as s = q0 F = {q0 }

Short Problems
Consider a diagram M5

1. NO! it is NOT DFA - initial state does not exist

Short Problems
Consider a diagram M6

1. NO! Initial state does exist, but is not a function; (q0 , b )


is not defined and we didnt say plus trap states

Short Problems
Consider a diagram M7

1. Yes! it is DFA
Initial state exists and we can complete definition of by
adding a trap state as pictured below

Short Problems
Consider a diagram M8

1. Yes! Initial state exists and it is a short diagram of a DFA


We make a function by adding a trap state q2

3. L (M8) = aa
We chose to add one trap state but it is possible to add as
many as one wishes
Observe that L (M8) = L (M1) and M1, M8 are defined for
different alphabets

Two Problems
P1 Let = {a1 , a2 , . . . , a1025 , . . . , a2105 }
Draw a state diagram of M such that L (M ) = a1025( a1025 )
P2
1. Draw a state diagram of transition function given by
the table below
2. Give an example and automaton M with with this

3.

Describe the language of M

P1 Solution
P1

Let = {a1 , a2 , . . . , a1025 , . . . , a2105 }

Draw a state diagram of M such that L (M ) = a1025 (a1025 )


Solution

PLUS a LOT of trap states!

has 2105 elements; we need a trap state for each of them


except a1025

P1 Solution
Observe that we have a following
pattern for any

L (M ) = +

for any

PLUS a LOT of trap states! except for the case when

= {}

P2 Solutions
P2
1. Draw a state diagram of transition function given by
the table below
2.

Give an example and automaton M with with this

Here is the example of M from our book, page 59

L (M ) = {w {a , b } : w does not contain three consecutive b 0 s }

P2 Solution
Observe that the book example is only one of many possible
examples of automata we can define based on with the
following
State diagram:

Two more examples follow


Please invent some more of your own!

P2 Examples
Example 1
Here is a full diagram of M1

L (M ) = (a b ) =
Observe that e L (M1) by the DFA Theorem and the states
q0 , q1 , q2 are trap states

P2 Examples
Example 2
Here is a full diagram of M1 from Example 1

L (M ) = (a b ) =
Observe that we can make all, or any of the states q0 , q1 , q2
as final states and they will still will remain the trap states
Definition
A trap state of a DFA automaton M is any of its states that
does not influence the language L(M ) of M

P2 Examples
Example 3
Here is a full diagram of M2

L (M ) =
Observe that F = and hence here is no computation that
would finish in a final state

More Problems
P3

Construct a DFA M such that


L (M ) = {w {a , b } : w has abab as a substring }

Problems Solutions
P3

Construct a DFA M such that


L (M ) = {w {a , b } : w has abab as a substring }

Solution The essential part of the diagram must produce


abab and it can be surrounded by proper elements on both
sides and can be repeated
Here is the essential part of the diagram

Problems Solutions
We complete the essential part following the fact that it can be
surrounded by proper elements on both sides and can be
repeated
Here is the diagram of M

Observe that this is a pattern diagram; you need to add


names of states only if you want to list all components
M does not have trap states

More Problems
P4

Construct a DFA M such that

L (M ) = {w {a , b } : every substring of length 4 in word w


contains at least one b }

More Problems
P4

Construct a DFA M such that

L (M ) = {w {a , b } : every substring of length 4 in word w


contains at least one b }
Solution Here is a short pattern diagram (the trap states
are not included)

More Problems
P5

Construct a DFA M such that


L (M ) = {w {a , b } : every word w contains
an even number of sub-strings ba }

More Problems
P5

Construct a DFA M such that


L (M ) = {w {a , b } : every word w contains
an even number of sub-strings ba }

Solution

Here is a pattern diagram

Zero is an even number so we must have that e L (M ), i.e.


we have to make the initial state also a final state

More Problems
P6

Construct a DFA M such that


L (M ) = {w {a , b } : each a in w is
immediately preceded and immediately followed by b }

More Problems
P6

Construct a DFA M such that


L (M ) = {w {a , b } : each a in w is
immediately preceded and immediately followed by b }

Solution: Here is a short pattern diagram - and we need


to say: plus trap states )

It is a short diagram because we omitted needed trap states


(can be more then one, but one is sufficient)
Complete the diagram as an exercise

More Problems
P7

Here is a DFA M defined by the following diagram

Describe L (M ) as a regular expression

More Problems
P7

Here is a DFA M defined by the following diagram

Describe L (M ) as a regular expression


Solution
L (M ) = a (a ba ba )
Observe that e L (M ) by the DFA Theorem

Short Problems
SP1

Given an automaton M1

M1 = ( K = {q0 , q1 }, = {a , b }, , s = q0 , F = )

(q0 , a ) = q0 , (q0 , b ) = q0 , (q1 , a ) = q0 , (q1 , b ) = q0


1.

Draw its state diagram

2.

List trap states, if any

3. Describe L(M1)

SP1 Solution
SP1
1.

Here is the state diagram

2.

q1 is a trap state - M1 never gets there

3.

L (M1) =

Short Problems
SP2

Given an automaton M2

M2 = ( K = {q0 , q1 }, = {a , b }, , s = q0 , F = {q1 })

(q0 , a ) = q0 , (q0 , b ) = q0 , (q1 , a ) = q0 , (q1 , b ) = q1


1.

Draw its state diagram

2.

List trap states, if any

3.

Describe L(M2)

SP2 Solution
SP2
1.

Here is the state diagram

2. q1 is a trap state - it does not influence the language of


M1
3.

L (M2) =

Short Problems
SP3

Given an automaton M3

M3 = (K = {q0 , q1 }, = {a , b }, , s = q0 , F = {q1 })

(q0 , a ) = q0 , (q0 , b ) = q1 , (q1 , a ) = q1 , (q1 , b ) = q0


1.

Draw its state diagram

2.

List trap states, if any

3.

Describe L(M3)

SP3 Solution
SP3
1.

Here is the state diagram

2.

There are no trap states

3.

L (M3) = a b a ba (a ba ba b )
L (M3) = a ba (a ba ba b )

Short Problems
SP4 Given an automaton M4 = ( K , , , s , F ) for
K = {q0 , q1 , q2 , q3 }, = {a , b }, s = q0 , F = {q0 , q1 , q2 }
and defined by the table below

1. Draw its state diagram


2. Give a property describing L(M4)

SP4 Solution
SP4
1.

Here is the state diagram

Observe that state q3 is a trap state and the short diagram


is as follows

SP4 Solution
SP4
1. Here is the short diagram

2. The language of M4 is
L (M4) = {w : neither aa nor bb is a substring of w }

Short Problems
SP5 Given an automaton M5 = ( K , , , s , F ) for
K = {q0 , q1 , q2 , q3 }, = {a , b }, s = q0 , F = {q1 }
and defined by the table below

1. Draw its state diagram


2. Give a property describing L(M5)

SP5 Solution
SP5
1.

Here is the state diagram

2.

L (M5) = {w : w has an odd number of a s


and an even number of of b s }

You might also like