Midterm Examination for Discrete Mathematics

advertisement
Formal Language and Automata Theory: Quiz 1
Name:_________________ Reg.No.:________________
2013/10/30
Score:_______________
1. [10pts] Let A= {01,1,101} and B = {0,10,110}.
1.1 Which of the following strings are in AB ?
(a) 1010
(b) 1100
(c) 0101
(d) 110 (e) 10101
1.2 List all strings x in A3 with |x| < 5.
ANS:
2. [15pts] Which of the following statements are correct? Let A,B and C are arbitrary languages.
(a) If A  B then CA  CB
(b) A (B  C) = AB  AC.
(c) (A*)* = A*
(d) If A2  A then A+ = A.
(e) {x,y,z}*  {xyz}*, where x,y and z are arbitrary strings.
3. [25pts] Given a DFA M shown below as a state transition diagram :
M
(a) Fill the above table to get a complete state transition table for the DFA M.
(b) Let M = (Q, , , s, F). Then what are the contents of Q, , , S and F, respectively.
 = _____________________
F =______________________
 Q = _______________________
 s =_______________________
 ={
}
Note: Use triple (p,a,q) to represent the case that (p,a) = q.
1
(c) For each input given in the table below, list the sequence of states traversed while running
the machine with the input and determine if the input is accepted.
input
Sequence of states traversed

accepted?
q1
abba
baab
4. [35pts] Let = {a,b}. Construct a DFA for each of the following languages. Use state transition
diagram for your answer. Note: #c(x) denotes the number of occurrences of symbol c in x.
(a)
L1 = { x {a,b}* | x starts with a and ends with b }.
(b)
L2 = { x{0,1}* | x contains the substring 001
(c)
L3 = { x {0,1}* | x ends with 1001 }.
}
(d) [5pts] Given two arbitrary binary number x= x1x2…xn and y = y1y2…yn of the same length, we
want to determine if x > y. Let 2 = { (0,0),(0,1),(1,0),(1,1) }, and for the pair (x,y) of binary
number x and y of the same length, let e(x,y)= (x1,y1) (x2,y2) …(xn,yn) be a string over 2.
Design a DFA M such that L(M) = { e(x,y) | x and y are binary numbers of the same length
and x > y.}
2
5. [25pts]
(a) Find a DFA M1 with two states: p,q such that L(M1) = { x | the length of x is odd }.
(b) Find a DFA M2 with three states:1,2,3 such that L(M2) = { x | x ends with bb }
Note: remember to mark starting and final states!
M1
a
M2
b
p
1
q
2
a
b
3
(c) Use the product construction to generate a DFA M3 from M1 and M2 with the set of states
{p,q}x{1,2,3} such that L(M3) = { x | The length of x is odd and x does not ends with bb. }. Give
your answer using state transition table. [15pts]
M3
a
b
6. [25pts] For a given alphabet , the regular expression over  is defined inductively as follows:
Basis: 1. The symbol e, , and every symbol a   are regular expressions.
Recursion: 2. If  and  are regular expressions, then so are (), (), and *.
Given a regular expression , the language L() denoted by  is defined inductively as follows:
Basis: L(e) = {}, L()= {} and L(a) = {a} for every symbol a  .
Recursion: L(()) = L()  L(), L(()) = L()  L(), L(*)= L()*.
For any string w = x1x2 · · ·xn, the reverse of w, written rev(w), is the string xn · · ·x2x1 ,i.e.,w
written in reverse order. For any language A  *, let rev(A) = {rev(w) | w  A}. We now want
you to construct a mapping R from regular expressions to regular expressions such that if A =
3
L(r) for some regular expression r, then rev(A) = L( R(r) ). The mapping R should be defined
recursively as follows:
(a) Basis: R(e) = ______, R()= ________ and R(a) = __________ for every a  .
(b) Recursion: R(()) = __________,
R(()) = ___________,
R(*)= ___________.
(c) Show the correctness of your answer by proving that : for all regular expressions ,
rev(L()) = L( R()). Hint: Use induction on the structure of . [13pts]
4
Download