Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 1502 — Formal Methods in Computer Science

Assignment 2 (100 points)

1  (40 points) Consider the following NFAs (a) and (b) below:

a

1

a,b

 

2

 

(a)


e

 

2

 

a

a

 

b

(b)

Answer the following questions:

(a)  (5 points) Give a formal definition of the NFA (a)

(b)  (10 points) As discussed in class, every NFA has an equivalent DFA. Give the for-

mal definition of the DFA A (equivalent to NFA (a)) according to the construction given in Theorem 1.39.

(c)  (5 points) Draw the state diagram of the DFA A.

(d)  (5 points) Give a formal definition of the NFA (b)

(e)  (10 points) As discussed in class, every NFA has an equivalent DFA. Give the for-

mal definition of the DFA B (equivalent to NFA (b)) according to the construction given in Theorem 1.39.

(f)  (5 points) Draw the state diagram of the DFA B .

2  (18 points n 2 points per question) For each of the following languages, give two

strings that are members and two strings that are ott members—a total of four strings for each part. Assume the alphabet Σ = {a, b} in all parts.

a.  a*b*

b.  a(ba)*b

c.  a* n b*

d.  (aaa)*

e.  Σ* aΣ*bΣ* aΣ*

f.  aba n bab

g.  (ε n a)b

h.  (a n ba n bb)Σ*

i.  (a U u)Σ*

3  (42 points n 3 points per question) Give regular expressions generating the following

languages

Solutions:

a.  {w l w begins with 00 and ends with a 11}

b.  {w l w contains at least three 0s}

c.  {w l w contains the substring 0011 (i.e., w = x0011y for some x and y)}

d.  {w l w has length at most 3 and its second symbol is a 1}

e.  {w l w starts with 0 and has odd length, or starts with 1 and has even length}

f.  {w l w contains exactly one zero and two ones}

g.  {w l the length of w is at most 4}

h.  {w l every 0 in w must be followed by at least one 1}

i.  {w l every odd position of w is 0}

j.  {w l w contain at least two 0s and at most one 1}

k.  {ε, 0}

l.  {w l w contains an even number of 0s, or contains exactly two 1s}

m. The empty set

n. All strings except the empty string