Professional Documents
Culture Documents
HQ4 Sol
HQ4 Sol
Name of member 1:
Roll no. of member 1:
Name of member 2:
Roll no. of member 2:
Figure out how to use Math equations and symbols in Google Doc, either from Menu -> Insert ->
Equation or via plugins. Enabling Offline Editing may be useful. You can also type using ASCII
as is shown in the solved example that uses LATEX symbols in text.
You cannot assume any property of the extended transition function other than what has been
discussed in lecture. If you need any such property, you must prove it no matter how obvious it
seems.
HQ4. [Page limit 2 pages] You are given an NFA N=<Q,A,d,q0,F>. Construct another NFA
M=<Q,A,d,q0,E> where E is defined as the set of those states that have some path (using
0 or more transitions) to some final state.
(a) Give a recursive definition of E and use that to design an algorithm to construct E
just like we did for e-closure.
(b) Give a simple interpretation of the strings in L(M), i.e., construct a language K that
“intuitively” represents the strings accepted by M. Hint: Feel free to use standard
string operations/operators.
(c) Give a formal proof that M indeed accepts K using δ^ . You may first want to
present a set theoretic characterisation of E (e.g., E = { q in Q : … }). Hint: Avoid the
temptation to use graph-theoretical notations like edge, path, etc.
Algorithm to construct E:
def ConstructE():
E=F
while (flag is false):
flag = true
for all q in Q – E and all a in A U {e}: // important to search only in Q – E to end the loop
for all r in d(q,a):
if r is in E: add q to E, flag = false, continue
return E
(c) First, we write E = { q : there is some string z such that d’(q,z) has some state from F }
Now, M accepts w
iff w is in L(M)
iff d’(q0,w) has some state from E ................. [using definition of acceptance by NFA]
iff there exists some state q s.t. q d’(q0,w) and q E
.................................. [expanding d’(q0,w) has some state from E]
iff there exists some state q s.t. q d’(q0,w) and there exists some string z s.t. d’(q,z)
has some state from F
.................................... [using definition of E]
iff there exists some state q and some string z s.t. q d’(q0,w) and d’(q,z) has some
state in F ........ [moving “there exists z” forward since “q is in d’(q0,w)” does not depend on z]
iff there exists some string z s.t. d’(q0,wz) has some state in F ........[by Claim 2 below]
iff there exists some string z s.t. wz L(N) ......[using definition of acceptance by NFA]
iff w K. (QED) ................................................[using definition of K]
RHS becomes .
So, the claim holds for the base case.
IH: Assume that the claim holds for any string of length n.
IS: Consider a string w of length n+1, i.e., w=xa where a is a symbol and x is a string.
LHS becomes
RHS becomes
So the claim holds for w as well.
Hence, the claim holds for all strings.