Professional Documents
Culture Documents
1 Introduction:
1.1 Computation:
Digital Vs Analog
Sequential Vs Parallel Vs Concurrent
Batch Vs interactive
Digital Computers
Quantum Computers
DNA Computers
Molecular Computers
Analog Computers
1.4 Mathematical model of Computation
Definition 1
Definition 2
1.6.1 Alphabets
Example:
Example:
i. If ∑ = {a, b}, then abab, aabba, aaabba are all strings over the alphabet
∑ = {a, b}.
ii. If ∑ = {a}, then a, aa, aaa are all strings over the alphabet ∑ = {a}.
1.6.3 Languages
Example:
Languages Automata
Regular or Finite
Type 3 automaton
2 Introduction to Formal Proof
Definition
A proof not only convinces but explains why the statement is true and also
how it relates to other statements and how it fits into the overall theory. There are
two types of proofs:
1. Deductive proof
2. Inductive proof
2.1 Deductive Proof
A deductive proof consists of a sequence of statements whose truth leads us
from some initial statement called hypothesis or given statements to a conclusion
statement.
The theorem that is proved when we go from a hypothesis H to a
conclusion C is the statement “if H then C”, we say that “C is deduced from H”.
Theorem 1:
If x≥4 then 2x ≥x2.
Proof:
Here Hypothesis H is x≥4
Conclusion C is 2x ≥x2
x≥4:
Hypothesis has a parameter x and it is neither true nor false.
The truth depends on the value of the parameter i.e) h is true for x=6 and
false for x=2.
2x ≥x2:
The conclusion C is 2x ≥x2. This statement also uses parameter x and is true
for certain values of x and not for others.
Example:
C is false for x=3 since 23=8 which is not as large as 32=9 (8 ≥ 9).
C is true for x=4 since 24=42=16.
For x=5. The statement is also true since 25=32 is at least as large as 52=25 (32 ≥
25).
Let us conclude the conclusion as 2x ≥x2 will be true whenever x≥4.
Theorem 2:
Modus ponens:
Proof:
The intuitive argument that tells the conclusion 2x ≥x2 is true for the hypothesis
x ≥ 4. If the hypothesis is true for x, that is, x is the sum of the squares of four integers,
then x must be at least 4.
Statement Justification
1. x=a2+b2+c2+d2 Given
2. a≥1,b≥1,c≥1,d≥1 Given
3. a2≥1,b2≥1,c2≥1,d2≥1 Follows statement 2
4. x ≥ 4 Follows statement 1 and 3
5. 2x ≥x2 Follows statement 4
Step 1:
Let a, b, c and d is the names of the four integers. One of the given statements of
the theorem says x is the sum of the squares of four integers.
Step 2:
This statement represents four distinct statements, one of the four integers
involved. Each values being squared must be at least 1.
Step 3:
Step 4:
Step 5:
In the final step, we use the statement 4. Theorem 1 is the justification for writing
down its conclusion since its hypothesis is a previous statement.
Reduction to Definition:
If you are not sure how to start the proof, convert all terms in the hypothesis to
their definitions.
Example:
Definition 1:
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
the set S.
Definition 2:
Theorem 3:
Let S be a finite subset of some infinite set U. let T be the compliment of S with
respect to U. Then T is infinite.
1. H implies C
2. H only if C
3. C if H
4. Whenever H holds, C follows
Example:
1. x ≥ 4 implies 2x ≥x2
2. x ≥ 4only if 2x ≥x2
3. 2x ≥x2 if x ≥ 4
4. Whenever x ≥ 4, 2x ≥x2 follows.
Example:
Proof by Contrapositive:
The contrapositive of a conditional statements is formed by negating both the
hypothesis and the conclusion and then interchanging the resulting negations.
Ex: p→q
Theorem:
Conditional: For any real numbers a, b, if ab=0 then either a=0 or b=0.
Contrapositive: For any real numbers a, b, if a is not 0 and b is not 0, then ab is not 0.
Proof by Contradiction:
That is start by assuming both the hypothesis H and the negation of the conclusion
C
Complete the proof by showing that something known to be false follows logically
from H to not C. This form of proof is called as proof by contradiction.
Theorem:
To prove for any sets A, B, and C if A∩B = ϕ and C subset B and A∩C ≠ ϕ.
Therefore there exists x with x Є A∩C, then x Є A and x Є C.
In order to prove certain statement, we need to see all possible conditions in which
that statement remains rue. There are some situations n which the statement cannot be
true.
Theorem:
Thus the given pairs is true for any pairs of integers but if a=b then naturally a
mod b = b mod a.
Thus we need to change the statement slightly, we can say a mod b = b mod a
when a = b.
If E and F are two expressions representing sets, the statement E=F means that the
two sets represented are the same.
Example 1:
The commutative law of union says that we can take the union of two sets R and S
in either order.
That is R∪S=S∪R
In this case E is the expression R∪S and F is the expression S∪R.
The commutative law of union says that E = F.
Theorem:
R∪(S∩T)=(R∪S) ∩ (R∪T)
Proof:
In the ‘if’ part we assume element x is in E and show it is in F. Steps in ‘if part’ are as
follows:
Step No. Statement Justification
1 x is in R∪(S∩T) Given
2 x is in R or x is in S∩T (1) and definition of union
3 x is in R or x is in S and T (2) and definition of intersection
4 x is in R∪S (3) and definition of union
5 x is in R∪T (3) and definition of union
6 x is in (R∪S) ∩ (R∪T) (4), (5) and definition of intersection
Since we have now proved both parts of the if-and-only-if statement, the distributive law
of union over intersection is proved.
Inductive Proofs:
There is a special form of proof called inductive ie) essential when dealing with
recursively defined objects.
Many of the most familiar inductive proofs deals with integers, but in automata
theory we also need inductive proofs about such recursively defined concepts as
trees and expression of various sorts such as regular expressions.
Induction on Integers:
Steps:
Step 1:
The basis where we show s(i) for a particular integer c. Usually i=0
or i=1.
Step 2:
///////////////////////////////
Example 1:
𝑛(𝑛+1)
Prove by mathematical induction 1+2+3+…+n=
2
Proof:
1. Basis of induction:
L.H.S = 1
2. By Induction hypothesis:
𝑘(𝑘+1)
For every k > 0, 1+2+3+… + k =
2
L.H.S
𝑘(𝑘+1)
1+2+3+… + k + (k+1) = + (k+1)
2
𝑘
= (k+1) [ +1]
2
𝑘+2
= (k+1) [ ]
2
(𝑘+1)(𝑘+2) (𝑘+1)(𝑘+1+1)
= [∵ ]
2 2
= R.H.S
Example 2:
𝑛(𝑛+1)(2𝑛+1)
Prove by mathematical induction ∑𝑛𝑖=1 𝑖 2 =
6
[∴ ∑𝒏𝒊=𝟏 = 12+22+32+…+n2]
Proof:
1. Basis:
n=1
L.H.S = 12=1.
𝑛(𝑛+1)(2𝑛+1) 1(1+1)(2∗1+1)
R.H.S = =
6 6
1(2)(3)
= = 1.
6
L.H.S = R.H.S, given expression is true for n=1.
2. By induction Hypothesis:
𝑘(𝑘+1)(2𝑘+1)
For every k > 0, 12+22+32+…k2 = .
6
3. Statement to be shown in inductive step:
(𝑘+1)((𝑘+1)+1)(2(𝑘+1)+1)
12+22+32+…k2+(k+1)2 = .
6
L.H.S:
𝑘(𝑘+1)(2𝑘+1)
= +(k+1)2
6
𝑘(2𝑘+1)
= (k+1) [ +k+1]
6
𝑘(2𝑘+1)+6(𝑘+1)
= (k+1) [ ]
6
2𝑘 2 +𝑘+6𝑘+6
= (k+1) [ ]
6
2𝑘 2 +7𝑘+6
= (k+1) [ ]
6
2𝑘 2 +4𝑘+3𝑘+6
= (k+1) [ ]
6
2𝑘(𝑘+2)+3(𝑘+2)
= (k+1) [ ]
6
(𝑘+1)(2𝑘+2)
= (k+1) [ ]
6
(𝑘+1)+1 (2(𝑘+1)+1)
= (k+1) [ ]
6
(𝑘+1)(𝑘+1)+1 (2(𝑘+1)+1)
=
6
= R.H.S
Therefore P(k+1) is also true for every k > 0.
Example 3:
𝑛(3𝑛−1)
Prove that 1+4+7+… + (3n-2) = for n > 0.
2
Proof:
1. Basis of Induction:
n=1
L.H.S = 3(1) – 2
= 3-2=1
𝑛(3𝑛−1) 1(3(1)−1) 2
R.H.S = = = =1
2 2 2
Therefore L.H.S = R.H.S, given expression is true for n=1.
2. By induction hypothesis:
𝑘(3𝑘−1)
For every k >0, 1+4+7+…+ (3k-2) =
2
3. Statement to be shown in induction step:
(𝑘+1)(3(𝑘+1)−1)
1+4+7+…+(3k-2)+(3(k+1)-2) =
2
4. Proof of induction step:
L.H.S = 1+4+7+…+(3k-2)+(3(k+1)-2)
𝑘(3𝑘−1)
= + (3(k+1)) – 2, by induction hypothesis.
2
𝑘(3𝑘−1)+2(3(𝑘+1)−2)
=
2
3𝑘 2 −𝑘+2(3𝑘+3−2)
=
2
3𝑘 2 −𝑘+6𝑘+6−4
=
2
3𝑘 2 +5𝑘+2
= By factorization,
2
(𝑘+1)(3𝑘+2)
= 3𝑘 2 + 5𝑘 + 2 = 3𝑘 2 + 2𝑘 + 3𝑘 + 2
2
(𝑘+1)(3(𝑘+1)−1)
= =(2k+2)+3k(k+1) = 2(k+1) + 3k(k+1)
2
Example 4:
Proof:
1. Basis of Induction:
n=1
L.H.S = 6(1)+1 = 7
R.H.S = 1(3*1+4)
= 1(3+4) = 1(7)
=7
L.H.S = R.H.S
Therefore P(1) is true.
2. Induction Hypothesis:
For every k ≥ 1
7+13+19+…+ (6k+1) = k (3k+4)
P(k) is true.
3. Statement to be shown in induction step:
7+13+19+…+ (6k+1) + (6(k+1) +1)
= (k+1) (3(k+1) +4)
Therefore [(k+1) (3k+7)]
4. Proof of induction step:
L.H.S = 7+13+19+…+ (6k+1) +6(k+1) +1
Example 5:
1 𝑛
Prove by mathematical induction ∑𝑛𝑖=1 =
𝑖(𝑖+1) 𝑛+1
1 1 1 1 𝑛
i.e) + + +⋯+ =
1(2) 2(3) 3(4) 𝑛(𝑛+1) 𝑛+1
Proof:
1. Basis of induction:
n=1
1 1
L.H.S = =
1(1+1) 2
𝑛 1 1
R.H.S = = =
𝑛+1 1+1 2
∴ L.H.S = R.H.S
∴ P (1) is true.
2. Induction Hypothesis:
n=k
1 1 1 𝑘
for every k > 0, + + ⋯+ =
1(2) 2(3) 𝑘(𝑘+1) 𝑘+1
P(k) is true.
3. Statement to be shown in induction step:
1 1 1 1 𝑘+1
+ +⋯+ + =
1(2) 2(3) 𝑘(𝑘+1) (𝑘+1)((𝑘+1)+1) (𝑘+1)+1
4. Proof of induction step:
1 1 1 1 1 𝑘+1
+ + +⋯+ + (𝑘+1)((𝑘+1)+1) =
1(2) 2(3) 3(4) 𝑘(𝑘+1) 𝑘+1+1
1 1 1 1 1
L.H.S = + + + ⋯+ + (𝑘+1)((𝑘+1)+1)
1(2) 2(3) 3(4) 𝑘(𝑘+1)
𝑘 1
= + (𝑘+1)((𝑘+1)+1)
𝑘+1
𝑘(𝑘+1)((𝑘+1)+1)+(𝑘+1)
=
(𝑘+1)(𝑘+1)((𝑘+1)+1)
𝑘(𝑘+1)(𝑘+2)+(𝑘+1)
=
(𝑘+1)(𝑘+1)(𝑘+2)
𝑘(𝒌+𝟏)(𝑘+2)+(𝑘+1)
=
(𝒌+𝟏)(𝑘+1)(𝑘+2)
𝑘(𝑘+2)+1
= by factorization, k2+k+k+1
(𝑘+1)(𝑘+2)
k2 +2k+1
= =k (k+1) + (k+1) = (k+1) (k+1)
(𝑘+1)(𝑘+2)
(𝒌+𝟏)(𝑘+1)
=
(𝒌+𝟏)(𝑘+2)
𝑘+1
=
𝑘+1+1
= R.H.S
Example 6:
Proof:
∑𝑛𝑖=1 𝑖 ∗ 𝑖! = (n+1)! – 1
1. Basis of induction:
n=1
L.H.S = R.H.S
2. Induction Hypothesis:
n=k
P (k) is true.
= (k+2)! – 1 3! * 4 = 4!
= R.H.S
Alphabet:
Example:
String:
A string (or) word over an alphabet set ∑ is a finite sequence of symbols from ∑.
Example:
i) If ∑ = {a,b} then abab, aabba area all strings over the alphabet ∑ = {a,b}.
ii) If ∑ = {a} then a, aa, aaa, are all strings over the alphabet ∑ = {a}.
Operation on Integers:
Length of a String:
Let w be the string then “length of the string │w│ is the number of
symbols composing the string.
Example:
then wv=a1a2a3…amb1b2b3…bn.
Example:
Example:
If ∑ = {0, 1} then
∑2 = {00, 01, 10, 11} set of all string of length over ∑ = {0, 1}.
Kleen’s Closure:
Let ∑ be an alphabet, then “kleen’s closure ∑*” denotes the set of all
strings over the alphabet ∑ (includes ε, empty string).
Example:
i) If ∑ = {a} then ∑* = {ε,a,aa…}.
ii) If ∑ = {0,1} then ∑*={ε,0,1,00,11,10…}
iii) If ∑ = {0} then ∑* = {ε, 0, 00, 000…}
∑0= {ε}
∑1= {a}
∑2= {aa}
∴ ∑* = ∑0∪∑1∪∑2∪…
Substring:
A string v appears within another string w(w=uv) is called substring of w.
If w=uv, then substrings u and v are said to be prefix and suffix of w respectively.
Example:
i) w=abbab be a string over an alphabet ∑ = {a,b} then
a,ab,abb,ba,bab,… are all substrings of w.
ii) w=123
iii) w=abbab
Prefixes = {ε, a, ab, abb, abba, abbab}
Palindrome:
i) A palindrome is a string, which is same whether written forward or
backward.
Example:
madam, 121
ii) If the length of the palindrome is even, then it can be obtained by
concatenation of a string and its reverse.
Example:
If U = 10 and UR = 01 then even palindrome UUR=1001.
Properties of string operations:
i) Concatenation is associative, that is for all strings u,v, and w
(uv)w = u(vw).
ii) If u and v are strings then the length of their concatenation is the
sum of the individual length, i.e) │uv│=│u│+│v│.
Example:
xy = abc123
Languages:
For any alphabet ∑, any subset L of ∑* is a language. A set of strings from
an alphabet is called a language.
Example:
i) English: It is a language over ∑= {a,b,c,…z}.
ii) Binary string: {0, 1, 01, 0101 …} is a language over ∑ = {o,1}.
iii) If ∑={a,b} is a alphabet then ∑*={ε, a,b,aa,ab…} is a language.
Notations:
1. {λ} or {ε} : Empty string or Null string language. It is a language over
every alphabet and it contains exactly one string ε or λ.
Example:
{λ} or {ε} has one string λ or ε.
2. Φ: Empty language.
Example:
It contains no strings.
////////////////////////////
Kleene Star (or) Star Closure:
For a language L, L* = ⋃∞ 𝑖
𝑖=0 𝐿 (or) L* = L ∪L ∪L …
0 1 2
= L* - {λ}
Union:
The union of L1 and L2 denoted by L1∪L2 is
L1∪L2 = {w: wЄL1 or w Є L2}
Intersection:
The intersection of L1 and L2 denoted by L1 ∩ L2 is
L1∩ L2 = {w: wЄL1 and wЄL2}
Computation:
Function f
Input x Output y=f(x)
TOC suggests various abstract models of computation represented mathematically.
Applications:
i) Compiler Design
ii) Robotics
iii) Artificial intelligence
iv) Knowledge Engineering
Finite Automaton:
Definition 1: A finite automaton has a set of states and its control moves from state to
state in response to external inputs.
Examples:
push
off on
push
h e n
Start
t th the then
Definitions:
The automaton cannot be in more than one state at any one time.
(or)
(or)
The term “deterministic” refers to the fact that for one each input there is one and
only one state to which the automaton can transition from its current state.
1. Transition Diagram
Example:
{q0,0} = q0
{q0,1} = q1
{q1,0} = q0
{q1,1} = q2
{q2,0} = q2
{q2, 1} = q1
Transition table:
Input Symbols
State 0 1
q0 q0 q1
q1 q0 q2
q2 q2 q1
δ(q,ε) = q
for all string w and input a, δ(q,wa) = δ(δ(q,w),a)
Similarly δ(q,aw) = δ(δ(q,a),w)
The transition function δ can be extended to δ’ that operates on states and strings.
i.e) δ’(q, ε) = q.
δ'(q,wa)= δ(δ’(q,w),a).
δ(q,ε) = q
for all string w and input a, δ(q,wa) = δ(δ(q,w),a)
Similarly δ(q,aw) = δ(δ(q,a),w)
The transition function δ can be extended to δ’ that operates on states and strings.
i.e) δ’(q, ε) = q.
δ'(q,wa)= δ(δ’(q,w),a).
Solution:
δ(q,ε) = q
for all string w and input a, δ(q,wa) = δ(δ(q,w),a)
Similarly δ(q,aw) = δ(δ(q,a),w)
The transition function δ can be extended to δ’ that operates on states and strings.
i.e) δ’(q, ε) = q.
δ'(q,wa)= δ(δ’(q,w),a).
Example 1:
Design a FA which accepts the only input 101 over the input set ∑={0,1}.
start 1 0 1
S1 S2 S2 S3 S4 S4
Example 2:
Solution:
Any binary number ends with ‘0’ are always “even”. [0010 (2), 0100 (4)…]
When a binary number ends with ‘1’ it always “odd”. [0001 (1), 0011(3)].
0
0 q2
Start
q0 1
0
1 q1
1
For example consider the input string 0100 i.e) 4 (even number) is traversed as
0 1 0 0
q0 q2 q1 q2 *q2 Accepted
0 1 0 1
q0 q2 q1 q2 q1 Not Accepted
Transition Table:
Input
State
0 1
q0 q2 q 1
q1 q2 q 1
*q2 q2 q 1
Example 3:
Design FA which accepts only those strings which start with 1 and ends with 0.
Solution:
1 0
0
Start 1
q0 q1 q2
1
For example consider the string w=1000
1 0 0 0
q0 q1 q2 q2*q2 Accepted
1 0 0 1
q0 q1 q2 q2q1 Not Accepted
Example 4:
Design FA which accepts odd number of 1’s and any number of 0’s.
Solution: 0
1 q2
Start
q0 1 1
Consider the string 1011 (odd) which is accepted and 1010 (even) not accepted.
Example 5:
Solution:
Start 1 1 1
q0 q1 q2 q3
Transition Table:
Input
State
1
q0 q1
q1 q2
q2 q3
*q3 q1
Example 6:
Design DFA to accept the string that always ends with 00.
Solution:
1 0
Start 0 0
q0 q1 q2
1
Consider the string 101000,
1 0 1 0 0 0
q0 q0 q1 q0 q1 q2 q2 Accepted
1 0 1 0 0 1
q0 q0 q1 q0 q1 q2 q0 Not Accepted
Transition Table:
Input
State
0 1
q0 q1 q 0
q1 q2 q 0
*q2 q2 q 0
Example 7:
Construct the transition graph for a FA which accepts a language L over ∑ = {0,1}
in which every string starts with 0 and ends with 1.
0 1
Start 1
0
q0 q1 q2
1
0
q3 Dead state
0,1
Example 8:
Design a DFA for accepting all the strings of {L=0m1n | m ≥ 0, n ≥ 0}
Solution:
0 1
Start 1
Transition Table: q0 q1
Input
State
0 1
q0 q0 q 1
*q1 - q1
Example 9:
Solution:
a
b
Start a a
q0 q1 q2
b
b
q3
a,b
Example 10:
i. (ab)n with n ≥ 0
ii. (ab)n with n ≥ 1
i) (ab)n with n ≥ 0
a
Start
q0 q1
b
ii) (ab)n with n ≥ 1
Start a b
q0 q1 q2
Example 11: a
Input
State
0 1
q0 q1 q 0
q1 q2 q 0
*q2 q2 q 0
Check whether the input string 101000 is accepted or not?
Solution:
δ'(q0,ε) = q0\
δ'(q0,1) = δ(δ'(q0,ε),1)
= δ(q0,1) = q0
δ'(q0,10) = δ(δ'(q0,1),0)
= δ(q0,0) = q1
δ'(q0,101) = δ(δ'(q0,10),1)
= δ(q1,1) = q0
δ'(q0,1010) = δ(δ'(q0,101),0)
= δ(q0,0) = q1
δ'(q0,10100) = δ(δ'(q0,1010),0)
= δ(q1,0) = q2
δ'(q0,101000) = δ(δ'(q0,10100),0)
= δ(q2,0) = q2
Example 12:
Input
State
0 1
q0 q2 q 1
q1 q2 q 1
*q2 q2 q 1
Check whether the input strings 0100 and 0101 are accepted or not.
Solution:
δ'(q0,ε) = q0
δ'(q0,0) = δ(δ'(q0,ε),0)
= δ(q0,0) = q2
δ'(q0,01) = δ(δ'(q0,0),1)
= δ(q2,1) = q1
δ(δ'(q0,010) = δ(δ'(q0,01),0)
= δ(q1,0) = q2
δ(δ'(q0,0100) = δ(δ'(q0,010),0)
= δ(q2,0) = q2
δ'(q0,ε) = q0
δ'(q0,0) = δ(δ'(q0,ε),0)
= δ(q0,0) = q2
δ'(q0,01) = δ(δ'(q0,0),1)
= δ(q2,1) = q1
δ'(q0,010) = δ(δ'(q0,01),0)
= δ(q1,0) = q2
δ'(q0,0101) = δ(δ'(q0,010),1)
= δ(q2,1) = q1
q1 is not the final state. Hence the given string 0101 is not accepted.
An NFA has a finite set of states, a finite set of input symbols, one start state and
set of accepting states.
The difference between the DFA and the NFA is in the type of δ
i) For the NFA, δ is a function that takes a state and an input symbol as
arguments, but returns a set of zero, one or more states.
δ (q,a) = {p,q}
Ex: δ (q0,a) = {q1,q2}
ii) For the DFA, δ is a function returns only one state.
δ (q,a) = {ps}
Ex: δ (q0,a) = {q1}
NFA:
0,1
Start 0 1
q0 q1 q2
The non deterministic finite automata (NFA) is defined by a five tuple notation
(Q, ∑, δ, S, F) where
Transition Diagram:
0,1
Start 0 1
q0 q1 q2
Transition Table is
Input
State
0 1
q0 { q0q1} {q1}
q1 φ {q1}
*q2 φs φ
Induction:
Suppose w is of the form w=xa, where a is the final symbol of w and x is the rest
of w.
Also suppose that δ’(q,x) = {p1,p2,…,pk}.
Let
Example:
0,1
Start 0 1
q0 q1 q2
Let us use δ’ to describe the process of input 00101 by the above NFA.
δ’(q0,ε) = {q0}
δ’(q0,00) = δ((q0,0),0)
= δ({q0,q1},0)
= δ(q0,0) ∪ δ(q1,0)
= {q0,q1} ∪ φ
= {q0,q1}
Finite Automata with Epsilon-Transition:
Introduction:
The ε-transitions in NFA are given in order to move from one state to another
without having any symbol from input set ∑.
Example:
2
0 1
In this NFA with ε, q0 is a start state with input 0; one can either be in state q0 or in
state q1.
If we get at the start a symbol 1, then with ε-move we can change state from q0 to
q1 and then input we can be in state q1.
For example, the string w=002 is accepted by the NFA along the path q0, q0, q0, q1,
q2, q2 with labelled 0, 0, ε, ε, 2.
Definition (or) Formal notation for an ε-NFA:
The language accepted by NFA with ε denoted by M = (Q, ∑, δ, q0, F) can
be defined as follows:
Let
M= (Q, ∑, δ, q0, F) be a NFA with ε where,
Q is a finite set of states
∑ is input symbols
δ is a transition function for transition from Q X { ∑ ∪ ε } to 2Q
q0 is a start state.
F is a set of final states such that F ⊆ Q.
The string w is accepted by NFA can be represented as
L(M) = {w | w ⊆ ∑* and δ transition for w from q0 reaches to F}
Example:
Construct NFA with ε which accepts a language consisting the strings of
any number of a’s followed by any number of b’s followed by any number of c’s.
Solution:
a b c
Start ε ε
q0 q1 q2
Transition Table:
input
State
a b c ε
q0 q0 φ φ q1
q1 φ q1 φ q2
*q2 φ φ q2 φ
Example:
0 1 2
Start ε ε
q0 q1 q2
Transition diagram
Input
State
0 1 2 ε
q0 q0 φ φ q1
q1 φ q1 φ q2
*q2 φ φ q2 φ
The ε-CLOSURE(q0) = { q0, q1, q2}. i.e) the path consisting of q0 along is a path
from q0 to q2 with all arcs labelled ε.
The path from q0 to q1 labelled ε shows that q0 is in ε-CLOSURE(q0) and path q0 ,
q1, q2 shows q2 is in ε-CLOSURE(q0).
ε-CLOSURE definition:
Example:
ε ε
2 3 6
ε
1
b
4 5 7
a ε
ε-closure(1) = {1,2,4,3,6}={1,2,3,4,6}
ε-closure(2) = {2,3,6}
ε-closure(5) = {5,7}
Example:
Start ε ε
q0 q1 q2
Solution:
Thus
= ε-closure(ẟ({q0,q1,q2},0))
= ε-closure(ẟ(q0,0)∪ẟ(q1,0) )∪ ẟ(q2,0)
= ε-closure({q0}∪{φ}∪{φ})
= ε-closure({q0})
Then
= ε-closure(ẟ({q0,q1,q2},1))
= ε-closure(ẟ(q0,1)∪ẟ(q1,1) )∪ ẟ(q2,1)
= ε-closure({φ}∪{q1}∪{φ})
= ε-closure({q1})
= {q1, q2}
Since ẟ(q0,01) = {q1, q2} which contains final state {q2}, it is an accepting string.
1. Find out all the ε transitions from each state from Q. That will be called as ε-
closure({qi}).
2. Then ẟ' transitions can be obtained. The ẟ' transitions means ε-closure on ẟ moves.
3. Step 2 is repeated for each input symbol and for each state of given NFA.
4. Using the resultant states the transition table for equivalent NFA without ε can be
built.
Example 1:
0 1 2
Start ε ε
q0 q1 q2
ε-closure(q2) = {q2}
= ε-closure(ẟ(ε-closure(q0),0)
= ε-closure(ẟ(q0,0)∪ẟ(q1,0) ∪ ẟ(q2,0))
= ε-closure(q0 ∪ φ ∪ φ)
= ε-closure(q0)
= ε-closure(ẟ(ε-closure(q0),1)
= ε-closure(ẟ(q0,1)∪ẟ(q1,1) ∪ẟ(q2,1))
= ε-closure(φ ∪ q1 ∪ φ)
= ε-closure(q1)
= {q1, q2}
= ε-closure(ẟ(ε-closure(q0),2)
= ε-closure(ẟ(q0,2)∪ẟ(q1,2) ∪ẟ(q2,2))
= ε-closure(φ ∪ φ ∪ q2)
= ε-closure(q2)
= {q2}
= ε-closure(ẟ(ε-closure(q1),0)
= ε-closure(ẟ({q1, q2}),0)
= ε-closure(φ ∪ φ)
= ε-closure(φ)
=φ
ẟ'(q1,1) = ε-closure(ẟ(ẟ'(q1, ε),1)
= ε-closure(ẟ(ε-closure(q1),1)
= ε-closure(ẟ({q1, q2}),1)
= ε-closure(q1 ∪ φ)
= ε-closure(q1)
= {q1,q2}
= ε-closure(ẟ(ε-closure(q1),2)
= ε-closure(ẟ({q1, q2}),2)
= ε-closure(φ ∪q2)
= ε-closure(q2)
= {q2}
= ε-closure(ẟ(ε-closure(q2),0)
= ε-closure(ẟ(q2,0))
= ε-closure(φ)
=φ
= ε-closure(ẟ(ε-closure(q2),1)
= ε-closure(ẟ(q2,1))
= ε-closure(φ)
=φ
ẟ'(q2,2) = ε-closure(ẟ(ẟ'(q2, ε),2)
= ε-closure(ẟ(ε-closure(q2),2)
= ε-closure(ẟ(q2,2))
= ε-closure(q2)
= {q2}
Therefore,
ẟ'(q0,1)= φ
ẟ'(q0,2)= φ
ẟ'(q1,2)= φ
ẟ'(q2,0)= {q2}
ẟ'(q2,1)= {q2}
ẟ'(q2,2)= {q2}
Transition Table:
Input
State
0 1 2
*q0 {q0, q1, q2} {q1, q2} {q2}
*q1 φ {q1, q2} {q2}
*q2 φ φ {q2}
0,1
q0 q1
0,1,2 1,2
q2
Here q0,q1 and q2 are the final state because ε-closure(q0), ε-closure(q1) and ε-closure(q2)
contains final state q2.
Exercise Problems:
4 5
a ε
ε
Start a b ε ε
0 1 2 3 8 9
b
ε 6 7 ε
Start
q0 a ε q2
q1
q0 ε ε
q1 q2
MD = (QD,∑,ẟD,q0,FD)
Then obtain,
Step 2:
Step 3:
The state obtained [p1,p2,...pn] ϵ QD. The state containing in pi is a final state in
DFA.
Example:
b a
ε
Start ε q2
q0 q1
b
Solution:
Input
State
a b c
-> q0 φ q0 q1
q1 q1 φ q2
*q2 q1 q0 φ
Step 1:
ε-closure(q0) = {q0,q1,q2}
ε-closure(q1) = {q1,q2}
ε-closure(q2) = {q2}
Step 2:
Find new states, here {q0,q1,q2} and {q1,q2} are new states, so find ẟ transition of
every input symbols.
{q0,q1,q2} ------------> A
{q1,q2} ------------> B
ẟ'(A,a) = ε-closure(ẟ(A,a))
= ε-closure(ẟ({q0,q1,q2}),a)
= ε-closure(ẟ(q0,a)∪ẟ(q1,a)∪ẟ(q2,a))
= ε-closure(q1)
ẟ'(A,b) = ε-closure(ẟ(A,b))
= ε-closure(ẟ({q0,q1,q2}),b)
= ε-closure(ẟ(q0,b)∪ẟ(q1,b)∪ẟ(q2,b))
= ε-closure(q0∪φ∪ q0)
= ε-closure(q0)
ẟ'(B,a) = ε-closure(ẟ(B,a))
= ε-closure(ẟ({q1,q2}),a)
= ε-closure(ẟ(ẟ(q1,a)∪ẟ(q2,a))
= ε-closure(q1∪ q1)
= ε-closure(q1)
ẟ'(B,b) = ε-closure(ẟ(B,b))
= ε-closure(ẟ({q1,q2}),b)
= ε-closure(ẟ(ẟ(q1,b)∪ẟ(q2,b))
= ε-closure(φ∪ q0)
= ε-closure(q0)
Step 3:
Transition Table:
Input
State
a b
->*A B A
*B B A
b a
a
A B
b
Example 2:
0 1 2
Start ε ε
q0 q1 q2
Solution:
Input
State
0 1 2 ε
->q0 q0 φ φ q1
q1 φ q1 φ q2
*q2 φ φ q2 φ
Step 1:
Step 2:
ẟ'(A,0) = ε-closure(ẟ(A,0))
= ε-closure(ẟ({q0,q1,q2}),0)
= ε-closure(ẟ(q0,0)∪ẟ(q1,0)∪ẟ(q2,0))
= ε-closure(q0∪ φ∪ φ)
= ε-closure(q0)
ẟ'(A,1) = ε-closure(ẟ(A,1))
= ε-closure(ẟ({q0,q1,q2}),1)
= ε-closure(ẟ(q0,1)∪ẟ(q1,1)∪ẟ(q2,1))
= ε-closure(φ∪q1∪ φ)
= ε-closure(q1)
ẟ'(A,2) = ε-closure(ẟ(A,2))
= ε-closure(ẟ({q0,q1,q2}),2)
= ε-closure(ẟ(q0,2)∪ẟ(q1,2)∪ẟ(q2,2))
= ε-closure(φ∪ φ ∪ q2)
= ε-closure(q2)
ẟ'(B,0) = ε-closure(ẟ(B,0))
= ε-closure(ẟ({q1,q2}),0)
= ε-closure(ẟ(q1,0)∪ẟ(q2,0))
= ε-closure(φ∪ φ)
= ε-closure(φ)
ẟ'(BS,0) = { φ }
ẟ'(B,1) = ε-closure(ẟ(B,1))
= ε-closure(ẟ({q1,q2}),1)
= ε-closure(ẟ(q1,1)∪ẟ(q2,1))
= ε-closure({q1} ∪ φ)
= ε-closure({q1})
ẟ'(B,2) = ε-closure(ẟ(B,2))
= ε-closure(ẟ({q1,q2}),2)
= ε-closure(ẟ(q1,2)∪ẟ(q2,2))
= ε-closure(φ ∪ {q2})
= ε-closure({q2})
ẟ'(C,0) = ε-closure(ẟ(C,0))
= ε-closure(ẟ({q2}),0)
= ε-closure(φ)
ẟ'(C,0) = { φ }
ẟ'(C,1) = ε-closure(ẟ(C,1))
= ε-closure(ẟ({q2}),1)
= ε-closure(φ)
ẟ'(C,1) = { φ }
ẟ'(C,2) = ε-closure(ẟ(C,2))
= ε-closure(ẟ({q2}),2)
= ε-closure({q2})
Step 3:
Transition table:
Input
State
0 1 2
->*A A B C
*B φ B C
*C φ φ C
Transition Diagram:
0 1
Start 1
A B
C
Exercise Problems:
q1
0
ε
Start 1
q0 q3 q4
ε 1
q2
Input
State
a b c ε
->p {p} {q} {r} φ
Q {q} {r} φ {p}
*r {r} φ {p} {q}
Theorem:
Proof:
Suppose
Theorem:
In ε-NFA, and ' are same and in NFA and ' are different.
Let x be any string (q0,x) = '(q0,x) and '(q0, ε) = ε-closure(q0).
Basic step:
Induction Step:
= '((q0,w) ,a)
= '(p,a)
= ’(’(q0,w),a)
= ’(q0,wa)
= ’(q0,x)
Introduction:
The ε-transitions in NFA are given in order to move from one state to another
without having any symbol from input set ∑.
Example:
2
0 1
In this NFA with ε, q0 is a start state with input 0; one can either be in state q0 or in
state q1.
If we get at the start a symbol 1, then with ε-move we can change state from q0 to
q1 and then input we can be in state q1.
For example, the string w=002 is accepted by the NFA along the path q0, q0, q0, q1,
q2, q2 with labelled 0, 0, ε, ε, 2.
Definition (or) Formal notation for an ε-NFA:
The language accepted by NFA with ε denoted by M = (Q, ∑, δ, q0, F) can
be defined as follows:
Let
M= (Q, ∑, δ, q0, F) be a NFA with ε where,
Q is a finite set of states
∑ is input symbols
δ is a transition function for transition from Q X { ∑ ∪ ε } to 2Q
q0 is a start state.
F is a set of final states such that F ⊆ Q.
The string w is accepted by NFA can be represented as
Start ε ε
q0 q1 q2
Transition Table:
input
State
a b c ε
q0 q0 φ φ q1
q1 φ q1 φ q2
*q2 φ φ q2 φ
0 1 2
Start ε ε
q0 q1 q2
Transition diagram
Input
State
0 1 2 ε
q0 q0 φ φ q1
q1 φ q1 φ q2
*q2 φ φ q2 φ
The ε-CLOSURE(q0) = { q0, q1, q2}. i.e) the path consisting of q0 along is a path
from q0 to q2 with all arcs labelled ε.
The path from q0 to q1 labelled ε shows that q0 is in ε-CLOSURE(q0) and path q0 ,
q1, q2 shows q2 is in ε-CLOSURE(q0).
ε-CLOSURE definition:
Example:
ε ε
2 3 6
ε
1
b
4 5 7
a ε
ε-closure(1) = {1,2,4,3,6}={1,2,3,4,6}
ε-closure(2) = {2,3,6}
ε-closure(5) = {5,7}
Example:
0 1 2
Start ε ε
q0 q1 q2
Solution:
Thus
= ε-closure(ẟ({q0,q1,q2},0))
= ε-closure(ẟ(q0,0)∪ẟ(q1,0) )∪ ẟ(q2,0)
= ε-closure({q0}∪{φ}∪{φ})
= ε-closure({q0})
Then
= ε-closure(ẟ({q0,q1,q2},1))
= ε-closure(ẟ(q0,1)∪ẟ(q1,1) )∪ ẟ(q2,1)
= ε-closure({φ}∪{q1}∪{φ})
= ε-closure({q1})
= {q1, q2}
Since ẟ(q0,01) = {q1, q2} which contains final state {q2}, it is an accepting string.
1. Find out all the ε transitions from each state from Q. That will be called as ε-
closure({qi}).
2. Then ẟ' transitions can be obtained. The ẟ' transitions means ε-closure on ẟ moves.
3. Step 2 is repeated for each input symbol and for each state of given NFA.
4. Using the resultant states the transition table for equivalent NFA without ε can be
built.
Example 1:
0 1 2
Start ε ε
q0 q1 q2
= ε-closure(ẟ(ε-closure(q0),0)
= ε-closure(ẟ(q0,0)∪ẟ(q1,0) ∪ ẟ(q2,0))
= ε-closure(q0 ∪ φ ∪ φ)
= ε-closure(q0)
= ε-closure(ẟ(ε-closure(q0),1)
= ε-closure(ẟ(q0,1)∪ẟ(q1,1) ∪ẟ(q2,1))
= ε-closure(φ ∪ q1 ∪ φ)
= ε-closure(q1)
= {q1, q2}
= ε-closure(ẟ(ε-closure(q0),2)
= ε-closure(ẟ(q0,2)∪ẟ(q1,2) ∪ẟ(q2,2))
= ε-closure(φ ∪ φ ∪ q2)
= ε-closure(q2)
= {q2}
= ε-closure(ẟ({q1, q2}),0)
= ε-closure(φ ∪ φ)
= ε-closure(φ)
=φ
= ε-closure(ẟ(ε-closure(q1),1)
= ε-closure(ẟ({q1, q2}),1)
= ε-closure(q1 ∪ φ)
= ε-closure(q1)
= {q1,q2}
= ε-closure(ẟ(ε-closure(q1),2)
= ε-closure(ẟ({q1, q2}),2)
= ε-closure(φ ∪q2)
= ε-closure(q2)
= {q2}
= ε-closure(ẟ(ε-closure(q2),0)
= ε-closure(ẟ(q2,0))
= ε-closure(φ)
=φ
= ε-closure(ẟ(ε-closure(q2),1)
= ε-closure(ẟ(q2,1))
= ε-closure(φ)
=φ
= ε-closure(ẟ(ε-closure(q2),2)
= ε-closure(ẟ(q2,2))
= ε-closure(q2)
= {q2}
Therefore,
ẟ'(q0,1)= φ
ẟ'(q0,2)= φ
ẟ'(q1,2)= φ
ẟ'(q2,0)= {q2}
ẟ'(q2,1)= {q2}
ẟ'(q2,2)= {q2}
Transition Table:
Input
State
0 1 2
*q0 {q0, q1, q2} {q1, q2} {q2}
*q1 φ {q1, q2} {q2}
*q2 φ φ {q2}
0,1
q0 q1
0,1,2 1,2
q
Here q0,q1 and q2 are the final state because
2
ε-closure(q0), ε-closure(q1) and ε-closure(q2)
contains final state q2.
2
Exercise Problems:
4 5
a ε
ε
Start a b ε ε
0 1 2 3 8 9
b
ε 6 7 ε
Start
q0 a ε q2
q1
q0 ε ε
q1 q2
a
Conversion of NFA with ε to DFA
Step 1:
MD = (QD,∑,ẟD,q0,FD)
Then obtain,
Step 2:
Step 3:
The state obtained [p1,p2,...pn] ϵ QD. The state containing in pi is a final state in
DFA.
Example:
b a
ε
Start ε q2
q0 q1
b
Solution:
Input
State
a b c
-> q0 φ q0 q1
q1 q1 φ q2
*q2 q1 q0 φ
Step 1:
ε-closure(q0) = {q0,q1,q2}
ε-closure(q1) = {q1,q2}
ε-closure(q2) = {q2}
Step 2:
Find new states, here {q0,q1,q2} and {q1,q2} are new states, so find ẟ transition of
every input symbols.
{q0,q1,q2} ------------> A
{q1,q2} ------------> B
ẟ'(A,a) = ε-closure(ẟ(A,a))
= ε-closure(ẟ({q0,q1,q2}),a)
= ε-closure(ẟ(q0,a)∪ẟ(q1,a)∪ẟ(q2,a))
= ε-closure(q1)
ẟ'(A,b) = ε-closure(ẟ(A,b))
= ε-closure(ẟ({q0,q1,q2}),b)
= ε-closure(ẟ(q0,b)∪ẟ(q1,b)∪ẟ(q2,b))
= ε-closure(q0∪φ∪ q0)
= ε-closure(q0)
ẟ'(B,a) = ε-closure(ẟ(B,a))
= ε-closure(ẟ({q1,q2}),a)
= ε-closure(ẟ(ẟ(q1,a)∪ẟ(q2,a))
= ε-closure(q1∪ q1)
= ε-closure(q1)
ẟ'(B,b) = ε-closure(ẟ(B,b))
= ε-closure(ẟ({q1,q2}),b)
= ε-closure(ẟ(ẟ(q1,b)∪ẟ(q2,b))
= ε-closure(φ∪ q0)
= ε-closure(q0)
Step 3:
Transition Table:
Input
State
a b
->*A B A
*B B A
b a
a
A B
b
Example 2:
0 1 2
Start ε ε
q0 q1 q2
Solution:
Input
State
0 1 2 ε
->q0 q0 φ φ q1
q1 φ q1 φ q2
*q2 φ φ q2 φ
Step 1:
Step 2:
ẟ'(A,0) = ε-closure(ẟ(A,0))
= ε-closure(ẟ({q0,q1,q2}),0)
= ε-closure(ẟ(q0,0)∪ẟ(q1,0)∪ẟ(q2,0))
= ε-closure(q0∪ φ∪ φ)
= ε-closure(q0)
ẟ'(A,1) = ε-closure(ẟ(A,1))
= ε-closure(ẟ({q0,q1,q2}),1)
= ε-closure(ẟ(q0,1)∪ẟ(q1,1)∪ẟ(q2,1))
= ε-closure(φ∪q1∪ φ)
= ε-closure(q1)
ẟ'(A,2) = ε-closure(ẟ(A,2))
= ε-closure(ẟ({q0,q1,q2}),2)
= ε-closure(ẟ(q0,2)∪ẟ(q1,2)∪ẟ(q2,2))
= ε-closure(φ∪ φ ∪ q2)
= ε-closure(q2)
ẟ'(B,0) = ε-closure(ẟ(B,0))
= ε-closure(ẟ({q1,q2}),0)
= ε-closure(ẟ(q1,0)∪ẟ(q2,0))
= ε-closure(φ∪ φ)
= ε-closure(φ)
ẟ'(BS,0) = { φ }
ẟ'(B,1) = ε-closure(ẟ(B,1))
= ε-closure(ẟ({q1,q2}),1)
= ε-closure(ẟ(q1,1)∪ẟ(q2,1))
= ε-closure({q1} ∪ φ)
= ε-closure({q1})
ẟ'(B,2) = ε-closure(ẟ(B,2))
= ε-closure(ẟ({q1,q2}),2)
= ε-closure(ẟ(q1,2)∪ẟ(q2,2))
= ε-closure(φ ∪ {q2})
= ε-closure({q2})
ẟ'(C,0) = ε-closure(ẟ(C,0))
= ε-closure(ẟ({q2}),0)
= ε-closure(φ)
ẟ'(C,0) = { φ }
ẟ'(C,1) = ε-closure(ẟ(C,1))
= ε-closure(ẟ({q2}),1)
= ε-closure(φ)
ẟ'(C,1) = { φ }
ẟ'(C,2) = ε-closure(ẟ(C,2))
= ε-closure(ẟ({q2}),2)
= ε-closure({q2})
Step 3:
Transition table:
Input
State
0 1 2
->*A A B C
*B φ B C
*C φ φ C
Transition Diagram:
0 1
Start 1
A B
Exercise Problems: C
ε 1
q2
Input
State
a b c ε
->p {p} {q} {r} φ
Q {q} {r} φ {p}
*r {r} φ {p} {q}
Theorem:
Proof:
Suppose
In ε-NFA, and ' are same and in NFA and ' are different.
Basic step:
Induction Step:
= '((q0,w) ,a)
= '(p,a)
= ’(’(q0,w),a)
= ’(q0,wa)
= ’(q0,x)
Hence, (q0,x) = ’(q0,x).