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

Module 1 FLAT

The document outlines the course structure for 'Formal Languages and Automata Theory' at Manipal Institute of Technology for the academic year 2024-2025, detailing the syllabus, major topics, and learning resources. It covers key concepts such as finite automata, regular languages, context-free languages, and Turing machines, along with their applications in various fields. The course aims to provide students with a mathematical understanding of grammar, language generation, and automata design.

Uploaded by

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

Module 1 FLAT

The document outlines the course structure for 'Formal Languages and Automata Theory' at Manipal Institute of Technology for the academic year 2024-2025, detailing the syllabus, major topics, and learning resources. It covers key concepts such as finite automata, regular languages, context-free languages, and Turing machines, along with their applications in various fields. The course aims to provide students with a mathematical understanding of grammar, language generation, and automata design.

Uploaded by

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

DEPARTMENT OF INFORMATION TECHNOLOGY

Academic Year : 2024 -2025


IV Semester

Course Name : FORMAL LANGUAGES AND


AUTOMATA THEORY
Course Code: DS_2251

FACULTY NAME (CC):


Dr. S. Priya, AP- IT

MANIPAL INSTITUTE OF TECHNOLOGY, BENGALURU


MANIPAL ACADEMY OF HIGHER EDUCATION
1
Course Description
This course will enable students:
• Understand the mathematical meaning of
Grammar
• Know how to generate Languages using grammars
• Design Automata for various languages

2
Syllabus – Course Content
Module -1 Teaching Hours: 08
INTRODUCTION TO THE THEORY OF COMPUTATION AND FINITE
AUTOMATA:
Three basic concepts, Some Applications, Deterministic Finite Accepters,
Nondeterministic Finite Accepters, Equivalence of Deterministic and
Nondeterministic Finite Accepters, Reduction of the Number of States in
Finite Automata.
Text Book 1: Chapter 1:1.2 - 1.3, Chapter 2: 2.1 - 2.4
Module -2 Teaching Hours: 07
REGULAR LANGUAGES, REGULAR GRAMMARS AND PROPERTIES OF
REGULAR LANGUAGES:
Regular Expressions, Connection between Regular Expressions and
Regular Languages, Regular Grammars, Closure Properties of Regular
Languages, Identifying Non-regular Languages.
Text Book 1: Chapter 3: 3.1 -3.3, Chapter 4: 4.1, 4.3

3
Module – 3 Teaching Hours 07
CONTEXT-FREE LANGUAGES AND SIMPLIFICATION OF
CONTEXT-FREE GRAMMARS AND NORMAL FORMS:
Context-Free grammars, Parsing and Ambiguity, Context-
Free Grammars and programming languages, Methods for
Transforming Grammars, Two important Normal Forms.
Text Book 1: Chapter 5: 5.1 -5.3, Chapter 6: 6.1 – 6.2
Module-4 Teaching Hours 06
PUSHDOWN AUTOMATA AND PROPERTIES OF
CONTEXT-FREE LANGUAGES:
Nondeterministic Pushdown Automata, Pushdown
Automata and Context–Free Languages, Deterministic
Pushdown Automata and Deterministic Context-Free
Languages, Two Pumping Lemmas, Closure properties and
Decision Algorithms for Context-Free Languages.
Text Book 1: Chapter 7: 7.1 – 7.3, Chapter 8: 8.1 -8.2

4
Module-5 Teaching Hours 08
TURING MACHINES AND OTHER MODELS OF TURING
MACHINES:
The Standard Turing Machine, Nondeterministic Turing
Machines, Linear Bounded Automata.
A HIERARCHY OF FORMAL LANGUAGES & AUTOMATA
Recursive and Recursively Enumerable Languages,
Unrestricted grammars, Context-Sensitive Grammars and
Languages, The Chomsky Hierarchy.
Text Book 1: Chapter 9: 9.1, Chapter 10:10.3, 10.5, Chapter
11: 11.1-11.4

5
Learning Resources
TEXTBOOK
1. Peter Linz, An Introduction to Formal Languages and Automat, (6e), Jones &
Bartlett Learning, 2016.

Reference Books

1. John C Martin, Introduction to Languages and the Theory of Computation,


(3e), McGraw Hill, India, 2007.

2. J E Hopcroft, Rajeev Motwani & Jeffrey D Ullman, Introduction to Automata


Theory, Languages and Computation, (3e), Pearson Education, 2006.

3. K.L.P. Mishra, N.Chandrashekharan, Theory of Computer Science, (3e), PHI


publications 2007.

4. Michael Sipser, Theory of Computation, Cengage Learning, 2007.

6
Outline Unit I

FINITE AUTOMATA

FA DFA

NFA EPSILON NFA

Reduction
Conversion

7
Major Topics

Finite Automata
1. Formal definition and examples
2. Design of FA
3. Definition of DFA and NFA
4. Equivalence of NFAs and DFAs

Regular Expressions and Languages


1. Definition of a regular expression
2. Definition of non-regular languages
3. Equivalence between regular language and finite
automaton
4. The pumping lemma for regular languages

8
Major Topics (..contd)

Context-Free grammars
1. Formal definition and examples
2. Design of context-free grammars
3. Ambiguity
4. Chomsky normal form
5. Non-context-free languages definition and examples
6. Pumping lemma for CFLs
Pushdown Automata
1. Definition and examples
2. Converting a CFG to a PDA
Turing machines
1. Formal definition and examples
Decidability
1. Decidability and undecidability
2. The Church-Turing Thesis
3. Undecidability of the Halting problem

9
Applications of Automata Theory

➢ Software for designing and checking the behavior of digital


circuits.
➢ Lexical Analyser of a typical compiler.

➢ Software for scanning large bodies of text(e.g, web pages) for


pattern finding.
➢ Software for verifying systems of all types that have a finites
number of states.

10
Applications of Different Automata

Finite Automata (or) Finite Accepters (FA)


The applications of Finite Automata are as follows −
•Design of the lexical analysis of a compiler.
•Recognize the pattern by using regular expressions.
•Use of the Mealy and Moore Machines for designing the
combination and sequential circuits.
•Helpful in text editors.
•Used for spell checkers.

11
Applications of Different Automata

Push Down Automata (PDA)


The applications of Pushdown automata are as follows −
•Used in the Syntax Analysis phase.
•Implementation of stack applications.
•Used in evaluations of the arithmetic expressions.
•Used for solving the Tower of Hanoi Problem.

12
Applications of Different Automata

Linear Bounded Automata (LBA)


The applications of linear bounded automata are as
follows −
•Used in the genetic programming implementation.
•Construction of syntactic parse trees.

13
Applications of Different Automata

Turing Machine (TM)


The applications of Turing machine are as follows −
•Used to solve the recursively enumerable problem.
•Used for knowing complexity theory.
•Used for neural networks implementation.
•Used in Robotics Applications.
•Used in the implementation of artificial intelligence.

14
Theory of Automata

➢ It is the study of abstract machines and the


computation problems that can be solved using
these machines.

➢ The abstract machine is called the automata.

➢ The main motivation behind developing the


automata theory was to develop methods to
describe and analyse the dynamic behaviour of
discrete systems.

15
Automata

➢ The term "Automata" is derived from the Greek word "αὐτόματα" which
means "self-acting".

➢ An automaton (Automata in plural) is an abstract self-propelled computing


device which follows a predetermined sequence of operations
automatically.

➢ An automaton with a finite number of states is called a Finite


Automaton (FA) or Finite State Machine (FSM).

16
Introduction to Formal Languages

Alphabet - Σ
An alphabet, Σ is any finite set of symbols.
Examples: ASCII, Unicode, {0,1} (binary
alphabet ), {a,b,c}.
Strings – s, w
The set of strings over an alphabet Σ is the set of
lists, each element of which is a member of Σ.
Strings shown with no commas, e.g., abc.
Σ* denotes this set of strings.
ε stands for the empty string (string of length 0).

17
Introduction to Formal Languages(..contd)

Example of Strings
{0,1}* = {ε, 0, 1, 00, 01, 10, 11, 000, 001, . . . }
• A language is a subset of Σ* for some alphabet
Σ.
• Example: The set of strings of 0’s and 1’s with no
two consecutive 1’s.
• L = {ε, 0, 1, 00, 01, 10, 000, 001, 010, 100, 101,
0000, 0001, 0010, 0100, 0101, 1000, 1001,
1010, . . . }

18
Introduction to Formal Languages(..contd)
Empty string:

Every alphabet ∑ has a special string called empty string which means the
string with zero occurrences of symbols.

This string represented by λ, e or ε. It is the string that may be chosen from


any alphabet whatsoever.

19
Introduction to Formal Languages(..contd)

Length of a string:
The finite occurrence of input symbols form ∑
present the length of a string. If s denotes the
string over alphabet ∑ then length of a string is
represented by |S|.

For instance, ‘001110’ is a string from the


alphabets ∑= {0, 1} has length 6. Similarly if ∑ =
{a, b} and S = ‘aabbabbba’ then |S| = 9.
Note: The length of empty string | ε| = 0.

20
Introduction to Formal Languages(..contd)

Power of an alphabet:
If ∑ is an alphabet, we can express the set of all strings
of a certain length form that alphabet by using an
exponential notation. We denoted it ∑n to be the set of
strings of length n, each of whose symbols is in given
input alphabet ∑.

For example: ∑0 = {ε} regardless of what alphabet ∑ is,


i.e. ε is the only string whose length is zero.
If ∑ = {0, 1}, then ∑1 = {0, 1}, similarly ∑2 = {00, 01, 10, 11} or
∑3 = {000, 001, 010, 011, 100, 101, 110, 111} and so on.

21
Introduction to Formal Languages(..contd)

Kleene star (or) Kleen Closure (*):


Kleene star is a unary operator introduced by Stephen Kleene. It is also called
kleene operator and kleene closure.

It is defined as the set of all possible strings of all possible lengths on alphabet ∑
including ‘ε’ (empty string).

Kleene closure is represented by ∑* or L*. It is widely used for regular expressions.

22
Introduction to Formal Languages(..contd)

Kleene plus(+) (or) Positive Closure:


Kleene plus defined as the set of all possible strings of
all possible lengths on alphabet ∑ excluding ‘ε’ (empty
string).

In other words Kleene plus omits the S0 term form the


kleene star string sets. Kleene plus is denoted by ∑+ or
L+.

23
Introduction to Formal Languages(..contd)

Concatenation of strings:
Concatenation of strings is the technique to merging the symbols of strings
together.

Let A and B be two strings.

Then AB denotes the concatenation of A and B, that is, the string formed by
making a copy of A and following it by a copy of B.

More precisely, if A is the string of composed of i symbol i.e. A = a1 a2 a3 .. .. .. ai


and B is the string composed of j symbols i.e. B = b1b2b3.. .. .. bj.

For example: Let A = 11001 and B = 010. Then the concatenation of strings as
follows;
AB={11001010},
and
BA = {01011001}.

24
Introduction to Chomskian Hiearchy

25
Introduction

Finite automata are finite collections of


states with transition rules that take you
from one state to another.
Original application was sequential
switching circuits, where the “state” was the
settings of internal bits.
Today, several kinds of software can be
modeled by FA.

26
Introduction to Finite Automata

A formalism for defining languages, consisting of:


1. A finite set of states (Q, typically).
2. An input alphabet (Σ, typically).
3. A transition function (δ, typically).
4. A start / inital state (q0, in Q, typically).
5. A set of final states (F ⊆ Q, typically).
“Final” and “accepting” are synonyms.

27
Introduction to Finite Automata (..contd)

28
Introduction to Finite Automata (..contd)

The Transition Function


• Takes two arguments: a state and an input
symbol.
• δ(q, a) = the state that the DFA goes to when it is
in state q and input a is received.

29
Introduction to Finite Automata (..contd)

Graph Representation of DFA’s


• Nodes = states.
• Arcs represent transition function.
• Arc from state p to state q labeled by all those input
symbols that have transitions from p to q.
• Arrow labeled “Start” to the start state.
• Final states indicated by double circles.

30
Representation of Finite Automata

Simplest representation is often a graph.


Nodes = states.
Arcs indicate state transitions.
Labels on arcs tell what causes the
transition.

31
Representation of Finite Automata

Transition Table

Final states
starred Columns =
0 1 input symbols

* A A B
Arrow for B A C
*
start state C C C

Rows = states

32
Types of Finite Automata

• Recognizer for “Regular Languages”


Types of FA
• Deterministic Finite Automata (DFA)
• The machine can exist in only one state at any
given time i.e from the current state and for the
current input, the automata moves to only one next
state
• Non-deterministic Finite Automata (NFA)
• The machine can exist in multiple states at the
same time i.e from the current state and for the
current input, the automata moves to more than one
next state
33
DFA (Deterministic finite automata)

•DFA refers to deterministic finite automata. Deterministic refers to


the uniqueness of the computation. The finite automata are called
deterministic finite automata if the machine is read an input string
one symbol at a time.

•In DFA, there is only one path for specific input from the current
state to the next state.

•DFA does not accept the null move, i.e., the DFA cannot change state
without any input character.

•DFA can contain multiple final states. It is used in Lexical Analysis


in Compiler.
34
Formal Definition of DFA

A DFA is a collection of 5-tuples same as we described in the


definition of FA.
1.Q: finite set of states
2.∑: finite set of the input symbol
3.q0: initial state
4.F: final state
5.δ: Transition function

35
DFA Example 1

DFA with ∑ = {0, 1} accepts all starting with 0.

Solution

36
DFA Example2

DFA with ∑ = {0, 1} accepts all ending with 0.

Solution

37
DFA Example 3

Design a FA with ∑ = {0, 1} accepts those string which starts


with 1 and ends with 0.

Solution

38
DFA Example 4

Accepts all strings without two consecutive 1’s.

0 0,1

1 1
A B C

Start 0

Previous Previous Consecutive


string OK, String OK, 1’s have
does not ends in a been seen.
end in 1. single 1.

39
DFA Example 5

Design FA with ∑ = {0, 1} accepts even number of 0's and even


number of 1's.

Solution

40
Extended Transition Function

• We describe the effect of a string of inputs on a


DFA by extending δ to a state and a string.
• Induction on length of string.
• Basis: δ(q, ε) = q
• Induction: δ(q,wa) = δ(δ(q,w),a)
• w is a string; a is an input symbol.

41
Extended Transition Function

• Convention:
• … w, x, y, x are strings.
• a, b, c,… are single symbols.
• Extended δ is computed for state q and inputs
a1a2…an by following a path in the transition
graph, starting at q and selecting the arcs with
labels a1, a2,…,an in turn.

42
Extended Transition Function(..contd)

Example: Extended Delta


0 1
A A B
B A C
C C C

δ(B,011) = δ(δ(B,01),1) = δ(δ(δ(B,0),1),1) =

δ(δ(A,1),1) = δ(B,1) = C

43
Delta-hat 𝛿መ

• In book, the extended δ has a “hat” to


distinguish it from δ itself.
• Not needed, because both agree when the
string is a single symbol.
መ a) = δ(δ(q, ε), a) = δ(q, a)
• 𝛿(q,

44
FA Examples

String 101 is in the language of the DFA below.


Start at A.

0 0,1

1 1
A B C

Start 0

45
1. Construct Deterministic Finite Automata (DFA) for accepting all the
strings ending with ‘0’ over the alphabet ∑={0,1}. Show the transition
functions and transition table.
2. Construct Deterministic Finite Automata (DFA) for accepting all the
strings start with ‘1’ and ends with ‘0’ over the alphabet ∑={0,1}. Show
the transition functions and transition table.
3. Construct Deterministic Finite Automata (DFA) for accepting all the
strings those do not contain two consecutive ones over the alphabet
∑={0,1}. Show the transition functions and transition table.
4. Construct Deterministic Finite Automata (DFA) for accepting all the
strings contain even number of 1’s and even number of 0’s over the
alphabet ∑={0,1}. Show the transition functions and transition table.
5. Construct DFA for the following: To accept the strings always end with
’00’

6. Construct Deterministic Finite Automata (DFA) for accepting all the


strings end with ‘abb’ over the alphabet ∑={a,b}. Show the transition
functions and transition table.
46
7. Construct FA :
a. String ends with ‘11’
b. String contains 3 consecutive 0s
c. String that has “aabb” as a substring.

String Acceptance and finding the language of DFA


1. Check whether the string “aab” is accepted by
the FA given in 7.c. Also Check whether the string
“aabba” and “aba” can be processed by the same
Finite Automata.

47
NFA (..contd)

• Start in one start state.


• Accept if any sequence of choices leads to a
final state.
• Intuitively: the NFA always “guesses right.”

48
NFA

• A nondeterministic finite automaton has the


ability to be in several states at once.
• Transitions from a state on an input symbol can
be to any set of states.
NFA also has five states same as DFA, but with different
transition function, as shown follows:
δ: Q x ∑ →2Q

49
NFA Example

Construct NFA for accepting the following strings:

1. Strings in which the third symbol from the right end is


always ‘a’ over the alphabet {a,b}

2. Strings end with ‘01’ over the alphabet {0,1}

3. Strings end with ‘aa’ over the alphabet {a,b}

4. Strings that containing ‘1100’ as a substring over the


alphabet {0,1}

50
NFA Example

NFA with ∑ = {0, 1} and accept all string of length atleast 2.

Transition Table:
Present State Next state for Input 0 Next State of Input 1

→q0 q1 q1

q1 q2 q2

*q2 ε ε

51
NFA Example Chess Board

• States = squares.
• Inputs = r (move to an adjacent red square) and
b (move to an adjacent black square).
• Start state, final state are in opposite corners.

52
NFA Example Chess Board (contd)

1 2 3
r b
1 2,4 5
2 4,6 1,3,5
4 5 6
3 2,6 5
4 2,8 1,5,7
7 8 9
5 2,4,6,8 1,3,7,9
6 2,8 3,5,9
r b b 7 4,8 5
1 2 1 5 8 4,6 5,7,9
4 3 1 * 9 6,8 5
5 3
7 7
9 Accept, since final state reached 53
Language of an NFA

• For our chessboard NFA we saw that rbb is


accepted.
• If the input consists of only b’s, the set of
accessible states alternates between {5} and
{1,3,7,9}, so only even-length, nonempty strings
of b’s are accepted.
• What about strings with at least one r?

54
Regular Language

• A language L is regular if it is the language


accepted by some DFA.
• Note: the DFA must accept only the strings in L, no
others.
• Some languages are not regular.
• Intuitively, regular languages “cannot count” to
arbitrarily high integers.

55
Non Regular Language

L1 = {0n1n | n ≥ 1}
• Note: ai is conventional for i a’s.
• Thus, 04 = 0000, e.g.
• Read: “The set of strings consisting of n 0’s
followed by n 1’s, such that n is at least 1.
• Thus, L1 = {01, 0011, 000111,…}

56
NFA vs DFA
DFA: For every state q in S and every character  in , one and only one transition of
the following form occurs:


q q’

NFA: For every state q in S and every character  in   {e}, one (or both) of the
following will happen:


•No transition: q q’ occurs


•One or more transitions: q q’ occurs

 p

57
Equivalence of NFA and DFA
Definition. Two automata A and A’ are equivalent if they recognize the
same language.
Subset Construction

• Given an NFA with states Q, inputs Σ, transition


function δN, state state q0, and final states F,
construct equivalent DFA with:
• States 2Q (Set of subsets of Q).
• Inputs Σ.
• Start state {q0}.
• Final states = all those with a member of F.

58
Subset Construction

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4}
3 2,6 5 {5}
4 2,8 1,5,7
5 2,4,6,8 1,3,7,9
6 2,8 3,5,9
7 4,8 5
8 4,6 5,7,9
* 9 6,8 5 Alert: What we’re doing here is
the lazy form of DFA construction,
where we only construct a state
if we are forced to.
59
Subset Construction (..contd)

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5}
4 2,8 1,5,7 {2,4,6,8}
5 2,4,6,8 1,3,7,9 {1,3,5,7}
6 2,8 3,5,9
7 4,8 5
8 4,6 5,7,9
* 9 6,8 5

60
Subset Construction (..contd)

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5} {2,4,6,8} {1,3,7,9}
4 2,8 1,5,7 {2,4,6,8}
5 2,4,6,8 1,3,7,9 {1,3,5,7}
6 2,8 3,5,9 * {1,3,7,9}
7 4,8 5
8 4,6 5,7,9
* 9 6,8 5

61
Subset Construction (..contd)

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5} {2,4,6,8} {1,3,7,9}
4 2,8 1,5,7 {2,4,6,8} {2,4,6,8} {1,3,5,7,9}
5 2,4,6,8 1,3,7,9 {1,3,5,7}
6 2,8 3,5,9 * {1,3,7,9}
7 4,8 5 * {1,3,5,7,9}
8 4,6 5,7,9
* 9 6,8 5

62
Subset Construction (..contd)

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5} {2,4,6,8} {1,3,7,9}
4 2,8 1,5,7 {2,4,6,8} {2,4,6,8} {1,3,5,7,9}
5 2,4,6,8 1,3,7,9 {1,3,5,7} {2,4,6,8} {1,3,5,7,9}
6 2,8 3,5,9 * {1,3,7,9}
7 4,8 5 * {1,3,5,7,9}
8 4,6 5,7,9
* 9 6,8 5

63
Subset Construction (..contd)

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5} {2,4,6,8} {1,3,7,9}
4 2,8 1,5,7 {2,4,6,8} {2,4,6,8} {1,3,5,7,9}
5 2,4,6,8 1,3,7,9 {1,3,5,7} {2,4,6,8} {1,3,5,7,9}
6 2,8 3,5,9 * {1,3,7,9} {2,4,6,8} {5}
7 4,8 5 * {1,3,5,7,9}
8 4,6 5,7,9
* 9 6,8 5

64
Subset Construction (..contd)

r b
r b
1 2,4 5 {1} {2,4} {5}
2 4,6 1,3,5 {2,4} {2,4,6,8} {1,3,5,7}
3 2,6 5 {5} {2,4,6,8} {1,3,7,9}
4 2,8 1,5,7 {2,4,6,8} {2,4,6,8} {1,3,5,7,9}
5 2,4,6,8 1,3,7,9 {1,3,5,7} {2,4,6,8} {1,3,5,7,9}
6 2,8 3,5,9 * {1,3,7,9} {2,4,6,8} {5}
7 4,8 5 * {1,3,5,7,9} {2,4,6,8} {1,3,5,7,9}
8 4,6 5,7,9
* 9 6,8 5

65
NFA’s With ε-Transitions

• We can allow state-to-state transitions on ε


input.
• These transitions are done spontaneously,
without looking at the input string.
• A convenience at times, but still only regular
languages are accepted.

66
NFA’s With ε-Transitions - Example

ε 0 1 ε
A {E} {B} ∅
1 1 B ∅ {C} {D}
1 B C D C ∅ {D} ∅
D ∅ ∅ ∅
A ε ε 0
* E
F
{F} ∅ {B, C}
{D} ∅ ∅
0
E F
0

67
Extended Delta
ε
1 1
1 B C D
Example: Extended Delta
A ε ε 0
0 E F
˄ 0
• δ(A, ε) = CL(A) = {A}.
˄
• δ (A, 0) = CL({E}) = {B, C, D, E}.
• δ(A,
˄
01) = CL({C, D}) = {C, D}.
• Language of an ε-NFA is the set of strings w
such that (q0, w) contains a final state.

68
Example: ε-NFA-to-NFA
Interesting
closures: CL(B)
= {B,D}; CL(E)
= {B,C,D,E}
0 1 ε A
0 1
{E} {B}
A {E} {B} ∅ B ∅ {C}
B ∅ {C} {D} * C ∅ {D}
C ∅ {D} ∅ D ∅ ∅
D ∅ ∅ ∅
* E {F} {C, D}
* E {F} ∅ {B, C} F {D} ∅
F {D} ∅ ∅ *

Since closure of
ε-NFA E includes B and
Since closures of C; which have
B and E include transitions on 1
final state D. to C and D.

69
NFA with ε to DFA

Step 1: We will take the ε-closure for the starting state of NFA as a
starting state of DFA.

Step 2: Find the states for each input symbol that can be traversed from
the present. That means the union of transition value and their closures
for each state of NFA present in the current state of DFA.

Step 3: If we found a new state, take it as current state and repeat step
2.

Step 4: Repeat Step 2 and Step 3 until there is no new state present in
the transition table of DFA.

Step 5: Mark the states of DFA as a final state which contains the final
state of NFA.

70
NFA with ε into its equivalent DFA

Convert the NFA with ε into its equivalent DFA.

Solution:
Let us obtain ε-closure of each state.
1.ε-closure {q0} = {q0, q1, q2}
2.ε-closure {q1} = {q1}
3.ε-closure {q2} = {q2}
4.ε-closure {q3} = {q3}
5.ε-closure {q4} = {q4}

71
ε NFA to DFA(..contd)

Now, let ε-closure {q0} = {q0, q1, q2} be state A.

Hence

δ'(A, 0) = ε-closure {δ((q0, q1, q2), 0) }


= ε-closure {δ(q0, 0) ∪ δ(q1, 0) ∪ δ(q2, 0) }
= ε-closure {q3}
= {q3} call it as state B.

δ'(A, 1) = ε-closure {δ((q0, q1, q2), 1) }


= ε-closure {δ((q0, 1) ∪ δ(q1, 1) ∪ δ(q2, 1) }
= ε-closure {q3}
= {q3} = B.

72
ε NFA to DFA(..contd)

Now,

δ'(B, 0) = ε-closure {δ(q3, 0) }



δ'(B, 1) = ε-closure {δ(q3, 1) }
= ε-closure {q4}
= {q4} i.e. state C
For state C:

δ'(C, 0) = ε-closure {δ(q4, 0) }



δ'(C, 1) = ε-closure {δ(q4, 1) }

73
Minimization of DFA
• The process of reducing a given DFA to its minimal
form is called as minimization of DFA.
• It contains the minimum number of states.
• The DFA in its minimal form is called as a Minimal
DFA.

74
Minimization of DFA

The steps to minimize the DFA using Partitioning


Method or Equivalence Method :
Step 1: Remove all the states that are unreachable
from the initial state via any set of the transition of
DFA.
Step 2: Draw the transition table for all pair of states.
Step 3: Now split the transition table into two tables
T1 and T2. T1 contains all final states, and T2
contains non-final states.

75
Minimization of DFA
Step 4: Find similar rows from T1 such that:

1. δ (q, a) = p
2. δ (r, a) = p
That means, find the two states which have the same value of a
and b and remove one of them.

Step 5: Repeat step 3 until we find no similar rows available in


the transition table T1.

Step 6: Repeat step 3 and step 4 for table T2 also.

Step 7: Now combine the reduced T1 and T2 tables. The


combined transition table is the transition table of minimized
DFA. 76
Minimization of DFA

Minimize the following DFA

77
Minimization of DFA

Solution:
Step 1: In the given DFA, q2 and q4 are the unreachable
states so remove them.
Step 2: Draw the transition table for the rest of the states.

78
Minimization of DFA

Step 3: Now divide rows of transition table into


two sets as:
1. One set contains those rows, which start from
non-final states:

79
Minimization of DFA

2. Another set contains those rows, which starts from final states.

Step 4: Set 1 has no similar rows so set 1 will be the same.

80
Minimization of DFA
Step 5: In set 2, row 1 and row 2 are similar
since q3 and q5 transit to the same state on 0
and 1. So skip q5 and then replace q5 by q3 in
the rest.

Step 6: Now combine set 1 and set 2 as:

81
Minimization of DFA

Now it is the transition table of minimized DFA.

82
Minimization of DFA

Minimization of DFA using Myhill-Nerode Theorem :

Steps for the Minimization of DFA :


1.Create the pairs of all the states involved in the given DFA.

2.Mark all the pairs (Qa,Qb) such a that Qa is Final state and Qb is Non-
Final State.

3.If there is any unmarked pair (Qa,Qb) such a that δ(Qa,x) and δ(Qb,x) is
marked, then mark (Qa,Qb). Here x is a input symbol. Repeat this step
until no more marking can be made.

4.Combine all the unmarked pairs and make them a single state in the
minimized DFA.

83
Minimization of DFA

Minimize the following DFA using table filling method

84

You might also like