0% found this document useful (0 votes)
32 views36 pages

Lect 14-16

The document discusses theory of automata and finite automata. It defines finite automata as a language defining method that represents an abstract machine used to represent regular languages. Finite automata can be specified using transition tables or directed graphs. Deterministic finite automata (DFA) are discussed, which consist of 5 tuples - a set of states, a set of input symbols, an initial state, a set of final/accepting states, and a transition function. Several examples of DFAs are constructed to accept various languages over different alphabets and regular expressions.

Uploaded by

Ayesha Sabir
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)
32 views36 pages

Lect 14-16

The document discusses theory of automata and finite automata. It defines finite automata as a language defining method that represents an abstract machine used to represent regular languages. Finite automata can be specified using transition tables or directed graphs. Deterministic finite automata (DFA) are discussed, which consist of 5 tuples - a set of states, a set of input symbols, an initial state, a set of final/accepting states, and a transition function. Several examples of DFAs are constructed to accept various languages over different alphabets and regular expressions.

Uploaded by

Ayesha Sabir
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/ 36

Theory Of Automata

1
Lecture # 14-16
Theory of Automata

2
3
Finite Automata
A language defining method
 Also known as Finite State Machine (FSM), Finite
State Automata (FSA) ,State Machines.
 It is just like a ludo in which token changes position
on the input if certain number of dice

4
5
1:Deterministic Finite Automata
 It represents an abstract machine which is used to
represent a regular language

 A regular expression can also be represented using


Finite Automata

There are two ways to specify an FA:


1) Transition Tables and
2) Directed Graphs.

6
Graphical Representation
Each node (or vertex) represents a state, and the
edges (or arcs) connecting the nodes represent
the corresponding transitions.
Each state can be labeled

7
 DFA consists of 5 tuples {Q, ∑, q, F, δ}.

 Q : set of all states.


 ∑ : set of input symbols. ( Symbols which machine
takes as input )
 q : Initial state. ( Starting state of a machine )
 F : set of final state.
 δ : Transition Function,
defined as δ : Q X ∑ --> Q.

8
 For a particular input character, the machine goes to
one state only.

 Null (or ε) move is not allowed.

 DFA cannot change state without any input


character.

Question: Why FA is said to Finite Automata?

9
Transition Table
STATE INPUT INPUT
0 1
q0 q1 q0
q1 q1 q2
* q2 q2 q2

 The indicates the start state: here q0


 The * indicates the final state(s) (here only one final
state q1)

10
 This defines the following transition diagram

 0 1
q0 q1 q2

 1 0 0,1

11
Some more Examples of DFA

12
1: Construct a DFA with ∑ = {0, 1} accepts all
strings starts with 0.
Also construct a Transition Table for the this DFA

Hint: First make the language for the above DFA.

13
 Construct a DFA with ∑ = {0, 1} accepts all strings
starts with 0.
 L = {0,00,01,001,011,……..}
0,1
0
q0 q1

0,1
q2

14
Here
 q0 is initial or start state

On getting 0 input it goes to q1


On getting 1 input it goes to q2

 q1 is the final state having self loop (having all combinations of 0 and 1
strings)

 The state q2 is the Dead State or Trap state.

 Dead State: The strings are trapped in this state and will not reach the
final state and hence not acceptable by DFA

 The strings which reaches the final state will only be accepted by DFA.

15
2: Construct a DFA with ∑ = {0, 1} accepts all
strings ending with 0.

16
Construct a DFA with ∑ = {0, 1} accepts all strings ending
with 0.

L= {0,00,10,000,100,110,0000,…….}

 Construct a Transition Table for the above DFA

17
3:Construct a DFA that accepts set of all strings
over {0, 1} of length 2 .
Also define 5 tuples for it .

18
 ∑ = {0, 1}
 L ={00,01,10,11}

0,1 0,1
q0 q1 q2

0,1

0,1
q2

19
4: Construct a DFA that accepts set of all strings
ending with 100

20
 ∑ = {0, 1}
 L ={100,0100,1100,01100,……..}
1

1 0 0

q0 q1 q2 q3

0 1

0, 1

21
 Construct a DFA for language with a substring ab .
 Construct a DFA with minimum number of states for
strings with odd number of a’s.
 Construct a DFA for ∑={0,1} for strings that have an
odd number of 1’s and any number of zero.
 Construct a DFA for ∑= {a,b,c} that accepts any
string with aab as a substring.
 Construct a DFA for ∑= {a,b} that accepts any string
with aababb as a substring.

22
Designing Finite Automata from Regular
Expression

1: Construct a DFA for R.E. = ab(a+b)*


(Hint: make strings (language) for the mentioned
R.E).

Solution:

 ∑={a,b}
 L= {ab,aba,abb,abaa,abab,abba,abbb,….}

23
Construct a DFA for R.E. = ab(a+b)*

a b
q0 q1 q2

a,b
a

b q3
a,b

24
 Don’t forget to draw Transition Table and mention 5
tuples for the all of these examples.

25
 2:Draw a DFA for the language accepting strings
starting with ‘a’ over alphabets {a,b}

26
 2:Draw a DFA for the language accepting strings
starting with ‘a’ over alphabets {a,b}

Solution:
 ∑ = {a,b}
 Regular Expression for the language will be
a(a+b)*

 L= {a,aa,ab,aaa,aab,aba,abb,…….}

27
 The required DFA is :

a,b
q0 q1
a

b
D
a,b

28
3:Construct a DFA for a regular expression
101(0+1)*

Solution:
 ∑ = {0,1}
L=
{101,1010,1011,10100,10101,10110,10111,…………
}

29

0,1

1 0 1
q0 q1 q2 q3

0 1 0

D 0,1

30
4: Draw a DFA that accepts a language L over input
alphabets {0,1} such that L is the set of all the
string starting with 00.

31
Solution:
 ∑ = {0,1}
 Regular Expression for the language will be
00(0+1)*

 L= {00,000,001,0000,0001,0010,0011,…….}

32

0,1

q00 q1 0 q2

1
1
D
0,1

33
5: Construct a DFA that accepts a language L over
imput alphabets {a,b} such that L is the set of all
string starting with aa or bb.

34
Solution:
 ∑ = {a,b}
 Regular Expression for the language will be
(aa+bb)(a+b)*

 L= {aa,bb,aaa,aab,bba,bba,……..}

35
Let’s solve it !

36

You might also like