Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit I Automata: 1.1.1. Basic Definitions of Automata Theory 1. Alphabets

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

CS8501 TOC - UNIT 1

UNIT I
AUTOMATA
Introduction to formal proof – Additional forms of proof – Inductive
proofs – Finite Automata (FA) – Deterministic Finite Automata (DFA) – Non-
deterministic Finite Automata (NFA) – Finite Automata with Epsilon transitions.

1.1. INTRODUCTION TO THEORY OF COMPUTATION


• The theory of computation describes the basic ideas and models
underlying computing.
• Computation involves taking some inputs and performing the required
operations on it, using syntactic procedures and algorithms and
producing the outputs accordingly.
• The term “Theory of Computation” suggests various abstract models of
computation, represented mathematically.
• Some of these models are as powerful as real computers.
• Each abstract computing machine recognizes a formal language at a
particular complexity.
• The simplest type of abstract machine is, Finite Automata(FA) or Finite
State Machine, which recognizes only the regular languages and used to
solve decision making problems.
• Software implementation of the corresponding Finite Automaton is used
to construct lexical analyzer of a compiler and text editors, pattern or
language recognizer.

1.1.1. BASIC DEFINITIONS OF AUTOMATA THEORY


1. Alphabets:
An alphabet is a finite, non empty set of symbols. It is denoted by „Σ‟. It
includes,
Σ = {0, 1} ; the binary alphabet.
Σ = {a, b, c, ..z} ; the set of all lower case letters.

2. Strings:
A string is a finite sequence of symbols chosen from some alphabet.
For ex:
Given an alphabet Σ = {a, b}, a string formed from Σ is “aba, ba, aab,
bba, abab,……”

[Mrs.S.Berlin Shaheema, AP/CSE] Page 1


CS8501 TOC - UNIT 1

3. The Empty String:


The empty string is the string with zero occurrences of symbols. It is
denoted as „ε‟.

4. Length of a string:
Length of a string is number of positions for symbols in a string. The
standard notation for the length of a string „w‟ is |w|. For ex:
| 011 | = 3
|ε|=0

5. Powers of an Alphabet:
If „Σ‟ is an alphabet, we can express the set of all strings of a certain
length from that alphabet by using an exponential notation. We define Σ k to be
the set of strings of length k, each of whose symbols is in Σ.
For ex:
• Σ0 = { ε }
• If Σ = {0, 1} then,
Σ 1 = {0, 1}
Σ 2 = {00, 01, 10, 11}
Σ 3 = {000, 001, 010, 011, 100, 101, 110, 111}
6. Concatenation of Strings:
Let „x‟ and „y‟ be strings, then „xy‟ denotes the concatenation of „x‟ and
„y‟ that is, the string formed by making a copy of „x‟ and following it by a copy
of „y‟.
For ex:
Let x = 01101, y = 110
xy = 01101110
yx = 11001101

7. Languages:
A set of strings all of which are chosen from some Σ *, where Σ is a
particular alphabet is called a language. If Σ is an alphabet, and L Σ*, then L is
a language over Σ.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 2


CS8501 TOC - UNIT 1

1.2. INTRODUCTION TO FORMAL PROOF


The automata theory lends itself to natural and interesting proofs, both of
the deductive kind and the inductive kind.

1. Deductive Proofs:
A deductive proof consist of a sequence of statements whose truth leads
us from some „initial statement‟ called „Hypothesis‟ or the „Given statement‟ to a
conclusion statement.
Format: A theorem that is proved when we go from a „Hypothesis H to a
Conclusion C‟ is a statement “If H then C”. We say that C is deduced from H.

Theorem: If x ≥ 4 then 2x ≥ x2.


Proof:
First notice that the hypothesis H is “x ≥ 4”. This hypothesis has a
parameter x, and thus is neither true or false. Rather, its truth depends on the
value of the parameter x.
Ex: H is true for x = 6 and false for x = 2.
The conclusion C is “2x ≥ x2”. This statement also uses parameter x and
is true for certain values of x and not others.

Ex: (i) C is false for x = 3.


ie) 23 ≥ 32 ⇒ 8 ≥ 9 ⇒ false
(ii) C is true for x = 4.
ie) 24 ≥ 42 ⇒ 16 ≥ 16 ⇒ true.
We take x = 5
25 ≥ 52 ⇒ 32 ≥ 25 ⇒ true.

The statement “If x ≥ 4 then 2x ≥ x2”, for all integers x. In fact, we do


not need to assume x is an integer, but the proof talked about repeatedly
increasing x by 1, stating at x = 4. So we really addressed only the situation
where x is an integer.
Finally the conclusion is, 2x ≥ x2 will be true whenever x ≥ 4.

2. Reduction to Definitions:
In many theorems of Automata theory, the terms used in the statement
may have implications that are less obvious. A useful way to proceed in many

[Mrs.S.Berlin Shaheema, AP/CSE] Page 3


CS8501 TOC - UNIT 1

proof is, “If you are not sure how to start a proof”, convert all terms in the
hypothesis to their definitions.

Theorem:
Let S be a finite subset of some infinite set U. Let T be the complement
of S with respect to U. Then T is infinite.

Proof:
This theorem uses two definitions,
(a) A set S is finite if there exists an integer n such that S has exactly n
elements. We write ||S|| = n, where ||S|| is used to denote the number of
elements in a set S. If the set S is not finite, we say S is infinite. An
infinite set is a set that contains more than any integer number of
elements.
(b) If S and T are both subsets of some set U, then T is the complement of
S(with respect to U) if S T = U and S T = . That is, each element
of U is in exactly one of S and T. Put another way, T consists of exactly
those elements of U that are not in S.

Original Statement New Statement


There is a integer n
S is finite
such that ||S|| = n
For no integer p
U is infinite
is ||U|| = p
T is the complement of S S T = U and S T =
Fig. 1.1. Restarting the givens of theorem

3. Other Theorem Forms:


The “if-then” form of theorem is most common. There are some other
forms of statements proved as theorem also.

(i) Way of Saying “If-then”


“If H then C‟ may appear as,
(a) H implies C.
(b) H only if C.
(c) C if H.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 4


CS8501 TOC - UNIT 1

(d) Whenever H holds, C follows.

(ii) If-And-Only-If Statements:


A statement of the form “A if and only if B”. Other forms of this
statement are,
(a) A iff B
(b) A is equivalent to B
Or
A exactly when B
In formal logic, may see the operator ↔ or to denote an “if-and-only-
if” statement.
(ie) A B and A ↔ B mean the same as “A if-and-only-if B”.
To prove “A if-and-only-if B” statement, First prove “A if-and-only-if
C”, and then prove “C if-and-only-if B”. Each if-and-only-if step must be proved
in both directions.

4. Theorems that appear not to be If-Then Statements:


In some cases, we encounter a theorems that appears not to have
hypothesis.
Ex: Sin2 + cos2 = 1
From the definitions and the functions sin and cos values we can prove
the theorem.

1.3. ADDITIONAL FORMS OF PROOFS


Several additional forms of proofs are there,
(1) Proofs about sets
(2) Proofs by contradiction
(3) Proofs by counterexample

(1) Proofs about sets:


In automata theory, set theory plays an important role. If E and F are
two expressions representing sets, the statement E = F means that the two sets
represented are the same. More precisely, every element in the set represented
by E is in the set represented by F, and every element in the set represented by F
is in the set represented by E.
Ex:

[Mrs.S.Berlin Shaheema, AP/CSE] Page 5


CS8501 TOC - UNIT 1

Commutative law of union says, for two sets R and S.


ie) R S=S R
Here, R S = E
S R=F
The commutative law of union says that E = F.

1.3.1. Theorem:
R (S T)=(R S) (R T)
Proof:
The two set-expressions involved are E = R ( S T ) and F = ( R S)
( R T ). In this theorem to prove two parts, that is,
(i) If part
(ii) Only-if part

(i) To prove if part:


We assume element „x‟ is in E and show it is in F.
Take L.H.S. R ( S T ) and show it is in ( R S ) ( R T ).
x R (S T)
x R or x ( S T )
x R or x S and x R or x T [ x is in R or x is in both S and T ]
x R S and x R T
x (R S) (R T)

(ii) Only-if part:


Here we assume „x‟ is in F and show it is in E.
Take R.H.S. ( R S ) ( R T ) and show it is in R ( S T ).
x (R S) (R T)
x R S and x R T
x R or x S and x R and x T
x R or x S and x T
x R or x S T
x R (S T)

2. Proofs by Contradiction:
Another way to prove a statement of the form “if H then C” is, “H and
not C implies falsehood”. By assuming both the hypothesis H and the negation
of the conclusion C. Complete the proof by showing that something known to be

[Mrs.S.Berlin Shaheema, AP/CSE] Page 6


CS8501 TOC - UNIT 1

false follows logically from H and C. This form of Proof is called Proof by
Contradiction.
Ex:
Hypothesis H = U is an infinite set, S is a finite subset of U, and T is the
complement of S with respect to U. The conclusion C was “T is infinite”. But
we assumed T was finite. It is contradiction.

3. Proofs by Counterexample:
In real life, to resolve the question, we may alternately try to prove the
theorem, and if we cannot try to prove that its statement is false. But it is easier
to prove that a statement is not a theorem than to prove it is a theorem.

Alleged Theorem: All primes are odd.


Disproof: The integer 2 is a prime, but 2 is even.

The Contrapositive :
The contrapositive of the statement “if H then C” is “if not C then not
H”. A statement and its contrapositive are either both true or both false. So we
can prove either to prove the other.
Ex:
If x ≥ 4 then 2x ≥ x2.

The contrapositive of this statement is “if not 2x ≥ x2 then not x ≥ 4.

1.4. INDUCTIVE PROOFS


There is a special form of proof called “inductive”, which is essential
when dealing with recursively defined objects. Many of the inductive proofs
deal with integers, trees, expressions of various sorts etc.

1.4.1. Inductions on Integers:


Suppose we are given a statement S(n), about an integer n, to prove. One
common approach is to prove two things,
(1) The basis, where we show S(i) for a particular integer „i‟. Usually i=0 or
i=1.
(2) The inductive, where we assume n ≥ i, where „i‟ is the basis integer, and
we show that “if S(n) then S(n+1)”.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 7


CS8501 TOC - UNIT 1

Theorem:

For all n ≥ 0. 2
=
Proof:
The proof is in two parts, the basis and the inductive step, we prove each
in turn.
Basis:
Let n = 0,
2
First, To prove, L.H.S.
2
L.H.S. ⇒ = 0
To prove, R.H.S,
R.H.S. ⇒ = 0
L.H.S = R.H.S
Thus the equation is true for n = 0.
Induction:
Assume that, it is true for n. To prove it is true for n+1.
2
To prove L.H.S. , assume n= n+1

2
L.H.S. ⇒ ) + (n+1)2
⇒ + (n+1)2

⇒ + n2+2n+1

⇒ + n2+2n+1

⇒ + n2+2n+1

2

To prove, R.H.S. for n = n+1,


R.H.S. ⇒

[Mrs.S.Berlin Shaheema, AP/CSE] Page 8


CS8501 TOC - UNIT 1


L.H.S = R.H.S
2
ie) =
The given theorem is proved.

1.4.2. Structural Inductions:


The examples of structural inductions are, trees and expressions.
Ex: Here is the recursive definition of a tree.

Basis:
A single node is a tree, and that node is the root of the tree.
Induction:
If T1, T2,…Tk are trees, then we can form a new tree as follows,
1. Begin with a new node, N which is the root of the tree.
2. Add copies of all the trees T1, T2,…Tk.
3. Add edges from node N to the roots of each of the trees T1, T2,…Tk.

1.4.3. Mutual Inductions:


To prove a group of statements is no different from proving the
conjunction (logical AND) of all the statements. For instance the group of
statements S1(n), S2(n),…..Sk(n) could be replaced by the single statement S1(n)
AND S2(n) AND…..AND Sk(n).
However when there are really several independent statements to prove,
it is generally less confusing to keep the statements separate and to prove them

[Mrs.S.Berlin Shaheema, AP/CSE] Page 9


10

all in their own parts of the basis and inductive steps. We call this sort of proof is
mutual induction.

1.5. FINITE AUTOMATA(FA)


A finite automata has a finite set of states and its control moves from one
state to another in response to external inputs. There are two types of finite
automata; They are,
1. Deterministic Finite Automata(DFA)
2. Non-deterministic Finite Automata(NFA)

1. Deterministic Finite Automata:


The automaton cannot be in more than one state at any one time.
2. Non-deterministic Finite Automata:
In NFA is used to several states at once.

1.5.2. Formal Definition of Finite Automata:


A Finite Automata can be defined as 5 – tuples.
M = (Q, Σ, δ, q0, F)
Where,
Q - None empty, finite set of states.
Σ - Finite set of symbols.
δ - Transition function.
q0 - Initial state.
F - Finite set of final states.

1.6. DETERMINISTIC FINITE AUTOMATA (DFA)


DFA refers the fact that on each input there is one and only one state to
which the automaton can transition from its current state.
Ex:

1.6.1. Definition of a DFA:


A DFA consists of 5 – tuples.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 10


11

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

1.6.2. Simpler Notations for DFA’s:


There are two preferred notations for describing automata,
(1) A Transition Diagram: Which is a graph.
(2) A Transition Table: Which is a tabular listing of the δ function, which
by implication tells us the set of states and the input alphabet.

PROBLEMS:

Ex. 1:
Construct the transition diagram and the transition table for the following
language,
L = { x01y | x and y are any strings of 0‟s and 1‟s }

Soln:
The language include the strings are { 01, 100011, 11010, 101001,…..}
The strings not in the language are { 0, 1, 111000, 00, 11,….. }

Transition diagram:

Transition table:
Input
State
0 1
q0 q1 q0
q1 q1 q2
* q2 q2 q2

1.6.3. Theorem: Extending the transition function to strings on DFA:

[Mrs.S.Berlin Shaheema, AP/CSE] Page 11


12

Extended transition function describes, when we start in any state and


follow any sequence of inputs. If δ is our transition function, then the extended
transition function constructed from δ will be called .
δ consists of a state & a single symbol.
consists of a state & a string.

Proof: To compute (q, w) = r


Basis:
(q, ε) = q, That is, if we are in state q and read no inputs, then we are
still in state q.

Induction:
Suppose „w‟ is a string of the form „xa‟ that is,
a - is the last symbol of „w‟.
x - is the string consisting of all but except the last symbol.
For ex.,
w = 1101, is broken into xa,
x = 110 and a = 1
To compute (q, w),
First compute (q, x), it states that the automaton is in after processing
all but the last symbol of „w‟. Suppose this state is „p‟, that is; (q, x) = p.
ie) (q, w) = ( q, xa ) [ w = xa ]
= δ ( ( q, x ), a)
= δ ( p, a ) [ ( q, x ) = p ]
(q, w) = r [ δ ( p, a ) = r ]

PROBLEMS:
Ex. 1:
Consider the following DFA, check whether the input strings w1 = 1011
and w2 = 1100 is accepted by the finite automata or not?

[Mrs.S.Berlin Shaheema, AP/CSE] Page 12


13

Soln:
• w1 = 1011
(q0, ε ) = q0
(q0, 1) = δ( (q0, ε ), 1) = δ(q0, 1) = q0
(q0, 10) = δ( (q0, 1), 0) = δ(q0, 0) = q1
(q0, 101) = δ( (q0, 10), 1) = δ(q1, 1) = q2
(q0, 1011) = δ( (q0, 101), 1) = δ(q2, 1) = q2
Here answer is q2, that is the accepting state,
w1 = 1011 is accepted by finite automata.

• w2 = 1100
(q0, ε ) = q0
(q0, 1) = δ( (q0, ε ), 1) = δ(q0, 1) = q0
(q0, 11) = δ( (q0, 1), 1) = δ(q0, 1) = q0
(q0, 110) = δ( (q0, 11), 0) = δ(q0, 0) = q1
(q0, 1100) = δ( (q0, 110), 0) = δ(q1, 0) = q1
Here answer is q1, that is not the accepting state,
w2 = 1100 is not accepted by finite automata.

1.7. NON DETERMINISTIC FINITE AUTOMATA (NFA)


A Non Deterministic Finite Automata has the power to be in several
states at once.
Ex.,

[Mrs.S.Berlin Shaheema, AP/CSE] Page 13


14

1.7.1. Definition of NFA:


A DFA consists of 5 – tuples.
M = (Q, Σ, δ, q0, F)
Where,
Q - None empty, finite set of states.
Σ - Finite set of symbols.
δ - Transition function.
q0 - Initial state.
F - Finite set of final states.

1.7.2. Difference between DFA and NFA:


DFA NFA
1. In DFA δ is a transition function. 1. In NFA δ is a transition function that
takes a state and input symbol as
arguments.

2. DFA must returning exactly one 2. NFA returns a set of zero, one or
state. more states.

3. The language of a DFA is defined 3. The language of an NFA is defined


by, L(A) = (w | (q0, w) is in F} by, L(A) = {w | (q0, w) ∩ F ≠ Ø }

PROBLEMS:
Ex.1:
Consider the following NFA, check whether the input strings w1 = 0010
and w2 = 00101 is accepted by the finite automata or not?

Soln:
• w1 = 0010

[Mrs.S.Berlin Shaheema, AP/CSE] Page 14


15

Here answer is{ q0, q1}, both states are not accepting state.
w1 = 0010 is not accepted by finite automata.

• w2 = 00101

Here answer is{ q0, q2}, q2 is the accepting state.


w2 = 00101 is accepted by finite automata.

1.7.3. Theorem: Extending the transition function to strings on NFA:


Proof: To compute (q, w) = { r1, r2, …. rm }
Basis:
(q, ε ) = {q}. That is without reading any input symbols, we are only
in the state we began it.
Induction: To compute (q, w)
Suppose „w‟ is a string of the form „xa‟ that is,
a - is the last symbol of „w‟.
x - is the string consisting of all but except the last symbol.
First compute (q, x), it states that the automaton is in after processing
all but the last symbol of „w‟. Suppose that is; (q, x) = { p1, p2,………, pk }

[Mrs.S.Berlin Shaheema, AP/CSE] Page 15


16

ie) (q, w) = ( q, xa ) [ w = xa ]
= δ ( ( q, x ), a)
= δ ({ p1, p2,………, pk }, a ) [ ( q, x ) = { p1, p2,………, pk } ]
= δ ( pi, a ) [ ]
= { r1, r2, …….., rm }
PROBLEMS:
Ex.1:
Consider the following NFA, check whether the input string w1 = 0010
and w2 = 00101 is accepted by the finite automata or not?

Soln:
• w1 = 0010
(q0, ε ) = {q0}
(q0, 0) = δ( (q0, ε ), 0) = δ({q0}, 0) = { q0, q1}
(q0, 00) = δ( (q0, 0), 0) = δ({q0, q1}, 0) = { q0, q1}
(q0, 001) = δ( (q0, 00), 1) = δ({q0, q1}, 1) = { q0, q2}
(q0, 0010) = δ( (q0, 001), 0) = δ({q0, q2}, 0) = { q0, q1}
Here answer is { q0, q1}, both the states are not accepting state,
w1 = 0010 is not accepted by finite automata.

• w2 = 00101
(q0, ε ) = {q0}
(q0, 0) = δ( (q0, ε ), 0) = δ({q0}, 0) = { q0, q1}
(q0, 00) = δ( (q0, 0), 0) = δ({q0, q1}, 0) = { q0, q1}
(q0, 001) = δ( (q0, 00), 1) = δ({q0, q1}, 1) = { q0, q2}
(q0, 0010) = δ( (q0, 001), 0) = δ({q0, q2}, 0) = { q0, q1}
(q0, 00101) = δ( (q0, 0010), 1) = δ({q0, q1}, 1) = { q0, q2}

[Mrs.S.Berlin Shaheema, AP/CSE] Page 16


17

Here answer is { q0, q2}, q2 is the accepting state,


w2 = 00101 is accepted by finite automata.

1.7.4. Equivalence of Deterministic & Non-Deterministic Finite Automata:


The DFA‟s can do whatever NFA‟s can do involves an important
“construction” called the subset construction because it involves constructing
all subsets of the set of states of the NFA.
The subset construction starts from an NFA N = { QN, Σ, δN, q0, FN }. Its
goal is the description of a DFA D = { QD, Σ, δD, q0, FD }, such that L(D) = L(N).
If there are n elements in NFA there are 2n elements in DFA.

Theorem:
If D = { QD, Σ, δD, q0, FD } is the DFA constructed from NFA N = { QN,
Σ, δN, q0, FN } by the subset construction, then L(D) = L(N).
Proof:
To prove, by induction on |w| is that, D({q0}, w} = N(q0, w). Notice
that each of the functions returns a set of states from QN, but D interprets this
set as one of the states of QD (which is the power set of QN), while N interprets
this set as a subset of QN.
Basis:
Let |w| = 0, that is , w = ε. By the basis definitions of for DFA‟s and
NFA‟s both D({q0}, ε ) and N(q0, ε ) are {q0}.
Induction:
Let „w‟ be of length n+1, and assume the statement for length „n‟. Break
„w‟ up as w = xa, where „a‟ is the final symbol of „w‟. By the inductive
hypothesis, ({q0}, x) = (q0, x). Let both these sets of N‟s states be
{p1, p2,……,pk}. The inductive part of the definition of for NFA‟s tell us,
N(q0, w) = N(q0, xa)
= δN( N(q0, x), a)
= δN({p1, p2,…pk}, a)

N(q0,w) = --------------------- (1)


The subset construction on the other hand tell us that,

[Mrs.S.Berlin Shaheema, AP/CSE] Page 17


18

δD({p1, p2,…pk}, a) = ------------------ (2)


Now, let us use equation (2) and the inductive part of the definition of for
DFA‟s tell us,

D({q0}, w) = D({q0}, xa)


= δD( D({q0}, x), a)
= δD({p1, p2,…pk}, a)

D(q0, w) = --------------------- (3)


Thus equations (1) and (3) demonstrate that D({q0}, w} = N(q0, w).
When we observe that D and N both accept „w‟ if and only if D({q0}, w} or
N(q0, w), respectively contain a state in FN, we have a complete proof that L(D)
= L(N).

PROBLEMS:
Ex.1:
Convert the following NFA to it‟s equivalent DFA.

Soln:
Step 1: To find subset construction:

P(N) = 2n, where n is the total number of states. n =3,


P(N) = 23 = 8 , To find 8 subsets of the set of states.
P(N) = ( {}, {q0}, {q1}, {q2}, {q0, q1}, {q0, q2}, {q1, q2}, {q0, q1, q2} )

Step 2: To construct transition table:

[Mrs.S.Berlin Shaheema, AP/CSE] Page 18


19

Step 3: Renaming the States:

Input Input
State State
0 1 0 1
A A A
→ {q0} {q0, q1} {q0} →B E B
{q1} {q2} C A D
*{q2} *D A A
{q0, q1} {q0, q1} {q0, q2} E E F
*{q0, q2} {q0, q1} {q0} *F E B
*{q1, q2} {q2} *G A D
*{q0, q1, q2} {q0, q1} {q0, q2} *H E F

Step 4: To find transition function:


{q0} -------------------- (A)
δD ({q0}, 0) = {q0, q1} -------------------- (B)
δD ({q0}, 1) = {q0} -------------------- (A)
δD ({q0, q1}, 0) = {q0, q1} -------------- (B)
δD ({q0, q1}, 1) = {q0, q2} -------------- (C)
δD ({q0, q2}, 0) = {q0, q1} -------------- (B)
δD ({q0, q2}, 1) = {q0} -------------- (A)

Step 5: To construct transition diagram for DFA:

Ex.2:
Convert the following NFA to it‟s equivalent DFA.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 19


20

Input
State
0 1
→p {p,q} {p}
q {r} {r}
r {s}
*s {s} {s}

Soln:
Step 1: To find subset construction:
P(N) = 2n, where n is the total number of states. n = 4,
P(N) = 24 = 16 , To find 16 subsets of the set of states.
P(N) = ( {}, {p}, {q}, {r}, {s}, {p, q}, { p, r}, {p, s}, {q, r}, {q, s}, {r,s},
{{p, q, r}, {p, q, s}, {p, r, s}, {q, r, s}, {p, q, r, s})

Step 2: To construct transition table: Step 3: Renaming the States:


Input Input
State State
0 1 0 1
A A A
→ {p} {p, q} {p} → B F B
{q} {r} {r} C D D
{r} {s} D E A
*{s} {s} {s} *E E E
{p, q} {p, q, r} {p, r} F L G
{p, r} {p, q, s} {p} G M B
*{p, s} {p, q, s} {p, s} *H M H
{q, r} {r, s} {r} I K D
*{q, s} {r, s} {r, s} *J K K
*{r, s} {s} {s} *K E E
{p, q, r} {p, q, r, s} { p, r} L P G
*{p, q, s} {p, q, r, s} {p, r, s} *M P N
*{p, r, s} {p, q, s} {p, s} *N M H
*{q, r, s} {r, s} {r, s} *O K K
*{p, q, r, s} {p, q, r, s} {p, r, s} *P P N

Step 4: To find transition function:


{p} ------------------------------------ (A)
δD ({p}, 0) = {p, q} -------------------- (B) δD ({p, q, r, s}, 0) = {p, q, r, s} -------------- (E)
δD ({p}, 1) = {p} ----------------------- (A) δD ({p, q, r, s}, 1) = {p, r, s} ----------------- (G)

[Mrs.S.Berlin Shaheema, AP/CSE] Page 20


21

δD ({p, q}, 0) = {p, q, r} --- (C) δD ({p, q, s}, 0) = {p, q, r, s} ----- (E)
δD ({p, q}, 1) = {p, r} ------- (D) δD ({p, q, s}, 1) = {p, r, s} -------- (G)
δD ({p, q, r}, 0) = {p, q, r, s} - (E) δD ({p, r, s}, 0) = {p, q, s} ----- - (F)
δD ({p, q, r}, 1) = {p, r} ----- (D) δD ({p, r, s}, 1) = {p, s}------------ (H)
δD ({p, r}, 0) = {p, q, s} ------ (F) δD ({p, s}, 0) = {p, q, s} --------- (F)
δD ({p, r}, 1) = {p} ------- (A) δD ({p, s}, 1) = {p, s} ----------- (H)

Step 5: To construct transition diagram for DFA:

1.8. FINITE AUTOMATA WITH EPSILON TRANSITIONS


ε – transition only in NFA not in DFA. ε – NFA is move from one state
to another state without the input symbol.

1.8.1. Use of ε – transitions:


We shall begin with an informal treatment of ε – NFA‟s, using transition
diagrams with ε allowed as a label.
Ex:

[Mrs.S.Berlin Shaheema, AP/CSE] Page 21


22

1.8.2. The Formal Notation for an ε – NFA:


• An ε – NFA exactly do an NFA, with one exception; the transition
function must include information about transitions on ε.
• Formally, represent an ε – NFA A by, A = (Q, Σ, δ, q0, F), where all
components have their same interpretation as for an NFA, except that δ is
new a function that takes as arguments;
(1) A state in Q.
(2) A number of Σ {ε} that is, either an input symbol or the
symbol ε.

1.8.3. Epsilon – Closures:


ε-close a state q by following all transitions out of q that are labeled ε.
However, when we get to other states by following ε, we follow the ε –
transitions out of those states, and so on, eventually finding every state that can
be reached from q along any path whose arc‟s are all labeled ε.

1.8.4. Theorem: Extended Transitions and Languages for ε – NFA:


Suppose that E = (Q, Σ, δ, q0, F) is an ε – NFA. We first define , the
extended transition function, to reflect what happens on a sequence of inputs.
The appropriate recursive definition of is;
Basis:
(q, ε) = ECLOSE(q)
Induction:
Suppose „w‟ is of the xa, where „a‟ is the last symbol of „w‟. Note that
„a‟ is a member of Σ; it cannot be ε, which is not in Σ. To compute (q, w) as
follows:
1. Let {p1, p2,………pk} be (q, x). That is, the Pi‟s are all and only the
states that can reach from „q‟ following a path labeled „x‟.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 22


23

2. Let be the set {r1, r2, ……rm}, that is follow all transitions
labeled „a‟ from states we can reach from „q‟ along paths labeled „x‟.
The rj‟s are some of the states can reach from „q‟ along paths labeled „w‟.
3. The (q, w) =

ie) (q, w) = ECLOSE( ( q, xa )) [ w = xa ]


= ECLOSE(δ ( ( q, x ), a))
= ECLSOE(δ ({ p1, p2,……, pk }, a ))[ ( q, x ) = { p1, p2,…, pk } ]
= ECLOSE(δ ( pi, a )) [ ]
= ECLOSE({ r1, r2, …….., rm })
(q, w) = .

PROBLEMS:
Ex.1:
Consider the following ε – NFA, check whether the following input
string w = abab is accepted or not?

Soln:
w = abab
(q0, ε ) = ECLOSE({q0}) = {q0}
(q0, a) = ECLOSE(δ( (q0, ε ), a))
= ECLOSE(δ({q0}, a))
= ECLOSE ({q1}) = {q1, q2}
(q0, ab) = ECLOSE(δ( (q0, a), b))
= ECLOSE(δ({q1, q2}, b))
= ECLOSE({q2, q3}) = {q2, q3, q4}
(q0, aba) = ECLOSE(δ( (q0, ab), a))
= ECLOSE(δ({q2, q3, q4}, a))
= ECLOSE({q3}) = {q3, q4}

[Mrs.S.Berlin Shaheema, AP/CSE] Page 23


24

(q0, abab ) = ECLOSE(δ( (q0, aba), b))


= ECLOSE(δ({q3, q4}, b))
= ECLOSE({ q1}) = {q1, q2}
Here answer is { q1, q2 }, both the states are not accepting states,
w = abab is not accepted.

1.8.5. Eliminating ε – transitions:

Given any ε – NFA E, we can find a DFA D that accepts the same
language as E. Let E = (QE, Σ, δE, q0, FE). Then the equivalent DFA, D = (QD, Σ,
δD, q0, FD) is defined as follows;
1. QD is the set of subsets of QE.
2. q0 = ECLOSE(q0)
3. δD(S, a) is computed, for all „a‟ in Σ and sets „S‟ in QD by:
(a) Let S = {p1, p2, …..pk}
(b) Compute ; let this set be {r1, r2, ……… rm}.
(c) Then δD(S, a) =

PROBLEMS:
Ex.1:
Consider the following ε – NFA, compute the ε-closure of each state and
find it‟s equivalent DFA.

Soln:
Step 1: To find ε-closure:
ECLOSE({q0}) = {q0, q1, q2} --------------- (A)
δ(A, 0) = {q0}
δ(A, 1) = {q1}
δ(A, 2) = {q2}
ECLOSE({q1}) = {q1, q2} ---------------- (B)
δ(B, 0) =
δ(B, 1) = {q1}
δ(B, 2) = {q2}

[Mrs.S.Berlin Shaheema, AP/CSE] Page 24


25

ECLOSE({q2}) = {q2} ---------------- (C)


δ(C, 0) =
δ(C, 1) =
δ(C, 2) = {q2}

Step 2: To construct transition table:

Input
State
0 1 2
→*A A B C
*B B C
*C C

Step 3: To construct transition diagram for DFA:

This is not DFA, in DFA each state read all the input‟s exactly once. So
here, we construct one more transition diagram, for that we can add one more
state, that is known as “dead state”, which is represented by „d‟.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 25


26

Ex.2:
Consider the following ε – NFA, compute the ε-closure of each state and
find it‟s equivalent DFA.

Input
State
ε a b c
→p {q} {p}
q {r} {q}
*r {r}
Soln:
First construct transition diagram for this ε – NFA,

Step 1: To find ε-closure:


ECLOSE({p}) = {p, q, r} ----------------- (A)
δ(A, a) = {p}
δ(A, b) = {q}
δ(A, c) = {r}
ECLOSE({q}) = {q, r} ------------------ (B)
δ(B, a) =
δ(B, b) = {q}
δ(B, c) = {r}
ECLOSE({r}) = {r} ------------------- (C)
δ(C, a) =

[Mrs.S.Berlin Shaheema, AP/CSE] Page 26


27

δ(C, b) =
δ(C, c) = {r}

Step 2: To construct transition table:

Input
State
a b c
→*A A B C
*B B C
*C C

Step 3: To construct transition diagram for DFA:

This is not DFA, in DFA each state read all the input‟s exactly once. So
here, we construct one more transition diagram, for that we can add one more
state, that is known as “dead state”, which is represented by „d‟.

[Mrs.S.Berlin Shaheema, AP/CSE] Page 27

You might also like