Unit I Automata: 1.1.1. Basic Definitions of Automata Theory 1. Alphabets
Unit I Automata: 1.1.1. Basic Definitions of Automata Theory 1. Alphabets
Unit I Automata: 1.1.1. Basic Definitions of Automata Theory 1. Alphabets
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.
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,……”
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 Σ.
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.
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
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.
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
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
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.
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.
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
⇒
⇒
L.H.S = R.H.S
2
ie) =
The given theorem is proved.
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.
all in their own parts of the basis and inductive steps. We call this sort of proof is
mutual induction.
M = (Q, Σ, δ, q0, F)
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
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?
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.
2. DFA must returning exactly one 2. NFA returns a set of zero, one or
state. more states.
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
Here answer is{ q0, q1}, both states are not accepting state.
w1 = 0010 is not accepted by finite automata.
• w2 = 00101
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}
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)
PROBLEMS:
Ex.1:
Convert the following NFA to it‟s equivalent DFA.
Soln:
Step 1: To find subset construction:
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
Ex.2:
Convert the following NFA to it‟s equivalent DFA.
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})
δ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)
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) =
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}
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}
Input
State
0 1 2
→*A A B C
*B B C
*C C
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‟.
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,
δ(C, b) =
δ(C, c) = {r}
Input
State
a b c
→*A A B C
*B B C
*C C
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‟.