KCS402
KCS402
Section- A
1.
What do you mean by ⋀- closure in FA?
Solution: ⋀ -closure for a given state Q means a set of states which can be reached from the state Q
1.a.
With only (null) move includes the state Q itself.
Design a regular expression that accepts all the strings for input alphabet {a,b}containing exactly 2
b’s.
1.b.
Solution: a*bba*
𝛿̂ (𝑞𝑖 , 𝑟𝑒) = 𝑞𝑗
1.c.
Give English description of the language of the following regular expression (0*.1*)*00(0+1)*.
1.d. Solution: The set of all string which contains exactly two 0’s.
Given a DFA M. Suggest a procedure to draw DFA which accepts the complement of the language
accepted by M.
1.e. Solution: The complement of a DFA can be obtained by making the non-final states as final states
and vice-versa.
SECTION - B
2.
Design the DFA of the following language over {0,1}:
(i). All strings with Even no. of 0’s and even no. of 1’s.
a.
(Ii). All strings of length at most 4.
Solution: (i)
(II)
Differentiate Between NFA & DFA. Convert the following NFA to equivalent DFA.
b.
Solution: Difference between Deterministic Finite Automata and the Non deterministic Finite
Automata ((DFA Vs NFA):
S.
DFA NFA
No.
For Every symbol of the alphabet, there is We do not need to specify how does the
1.
only one state transition in DFA. NFA react according to some symbol.
State / Alphabet a b
State / Alphabet a b
Find the regular expression corresponding to the finite automata given below:
a.
Let ∑={a,b}. For each of the following languages over ∑, find a regular expression representing it:
(i) All string that exactly contain one ‘a’.
b. (ii) All string beginning with ‘ab’.
(iii) All string that contain either the sub-string ‘aaa’ or ‘bbb’.
Solution:
(i) r .e.=b*ab*
(ii) r .e.=ab(a+b)*\
(iii) r .e. =(a+b)*(aaa+bbb) (a+b)*
4.
Differentiate Mealy and Moore machine with example. Convert the given Mealy machine as shown
in fig. into Moore Machine.
a. Output depends both upon the present state Output depends only upon the present state.
and the present input
Generally, it has fewer states than Moore Generally, it has more states than Mealy
Machine. Machine.
The value of the output function is a The value of the output function is a function
function of the transitions and the changes, of the current state and the changes at the
when the input logic on the present state is clock edges, whenever state changes occur.
done.
Mealy machines react faster to inputs. In Moore machines, more logic is required to
They generally react in the same clock decode the outputs resulting in more circuit
cycle. delays. They generally react one clock cycle
later.
Transition table for above Mealy machine is as follows:
o For state q1, there is only one incident edge with output 0. So, we don't need to split this state
in Moore machine.
o For state q2, there is 2 incident edge with output 0 and 1. So, we will split this state into two
states q20( state with output 0) and q21(with output 1).
o For state q3, there is 2 incident edge with output 0 and 1. So, we will split this state into two
states q30( state with output 0) and q31( state with output 1).
o For state q4, there is only one incident edge with output 0. So, we don't need to split this state
in Moore machine.
State pumping lemma for regular set. Show that the set 𝐿 = { 𝑎𝑝 |𝑝 𝑖𝑠 𝑝𝑟𝑖𝑚𝑒 𝑛𝑢𝑚𝑏𝑒𝑟} is not
regular.
Solution: Formal statement Pumping Lemma for Regular language: “ Let L be a regular set, then
there exists a positive integer constant m such that , if ω is any word in L such that the length of ω is
at least m that is |𝜔| ≥ 𝑚 and we can rewrite ω=xyz in such a way that
I) |𝑥𝑦| ≤ 𝑚
II) |𝑦| ≥ 1 , 𝑦 ≠ ˄, (𝑦 𝑖𝑠 𝑝𝑢𝑚𝑝𝑒𝑑)
III) 𝐹𝑜𝑟 𝑎𝑙𝑙 𝑖 ≥ 0, 𝑥𝑦 𝑖 𝑧 ∈ 𝐿.
Application of Pumping Lemma: It is used to check whether a given language is regular language
or not.
Step:
I) Assume that given language L is regular language. Let m be the constant of pumping
lemma as 𝑚 = |𝑤| + 1.
II) Take a language string ω from L such that |𝜔| ≥ 𝑚 & write ω =xyz. It means ω can be
broken into three parts as x, y and z.
b.
III) Find a suitable 𝑖 ≥ 0, 𝑥𝑦 𝑖 𝑧 ∈ 𝐿.
Note:
Pumping lemma should not used to proof that a given language to be regular.
Which string ω to select is very important and it is the key to solution using pumping lemma so
always take larger string.
Suppose the statement is true, and this langauge is regular. Then there exists a FSA(finite state
automaton) that recognizes this language, which we call M.
The pumping lemma says that there exists a natural number p such that for every string s in L(M) of
length at least p, there is a decompositon of s=xyz such that: |y| > 0 |xy| <= p
Now, we can assume that there is a string w in L(M) such that |w|=k is the first prime number greater
than p since there are infinitely many prime numbers.
Because w is in L(M) and |w| > p, w can be decomposed as w=xyz that satisfies the above conditions.
Now consider the string .
By the condition 3 above, v is in L(M). Thus, the length of v must be a prime number. But . Clearly,
k | k(1+|y|) and k > 1. Hence |v| is not prime. This contradiction implies that the supposition is false,
and the given langauge is not regular.
5.
Design a mealy machine that scans sequence of inputs of 0 and 1 and generates output ‘A’ if the
input string terminates in 00, output ‘B’ if the string terminates in 11, and output ‘C’ otherwise.
Solution:
a.
Construct the minimum state automata equivalent to DFA described by the fig.
𝑞1 𝑞3 𝑞4
b.
𝑞2 𝑞5 𝑞6
𝑞3 𝑞3 𝑞4
𝑞4 𝑞5 𝑞6
∗ 𝑞5 𝑞3 𝑞4
𝑞6 𝑞5 𝑞6
Solution: Q={𝑞0 , 𝑞1 , 𝑞2 , 𝑞3 , 𝑞4 , 𝑞5 , 𝑞6 }
𝜋0 is collection of final and nonfinal.
𝜋0 = ({𝑞5 }, {𝑞0 , 𝑞1 , 𝑞2 , 𝑞3 , 𝑞4 , 𝑞6 })
On providing input 0 breaks into 𝑠𝑒𝑡{𝑞0 , 𝑞1 , 𝑞3 } 𝑎𝑛𝑑 {𝑞2 , 𝑞4 , 𝑞6 }.
After this provide 1 to both set{𝑞0 , 𝑞1 , 𝑞3 } 𝑎𝑛𝑑 {𝑞2 , 𝑞4 , 𝑞6 } belongs to same block. So further not
break.