You are on page 1of 48

UNIT - I

FINITE AUTOMATA
Lecture Notes

UNIT I FINITE AUTOMATA

Computation:

· Computation is a general term for any type of information processing.

·It is a process following a well defined model that is understood and can be

expressed in an algorithm, protocol network topology etc.,


· It is also a major subject matter of computer science, it investigates what can
or cannot be done in a computational manner.

Classes of Computation:

Computation can be classified as follows:

• Digital Vs Analog
• Sequential Vs Parallel Vs Concurrent
• Batch Vs interactive

Computation as Physical Phenomenon:

A computation can be seen as a purely physical phenomenon occurring


inside a closed “physical system” called a computer.

Mathematical model of Computation

In the theory of Computation, a diversity of mathematical models of


computers has been developed.
1. State models including-Turing Machine, Push Down Automata, Finite
Automata

2. Functional models including-Lambda calculus


3. Logical models including Logic programming
4. Concurrent models including Actor model
Lecture Notes

Automata
Definition 1
An open-ended computer science discipline that concerns an abstract device
called an automaton, which performs a specific and recognition function.

Definition 2

A formal system that represents a machine that acts according to given


specification. Automata Theory is the study of abstract computing devices
which are closely related to today’s computers.

Applications of Automata Theory

1. It plays important role in compiler design.

2. To prove the correctness of the program automata theory is used.

3 Switching theory and design and analysis of digital circuits automata theory is
applied.

Languages and Automata


Introduction to Formal proof

Statements:
If H then C – If Hypothesis then Conclusion

H iff C – Hypothesis if and only if Conclusion

If H then C – Assume H and prove C

If C then H – Assume C and prove H

Interpretation of Statements:

An “If H then C” statement is typically expressed as:


H⇒C or H implies C

The logic truth table for implication is:

H C H⇒C (i.e. ¬H V C)
F F T
F T T
T F F
T T T

If and Only If statements, e.g. “If and only if H then C” means that H ⇒ C and

C ⇒ H.

Sometimes this will be written as

H ⇔ C or “H iff C”.

The truth table is:

H C H ⇔ C (i.e. H equals C)
F F T
F T F
T F F
T T T
Basic Proofs:
1. Deductive proof
2. Contra-positive proof
3. Contradiction based proof
4. Induction
• Mathematical
• Structural
• Mutual

Deductive Proof:

A deductive proof consists of a sequence of statement whose truth leads us


from some initial statement (hypothesis or given statements) to a conclusion
statement.

• Each step of a deductive proof MUST follow from a given fact or previous
statements (or their combinations) by an accepted logical principle.

•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 .

Here, H is x > 4 and C is 2x > x2

Intuitive deductive proof


Each time x increases by one, the left-hand side doubles in size.

However, the right side increases by the ratio ((x+1)/x)2.

When x=4, this ratio is 1.56.


As x increases and approaches infinity, the ratio ((x+1)/x)2 approaches 1.

This means the ratio gets smaller as x increases.

Consequently, 1.56 is the largest that the right-hand side will increase.

Since 1.56 < 2, the left side is increasing faster than the right side
Theorem 2:

If x is the sum of the squares of four positive integers, then 2 x ≥ x2.

Statement Justification

1. If x ≥ 4, then 2x ≥ x2 Given theorem

2. x = a2 + b2 + c2 + d2 Given

3. a ≥ 1, b ≥ 1, c ≥ 1, d ≥ 1 Given

4. a 2 ≥ 1, b2 ≥ 1, c2 ≥ 1, d2 ≥ 1 From (3) and principle of arithmetic

5. x ≥ 4 From (2), (4) and principle of arithmetic

6. 2 x ≥ x2 From (1) and (5)

Reductions to Theorems:

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.

Original Statement New Statement

S is finite There is a integer n such that ║S║= n

U is infinite For no integer p, is ║U║= p

T is the complement of S S U T = U and S ∩ T = Φ

Proof:

Since S and T are complements, and their union is an infinite set, and given S is
finite, T has to be infinite in order to satisfy this

║S║ + ║T║= ║U║

n+x=∞

Therefore x = ∞
If-And-Only-If Statements :
Let x be a real number. Then floor of x is the same as ceiling of x iff x is an integer

If x is an integer, then floor of x is the same as ceiling of x

If floor of x is the same as ceiling of x then x is an integer

Sometimes theorems contain if-and-only-if statements.

• A if and only if B
• A iff B
• A is equivalent to B

In this case we must prove in both directions. In order to prove A if and only if B,
we must prove the following two statements:

1. If-Part: if B then A

2. Only-If-Part: if A then B

A Sample iff Theorem: Let x be a real number. Then ⎣x⎦= ⎡x⎤ if and only if x
is an integer.

Note:

⎣x⎦ is the floor of real number x is the greatest integer equal to or less than x

⎡x⎤ is the ceiling of real number x is the least integer equal to or greater than x.

Let x be a real number. Then ⎣x⎦= ⎡x⎤ if and only if x is an integer.

If-Part: Given that x is an integer.

By definitions of ceiling and floor operations. ⎣x⎦ = x and ⎡x⎤ = x . Thus, ⎣x⎦= ⎡x⎤.

Only-If-Part: Given that ⎣x⎦= ⎡x⎤ ,

By definitions of ceiling and floor operations. ⎣x⎦ ≤ x and ⎡x⎤ ≥ x .Since given that
⎣x⎦= ⎡x⎤, ⎡x⎤ ≤ x and ⎡x⎤ ≥ x. By the properties of arithmetic inequalities, ⎡x⎤ = x.
Since ⎡x⎤ is always an integer, x MUST be integer too.
Proof: Assume floor of x = ceiling of x – (0)
Prove: x is an integer
Using definitions of floor and ceiling
Floor of x is less than or equal to x (1)
Ceiling of x is greater than or equal to x (2)
But we know floor of x and ceiling of x are equal.
Substituting (0) in (2) we get
Ceiling of x is less than or equal to x (3)
From (3) and (1) we conclude ceiling of x is x
Similar corollary to prove floor of x is x.
Thus x is an integer Only if part
Assume x is integer.
By definition, when x is integer both floor and ceiling are equal to x

Proving Equivalences about Sets:

Rules about sets:

RUS=SUR
R U S=E
S U R =F
Commutative law says E = F
Prove:
An element x is in E iff x is in G
If x is in E then x is in F
If x is in F then x is in E

In order to prove two sets are equal ( S = T ), we have to prove that 1. If x is a


member of S, then x is also a member of T (S ⊆ T), and 2. If x is a member of T,
than x is also a member of S (T ⊆ S),

Theorem: R ∪ ( S ∩ T) = (R ∪ S) ∩ (R ∪ T)

We have to show that

1. If x is in R ∪ ( S ∩ T) , than x is in (R ∪ S) ∩ (R ∪ T), and

2. If x is in (R ∪ S) ∩ (R ∪ T), than x is in R ∪ ( S ∩ T).


Proof of R ∪ ( S ∩ T) = (R ∪ S) ∩ (R ∪ T)

Proof of If-Part:

Proof of R ∪ ( S ∩ T) = (R ∪ S) ∩ (R ∪ T)

Proof of Only-If-Part:

Contrapositive :

To prove “if H then C”, we would prove “if not C then not H”

For example, the assertion "If it is my car, then it is red" is equivalent to "If that
car is not red, then it is not mine".

To prove "If P, Then Q" by the method of contra positive means to prove "If Not
Q, Then Not P".
Example:

An integer x is called even (respectively odd) if there is another integer k for


which x = 2k (respectively 2k+1).

Two integers are said to have the same parity if they are both odd or both even.

Theorem. If x and y are two integers for which x+y is even, then x and y have
the same parity

Proof:

The contra positive version of this theorem is "If x and y are two integers with
opposite parity, then their sum must be odd."

Assume x and y have opposite parity.

Since one of these integers is even and the other odd, there is no loss of
generality to suppose x is even and y is odd.

Thus, there are integers k and m for which x = 2k and y = 2m+1. Then, we
compute the sum x+y = 2k + 2m + 1 = 2(k+m) + 1, which is an odd integer
by definition.

Proof by Contradiction:
Another way to prove a statement of the form “if H then C” is to prove the

statement. “H and not C implies falsehood”

In order create the proof: – 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 and not C

This form of proof is called proof by contradiction.


Example :

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:
Assume T is finite. S is also finite. Then compute union of S U T
S U T will be finite. But given that it is infinite.
Hence, our assumption that T is finite is a contradiction

Theorem : a mod b ≡b mod a iff a = b

Two parts
If a = b, then a mod b = b mod a
Assume a = b,
Hence, a mod a = b mod b = 0, then hypothesis
If a mod b ≡b mod a then a = b
Contradiction:
Assume a ≠ b, consider a < b and a > b
If a < b then a mod b = a (1)
And b mod a < a (2)
But given (1) and (2) are equal, hence contradiction
By symmetry, b < a will have
b mod a = b and a mod b < b.
Hence, a = b is the scenario

Contra positive vs. Contradiction :

Both methods are somewhat similar, but there is a primary difference

In contra positive, we assume ¬C and prove ¬H, given H=>C.

The method of Contrapositive has the advantage that your goal is clear:
Prove Not H.

In the method of Contradiction, your goal is to prove a contradiction, but


it is not always clear what the contradiction is going to be at the start.

Indeed, one may never be found (and will never be found if the
hypothesis is false)
Mathematical Induction :

Inductive Proof

• 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.
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”.

Induction on Integers:
There is a given statement P(n) involving the natural number n such that
1.The statement is true for n=1, i.e., P(1) is true, and
2.If the statement is true for n=k (where k is some positive integer ), then the
statement is also true for n=k+1 , i.e., truth of P(k) implies the truth of P(k+1).
3. Then, P(n) is true for all natural numbers n.

Essential for proving recursively defined objects


We can perform induction on integers, automata, and concepts like trees or graphs.
To make an inductive proof about a statement S(X) we need to prove two things
Basis : Prove for one or several small values of X directly.
Inductive step: Assume S(Y ) for Y “smaller than" X; then prove S(X)
using that assumption
Structural Inductions:

Basic Step: Show that the result holds for all elements specified in the basis step
of the recursive definition to be in the set.

Recursive step: Show that if the statement is true for each of the elements used
to construct new elements in the recursive step of the definition, the result
holds for these new elements.

We need to prove statements about recursively defined structures. Like inductions


all recursive definitions have

basis case: one or more elementary structures are defined

An inductive step: complex structures are defined in terms of previously defined


structures. A recursive definition of a non-empty tree:

A single node is a non-empty tree and that node is the root of that tree.

If T1 ,T2 ,…,Tk are non-empty trees (k≥1) and N is a new node, the a new non-
empty tree T can be created using new node N, new k edges and T1 ,T2 ,…,Tk as
follows:

Let |V| be the number nodes and |E| be the number of edges of a non-empty tree T
Theorem: For a non-empty tree T, |V| = |E| + 1.

Proof: Structural induction on number of nodes.


Basis: |V|=1 The tree contains only one node and no edges (|E|=0). Thus 1=0+1.

Inductive Hypothesis: Suppose that for a non-empty tree T with m nodes where
1≤m≤n, |V|=|E|+1 Induction: Let T be a non-empty tree with n+1 nodes. T must
be created as follows:

Each of trees T1 ,…,Tk must contain nodes less than or equal to n. So, we can apply
IH to each of trees T1 ,…,Tk . Thus, |V1 |=|E1 |+1 … |Vk |=|Ek |+1

For T, |V| = |V1 |+…+ |Vk |+1 |E| = |E1 |+…+ |Ek |+k

|V| = |V1 |+…+ |Vk |+1 = |E1 |+1+…+ |Ek |+1+1 by IH

= |E1 |+…+ |Ek |+k+1 = |E| + 1.

Mutual Induction:

Let us consider revisit the on/off switch, which we represented as an automaton.


The automaton itself is reproduced as Fig

Since pushing the button switches the state between on and off , and the switch
starts out in the off state, we expect that the following statements will together
explain the operation of the switch
S1(n): The automaton is in state off after n pushes if and only if n is even

S2(n): The automaton is in state on after n pushes if and only if n is odd

We give the basis and inductive parts of the proofs of statements S1(n) and S2(n)
below The proofs depend on several facts about odd and even integers if we add or
subtract from an even integer. we get an odd integer, and if we add or subtract
from an odd integer we get an even integer
BASIS: For the basis, we choose n Since there are two statements, each of which
must be proved in both directions because S1 and S2 are each “if-and-only-if”
statements) there are actually four cases to the basis, and four cases to the
induction as well

1. [S1: If] Since is in fact even, we must show that after pushes, the automaton
of Fig is in state off. Since that is the start state, the automaton is indeed in
state off after pushes
2. [S2: Only if] The automaton is in state off after pushes, so we must show
that is even But is even by definition of even, so there is nothing more to
prove
3. [S3:IF] The hypothesis of the if part of S1 is that is odd Since this hypothesis
H is false, any statement of the form if H then C is true, Thus, this part of the
basis also holds
4. [S4: Only if] The hypothesis, that the automaton is in state on after pushes,
is also false, since the only way to get to state on is by following an arc
labeled Push ,which requires that the button be pushed at least once Since
the hypothesis is false, we can again conclude that the if-then statement is
true

INDUCTION : Now, we assume that S1(n) and S2(n) are true, and try to prove
S1(n+1) and S2(n+1). Again, the proof separates into four parts

1. [S1(n+1) If]: The hypothesis for this part is that n+1 is even. Thus, n is odd
The if part of statement S2(n) says that after n pushes, the automaton is in
state on The arc from on to off labeled Push tells us that the( n+1)st push
will cause the automaton to enter state off. That completes the proof of the if
part of S1(n+1)

2. [S1(n+1) Only-if] : The hypothesis is that the automaton is in state off after
n+1 pushes. Inspecting the automaton of Fig tells us that the only way to get
to state off after one or more moves is to be in state on and receive an input
Push Thus, if we are in state off after n+1 pushes, we must have been in
state on after n pushes Then, we may use the only if part of statement S2(n)
to conclude that n is odd. Consequently, n+1 is even, which is the desired
conclusion for the only-if portion of S1(n+1)

3. [S2(n+1) If] : This part is essentially the same as part (1) with the roles of
statements S1 and S2 exchanged, and with the roles of odd and even
exchanged The reader should be able to construct this part of the proofeasi

4. [S2(n+1) Only-if] : This part is essentially the same as part (2) with the roles
of statements S1 and S2 exchanged, and with the roles of odd and even
exchanged
Example 1: Prove by mathematical induction 1+2+3+…+n= 𝑛(𝑛+1)/2
Proof:
1. Basis of induction:
Base case: n=1
L.H.S = 1
R.H.S = 𝑛(𝑛+1)2 = (1)(1+1)/2 = 2/2=1
2. By Induction hypothesis:
For every k > 0, 1+2+3+… + k = 𝑘(𝑘+1)2
3. Statement to be shown in induction step:
1+2+3+… + k + (k+1) = (𝑘+1)((𝑘+1)+1)/2
4.Proof of Induction step:
L.H.S
1+2+3+… + k + (k+1) = 𝑘(𝑘+1)/2 + (k+1)
= (k+1) [ 𝑘/2 +1]
= (k+1) [ (𝑘+2)/2]
= (𝑘+1)(𝑘+2)/2 [∵ (𝑘+1)(𝑘+1+1)2]
= R.H.S
P(k+1) is also true for every k > 1

Example 2: Prove by mathematical induction 1+3+5+...+(2n−1)=n2


Proof:
Step 1 − For n=1, 1=12 Hence, step 1 is satisfied.
Step 2 − Let us assume the statement is true for n=k
Hence, 1+3+5+⋯+(2k−1)=k2 is true
Step 3 We have to prove that
1+3+5+...+(2(k+1)−1)=(k+1)2 also holds
Proof:
1+3+5+⋯+(2(k+1)−1)
=1+3+5+⋯+(2k+2−1)
=1+3+5+⋯+(2k+1)
=1+3+5+⋯+(2k−1)+(2k+1)
=k2+(2k+1)
=(k+1)2
which satisfies the step 2.
Hence, 1+3+5+⋯+(2n−1)=n2 is proved
Example 3 : If x >4 then 2x ≥ x2 Using Mathematical Induction.

Basis: If x=4, then 2x is 16 and x2 is 16. Thus, the theorem holds.

Induction: Suppose for some x >4 that 2x ≥ x2. With this statement as the
hypothesis, we need to prove the same statement, with x+1 in place of x:
2(x+1)≥ (x+1)2

2(x+1)≥ (x+1)2 (i)

Rewrite in terms of S(x)

2(x+1) ≥ 2*2x

We are assuming 2x ≥ x2

So therefore 2(x+1) ≥ 2*2x ³ 2x2 (ii)

Substitute (ii) into (i)

2x2 ≥ (x+1)2
2x2 ≥ (x2+2x+1)

x2 ≥ 2x+1

x ³≥ 2 + 1/x

Since x >=4, we get some value >=4 on the left side. The right side will equal at
most 2.25 and in fact gets smaller and approaches 2 as x increases. Consequently,
we have proven the theorem to be true by induction.
Example 4: Prove by mathematical induction For every positive integer n, prove
that 7ⁿ-3ⁿis divisible by 4

Proof:
Let P(n): 7ⁿ-3ⁿis divisible by 4
Step: 1 P(1): 7¹-3¹ = 4 which is divisible by 4. Thus P(n) is true for n=1
Step :2 Let P(k) be true for some natural number k
i.e., P(k) : 7ᵏ-3ᵏis divisible by 4.
We can write 7ᵏ-3ᵏ= 4d, where d ∊ N.
Step :3 To prove that P(k+1) is true whenever P(k) is true.
P(k+1) : 7ᵏ+1- 3ᵏ+1is divisible by 4
Proof: 7⁽ᵏ⁺¹⁾-3⁽ᵏ⁺¹⁾=7⁽ᵏ⁺¹⁾-7.3ᵏ+7.3ᵏ-3⁽ᵏ⁺¹⁾ (for convenience adding and subtracting 7.3ᵏ)

=7(7ᵏ-3ᵏ)+(7-3)3ᵏ
=7(4d)+(7-3)3ᵏ
=7(4d) +4.3ᵏ
=4(7d+3ᵏ)
From the last line, we see that 7⁽ᵏ⁺¹⁾-3⁽ᵏ⁺¹⁾ is divisible by 4.
Thus P(k+1) is true when P(k) is true.

Example 5: Prove the following by using the principle of mathematical induction


for all n ∊ N 1.2.3+2.3.4+……..+n(n+1)(n+2)= n(n+1)(n+2)(n+3)/4
Proof:
Let P(n)=1.2.3+2.3.4+………..+n(n+1)(n+2)=n(n+1)(n+2)(n+3)/4
Step :1 For n=1
P(1)≣ 1.2.3= 1(1+1)(1+2)(1+3)/4
6 = 1×2×3×4/4
6 = 24/4=6 which is true.
Step :2 Assume that P(k) is true for some positive integer k
1.2.3+2.3.4+………+k(k+1)(k+2)= k(k+1)(k+2)(k+3)/4 -----[1]
Step :3
We shall now prove that P(k+1) is also true
Now we have , P(k+1):
1.2.3+2.3.4+………..+(k+1)(k+1+1)(k+1+2)=(k+1)(k+2)(k+3)(k+4)/4
Proof: 1.2.3+2.3.4+………..+(k+1)(k+1+1)(k+1+2)
= k(k+1)(k+2)(k+3)/4 + (k+1)(k+2)(k+3)
= k(k+1)(k+2)(k+3) + 4(k+1)(k+2)(k+3)/4
= (k+1)(k+2)(k+3)(k+4)/4 =RHS
Concepts of Automata Theory:

Alphabet:
An alphabet is a finite, non-empty set of symbols. It is denoted by Σ.
Example:
i) Σ= {a,b}, an alphabet of 2 symbols a and b.
)i Σ= {0, 1, 2}, an alphabet of 3 symbols 0, 1 and 2.
)i Σ= {a,b,…,z}, the set of all lower case letters.

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:
i) If w=abcd then │w│= 4.
ii) If x=0101010 then │x│= 7.
iii) │ε│=0.

Empty
i) The string consisting of zero symbols or the length of a string is zero.
ii) It is denoted by ε.│ε│=0

Null String: no input string , denoted by ∅


Concatenation of String:
The concatenation of two strings w and v is the string obtained by appending the
symbols of v to the right end of w.
i.e) if w=a1a2a3…am and v=b1b2b3…bn
then wv=a1a2a3…amb1b2b3…bn.
Example:
i)If x=010, y=1 then
xy=0101 and yx=1010
ii)If x=COMP and y=UTER then
xy=COMPUTER
iii) Empty string is the identity element for concatenation operator i.e) wε= εw.

Reverse of a String:
i) The reverse of a string is obtained by writing the symbols in reverse order.
ii)Let w is a string. Then its reverse is wR.
i.e) w=a1a2a3…am

wR = am… a3a2a1
iii) If u=100010 the uR=010001

Power of an alphabet:
Let Σbe an alphabet, then
Σ*denotes the set of all string over the alphabet Σ.
Σm denotes the set of all string over the alphabet Σof length m.
Example:
If Σ= {0, 1} then
Σ0 = {ε}empty string.
Σ1 = {0, 1} set of all string of length one over Σ= {0, 1}.
Σ2 = {00, 01, 10, 11} set of all string of length over Σ= {0, 1}.
Kleene Closure:
Let Σbe an alphabet, then “kleene 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…}

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
Prefixes = {ε, 1, 12, 123}
Suffixes = {ε, 3, 23, 123}
iii) w=abbab
Prefixes = {ε,a, ab, abb, abba, abbab}
Suffixes = {ε,b, ab, bab, bbab, 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:
x=abc and y=123
xy = abc123

│xy│=6 i.e) │x│=3, │y│=3 hence │xy│=│x│+│y│

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.
3. Σ*:Universal language.
It contains all string over the alphabet Σ.
Lecture Notes

FINITE AUTOMATA

Finite Automata (FA) is the simplest machine to recognize patterns.


The five tuples are
Q : Finite set of states
Σ:set of Input Symbols
q:Initial state.
F: set of Final states
δ:Transition Function
Automaton is an abstract computing device

FA is of two types
1. Deterministic Finite Automata-DFA
2. Nondeterministic Finite Automata-NFA

Examples
1. FA for on/off switch-Digital Systems
2. Lexical Analysis - Recognizing a string “int”

Deterministic Finite Automata: (DFA)

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.

A deterministic finite automaton consists of (Q, Σ,δ,q0,F)

i. A finite set of states often denoted by Q


ii. A finite set of input symbols often denoted ∑.
iii. A transition function that takes as arguments a state and input
symbol and return a state. It is denoted by δ.
1. δis represented by arcs between states and the labels on
the arcs.
2. If ‘q’ is a state and ‘a’ is an input symbol then δ(q,a) is the
state ‘p’ such that δ(q,a)=p.
iv. A start state one of the states in qo.
v. A set of final or accepting states F. The set F is a subset of Q.
Lecture Notes

Transition Diagram
i. For each state in Q there is a node.
ii. For each state ‘q’ in Q and each input symbol a in ∑, let δ(q,a)=p. Then the
transition diagram has an arc from node ‘q’ to node P labeled ‘a’.

iii. There is an arrow into the start state q0 labeled start.


iv. Nodes corresponding to accepting states are marked by a double circle.

Transition table
• A transition table is a tabular representation of a function like δthat
takes two arguments and returns a value.
• The rows of the table correspond to the states and the columns correspond
to the inputs.
• The entry for the row corresponds to state ‘q’ and the column corresponds
to inputs ‘a’ is the state δ(q,a).

State Input symbols

0 1

-> * q0 q0 q1

q1 q0 q1
Extending the transition function to strings:
• We define an extended transition function that describes what happens
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 δ’.

• The extended transition function is a sequence is a function that takes a


state ‘q’ and a string ‘w’ and returns a state P.
δ'(q,w) = δ(δ’(q,x),a) [w=xa]
Problems
1. Design a FA which checks whether the given binary number is even.

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)].

2. Design DFA to accept the string that always ends with 00.

3. Design a DFA for accepting all the strings that ends with ab
Non deterministic Finite Automata (NFA)

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}

1. Construct NFA accepting all strings that end with 01.

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

Finite Automata with Epsilon-Transition:

The ε-transitions in NFA are given in order to move from one state to
another without having any symbol from input set ∑.
Definition (or) Formal notation for an ε-NFA:
The language accepted by NFA with εdenoted by M = (Q, ∑, δ,q0, F) can be
defined as follows:
M= (Q, ∑, δ,q0, F) be a NFA with ε
where, Q is a finite set of states
∑ is input symbols
δis a transition function , 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}

Problem: 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.

Epsilon Closures: (E-closure())

Epsilon closure for a given state X is a set of states which can be reached from
the states X with only (null) or εmoves including the state X itself.

∈-closure(1) : {1,2,3,5,8}
∈-closure(2) : { 2,3,5}
∈-closure(3) : { 3}
∈-closure(4) : { 4,7,8,2,3,5}
∈-closure(5) : { 5}
∈-closure(6) : { 6,7,8,2,3,5}
∈-closure(7) : { 7,8,2,3,5}
∈-closure(8) : { 8}
Lecture Notes

Conversion of NFA with εto DFA

Step 1:
Consider M=(Q,Σ,δ,q0,F) is a NFA with ε,we have to convert this NFA with εto
equivalent DFA denoted by MD = (QD,Σ,δD,q0,FD)

Then obtain, ε-closure(q0) = {p1,p2,...pn} then [p1,p2,...pn] becomes a start


state of DFA. Now [p1,p2,...pn] ϵFD.
Step 2:
We will obtain δtransitions on [p1,p2,...pn] for each input.
δD([[p1,p2,...pn],a) = ε-closure(δ(p1,a) δ(p2,a) ..δ(pn,a))

= ⋃ε−closure(pi,a)𝑛𝑖=1 where 'a' is the input ϵΣ.


Step 3:
The state obtained [p1,p2,...pn] ϵQD. The state containing in pi is a final state in
DFA.

Theorem:
A language L is accepted by some ε-NFA if and only if(iff) L is accepted by some
DFA.

Proof:
Suppose
L=L(D) for some DFA.
D into an ε-NFA E by adding transition δ(q, ε)= φfor all states q of D.
we must also convert the transition of D on input symbols.
Example:
δD(p,a) = p into an NFA transition to the set containing only p.
i.e) δE(p,a) = {p}.

Thus e transition of E and D are the same, but E explicitly states that there are no
transition out of any state on ε.
Lecture Notes
Let E=(QE,Σ,δE,q0,FE) be an ε-NFA. Apply the modified subset construction
described above to produce the DFA.

D = (QD,Σ,δD,q0,FD)

we need to show that L(D) = L(E) an we do so b showing that the extended


transition functions of E and D are the same.

Formally
δ'E(q0,w) = δ'D(qD,w) by induction on the length of w.

Basis:
if |w| = 0, then w = ε.
we know δ'E(q0, ε)= ECLOSE(q0).
we also know that qD = ECLOSE(q0), because this is how the start state of D is
defined.
for DFA, we know that δ'(p, ε)= p for any state p, so on particular
δ'D(qD, ε)= ECLOSE (q0).
we have thus proved that δ'E(q0, ε)= δ'D(qD, ε).

Induction:
Suppose w=xa, where a is the final symbol of w and assume that the statement
holds for x.
i.e) δ'E(q0, x) = δ'D(qD, x).
let both these sets of states be {p1,p2,...pk}.
By the definition of δ'for ε-NFA's ,we compute δ'E(q0, w) by
let {r1,r2,...rm} be ⋃δE(Pi,a)𝑘𝑖=1
Then δ'E(q0,w) = ECLOSE({r1,r2,...rm})

If we examine the construction of DFA D in the modified subset construction, we


see that δD({P1,P2,...Pk},a) is the same set as δ'E(q0, w).
we have now proved that δ'E(q0, x) = δ'D(qD, w) and completed the inductive
part.

Theorem:
If L is accepted by NFA with ε-transitions, then L is accepted by an NFA without
ε-transitions. That is L(M) = L(M')

Proof:

Let M = (Q,Σ,δ,q0,F) be an NFA with ε-transitions.


Construct M' which is NFA without ε-transitions. M' = (Q,,',q0,F') where F' =
{𝐹∪{𝑞0} 𝑖𝑓ε−closure(q0) contains a state of F𝐹,𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

By induction: In ε-NFA, and ' are same and in NFA and ' are different.
Lecture Notes

Extended transition function

DFA :
Basis: |W|=0
δˆ(q, ε)= q
If we are in a state q and read no inputs, then we are still in state q
Induction: |W|>1
Suppose w is a string of the form xa;
Then: δˆ(q, w) = δˆ(q, xa)
= δ(δˆ(q, x), a)
= δ(p , a ) let δˆ(q, x) = p
= [r]
NFA:
Basis: δˆ(q, ε)= q
If we are in a state q and read no inputs, then we are still in state q
Induction:
Suppose w is a string of the form xa
Then: δˆ(q, w) = δ(δˆ(q, x), a)
= δ({p1, p2, . . . pk , },a) let δˆ(q, x) = {p1, p2,
. . . pk , }

= U { δ(p1, a ) , δ(p2, a ) ,….}


= {r1, r2, . . . , rm}
NFA-ε :
Basis: δˆ(q, ε) = ε-Clsoure (q) =q
If we are in a state q and read no inputs, then we are still in state q
Induction:
Suppose w is a string of the form xa
Then: δˆ(q, w) = ε-Clsoure(δ(δˆ(q, x), a))
= ε-Clsoure δ({p1, p2, . . . pk , },a) let δˆ(q, x) = {p1, p2, . . . pk , }

= ε-Clsoure U { δ(p1, a ) , δ(p2, a ) ,….}


= ε-Clsoure {r1, r2, . . . , rm}
={r1, r2, . . . , rm}
Lecture Notes

1. a. Convert the given NFA to DFA.

Solution:
Initial State of given NFA is {q0 }
Since NFA is equivalent to DFA,
Let the Initial State of DFA be [q0] -------------A

Now we will obtain δtransition for state A.


δ’(A, 0)= δ’({q0}, 0) = {q0} =[q0] -------- A Transition table
δ’(A, 1)= δ’({q0}, 1) = {q1}=[q1] -------- B (new state generated)

The δtransition for state B is obtained as:


δ’(B, 0)= δ’({q1}, 0) = {q1, q2} =[q1,q2] -------- C
δ’(B,1) = δ’({q1}, 1) = {q1}=[q1] -------- B

Now we will obtain δ'transition on C.


δ’(C, 0) =δ’({q1, q2}, 0)
= δ(q1, 0) ∪ δ(q2, 0)
= {q1, q2} ∪ {q2}
= [q1, q2] -------- C

δ’(C, 1) =δ’({q1, q2}, 1)


= δ(q1, 1) ∪ δ(q2, 1)
= {q1} ∪ {q1, q2}
= {q1, q2}
= [q1, q2] -------- C
Lecture Notes

Resultant DFA

DFA - Transition table

state Input symbols

0 1

→A A B

B C B

*C C C

DFA - Transition diagram


Lecture Notes

Convert the following NFA-ε into its equivalent NFA.

a)

Note:
No change in Initial State
No change in the total No. Of States
May be change in Final States
Changes in transitions

Solution:
ε-Closure(q0)={q0,q1}
ε-Closure(q1)={q1}

Initial state of given nfa-ε is {q0}


Now, initial state of nfa will be {q0}

Now find the transition of q0 on inputs 0,1


δ(q0,0)=ε-Closure(δ(ε-Closure(q0),0))
=ε-Closure(δ({q0,q1},0))
=ε-Closure(q0)
={q0,q1}
δ(q0,1)=ε-Closure(δ(ε-Closure(q1),1))
=ε-Closure(δ({q0,q1},1))
=ε-Closure(q1)
={q1}
Now find the transition of q1 on inputs 0,1
δ(q1,0)=ε-Closure(δ(ε-Closure(q1),0))
=ε-Closure(δ({q1},0))
=ε-Closure(Φ)

δ(q1,1)=ε-Closure(δ(ε-Closure(q1)1))
=ε-Closure(δ({q1},1))
=ε-Closure(q1)
={q1}
Final State
q0 & q1 Both are final states because q1 lies in both
ε-Closure(q0)={q0,q1}
ε-Closure(q1)={q1}
Resultant NFA:

Transition table

State Input symbol

0 1

*q0 {q0,q1} {q1}

* q1 Φ {q1}

Transition diagram
Conversion of NFA-ε into its equivalent NFA.

Convert the following NFA-ε into its equivalent NFA.

b)

Solution:
ε-Closure(A)={A,B}
ε-Closure(B)={B,D}
ε-Closure(C)={C}
ε-Closure(D)={D}

Initial state of given nfa-ε is {A}


Now, initial state of nfa will be {A}

Now find the transition of A on inputs 0,1


δ(A,0)=ε-Closure(δ(ε-Closure(A),0))
=ε-Closure(δ({A,B},0))
=ε-Closure(δ(A,0)U δ(B,0))
= ε-Closure(A,C)
={A,B,C}
δ(A,1)=ε-Closure(δ(ε-Closure(A),1))
=ε-Closure(δ({A,B},1))
=ε-Closure(δ(A,1)U δ(B,1))
=ε-Closure(∅)
={∅}
Now find the transition of B on inputs 0,1
δ(B,0)=ε-Closure(δ(ε-Closure(B),0))
=ε-Closure(δ({B,D},0))
=ε-Closure(δ(B,0)U δ(D,0))
= ε-Closure(C,D)
={C,D}
δ(B,1)=ε-Closure(δ(ε-Closure(B),1))
=ε-Closure(δ({B,D},1))
=ε-Closure(δ(B,1)U δ(D,1))
=ε-Closure(∅,D)
={D}
Now find the transition of C on inputs 0,1
δ(C,0)=ε-Closure(δ(ε-Closure(C),0))
=ε-Closure(δ(C,0))
= ε-Closure(∅)
={∅}
δ(C,1)=ε-Closure(δ(ε-Closure(C),1))
=ε-Closure(δ(C,1))
=ε-Closure(∅)
={∅}
Now find the transition of D on inputs 0,1
δ(D,0)=ε-Closure(δ(ε-Closure(D),0))
=ε-Closure(δ(D,0))
= ε-Closure(D)
={D}
δ(D,1)=ε-Closure(δ(ε-Closure(D),1))
=ε-Closure(δ(D,1))
=ε-Closure(D)
={D}
Resultant NFA:

Transition table
State Input symbol
0 1
->A {A,B,C} Φ

*B {C,D} {D}

C Φ Φ

*D {D} {D}

Note:
B & D are final states because final state of given NFA-ε D lies in both
ε-Closure(B)={B,D}
ε-Closure(D)={D}
Conversion of NFA-ε to DFA

Convert the following NFA-ε into its equivalent DFA.


a)

Solution:

Let us obtain the ε-closure of each state.


ε-closure(q0) = {q0, q1, q2}
ε-closure(q1) = {q1, q2}
ε-closure(q2) = {q2}

Let the initial state of DFA be ε-closure({q0})


= {q0, q1, q2}
= [q0, q1, q2] ----- A
Transitions of A on inputs 0,1,2

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


= ε-closure(δ(q0, 0) ∪ δ(q1, 0) ∪ δ(q2, 0))
= ε-closure({q0})
= {q0, q1, q2}
= [q0, q1, q2] ----- A

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


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

δ'(A, 2) = ε-closure(δ((q0, q1, q2), 2))


= ε-closure(δ(q0, 2) ∪ δ(q1, 2) ∪ δ(q2, 2))
= ε-closure({q2})
= {q2}
= [q2] ------C
Lecture Notes

Transitions of B on inputs 0,1,2

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


= ε-closure{δ(q1, 0) ∪ δ(q2, 0)}
= ε-closure{∅}
= ∅ ------- ∅

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


= ε-closure{δ(q1, 1) ∪ δ(q2, 1)}
= ε-closure{q1}
= {q1, q2}
= [q1, q2] ------- B

δ'(B, 2) = ε-closure{δ((q1, q2), 2)}


= ε-closure{δ(q1, 2) ∪ δ(q2, 2)}
= ε-closure{q2}
= {q2}
= [q2] ------- C

Transitions of C on inputs 0,1,2

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


= ε-closure{∅ }
= ∅ ------- ∅

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


= ε-closure{∅ }
= ∅------- ∅

δ'(C, 2) = ε-closure{δ(q2, 2)}


= {q2}
= [q2] ------- C
Lecture Notes

Resultant DFA :

States Inputs
0 1 2

->*A A B C

*B ∅ B C

*C ∅ ∅ C

Note:

Final state of given NFA is {q2}

A = {q0, q1, q2} B = {q1, q2} C = {q2}

Since q2 lies in DFA states A,B,C , all the three states becomes the final
states of resultant DFA.
Lecture Notes

Convert the following NFA-ε into its equivalent DFA.

b)
States Inputs
0 1 ε
->A {B} {A} {B}
B ∅ {B} {C}
*C {C,A} {C} ∅

Solution:

Let us obtain the ε-closure of each state.


ε-closure(A) = {A,B,C}
ε-closure(B) = {B,C}
ε-closure(C) = {C}

Let the initial state of DFA be ε-closure({A})


= {A,B,C}
= [A,B,C] ----- X
Transitions of X on inputs 0,1
δ’(X, 0)= ε-closure{δ(X, 0)}
= ε-closure{δ((A,B,C), 0)}
= {B,C}
= [B,C] -------- Y

δ’(X, 1) )=ε-closure{δ(X, 1)}


=ε-closure{δ((A,B,C), 1)}
={A,B,C}
= [A,B,C] ------- X
Lecture Notes

Transitions of Y on inputs 0,1


δ’(Y, 0) =ε-closure{δ(Y, 0)}

=ε-closure{δ((B,C), 0)}
= {C}
= [C] ---------Z

δ’(Y, 1) =ε-closure{δ(Y, 1)}


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

= {B,C}
=[B,C] ------Y

Transitions of Z on inputs 0,1

δ’(Z, 0)=ε-closure{δ(Z, 0)}


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

= [C] -----------Z

δ’(Z, 1)= ε-closure{δ(Z, 1)}


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

= [C] ----------Z

Resultant DFA : States Inputs


0 1
->*X Y X
*Y Z Y
*Z Z Z
Part A Q & A

S.No Questions K CO
Level Level
1. Define hypothesis.

The formal proof can be using deductive proof and


inductive proof. The deductive proof consists of sequence
of statements given with logical reasoning in order to K2 CO1
prove the first or initial statement. The initial statement is
called hypothesis.
2. What is deductive and inductive proof?
A deductive proof consists of a sequence of statements,
which starts from a hypothesis, or a given statement to a
conclusion. Each step is satisfying some logical principle.
K2 CO1
Inductive proof is a recursive kind of proof which consists
of sequence of parameterized statements that use the
statement itself with lower values of its parameter.

3. Give some examples for additional forms of proof.


1. Proofs about sets
2. Proofs by contradiction
3. Proofs by counter examples. K2 CO1

4. Difference between proof by contradiction and


contrapositive
A proof by contradiction is a method of proving a
statement by assuming the hypothesis to be true and
conclusion to be false, and then deriving a contradiction. K2 CO1
A proof by contraposition is based on the fact that the
statement ‘If A, then B' is logically equivalent to the
statement ‘If not B, then not A’. In other words, we have
(A⟹B)⟺(¬B⟹¬A)
An interesting thing is that we can prove above
statement using the method of contradiction! So, in
proof by contraposition we assume that B is false
and then show that A is false.
Part A Q & A

S.No Questions K CO
Level Level
5. What is the use of Structural induction proof?
Structural induction is used to prove that some
proposition P(x) holds for all x of some sort of recursively
defined structure.
K2 CO1
6. Define Induction Principle.

Mathematical induction is a technique to prove that a


mathematical statement, S(n) is true for all integer n≥n0,
where n0 is a fixed integer. I have written the statement
K2 CO1
as S(n) to emphasize that it depends only on n. To prove
this, we need to prove the following:
1. Basis step: S(0) is true
2. Induction step: If S(k) is true then S(k+1) is true, for
k≥n0
proving the above two things is equivalent to proving that
S(n) is true for all integer n≥n0.
7. Give the examples/applications designed as finite
state system.

Text editors and lexical analyzers are designed as finite


state systems. A lexical analyzer scans the symbols of a
K2 CO1
program to locate strings corresponding to identifiers,
constants etc, and it has to remember limited amount of
information
8. Write any three applications of Automata Theory.
1. It is base for the formal languages and these formal
languages are useful of the programming
languages.
K2 CO1
2. It plays an important role in complier design.
3. To prove the correctness of the program automata
theory is used.
4. In switching theory and design and analysis of
digital circuits automata theory is applied.
5. It deals with the design finite state machines.
Part A Q & A

S.No Questions K CO
Level Level
9. Define Finite Automation.
A finite automata is a collection of 5 tuples
(Q, Σ.δ,q0, F )
where Q is a finite set of states, which is non empty. K2 CO1
Σis an input alphabet, indicates input set.
δis a transition function
q0 is an initial state (q0 in Q)
F is a set of final states.

10. Design FA which accepts odd number of 1’s and any


number of 0’s.

K3 CO1

11. Design FA to check whether given unary number is


divisible by three.

K3 CO1

12. Design FA to check whether given binary number is


divisible by three.

K3 CO1
Part A Q & A

S.No Questions K CO
Level Level
13. Design NFA which accepts the language
{ w ∈Σ∗ | w contains at least two 0s, or exactly two
1s }

K3 CO1

14. Define Epsilon closure.


Epsilon closure for a given state X is a set of
states which can be reached from the states X with only
(null) or εmoves including the state X itself
K2 CO1

15. Obtain εclosure of each state in the following NFA


with εmove.

K2 CO1

∈ closure(1) : {1,2,3,5,8} ∈closure(5) : { 5}


∈ closure(2) : { 2,3,5} ∈closure(6) : { 6,7,8,2,3,5}
∈ closure(3) : { 3} ∈closure(7) : { 7,8,2,3,5}
∈ closure(4) : { 4,7,8,2,3,5} ∈closure(8) : { 8}
Part A Q & A

S.No Questions K CO
Level Level

16. Give the language accepted by DFA

A language L is accepted by a DFA <Q , , , q0 , F > ,


if and only if L = { w | *( q , w ) € FA } . That is, the
0
language accepted by a DFA is the set of strings accepted K2 CO1
by the DFA

17. Differentiate DFA and NFA?

DFA NFA

DFA is NFA is Non-Deterministic K2 CO1


1.
Deterministic Finite Automata
Finite Automata
2. For given state, on a For given state, on a
given input we reach to given input we reach to
deterministic and unique more than one state.
δˆ (q0, w) ={p}
state.
δˆ (q0, w) =[p]

3. DFA is a subset of NFA Need to convert NFA to


DFA in the design of
complier.
4. L(A) = {w | δˆ(q0, w) is in F} L(A) = {w | δˆ(q0, w) ∩F ,
ƒ= ∅}

5. DFA cannot use Empty NFA can use Empty


String transition. String transition.

18. Write short notes on Minimization of DFA?


• Reducing the number of states from given FA
• First find out which two states are equivalent we than
replace those two states by one representative state.
• For finding the equivalent states we will apply the K2 CO1
following rule
The two states S1 & S2 are equivalent if and only
if both the states are final or non-final states.
Part A Q & A

S.No Questions K CO
Level Level
19. Explain the extended transition function for ε-NFA

Basis: δˆ(q, ε)= ε-Clsoure (q) =q

Suppose w is a string of the form xa


K2 CO1

Then: δˆ(q, w) = ε-Clsoure(δ(δˆ(q, x), a))


= ε-Clsoure δ({p1, p2, . . . pk , },a)
let δˆ(q, x) = {p1, p2, . . . pk , }
= ε-Clsoure U { δ(p1, a ) , δ(p2, a ) ,….}
= ε-Clsoure {r1, r2, . . . , rm}
={r1, r2, . . . , rm}
20. Define extended transition function

The extended transition function is a function that takes


a state q and a string w and returns a state p K2 CO1

Eg.
δˆ(q0, 11001) =δ(δˆ(q0, 1)1001)
=δ(δˆ(q0, 1)001)
=δ(δˆ(q0, 0)01)
=δ(δˆ(q1, 0)1)
=δ(q2, 1)
=q0

You might also like