SlideShare a Scribd company logo
1 of 33
Download to read offline
1
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
01725-402592
2
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Automata (Chapter:01)
Automata theory deals with the definitions and properties of mathemetical models of
computation. These models plays a roll in several applied areas of computer science.
There are two types of mathemetical models-
1. The finite automata is a mathemetical model which is used in text processing, compilers
and hardware design.
2. Second model- context free grammar is used in programming languages and artificial
intelligence.
Q.2014-1(a): What is a finite automaton? Write the kinds of finite automata.
The finite automata is a mathemetical model which is used in text processing, compilers and
hardware design. Most important kinds-
1. Software for designing and checking the behavior of digital circuits.
2. The lexical analyzer of a typical compiler.
3. Software for scanning large bodies of text.
4. Software for verifying systems having finite number of distinct states.
Example 1.1:
Properties:
1. Finite states.
2. Every state has atleast one input.
3. Transition from one state to another requires an input
Example 1.2 --- an FA modeling recognition of the keyword “then” in a lexical analyzer
The double circles specify the final or “accepting state.”
Ashek Mahmud Khan
Dept. of CSE (JUST)
01725-402592
Start
Push
Push
3
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Structural Representation:
1. Grammar: A grammar consists of collection of rules called productions. Each rule
appears as a line in the grammar, comprising a symbol and a string separated by an arrow.
The symbol is called a variable. The string consists of variables and other symbols.
A A+1; B A; B #
2. Regular Expression: Regular expressions are built up with the help of regular operations.
For example-
( 0U1)0*
Where, ( 0U1) means ({0}U{1}).The value of this part is the language {0,1} and the part
0* means {0}*. The value of this part is the language consisting of all strings consisting
any number of 0s.
Q.2014-1(b): Define (i) Alphabet (ii) String
1. Alphabet: An alphabet is a finite, nonempty set of symbols. The members of an alphabet
are the symbols of the alphabet. An alphabet is denoted by ∑.
2. String: A string is a finite sequence of symbols chosen from some alphabet. It is usually
written next to one another and not separated by commas. For example- if ∑={0,1}, then
01001 is a string over ∑.
3. Empty String: An empty string is a string with zero occurrences of symbols or a string
of zero length.
4. Language: A language is a set of strings.
Q.2014-1(d): Describe induction proof. Using induction proof, give recursive
definition of a tree.
4
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Theorem – 1.1: if x ≥ 4, then 𝟐 𝒙
≥ 𝒙 𝟐
First, notices that the hypothesis H is “x ≥ 4”. This hypothesis has a parameter, x, and thus is
neither true nor false. Rather, its truth depends on the value of the parameter x e.g. H is true for
x= 6 and false x=2.
Likewise, the conclusion C is “2 𝑥
≥ 𝑥2
". 𝑇ℎ𝑖𝑠 𝑠𝑡𝑎𝑡𝑒𝑚𝑒𝑛𝑡 𝑎𝑙𝑠𝑜 𝑢𝑠𝑒𝑟𝑠 parameter x and is true is
for certain values of x and not others.
For example –let,
x=1, 21
= 2 and 12
= 1 which is false
x=2, 22
= 4 and 22
= 2 which is false
x=3, 23
= 8 and 32
= 9 which is false
x=4, 24
= 16 and 42
= 16 which is true
x=5, 25
= 32 and 52
= 25 which is true
x=6, 26
= 64 and 62
= 36 which is true
The conclusion 2 𝑥
≥ 𝑥2
will be true when ever x ≥ 4. We already saw that it is true for x =4;
5
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Q.2014-1(c)/Theorem-1.4: Prove that If x is the sum of the squares of four positive
integers, then 2x
≥x2
.
Proof: The intuitive idea of the proof is that if the hypothesis is true for x, that is, x is the sum of
the squares of four positive integers, and then x must be at least 4.
Step Statement justification
1.
2.
3.
4.
5.
x=𝑎2
+𝑏2
+𝑐2
+𝑑2
a ≥ 1; b ≥ 1; c ≥ 1; d ≥ 1;
𝑎2
≥ 1; 𝑏2
≥ 1; 𝑐2
≥1; 𝑑2
≥1;
x ≥ 4
2 𝑥
≥ 𝑥2
Given
Given
Step (2) and properties of arithmetic
Step(1), (3), and properties of
arithmetic
Step(4) and 2 𝑥
≥ 𝑥2
Table: A formal proof 𝟐 𝒙
≥ 𝒙 𝟐
Table shows the sequence of statements we need to prove 2 𝑥
≥ 𝑥2
. In step (1), we have
repeated one of the given statements of the theorem, that x is the sum of the squares of four
integers. Giving the four integers the names a, b, c and d. In step (2), we put down the other part
of the hypothesis of the theorem that the values being squared are each at least 1; step (4) users
statements (1) and (3). The first statement tells us that x is the sum of the four squares in
question, and statement (3) tells us that each of the squares is at least 1. Again using well known
properties of arithmetic, we conclude that x is at least 1+1+1+1; or 4
At the find step (5), we use statement (4), which is the hypothesis of theorem 2 𝑥
≥ 𝑥2
.
Finite Automata (Chapter:02)
Q.2014-2(a): What is a finite automaton? Write the use of finite automaton.
Finite automata: A finite automaton has a set of states and its “control” moves from state to
state in response to external “inputs”. A finite automaton is a simple idealized machine used to
recognize patterns within input taken from some character set or alphabet. The job of an finite
automaton is to accept or reject an input depending on whether the pattern defined in the input.
Use of finite automaton:
 Text processing,
 Compilers design and
 Hardware design.
6
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Deterministic Finite Automata: A deterministic finite automaton means that the automaton
cannot be in more than one state at any one time. The term “deterministic” refers to the fact that
on each input there is one and only one state to which the automaton can transition from its
current state.
Q.2014-2(b): Write the Formal definition of DFA.
Formal definition of deterministic finite automaton (DFA): A finite automaton is a 5-tuple
(Q, ∑, δ, q₀, F) where-
1. Q is a finite set called the states,
2. ∑ is a finite set called the alphabet,
3. δ: Q × ∑→ Q is the transition function,
4. q₀ Є Q is the start state and
5. F ⊆ Q is the set of accept states.
How a DFA processes strings?
The first thing we need to understand about a DFA is how the DFA decides whether or not to
“accept” a sequence of input symbols. The “language” of the DFA is the set of all strings that the
DFA accepts. Suppose a1 a2……an is a sequence of input symbols. We start out with the DFA in
its start state, q0. We consult the transition function 𝛿, say 𝛿(q0,a1) = q1 to find the state that the
DFA A enters after processing the first input symbol a1. We process the next input symbol, a2 by
evaluating 𝛿(q1,a2); let us suppose this state is q2. We continue in this manner, finding states q3,
q4….., qn such that 𝛿(qi-1,ai) = qi for each i. If qn is a member of F, then the input a1a2……an is
accepted, and if not then it is “rejected”.
Example 2.1 & 2.2: {ѡ|ѡ is of the form x01y for some strings x and y consisting of 0’s and
1’s only}
Formal Definition: Suppose, the finite automaton M, we can describe M formally by writing
M= (Q, ∑, δ, q₀, F), where-
7
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
1. Q ={q₀, q₁, q₂},
2. ∑ ={0,1},
3. δ is described as-
δ 0 1
q₀ q₁ q₀
*q₁ q₁ q₂
q₂ q₂ q₂
4. q₀ is the start state and
5. F = {q₂}.
Q.2014-2(d): Describe the extended transition function for DFA.
Extended Transition Function: The extended transition function is a function that takes a
state q and a string ѡ and returns a state p- the state that the automaton reaches when starting in
state q and processing the sequence of inputs ѡ. We define δˆ by induction on the length of the
input string, as follows:
BASIS: δˆ(q,ϵ)=q. That is, if we are in state q and read no inputs, then we are still in state q.
INDUCTION: Suppose ѡ is a string of the form xa; that is, a is the last symbol of ѡ, and x is the
string consisting of all but the last symbol. For example, ѡ is broken into x= 110, and a=1. Then
δˆ (q, ѡ)= δ(δˆ(q, x),a)
To compute δˆ(q, ѡ), first compute δˆ(q, x), the state that the automaton is in after processing all
but the last symbol of ѡ. Suppose this is state p, that is δˆ(q, x)=p. Then δˆ(q, ѡ) is what we get
by making a transition from state p on input a, the last symbol of ѡ. That is,
δˆ(q, ѡ)= δ(p, a).
Q.2014-2(d)/Example 2.4: Write the steps for the following language using extended
transition function- {ѡ|ѡ has both an even number of 0’s and an even number of 1’s}.
8
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Solution:
Formal Definition: 1. Q ={q₀, q₁, q₂,q3}
2. ∑ = {0,1}
3. δ is described as-
δ 0 1
q₀ q0 q1
q₁ q₂ q0
q₂ q₁ q3
q3 q0 q₂
4. q₀ is the start state and
5. F = {q0}.
 { ѡ|ѡ accept any number of 1’s}
Solution:
Formal Definition:
1. Q ={q₀, q₁, q₂}
2. ∑ ={0,1}
3. δ is described as-
9
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
δ 0 1
q₀ q₁ q₀
q₁ q₁ q₂
*q₂ q₂ q₂
4. q₀ is the start state and
5. F = {q₂}.
 {ѡ|ѡ ends in 00}
Solution:
Formal Definition:
1. Q ={q₀, q₁, q₂}
2. ∑ ={0,1}
3. δ is described as-
δ 0 1
q₀ q₁ q₀
q₁ q₂ q₀
*q₂ q₂ q₀
4. q₀ is the start state and
5. F = {q₂}.
10
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
 { ѡ|ѡ has two consecutive 1’s or two consecutive 0’s }
Solution:
Formal Definition:
1. Q ={q₀, q₁, q₂ ,q3 ,q4 ,q5 ,q6 ,q7 ,q8}
2. ∑ ={0,1}
3. δ is described as-
δ 0 1
q0 q3 q1
q1 q4 q2
q2 q5 q2
q3 q6 q4
q4 q7 q5
q5 q8 q5
q6 q6 q7
q7 q7 q8
*q8 q8 q8
4. q₀ is the start state and
5. F = {q8}.
Q.2014-2(c): Draw the DFA’s and formal definition for the following languages- (i) {ѡ|ѡ
does not contain ab, ba, bbba}.
11
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
 Construct DFA’s all strings with exactly one a.
 Construct DFA’s all strings with at least one a.
 Construct DFA’s all strings with at least one a and exactly two b’s.
Q.2014-2(c): Draw the DFA’s and formal definition for the following languages- (ii)
Construct DFA’s all the strings with exactly two a’s and more than two b’s.
The automaton is constructed with similar techniques as above
Regular Language of DFA:
A language is called a regular language if some finite automaton recognizes it. Let, M= (Q, ∑, δ,
q₀, F) be a finite automaton and let ѡ = ѡ₁, ѡ₂, ------, ѡn be a string where each ѡi is a member
of the alphabet ∑. Then M accepts ѡ if a sequence of states r₀, r₁, r₂, -----, rn in Q exists with
three conditions-
b
b
a
a b
a
b b
a a a
a a
a
b
b
b a
b
b
a
b
a
12
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
1. r₀=q₀,
2. δ(ri , ѡi+1 )= ri+1, for i=0,1,------n-1 and
3. rn Є F.
The first condition says that the machine starts in the start state. Condition 2 says that the
machine goes from state to state according to the transition function. Condition 3 says that the
machine accepts its input if it ends up in an accept state. We say that M recognizes language A
if-
A= {ѡ|M accepts ѡ}
Q.2014-3(a): Explain the Language of NFA with proper example.
Non-Deterministic Finite Automata: In deterministic computation, when the machine is in a
given state and reads the next input symbol, we know what the next state will be, it is
determined. But in nondeterministic computation, several choices may exist for the next state at
any point. It has the power to be in several states at once. This ability is often expressed as an
ability to “guess” something about its input. Formal definition of nondeterministic finite
automaton: A finite automaton is a 5-tuple ( Q, ∑, δ, q₀, F ), where-
1. Q is a finite set called the states,
2. ∑ is a finite set called the alphabet,
3. δ: Q × ∑ɛ → P(Q) is the transition function,
4. q₀ Є Q is the start state and
5. F ⊆ Q is the set of accept states.
Example 2.6: An NFA accepting all strings that end in 01.
Formal Definition: Suppose, the finite automaton M, we can describe M formally by writing
M= (Q, ∑, δ, q₀, F), where-
1. Q ={q₀, q₁, q₂},
2. ∑ ={0,1},
3. δ is described as-
13
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
𝛿 0 1
q₀ { q₀, q₁ } { q₀ }
q₁ ɸ { q₂ }
q₂ ɸ ɸ
4. q₀ is the start state and
5. F ={q₂}.
Extended Transition Function (NFA):
The extended transition function is a function that takes a state q and a string of input symbols ѡ
and returns the set of states that the NFA is in if it starts in state q and processes the string ѡ.
Formally we define δˆ for an NFA’s transition function δ by:
BASIS: δˆ(q,ϵ)= {q}. That is, without reading any input symbols, we are only in the state we
began in.
INDUCTION: Suppose ѡ is of the form ѡ=xa; that is, a is the last symbol of ѡ, and x is the
string consisting of all but the last symbol. Also suppose that δˆ(q, x) = { p1, p2, -----,pk}. Let-
𝛿𝑘
𝑖=1 (pi,a)= {r1, r2, -----, rm}
Then, δˆ (q, ѡ)= {r1, r2, -----, rm}
Example-2.8: Let us use δˆ to describe how the string 01010 is processed by the NFA of Fig.
2.8
Fig. 2.8
1. δˆ(q0, ϵ) = {q0}
2. δˆ(q0, 0) = δ(q0, 0) = {q0}
3. δˆ(q0, 01) = δ(q0, 1) = {q0, q1}
4. δˆ(q0, 010) = δ(q0, 0) ∪ δ(q1, 0) = {q0}∪{q2}= { q0, q2}
14
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
5. δˆ(q0, 0101) = δ(q0, 0) ∪ δ(q2, 1) = {q0, q1}∪ ∅ = {q0, q1}
6. δˆ(q0, 01010) = δ(q0, 0) ∪ δ(q1, 0) = {q0}∪ {q2} = {q0, q2}
Line (1) is the basic rule. We obtain line (2) by applying δ with input 0 to the state q0 from the
previous set to get {q0} once again. Now input 1 applied to this result in {q0, q1} in line (3).
Line (4) is obtained by applying δ with input 0 to the two states resulting from (3) and taking
their union. Lines (5) and (6) are similar to (4).
Language of NFA:
An NFA accepts a string ѡ if it is possible to make any sequence of choices of next state, while
reading the characters of ѡ and go from the start state to any accepting state. The fact that other
choices using the input symbols of ѡ lead to a non accepting state or do not lead to any state at
all, does not prevent ѡ from being accepted by the NFA as a whole. Formally, if A= (Q, ∑, δ, q₀,
F) is an NFA, then
L(A) = {ѡ|δˆ (q₀, ѡ) ∩ F≠ ɸ}
That is, L (A) is the set of strings ѡ in ∑*. Such that δˆ(q₀, ѡ) contains at least one accepting
state.
Example 2.9: Formally prove that, the following NFA accepts the language L= {ѡ|ѡ ends in
01}
Proof: The proof is a mutual induction of the following three statements that characterize the
three states:
1. δˆ (q₀, ѡ) contains q₀ for every ѡ.
2. δˆ (q₀, ѡ) contains q₁, if and only if ѡ ends in 0.
3. δˆ (q₀, ѡ) contains q₂, if and only if ѡ ends in 01.
Q.2014-3(b): Describe the Equivalence of DFA to NFA. Write the steps to construct a DFA
from an NFA.
Equivalence of DFA to NFA: Although, for some languages an NFA is easier to cons tract than
a DFA, every language that can be described by some NFA can also be described by some DFA.
15
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
The proof that 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 states of the
NFA.
The subset construction starts from an NFA N = (Qɴ, ∑, δɴ, q₀, Fɴ). Its goal is the description of
a DFA D=(Qᴅ, ∑, δᴅ, {q₀}, Fᴅ) such that L(D) = L(N). Here, the input alphabets of the two
automata are the same and the start state of D is the set containing only the start state of N. The
other components of D are constructed as follows-
Steps to construct a DFA from an NFA:
1. Qᴅ is the set of subsets of Qɴ and Qᴅ is the power set of Qɴ. That is, if Qɴ has n states,
then Qᴅ will have 2n
states. Often, all these states are not accessible from the start state of
Qᴅ. Inaccessible states can be “thrown away”. So effectively, the number of states of D
may be much smaller than 2n
.
2. Fᴅ is the set of subsets S of Qɴ such that S∩Fɴ ≠ ɸ. That is, Fᴅ is all sets of N’s states that
include at least one accepting state of N.
3. For each set S ⊆ Qɴ and for each input symbol a in ∑,
δᴅ(S, a) = 𝛿 𝑁𝑝 𝑖𝑛 𝑠 (p, a)
Q.2014-3(d)/Example 2.9: Convert the following NFA to its equivalent DFA.
To convert the NFA to its equivalent DFA, we have to first construct all subsets of the states of
the NFA.
𝜹 0 1
ɸ ɸ ɸ
{q₀} {q₀, q₁} {q₀}
{q₁} ɸ {q₂}
16
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
*{q₂} ɸ ɸ
{q₀, q₁} {q₀, q₁} {q₀, q₂}
*{q₀, q₂} {q₀, q₁} {q₀}
*{q₁, q₂} ɸ {q₂}
*{q₀, q₁, q₂} {q₀, q₁} {q₀, q₂}
Theorem 2.11: If D= (Qᴅ, ∑, δᴅ, q₀, Fᴅ) is the DFA Constructed from NFA N = (Qɴ, ∑, δɴ,
q₀, Fɴ) by the subset construction, then L(D)= L(N).
Proof: What we actually prove first, by induction on |w|, is that
δˆD ({q0},w) = δˆN(q0,w)
(Text book: Page-63 W: J.E. Hopcroft)
Q.2014-3(c)/Theorem 2.12: A language L is accepted by some DFA if and only if L is
accepted by some NFA.
Proof: (If) If D= (Qᴅ, ∑, δᴅ, q₀, Fᴅ) is the DFA Constructed from NFA N = (Qɴ, ∑, δɴ, q₀, Fɴ)
by the subset construction, then L(D)= L(N).
(Only if) This part is easy; we have only to convert a DFA into an identical NFA. Put intuitively,
if we have the transition diagram for a DFA, we have also interpreted it as the transition diagram
of NFA, which happens to have exactly one choice of transition in any situation. More formally,
let D= (Q, ∑, δD, q₀, F) be a DFA. Define N= (Q, ∑, δN, q₀, F) to be the equivalent NFA, where
δN is define by the rule.
If δD (q, a)= p, then δN(q, a) = {p}
It is the easy to show by induction on |w|, that if δD (q₀, w)= p then
δN (q₀, w)={p}
We leave the proof to the reader. As a consequence, w is accepted by D if and only if it is
accepted by N; L(D)=L(N).
17
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Exercise-2.3.2: Convert to a DFA the following NFA
Solution:
Q.2014-4(a): what are the uses of ɛ-transitions.
We shall begin with an informal treatment of ɛ- NFA’s, using transition diagrams with ɛ
allowed as a label. In the examples of follow, think of the automaton as accepting those
sequences of labels along paths from the start state to an accepting state.
Q.2014-4(b)-(ii)/ Example-2.16: An ɛ- NFA that accepts decimal numbers consisting of
1. An optional + or – sign, 2.A string of digits, 3.A decimal point and 4.Another string of
digits.
Fig. 2.16
.
.
18
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Extended Transitions and Languages for ɛ-Transitions:
Example-2.20: Let us compute δˆ(q0,5.6) for the ɛ-NAF of Fig. 2.16. A summary of steps
needed are as follows:
 δˆ(q0, ɛ) = ECLOSE(q0)= {q0,q1}.
 Compute δˆ(q0,5) as follows:
1. First Compute the Transitions on input 5 from the states q0 and q1 we obtained in the
calculation of δˆ(q0, ɛ), above. That is, δ(q0, 5) ∪ δ(q1, 5)= { q1,q4}.
2. Next, ɛ-close the numbers of the set computed in step (1). We get,
ECLOSE(q1) ∪ ECLOSE(q4) = {q1}∪{q4}={ q1,q4}.
 Compute δˆ(q0, 5.) as follows:
1. First Compute δ(q1, .) ∪ δ(q4, .)= {q2}∪{q3}={ q2, q3}.
2. Then Compute δˆ(q0, 5.) = ECLOSE(q2) ∪ ECLOSE(q3) = {q2}∪{q3,q5}={q2,q3,q5}.
 Compute δˆ(q0, 5.6) as follows:
1. First Compute δ(q2, 6) ∪ δ(q3, 6) ∪ δ(q5, 6)= {q3}∪{q3}∪ ∅ ={q3}.
2. Then Compute δˆ(q0, 5.6)= ECLOSE(q3) = {q3, q5}
NFA Machines:
** Draw a machine divided by 2 or 3 and 2 and 3.
Q.2014-4(b-(i)): Draw a machine that accepts ɛ, a, baba and baa, but not b, bb, babba.
** Draw a machine that accepts abc, abd and aacd.
** Draw a machine that accepts 0101, 101, 011.
** Draw a machine that accepts both state and regular.
Q. 2014-4(a)/ 2.5.5: How we can 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, qD, FD) is defining as follows:
19
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
1. QD is the set of subsets of QE.
2. qD = ECLOSE(q0); that is, we get the start state of D by closing the set consisting of only
the start state of E.
3. FD is those sets of states that contain at least one accepting state of E.
That is, FD = {S | S is in QD and S∩FD ≠ ∅}.
4. δD(S, a) is computed, for all a in and sets S in QD by:
(a) Let S= {p1, p2,……,pk}.
(b) Compute δ(𝑝𝑖
𝑘
𝑖=1 , 𝑎); let this set be {r1, r2,…., rj.
(c) Then δD(S, a) = 𝐸𝐶𝐿𝑂𝑆𝐸(𝑟𝑗 )𝑚
𝑗=1 .
Example-2.21 Description of eliminating ɛ-Transitions
Theorem-2.22 A language L is accepted by some ∈-NFA if and only if L is accepted by some
DFA.
This direction is easy. Suppose L = L(D) for same DFA.
Let E= (QE, , δE, q0, FE) be an ∈-NFA. Apply the modified subset construction described
above to produce the DFA, D = (QD, , δD, qD, FD). We need to show that L(D)= L(E).
Basis: If |w| = 0, then w = ∈. We know 𝛿E (q0, ∈) = ECLOSE(q0). We also know that qD =
ECLOSE(q0), because that is how the start state of D is defined. Finally, for a DFA, we know
that 𝛿E (p, ∈) = p for any state p, so particular, 𝛿D(qD, ∈) = ECLOSE(q0). We have thus proved
that 𝛿E(q0, ∈)=𝛿D (qD, ∈).
Induction: Suppose 𝑤 = 𝑥a, where a is final symbol of 𝑤, and assume that the statement holds
for 𝑥. That is, 𝛿E(q0, 𝑥)= 𝛿D(qD, 𝑥). Let both these set of states be {p1,p2,…..,pk}.
By the definition of 𝛿 for ∈-NFA’s, we compute 𝛿E(q0, 𝑤) by:
1. Let {r1,r2,……., rm} be 𝛿 𝐸(𝑝𝑖, 𝑎)𝑘
𝑖=1 .
2. Then 𝛿E(q0, 𝑤) = 𝐸𝐶𝐿𝑂𝑆𝐸(𝑟𝑗 )𝑚
𝑗=1 .
Regular Expressions &Languages (Chapter:03)
Q. 2014-4(c): What is a regular expression? Write the formal Definition expression.
Regular Expression: Regular expressions are built up with the help of regular operations. For
example-
20
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
(0U1)0*
Where, (0U1) means ({0} U {1}).The value of this part is the language {0,1} and the part 0*
means {0}*. The value of this part is the language consisting of all strings consisting any
number of 0s.
Formal Definition: Say that, L is a regular expression if L is-
1. a for some a in the alphabet ∑,
2. Ɛ,
3. ɸ,
4. (L1 ∪ L2), where L1 and L2 are regular expressions,
5. (L1.L2), where L1 and L2 are regular expressions,
6. (L1*), where L1 is a regular expressions,
Operations: The operations of regular expressions are-
1. Union: The union of two languages L and M, denoted by (L ∪ M), is the set of strings
that are in either L or M or both. For example- if L = {001, 10, 111} and M = {ɛ, 001},
then (L∪M) ={ɛ, 01, 001, 111}.
2. Concatenation: The concatenation of two languages L and M is the set of strings that
can be formed by taking any string L and the concatenating it with any string in M. For
example- if L = {001, 10, 111} and M = {ɛ, 001}, then (L.M) = {001, 01, 111, 001001,
10001, 111001}.
3. Closure: The closure of a language L is denoted by L* and represents the set of those
strings that can be formed by taking any number of strings from L. For example- if L ={0,
11}, then L*= {011, 110, 11011, 1110}
Star Closure: L*= L1 L2 L3 ----------------
Kleene Closure: L*= L0 L1 L2 ----------------
Q.2014-5(b)/Example 3.5: Convert the following DFA to an equivalent regular
Expression.
21
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Associability & Commutability Laws:
5 (c): Associability: Associability is the property of an operator that allows us to regroup the
operands when the operator is applied twice. Laws:-
1. (L+M)+N= L+(M+N), that is associative law for union.
2. (LM)N= L(MN), that is associative law for concatenation.
Commutativity: Commutativity is the property of an operator that says we can switch the
order of its operands and get the same resuly. Laws:-
1. L+M= M+L , that is commutative law for union.
Identities & Annihilators:
Identity: An identity for an operator is a value such that when the operator is applied to the
identity and some other value, the result is the other value. Laws:-
1. ɸ+L= L+ɸ= L, this law asserts that ɸ is the identity for union.
2. ɛL=Lɛ= L, this law asserts that ɛ is the identity for concatenation.
22
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
5(c): Annihilator: An annihilator for an operator is a value such that when the operator is
applied to the annihilator and some other value, the result is the annihilator. Laws:-
1. ɸL= Lɸ= ɸ, this law asserts that ɸ is the annihilator for concatenation.
5(c): Distributive Law: A distributive law involves two operators and asserts that one
operator can be pushed down to be applied to each argument of the other operator
individually. Laws:-
1. L(M+N)= LM+LN, this is the left distributive law of con catenation over union.
2. (M+N)L= ML+NL, this is the right distributive law of concatenation over union.
Properties of Regular Language: (Chapter:04)
Q. 2014-7(a): What is pumping lemma? Describe the pumping lemma theorem for regular
languages.
In the theory of formal languages, the pumping lemma for regular languages describes an
essential property of all regular languages.
The technique for proving non regularity of some language is provided by a theorem about
regular languages called pumping lemma
Pumping lemma states that all regular languages have a special property.
If we can show that a language L does not have this property we are guaranteed that L is not
regular.
Using pumping lemma theorem, prove the following languages are not regular.
a. {0n
|n is a perfect cube}- (Q. 2014-7(b))
Solution: L is infinite. Suppose L is also regular. Then according to pumping lemma there exists
an integer n such that for every string w in where |w| >= n, we can break w into three strings w =
xyz such that: |y| > 0, |xy| <= n and for all k>=0 , the string xyk
z is also in L.
Choose w to be w = 0s
where s = n3
that is it is a perfect square.
Let w= 00000000000000000………00000 = xyz . (The length of w = s = n3
in this case.)
Let |xy| <= n and |y| = k.
23
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
That is w = 0000 0k
000…
x y z
So, |xyz| = |xz| + |y| = (n3
-k ) + (k)
From pumping lemma, I can pump y any number of times and the new string should also belong
to the language. Suppose I pump y twice then, the new string should belong to the language that
is it should have length that is a perfect cube but |xy2
z| = |xz| + 2|y| = (n3
- k ) + 2k = n3
+ k where
n3
+ k < n3
+ n (k <= n as |xy| <=n and |y| = k ) < n3
+ 3 n2
+ 3n +1 = (n+1)3
and n3
+ k > n3
(Ask > 0)
=> n3
< n3
+ k < (n+1)3
 n3
+ k is not a perfect cube
 xy2
z is not in L
 This is a contradiction to the pumping lemma
 So, our initial assumption must have been wrong that is L is not regular
b. ** The language Lpr consisting of all strings of 1's whose length is a prime is not regular.
24
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
c. ** {0n
1n
|n≥1}
d. {0n
1m
2n
|n and m are arbitrary integers- (Q. 2014-7(b))
e. ** The language consisting of all strings of 0's & 1's that is of the form ѡѡR
.
The Post correspondence problem: The Post correspondence problem (due to Emil Post) is
another un decidable problem that turns out to be a very helpful tool for proving problems in
logic or in formal language theory to be un decidable.
Q. 2014-7(d): T: 4.11: Prove that- if L is a regular language, so is LR
.
25
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Context-Free Grammars and Language: (Chapter:05)
Q. 2014-6(a): What is Context-Free Grammar? (CT-02) Write the components used for
grammatical description of a language.
Grammar: A grammar consists of collection of rules called productions. Each rule appears as a
line in the grammar, comprising a symbol and a string separated by an arrow. The symbol is
called a variable. The string consists of variables and other symbols.
A A+1
B A
B #
Components: There are four components in a grammatical description of a language-
1. Terminals: There is a finite set of symbols that form the strings of the language being
defined. These symbols are called terminals or terminal symbols.
2. Non-Terminals: There is a finite set of variables where each variable represents a
language; i.e. a set of strings. These variables are called non-terminals.
3. Start Symbol: One of the variable represents the language being defined it. These
variables is called start symbol.
4. Production or Rules: There is a finite set of production or rules that represent the
recursive definition of the language. Each production consists of-
 A variable that is being defined by the production. This variable is often called the
head of the production
 The production symbol, and
 A string of zero or more terminals and variables. (Body of production).
Formal definition of context-free Grammar: A context-free Grammar is a 4-tuple (V, ∑,
R, S), where-
1. V is a finite set called variables,
2. ∑ is a finite set, disjoint from V, called the terminals,
3. R is a finite set of rules, with each rule being a variable and a string of variables and
terminals,
4. S Є V is the start variable.
26
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
CT-02/Example 5.5: a*(a+b00) with leftmost and rightmost derivations.
With context-free Grammar, show the inference that a*(a+b00) is in the language of variable E
can be reflected in a derivation of that string, starting with the string E.
Derivation:
E E*E I*E a*E a*(E+E)
a*(I+E) a*(a+E) a*(a+I) a*(a+I0)
a*(a+I00) a*(a+b00)
Formal definition of Construction Pares trees: Let us fix on a grammar G= (V, T, P, S).
The pares tree for G are trees with the following condition:
1. Each interior node is labeled by a variable in V.
2. Each left labeled by either a variable, a terminal, or ∈.
3. If a interior node is labeled A, and its children are labeled
X1, X2, ……. Xk
CT-02: Parse Tree: There is a tree representation for derivations that has proved extremely
useful. This tree shows us clearly how the symbols of a terminal string are grouped into
substrings, each of which belongs to the language of one of the variables of the grammar. This
tree is known as a “parse tree”.
CT-02: Application of context-free grammar:
1. Grammars are used to describe programming languages.
2. Grammars are used to in the development of XML (Extensible Markup Language).
27
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
3. Others.
Q. 2014-6(c): Explain the Ambiguous Grammar?
Ambiguous Grammar: A string ѡ is derived ambiguously in context-free grammar G, if it has
two or more different leftmost derivations. A grammar G is ambiguous if it generates some
string ambiguously.
Q. 2014-6(c)/ Example 5.25: Show the ambiguous grammars for E+E*E.
Solution: (1) E→E+E →E+E*E (2) E→E*E →E+E*E
Removing Ambiguity from Grammar:
Q. 2014-6(d): Write the Causes of Ambiguity. How we can remove Ambiguity from a
Grammar.
The Causes of Ambiguity: There are two causes of ambiguity in the grammar:
1. The precedence of operators is not respected. While Fig (a) properly groups the * before
the + operator, Fig (b) is also a valid pares tree and groups the + ahead of the *.
2. A sequence of identical operators can group either from the left or from the right.
Remove Ambiguity from a Grammar: -A factor is an expression that cannot be broken
apart by any adjacent operator, either a* or a +. They only factors in our expression language
are: (a) Identifiers. (b) Any parenthesized expression.
-A term is an expression that cannot be broken by the + operator. In our example, where + and *
are the only operators, a term is a product of one or more factors.
28
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
-An unambiguous expression grammar:
I→ a|b|Ia|Ib|I0|I1
F→ I|(E)
T→ F|T*F
E→ T|E+T
Example 5.27: Show an unambiguous grammar for a+a*a.
Inherent Ambiguity: A context-free language L is said to be inherently ambiguous if all its
grammars are ambiguous. If even one grammar for L is unambiguous, then L is an unambiguous
language.
Chapter-06 (Pushdown automata)
Pushdown automata: A pushdown automata (PDA) is essentially an ∈-NFA with a stack.
On a transition, the PDA:
1. Consumes an input symbol.
2. Goes to a new state (or stays in the old).
3. Replaces the top of the stack by any string (does nothing, pops the stack, or pushes a string
onto the stack)
29
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Q. 2014-8(d): Give the formal definition of PDA. Draw the deterministic PDA for the
following Lwcwr
30
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Q. 2014-8(b)/Example: 6.2: Write the steps used for designing a PDA from the following
language-
31
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Example-6.4:
Chapter-07 (Properties of Context-free Language )
A context-free grammar: A context-free grammar (CFG) is a formal grammar in which every
production rule is of the form
V → w
Where V is a “non-terminal symbol” and w is a “string” consisting of terminals and/or non-
terminals.
 The term "context-free" expresses the fact that the non-terminal V can always be replaced
by w, regardless of the context in which it occurs.
 A formal language is context-free if there is a context-free grammar that generates it.
 Context-free grammars are powerful enough to describe the syntax of most programming
languages; in fact, the syntax of most programming languages is specified using context
free grammars.
32
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Normal forms for Context-Free Grammar: The goal is to show that every CFL (without ε) is
generated by a CFG in which all productions are of the form A  BC or A  a, where A, B, C
are variables, and a is a terminal. A number of simplifications is inevitable:
1. The elimination of useless symbols, “variables or terminals that do not appear in any
derivation of a terminal string from the start symbol”.
2. The elimination of ε-productions, those of the form A  ε for some variable A.
3. The elimination of unit productions, those of the form A  B for variables A and B.
Eliminating useless symbols:
 A symbol X is useful for Grammar G = {V, T, P, S}, if there is some derivation of the
form S ═>* a × b ═>* w , where w є T*
 X є V or X є T
 The sentential form of a × b might be the first or last derivation
 If × is not useful, then × is useless
Example 7.1: Consider the grammar: S→ AB | a; A→b
-Notice that only S and a are reachable after eliminating the non-generating B.
-A is not reachable; so it should be eliminated.
-The result: S→ a
-This production itself is a grammar that has the same result, which is {a}, as the original
grammar.
Eliminating unit productions:
 The last part concerns the eliminating of unit productions
 Any production of the form A  B, where A and B are variables, is called a unit
production.
 These productions introduce extra steps in the derivations that obviously are not needed in
there.
Example 7.12:
33
@ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592
Resulting grammar:
After eliminating the unit productions, the generated grammar is:
This grammar has no unit productions and still generates the same expressions as the previous
one.
Q. 2014-5(a): Prove that-if L=L(A) for some DFA A, then there is a regular expression R
such that L=L(R).
(Ans)Text Book-Page: 112
Q. 2014-5(c): Convert the regular expressions into its equivalent ∈-NFA
(i) (01+1)*
(ii) (0+1)*101

More Related Content

What's hot

Push down automata
Push down automataPush down automata
Push down automata
Somya Bagai
 

What's hot (20)

Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Deciability (automata presentation)
Deciability (automata presentation)Deciability (automata presentation)
Deciability (automata presentation)
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
0.0 Introduction to theory of computation
0.0 Introduction to theory of computation0.0 Introduction to theory of computation
0.0 Introduction to theory of computation
 
Lecture 3,4
Lecture 3,4Lecture 3,4
Lecture 3,4
 
Chomsky Normal Form
Chomsky Normal FormChomsky Normal Form
Chomsky Normal Form
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Kleene's theorem
Kleene's theoremKleene's theorem
Kleene's theorem
 
Lesson 05
Lesson 05Lesson 05
Lesson 05
 
3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl3.5 equivalence of pushdown automata and cfl
3.5 equivalence of pushdown automata and cfl
 
Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)Automata theory - Push Down Automata (PDA)
Automata theory - Push Down Automata (PDA)
 
Multi Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
 
1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa1.7. eqivalence of nfa and dfa
1.7. eqivalence of nfa and dfa
 
Pumping lemma for cfl
Pumping lemma for cflPumping lemma for cfl
Pumping lemma for cfl
 
Undecidabality
UndecidabalityUndecidabality
Undecidabality
 
1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets1.10. pumping lemma for regular sets
1.10. pumping lemma for regular sets
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
Types of grammer - TOC
Types of grammer - TOCTypes of grammer - TOC
Types of grammer - TOC
 
Push down automata
Push down automataPush down automata
Push down automata
 

Similar to Automata Theory

Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
jacksnathalie
 

Similar to Automata Theory (20)

Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Deterministic finite automata
Deterministic finite automata Deterministic finite automata
Deterministic finite automata
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithms
 
algorithm unit 1
algorithm unit 1algorithm unit 1
algorithm unit 1
 
QB104541.pdf
QB104541.pdfQB104541.pdf
QB104541.pdf
 
Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )Introduction to python programming ( part-2 )
Introduction to python programming ( part-2 )
 
Finite automata
Finite automataFinite automata
Finite automata
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Fsa
FsaFsa
Fsa
 
Theory of Computation - Lectures 4 and 5
Theory of Computation - Lectures 4 and 5Theory of Computation - Lectures 4 and 5
Theory of Computation - Lectures 4 and 5
 
Theoryofcomp science
Theoryofcomp scienceTheoryofcomp science
Theoryofcomp science
 
Dfa h11
Dfa h11Dfa h11
Dfa h11
 
Teori automata lengkap
Teori automata lengkapTeori automata lengkap
Teori automata lengkap
 
Anu DAA i1t unit
Anu DAA i1t unitAnu DAA i1t unit
Anu DAA i1t unit
 
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
 
Theory of computation:Finite Automata, Regualr Expression, Pumping Lemma
Theory of computation:Finite Automata, Regualr Expression, Pumping LemmaTheory of computation:Finite Automata, Regualr Expression, Pumping Lemma
Theory of computation:Finite Automata, Regualr Expression, Pumping Lemma
 
Nondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdfNondeterministic Finite Automata AFN.pdf
Nondeterministic Finite Automata AFN.pdf
 

More from Jessore University of Science & Technology, Jessore.

More from Jessore University of Science & Technology, Jessore. (15)

Compact it job solution part 01 (Preliminary)
Compact it job solution part 01 (Preliminary)Compact it job solution part 01 (Preliminary)
Compact it job solution part 01 (Preliminary)
 
Distributed system
Distributed systemDistributed system
Distributed system
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Operating system
Operating systemOperating system
Operating system
 
Pattern recognition
Pattern recognitionPattern recognition
Pattern recognition
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Number system and digital device (Chapter 3)
Number system and digital device (Chapter 3)Number system and digital device (Chapter 3)
Number system and digital device (Chapter 3)
 
Programming Language (chapter 5 for class 11 and 12)
Programming Language (chapter 5 for class 11 and 12)Programming Language (chapter 5 for class 11 and 12)
Programming Language (chapter 5 for class 11 and 12)
 
Computer networks
Computer networksComputer networks
Computer networks
 
A to z of Cyber Crime
A to z of Cyber CrimeA to z of Cyber Crime
A to z of Cyber Crime
 
Syntax analysis
Syntax analysisSyntax analysis
Syntax analysis
 
Industrial Management
Industrial ManagementIndustrial Management
Industrial Management
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
IEEE-488
IEEE-488IEEE-488
IEEE-488
 
HTML-Bangla E-book
HTML-Bangla E-bookHTML-Bangla E-book
HTML-Bangla E-book
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Automata Theory

  • 1. 1 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 01725-402592
  • 2. 2 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Automata (Chapter:01) Automata theory deals with the definitions and properties of mathemetical models of computation. These models plays a roll in several applied areas of computer science. There are two types of mathemetical models- 1. The finite automata is a mathemetical model which is used in text processing, compilers and hardware design. 2. Second model- context free grammar is used in programming languages and artificial intelligence. Q.2014-1(a): What is a finite automaton? Write the kinds of finite automata. The finite automata is a mathemetical model which is used in text processing, compilers and hardware design. Most important kinds- 1. Software for designing and checking the behavior of digital circuits. 2. The lexical analyzer of a typical compiler. 3. Software for scanning large bodies of text. 4. Software for verifying systems having finite number of distinct states. Example 1.1: Properties: 1. Finite states. 2. Every state has atleast one input. 3. Transition from one state to another requires an input Example 1.2 --- an FA modeling recognition of the keyword “then” in a lexical analyzer The double circles specify the final or “accepting state.” Ashek Mahmud Khan Dept. of CSE (JUST) 01725-402592 Start Push Push
  • 3. 3 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Structural Representation: 1. Grammar: A grammar consists of collection of rules called productions. Each rule appears as a line in the grammar, comprising a symbol and a string separated by an arrow. The symbol is called a variable. The string consists of variables and other symbols. A A+1; B A; B # 2. Regular Expression: Regular expressions are built up with the help of regular operations. For example- ( 0U1)0* Where, ( 0U1) means ({0}U{1}).The value of this part is the language {0,1} and the part 0* means {0}*. The value of this part is the language consisting of all strings consisting any number of 0s. Q.2014-1(b): Define (i) Alphabet (ii) String 1. Alphabet: An alphabet is a finite, nonempty set of symbols. The members of an alphabet are the symbols of the alphabet. An alphabet is denoted by ∑. 2. String: A string is a finite sequence of symbols chosen from some alphabet. It is usually written next to one another and not separated by commas. For example- if ∑={0,1}, then 01001 is a string over ∑. 3. Empty String: An empty string is a string with zero occurrences of symbols or a string of zero length. 4. Language: A language is a set of strings. Q.2014-1(d): Describe induction proof. Using induction proof, give recursive definition of a tree.
  • 4. 4 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Theorem – 1.1: if x ≥ 4, then 𝟐 𝒙 ≥ 𝒙 𝟐 First, notices that the hypothesis H is “x ≥ 4”. This hypothesis has a parameter, x, and thus is neither true nor false. Rather, its truth depends on the value of the parameter x e.g. H is true for x= 6 and false x=2. Likewise, the conclusion C is “2 𝑥 ≥ 𝑥2 ". 𝑇ℎ𝑖𝑠 𝑠𝑡𝑎𝑡𝑒𝑚𝑒𝑛𝑡 𝑎𝑙𝑠𝑜 𝑢𝑠𝑒𝑟𝑠 parameter x and is true is for certain values of x and not others. For example –let, x=1, 21 = 2 and 12 = 1 which is false x=2, 22 = 4 and 22 = 2 which is false x=3, 23 = 8 and 32 = 9 which is false x=4, 24 = 16 and 42 = 16 which is true x=5, 25 = 32 and 52 = 25 which is true x=6, 26 = 64 and 62 = 36 which is true The conclusion 2 𝑥 ≥ 𝑥2 will be true when ever x ≥ 4. We already saw that it is true for x =4;
  • 5. 5 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Q.2014-1(c)/Theorem-1.4: Prove that If x is the sum of the squares of four positive integers, then 2x ≥x2 . Proof: The intuitive idea of the proof is that if the hypothesis is true for x, that is, x is the sum of the squares of four positive integers, and then x must be at least 4. Step Statement justification 1. 2. 3. 4. 5. x=𝑎2 +𝑏2 +𝑐2 +𝑑2 a ≥ 1; b ≥ 1; c ≥ 1; d ≥ 1; 𝑎2 ≥ 1; 𝑏2 ≥ 1; 𝑐2 ≥1; 𝑑2 ≥1; x ≥ 4 2 𝑥 ≥ 𝑥2 Given Given Step (2) and properties of arithmetic Step(1), (3), and properties of arithmetic Step(4) and 2 𝑥 ≥ 𝑥2 Table: A formal proof 𝟐 𝒙 ≥ 𝒙 𝟐 Table shows the sequence of statements we need to prove 2 𝑥 ≥ 𝑥2 . In step (1), we have repeated one of the given statements of the theorem, that x is the sum of the squares of four integers. Giving the four integers the names a, b, c and d. In step (2), we put down the other part of the hypothesis of the theorem that the values being squared are each at least 1; step (4) users statements (1) and (3). The first statement tells us that x is the sum of the four squares in question, and statement (3) tells us that each of the squares is at least 1. Again using well known properties of arithmetic, we conclude that x is at least 1+1+1+1; or 4 At the find step (5), we use statement (4), which is the hypothesis of theorem 2 𝑥 ≥ 𝑥2 . Finite Automata (Chapter:02) Q.2014-2(a): What is a finite automaton? Write the use of finite automaton. Finite automata: A finite automaton has a set of states and its “control” moves from state to state in response to external “inputs”. A finite automaton is a simple idealized machine used to recognize patterns within input taken from some character set or alphabet. The job of an finite automaton is to accept or reject an input depending on whether the pattern defined in the input. Use of finite automaton:  Text processing,  Compilers design and  Hardware design.
  • 6. 6 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Deterministic Finite Automata: A deterministic finite automaton means that the automaton cannot be in more than one state at any one time. The term “deterministic” refers to the fact that on each input there is one and only one state to which the automaton can transition from its current state. Q.2014-2(b): Write the Formal definition of DFA. Formal definition of deterministic finite automaton (DFA): A finite automaton is a 5-tuple (Q, ∑, δ, q₀, F) where- 1. Q is a finite set called the states, 2. ∑ is a finite set called the alphabet, 3. δ: Q × ∑→ Q is the transition function, 4. q₀ Є Q is the start state and 5. F ⊆ Q is the set of accept states. How a DFA processes strings? The first thing we need to understand about a DFA is how the DFA decides whether or not to “accept” a sequence of input symbols. The “language” of the DFA is the set of all strings that the DFA accepts. Suppose a1 a2……an is a sequence of input symbols. We start out with the DFA in its start state, q0. We consult the transition function 𝛿, say 𝛿(q0,a1) = q1 to find the state that the DFA A enters after processing the first input symbol a1. We process the next input symbol, a2 by evaluating 𝛿(q1,a2); let us suppose this state is q2. We continue in this manner, finding states q3, q4….., qn such that 𝛿(qi-1,ai) = qi for each i. If qn is a member of F, then the input a1a2……an is accepted, and if not then it is “rejected”. Example 2.1 & 2.2: {ѡ|ѡ is of the form x01y for some strings x and y consisting of 0’s and 1’s only} Formal Definition: Suppose, the finite automaton M, we can describe M formally by writing M= (Q, ∑, δ, q₀, F), where-
  • 7. 7 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 1. Q ={q₀, q₁, q₂}, 2. ∑ ={0,1}, 3. δ is described as- δ 0 1 q₀ q₁ q₀ *q₁ q₁ q₂ q₂ q₂ q₂ 4. q₀ is the start state and 5. F = {q₂}. Q.2014-2(d): Describe the extended transition function for DFA. Extended Transition Function: The extended transition function is a function that takes a state q and a string ѡ and returns a state p- the state that the automaton reaches when starting in state q and processing the sequence of inputs ѡ. We define δˆ by induction on the length of the input string, as follows: BASIS: δˆ(q,ϵ)=q. That is, if we are in state q and read no inputs, then we are still in state q. INDUCTION: Suppose ѡ is a string of the form xa; that is, a is the last symbol of ѡ, and x is the string consisting of all but the last symbol. For example, ѡ is broken into x= 110, and a=1. Then δˆ (q, ѡ)= δ(δˆ(q, x),a) To compute δˆ(q, ѡ), first compute δˆ(q, x), the state that the automaton is in after processing all but the last symbol of ѡ. Suppose this is state p, that is δˆ(q, x)=p. Then δˆ(q, ѡ) is what we get by making a transition from state p on input a, the last symbol of ѡ. That is, δˆ(q, ѡ)= δ(p, a). Q.2014-2(d)/Example 2.4: Write the steps for the following language using extended transition function- {ѡ|ѡ has both an even number of 0’s and an even number of 1’s}.
  • 8. 8 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Solution: Formal Definition: 1. Q ={q₀, q₁, q₂,q3} 2. ∑ = {0,1} 3. δ is described as- δ 0 1 q₀ q0 q1 q₁ q₂ q0 q₂ q₁ q3 q3 q0 q₂ 4. q₀ is the start state and 5. F = {q0}.  { ѡ|ѡ accept any number of 1’s} Solution: Formal Definition: 1. Q ={q₀, q₁, q₂} 2. ∑ ={0,1} 3. δ is described as-
  • 9. 9 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 δ 0 1 q₀ q₁ q₀ q₁ q₁ q₂ *q₂ q₂ q₂ 4. q₀ is the start state and 5. F = {q₂}.  {ѡ|ѡ ends in 00} Solution: Formal Definition: 1. Q ={q₀, q₁, q₂} 2. ∑ ={0,1} 3. δ is described as- δ 0 1 q₀ q₁ q₀ q₁ q₂ q₀ *q₂ q₂ q₀ 4. q₀ is the start state and 5. F = {q₂}.
  • 10. 10 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592  { ѡ|ѡ has two consecutive 1’s or two consecutive 0’s } Solution: Formal Definition: 1. Q ={q₀, q₁, q₂ ,q3 ,q4 ,q5 ,q6 ,q7 ,q8} 2. ∑ ={0,1} 3. δ is described as- δ 0 1 q0 q3 q1 q1 q4 q2 q2 q5 q2 q3 q6 q4 q4 q7 q5 q5 q8 q5 q6 q6 q7 q7 q7 q8 *q8 q8 q8 4. q₀ is the start state and 5. F = {q8}. Q.2014-2(c): Draw the DFA’s and formal definition for the following languages- (i) {ѡ|ѡ does not contain ab, ba, bbba}.
  • 11. 11 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592  Construct DFA’s all strings with exactly one a.  Construct DFA’s all strings with at least one a.  Construct DFA’s all strings with at least one a and exactly two b’s. Q.2014-2(c): Draw the DFA’s and formal definition for the following languages- (ii) Construct DFA’s all the strings with exactly two a’s and more than two b’s. The automaton is constructed with similar techniques as above Regular Language of DFA: A language is called a regular language if some finite automaton recognizes it. Let, M= (Q, ∑, δ, q₀, F) be a finite automaton and let ѡ = ѡ₁, ѡ₂, ------, ѡn be a string where each ѡi is a member of the alphabet ∑. Then M accepts ѡ if a sequence of states r₀, r₁, r₂, -----, rn in Q exists with three conditions- b b a a b a b b a a a a a a b b b a b b a b a
  • 12. 12 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 1. r₀=q₀, 2. δ(ri , ѡi+1 )= ri+1, for i=0,1,------n-1 and 3. rn Є F. The first condition says that the machine starts in the start state. Condition 2 says that the machine goes from state to state according to the transition function. Condition 3 says that the machine accepts its input if it ends up in an accept state. We say that M recognizes language A if- A= {ѡ|M accepts ѡ} Q.2014-3(a): Explain the Language of NFA with proper example. Non-Deterministic Finite Automata: In deterministic computation, when the machine is in a given state and reads the next input symbol, we know what the next state will be, it is determined. But in nondeterministic computation, several choices may exist for the next state at any point. It has the power to be in several states at once. This ability is often expressed as an ability to “guess” something about its input. Formal definition of nondeterministic finite automaton: A finite automaton is a 5-tuple ( Q, ∑, δ, q₀, F ), where- 1. Q is a finite set called the states, 2. ∑ is a finite set called the alphabet, 3. δ: Q × ∑ɛ → P(Q) is the transition function, 4. q₀ Є Q is the start state and 5. F ⊆ Q is the set of accept states. Example 2.6: An NFA accepting all strings that end in 01. Formal Definition: Suppose, the finite automaton M, we can describe M formally by writing M= (Q, ∑, δ, q₀, F), where- 1. Q ={q₀, q₁, q₂}, 2. ∑ ={0,1}, 3. δ is described as-
  • 13. 13 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 𝛿 0 1 q₀ { q₀, q₁ } { q₀ } q₁ ɸ { q₂ } q₂ ɸ ɸ 4. q₀ is the start state and 5. F ={q₂}. Extended Transition Function (NFA): The extended transition function is a function that takes a state q and a string of input symbols ѡ and returns the set of states that the NFA is in if it starts in state q and processes the string ѡ. Formally we define δˆ for an NFA’s transition function δ by: BASIS: δˆ(q,ϵ)= {q}. That is, without reading any input symbols, we are only in the state we began in. INDUCTION: Suppose ѡ is of the form ѡ=xa; that is, a is the last symbol of ѡ, and x is the string consisting of all but the last symbol. Also suppose that δˆ(q, x) = { p1, p2, -----,pk}. Let- 𝛿𝑘 𝑖=1 (pi,a)= {r1, r2, -----, rm} Then, δˆ (q, ѡ)= {r1, r2, -----, rm} Example-2.8: Let us use δˆ to describe how the string 01010 is processed by the NFA of Fig. 2.8 Fig. 2.8 1. δˆ(q0, ϵ) = {q0} 2. δˆ(q0, 0) = δ(q0, 0) = {q0} 3. δˆ(q0, 01) = δ(q0, 1) = {q0, q1} 4. δˆ(q0, 010) = δ(q0, 0) ∪ δ(q1, 0) = {q0}∪{q2}= { q0, q2}
  • 14. 14 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 5. δˆ(q0, 0101) = δ(q0, 0) ∪ δ(q2, 1) = {q0, q1}∪ ∅ = {q0, q1} 6. δˆ(q0, 01010) = δ(q0, 0) ∪ δ(q1, 0) = {q0}∪ {q2} = {q0, q2} Line (1) is the basic rule. We obtain line (2) by applying δ with input 0 to the state q0 from the previous set to get {q0} once again. Now input 1 applied to this result in {q0, q1} in line (3). Line (4) is obtained by applying δ with input 0 to the two states resulting from (3) and taking their union. Lines (5) and (6) are similar to (4). Language of NFA: An NFA accepts a string ѡ if it is possible to make any sequence of choices of next state, while reading the characters of ѡ and go from the start state to any accepting state. The fact that other choices using the input symbols of ѡ lead to a non accepting state or do not lead to any state at all, does not prevent ѡ from being accepted by the NFA as a whole. Formally, if A= (Q, ∑, δ, q₀, F) is an NFA, then L(A) = {ѡ|δˆ (q₀, ѡ) ∩ F≠ ɸ} That is, L (A) is the set of strings ѡ in ∑*. Such that δˆ(q₀, ѡ) contains at least one accepting state. Example 2.9: Formally prove that, the following NFA accepts the language L= {ѡ|ѡ ends in 01} Proof: The proof is a mutual induction of the following three statements that characterize the three states: 1. δˆ (q₀, ѡ) contains q₀ for every ѡ. 2. δˆ (q₀, ѡ) contains q₁, if and only if ѡ ends in 0. 3. δˆ (q₀, ѡ) contains q₂, if and only if ѡ ends in 01. Q.2014-3(b): Describe the Equivalence of DFA to NFA. Write the steps to construct a DFA from an NFA. Equivalence of DFA to NFA: Although, for some languages an NFA is easier to cons tract than a DFA, every language that can be described by some NFA can also be described by some DFA.
  • 15. 15 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 The proof that 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 states of the NFA. The subset construction starts from an NFA N = (Qɴ, ∑, δɴ, q₀, Fɴ). Its goal is the description of a DFA D=(Qᴅ, ∑, δᴅ, {q₀}, Fᴅ) such that L(D) = L(N). Here, the input alphabets of the two automata are the same and the start state of D is the set containing only the start state of N. The other components of D are constructed as follows- Steps to construct a DFA from an NFA: 1. Qᴅ is the set of subsets of Qɴ and Qᴅ is the power set of Qɴ. That is, if Qɴ has n states, then Qᴅ will have 2n states. Often, all these states are not accessible from the start state of Qᴅ. Inaccessible states can be “thrown away”. So effectively, the number of states of D may be much smaller than 2n . 2. Fᴅ is the set of subsets S of Qɴ such that S∩Fɴ ≠ ɸ. That is, Fᴅ is all sets of N’s states that include at least one accepting state of N. 3. For each set S ⊆ Qɴ and for each input symbol a in ∑, δᴅ(S, a) = 𝛿 𝑁𝑝 𝑖𝑛 𝑠 (p, a) Q.2014-3(d)/Example 2.9: Convert the following NFA to its equivalent DFA. To convert the NFA to its equivalent DFA, we have to first construct all subsets of the states of the NFA. 𝜹 0 1 ɸ ɸ ɸ {q₀} {q₀, q₁} {q₀} {q₁} ɸ {q₂}
  • 16. 16 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 *{q₂} ɸ ɸ {q₀, q₁} {q₀, q₁} {q₀, q₂} *{q₀, q₂} {q₀, q₁} {q₀} *{q₁, q₂} ɸ {q₂} *{q₀, q₁, q₂} {q₀, q₁} {q₀, q₂} Theorem 2.11: If D= (Qᴅ, ∑, δᴅ, q₀, Fᴅ) is the DFA Constructed from NFA N = (Qɴ, ∑, δɴ, q₀, Fɴ) by the subset construction, then L(D)= L(N). Proof: What we actually prove first, by induction on |w|, is that δˆD ({q0},w) = δˆN(q0,w) (Text book: Page-63 W: J.E. Hopcroft) Q.2014-3(c)/Theorem 2.12: A language L is accepted by some DFA if and only if L is accepted by some NFA. Proof: (If) If D= (Qᴅ, ∑, δᴅ, q₀, Fᴅ) is the DFA Constructed from NFA N = (Qɴ, ∑, δɴ, q₀, Fɴ) by the subset construction, then L(D)= L(N). (Only if) This part is easy; we have only to convert a DFA into an identical NFA. Put intuitively, if we have the transition diagram for a DFA, we have also interpreted it as the transition diagram of NFA, which happens to have exactly one choice of transition in any situation. More formally, let D= (Q, ∑, δD, q₀, F) be a DFA. Define N= (Q, ∑, δN, q₀, F) to be the equivalent NFA, where δN is define by the rule. If δD (q, a)= p, then δN(q, a) = {p} It is the easy to show by induction on |w|, that if δD (q₀, w)= p then δN (q₀, w)={p} We leave the proof to the reader. As a consequence, w is accepted by D if and only if it is accepted by N; L(D)=L(N).
  • 17. 17 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Exercise-2.3.2: Convert to a DFA the following NFA Solution: Q.2014-4(a): what are the uses of ɛ-transitions. We shall begin with an informal treatment of ɛ- NFA’s, using transition diagrams with ɛ allowed as a label. In the examples of follow, think of the automaton as accepting those sequences of labels along paths from the start state to an accepting state. Q.2014-4(b)-(ii)/ Example-2.16: An ɛ- NFA that accepts decimal numbers consisting of 1. An optional + or – sign, 2.A string of digits, 3.A decimal point and 4.Another string of digits. Fig. 2.16 . .
  • 18. 18 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Extended Transitions and Languages for ɛ-Transitions: Example-2.20: Let us compute δˆ(q0,5.6) for the ɛ-NAF of Fig. 2.16. A summary of steps needed are as follows:  δˆ(q0, ɛ) = ECLOSE(q0)= {q0,q1}.  Compute δˆ(q0,5) as follows: 1. First Compute the Transitions on input 5 from the states q0 and q1 we obtained in the calculation of δˆ(q0, ɛ), above. That is, δ(q0, 5) ∪ δ(q1, 5)= { q1,q4}. 2. Next, ɛ-close the numbers of the set computed in step (1). We get, ECLOSE(q1) ∪ ECLOSE(q4) = {q1}∪{q4}={ q1,q4}.  Compute δˆ(q0, 5.) as follows: 1. First Compute δ(q1, .) ∪ δ(q4, .)= {q2}∪{q3}={ q2, q3}. 2. Then Compute δˆ(q0, 5.) = ECLOSE(q2) ∪ ECLOSE(q3) = {q2}∪{q3,q5}={q2,q3,q5}.  Compute δˆ(q0, 5.6) as follows: 1. First Compute δ(q2, 6) ∪ δ(q3, 6) ∪ δ(q5, 6)= {q3}∪{q3}∪ ∅ ={q3}. 2. Then Compute δˆ(q0, 5.6)= ECLOSE(q3) = {q3, q5} NFA Machines: ** Draw a machine divided by 2 or 3 and 2 and 3. Q.2014-4(b-(i)): Draw a machine that accepts ɛ, a, baba and baa, but not b, bb, babba. ** Draw a machine that accepts abc, abd and aacd. ** Draw a machine that accepts 0101, 101, 011. ** Draw a machine that accepts both state and regular. Q. 2014-4(a)/ 2.5.5: How we can 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, qD, FD) is defining as follows:
  • 19. 19 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 1. QD is the set of subsets of QE. 2. qD = ECLOSE(q0); that is, we get the start state of D by closing the set consisting of only the start state of E. 3. FD is those sets of states that contain at least one accepting state of E. That is, FD = {S | S is in QD and S∩FD ≠ ∅}. 4. δD(S, a) is computed, for all a in and sets S in QD by: (a) Let S= {p1, p2,……,pk}. (b) Compute δ(𝑝𝑖 𝑘 𝑖=1 , 𝑎); let this set be {r1, r2,…., rj. (c) Then δD(S, a) = 𝐸𝐶𝐿𝑂𝑆𝐸(𝑟𝑗 )𝑚 𝑗=1 . Example-2.21 Description of eliminating ɛ-Transitions Theorem-2.22 A language L is accepted by some ∈-NFA if and only if L is accepted by some DFA. This direction is easy. Suppose L = L(D) for same DFA. Let E= (QE, , δE, q0, FE) be an ∈-NFA. Apply the modified subset construction described above to produce the DFA, D = (QD, , δD, qD, FD). We need to show that L(D)= L(E). Basis: If |w| = 0, then w = ∈. We know 𝛿E (q0, ∈) = ECLOSE(q0). We also know that qD = ECLOSE(q0), because that is how the start state of D is defined. Finally, for a DFA, we know that 𝛿E (p, ∈) = p for any state p, so particular, 𝛿D(qD, ∈) = ECLOSE(q0). We have thus proved that 𝛿E(q0, ∈)=𝛿D (qD, ∈). Induction: Suppose 𝑤 = 𝑥a, where a is final symbol of 𝑤, and assume that the statement holds for 𝑥. That is, 𝛿E(q0, 𝑥)= 𝛿D(qD, 𝑥). Let both these set of states be {p1,p2,…..,pk}. By the definition of 𝛿 for ∈-NFA’s, we compute 𝛿E(q0, 𝑤) by: 1. Let {r1,r2,……., rm} be 𝛿 𝐸(𝑝𝑖, 𝑎)𝑘 𝑖=1 . 2. Then 𝛿E(q0, 𝑤) = 𝐸𝐶𝐿𝑂𝑆𝐸(𝑟𝑗 )𝑚 𝑗=1 . Regular Expressions &Languages (Chapter:03) Q. 2014-4(c): What is a regular expression? Write the formal Definition expression. Regular Expression: Regular expressions are built up with the help of regular operations. For example-
  • 20. 20 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 (0U1)0* Where, (0U1) means ({0} U {1}).The value of this part is the language {0,1} and the part 0* means {0}*. The value of this part is the language consisting of all strings consisting any number of 0s. Formal Definition: Say that, L is a regular expression if L is- 1. a for some a in the alphabet ∑, 2. Ɛ, 3. ɸ, 4. (L1 ∪ L2), where L1 and L2 are regular expressions, 5. (L1.L2), where L1 and L2 are regular expressions, 6. (L1*), where L1 is a regular expressions, Operations: The operations of regular expressions are- 1. Union: The union of two languages L and M, denoted by (L ∪ M), is the set of strings that are in either L or M or both. For example- if L = {001, 10, 111} and M = {ɛ, 001}, then (L∪M) ={ɛ, 01, 001, 111}. 2. Concatenation: The concatenation of two languages L and M is the set of strings that can be formed by taking any string L and the concatenating it with any string in M. For example- if L = {001, 10, 111} and M = {ɛ, 001}, then (L.M) = {001, 01, 111, 001001, 10001, 111001}. 3. Closure: The closure of a language L is denoted by L* and represents the set of those strings that can be formed by taking any number of strings from L. For example- if L ={0, 11}, then L*= {011, 110, 11011, 1110} Star Closure: L*= L1 L2 L3 ---------------- Kleene Closure: L*= L0 L1 L2 ---------------- Q.2014-5(b)/Example 3.5: Convert the following DFA to an equivalent regular Expression.
  • 21. 21 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Associability & Commutability Laws: 5 (c): Associability: Associability is the property of an operator that allows us to regroup the operands when the operator is applied twice. Laws:- 1. (L+M)+N= L+(M+N), that is associative law for union. 2. (LM)N= L(MN), that is associative law for concatenation. Commutativity: Commutativity is the property of an operator that says we can switch the order of its operands and get the same resuly. Laws:- 1. L+M= M+L , that is commutative law for union. Identities & Annihilators: Identity: An identity for an operator is a value such that when the operator is applied to the identity and some other value, the result is the other value. Laws:- 1. ɸ+L= L+ɸ= L, this law asserts that ɸ is the identity for union. 2. ɛL=Lɛ= L, this law asserts that ɛ is the identity for concatenation.
  • 22. 22 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 5(c): Annihilator: An annihilator for an operator is a value such that when the operator is applied to the annihilator and some other value, the result is the annihilator. Laws:- 1. ɸL= Lɸ= ɸ, this law asserts that ɸ is the annihilator for concatenation. 5(c): Distributive Law: A distributive law involves two operators and asserts that one operator can be pushed down to be applied to each argument of the other operator individually. Laws:- 1. L(M+N)= LM+LN, this is the left distributive law of con catenation over union. 2. (M+N)L= ML+NL, this is the right distributive law of concatenation over union. Properties of Regular Language: (Chapter:04) Q. 2014-7(a): What is pumping lemma? Describe the pumping lemma theorem for regular languages. In the theory of formal languages, the pumping lemma for regular languages describes an essential property of all regular languages. The technique for proving non regularity of some language is provided by a theorem about regular languages called pumping lemma Pumping lemma states that all regular languages have a special property. If we can show that a language L does not have this property we are guaranteed that L is not regular. Using pumping lemma theorem, prove the following languages are not regular. a. {0n |n is a perfect cube}- (Q. 2014-7(b)) Solution: L is infinite. Suppose L is also regular. Then according to pumping lemma there exists an integer n such that for every string w in where |w| >= n, we can break w into three strings w = xyz such that: |y| > 0, |xy| <= n and for all k>=0 , the string xyk z is also in L. Choose w to be w = 0s where s = n3 that is it is a perfect square. Let w= 00000000000000000………00000 = xyz . (The length of w = s = n3 in this case.) Let |xy| <= n and |y| = k.
  • 23. 23 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 That is w = 0000 0k 000… x y z So, |xyz| = |xz| + |y| = (n3 -k ) + (k) From pumping lemma, I can pump y any number of times and the new string should also belong to the language. Suppose I pump y twice then, the new string should belong to the language that is it should have length that is a perfect cube but |xy2 z| = |xz| + 2|y| = (n3 - k ) + 2k = n3 + k where n3 + k < n3 + n (k <= n as |xy| <=n and |y| = k ) < n3 + 3 n2 + 3n +1 = (n+1)3 and n3 + k > n3 (Ask > 0) => n3 < n3 + k < (n+1)3  n3 + k is not a perfect cube  xy2 z is not in L  This is a contradiction to the pumping lemma  So, our initial assumption must have been wrong that is L is not regular b. ** The language Lpr consisting of all strings of 1's whose length is a prime is not regular.
  • 24. 24 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 c. ** {0n 1n |n≥1} d. {0n 1m 2n |n and m are arbitrary integers- (Q. 2014-7(b)) e. ** The language consisting of all strings of 0's & 1's that is of the form ѡѡR . The Post correspondence problem: The Post correspondence problem (due to Emil Post) is another un decidable problem that turns out to be a very helpful tool for proving problems in logic or in formal language theory to be un decidable. Q. 2014-7(d): T: 4.11: Prove that- if L is a regular language, so is LR .
  • 25. 25 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Context-Free Grammars and Language: (Chapter:05) Q. 2014-6(a): What is Context-Free Grammar? (CT-02) Write the components used for grammatical description of a language. Grammar: A grammar consists of collection of rules called productions. Each rule appears as a line in the grammar, comprising a symbol and a string separated by an arrow. The symbol is called a variable. The string consists of variables and other symbols. A A+1 B A B # Components: There are four components in a grammatical description of a language- 1. Terminals: There is a finite set of symbols that form the strings of the language being defined. These symbols are called terminals or terminal symbols. 2. Non-Terminals: There is a finite set of variables where each variable represents a language; i.e. a set of strings. These variables are called non-terminals. 3. Start Symbol: One of the variable represents the language being defined it. These variables is called start symbol. 4. Production or Rules: There is a finite set of production or rules that represent the recursive definition of the language. Each production consists of-  A variable that is being defined by the production. This variable is often called the head of the production  The production symbol, and  A string of zero or more terminals and variables. (Body of production). Formal definition of context-free Grammar: A context-free Grammar is a 4-tuple (V, ∑, R, S), where- 1. V is a finite set called variables, 2. ∑ is a finite set, disjoint from V, called the terminals, 3. R is a finite set of rules, with each rule being a variable and a string of variables and terminals, 4. S Є V is the start variable.
  • 26. 26 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 CT-02/Example 5.5: a*(a+b00) with leftmost and rightmost derivations. With context-free Grammar, show the inference that a*(a+b00) is in the language of variable E can be reflected in a derivation of that string, starting with the string E. Derivation: E E*E I*E a*E a*(E+E) a*(I+E) a*(a+E) a*(a+I) a*(a+I0) a*(a+I00) a*(a+b00) Formal definition of Construction Pares trees: Let us fix on a grammar G= (V, T, P, S). The pares tree for G are trees with the following condition: 1. Each interior node is labeled by a variable in V. 2. Each left labeled by either a variable, a terminal, or ∈. 3. If a interior node is labeled A, and its children are labeled X1, X2, ……. Xk CT-02: Parse Tree: There is a tree representation for derivations that has proved extremely useful. This tree shows us clearly how the symbols of a terminal string are grouped into substrings, each of which belongs to the language of one of the variables of the grammar. This tree is known as a “parse tree”. CT-02: Application of context-free grammar: 1. Grammars are used to describe programming languages. 2. Grammars are used to in the development of XML (Extensible Markup Language).
  • 27. 27 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 3. Others. Q. 2014-6(c): Explain the Ambiguous Grammar? Ambiguous Grammar: A string ѡ is derived ambiguously in context-free grammar G, if it has two or more different leftmost derivations. A grammar G is ambiguous if it generates some string ambiguously. Q. 2014-6(c)/ Example 5.25: Show the ambiguous grammars for E+E*E. Solution: (1) E→E+E →E+E*E (2) E→E*E →E+E*E Removing Ambiguity from Grammar: Q. 2014-6(d): Write the Causes of Ambiguity. How we can remove Ambiguity from a Grammar. The Causes of Ambiguity: There are two causes of ambiguity in the grammar: 1. The precedence of operators is not respected. While Fig (a) properly groups the * before the + operator, Fig (b) is also a valid pares tree and groups the + ahead of the *. 2. A sequence of identical operators can group either from the left or from the right. Remove Ambiguity from a Grammar: -A factor is an expression that cannot be broken apart by any adjacent operator, either a* or a +. They only factors in our expression language are: (a) Identifiers. (b) Any parenthesized expression. -A term is an expression that cannot be broken by the + operator. In our example, where + and * are the only operators, a term is a product of one or more factors.
  • 28. 28 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 -An unambiguous expression grammar: I→ a|b|Ia|Ib|I0|I1 F→ I|(E) T→ F|T*F E→ T|E+T Example 5.27: Show an unambiguous grammar for a+a*a. Inherent Ambiguity: A context-free language L is said to be inherently ambiguous if all its grammars are ambiguous. If even one grammar for L is unambiguous, then L is an unambiguous language. Chapter-06 (Pushdown automata) Pushdown automata: A pushdown automata (PDA) is essentially an ∈-NFA with a stack. On a transition, the PDA: 1. Consumes an input symbol. 2. Goes to a new state (or stays in the old). 3. Replaces the top of the stack by any string (does nothing, pops the stack, or pushes a string onto the stack)
  • 29. 29 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Q. 2014-8(d): Give the formal definition of PDA. Draw the deterministic PDA for the following Lwcwr
  • 30. 30 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Q. 2014-8(b)/Example: 6.2: Write the steps used for designing a PDA from the following language-
  • 31. 31 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Example-6.4: Chapter-07 (Properties of Context-free Language ) A context-free grammar: A context-free grammar (CFG) is a formal grammar in which every production rule is of the form V → w Where V is a “non-terminal symbol” and w is a “string” consisting of terminals and/or non- terminals.  The term "context-free" expresses the fact that the non-terminal V can always be replaced by w, regardless of the context in which it occurs.  A formal language is context-free if there is a context-free grammar that generates it.  Context-free grammars are powerful enough to describe the syntax of most programming languages; in fact, the syntax of most programming languages is specified using context free grammars.
  • 32. 32 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Normal forms for Context-Free Grammar: The goal is to show that every CFL (without ε) is generated by a CFG in which all productions are of the form A  BC or A  a, where A, B, C are variables, and a is a terminal. A number of simplifications is inevitable: 1. The elimination of useless symbols, “variables or terminals that do not appear in any derivation of a terminal string from the start symbol”. 2. The elimination of ε-productions, those of the form A  ε for some variable A. 3. The elimination of unit productions, those of the form A  B for variables A and B. Eliminating useless symbols:  A symbol X is useful for Grammar G = {V, T, P, S}, if there is some derivation of the form S ═>* a × b ═>* w , where w є T*  X є V or X є T  The sentential form of a × b might be the first or last derivation  If × is not useful, then × is useless Example 7.1: Consider the grammar: S→ AB | a; A→b -Notice that only S and a are reachable after eliminating the non-generating B. -A is not reachable; so it should be eliminated. -The result: S→ a -This production itself is a grammar that has the same result, which is {a}, as the original grammar. Eliminating unit productions:  The last part concerns the eliminating of unit productions  Any production of the form A  B, where A and B are variables, is called a unit production.  These productions introduce extra steps in the derivations that obviously are not needed in there. Example 7.12:
  • 33. 33 @ Ashek Mahmud Khan; Dept. of CSE (JUST); 01725-402592 Resulting grammar: After eliminating the unit productions, the generated grammar is: This grammar has no unit productions and still generates the same expressions as the previous one. Q. 2014-5(a): Prove that-if L=L(A) for some DFA A, then there is a regular expression R such that L=L(R). (Ans)Text Book-Page: 112 Q. 2014-5(c): Convert the regular expressions into its equivalent ∈-NFA (i) (01+1)* (ii) (0+1)*101