Skip to content

TOC-As-2

Question 1

Convert the following NFA into an equivalent DFA. (20 pt)

Q1

First iteration

  • U0=E(q0)={q0,q1}
  • move(U0,0)={q0,q1,q2}
  • E(move(U0,0))={q0,q1,q2}=U1
  • move(U0,1)={q1,q2}
  • E(move(U0,0))={q1,q2}=U2

Second iteration

  • move(U1,0)={q0,q1,q2}
  • E(move(U1,0))={q0,q1,q2}=U1
  • move(U1,1)={q1,q2}
  • E(move(U1,1))={q1,q2}=U2

Third iteration

  • move(U2,0)={q0,q2}
  • E(move(U2,0))={q0,q1,q2}=U1
  • move(U2,1)={q1,q2}
  • E(move(U2,1))={q1,q2}=U2
QQ01
{q0,q1}U0U1U2
{q0,q1,q2}U1U1U2
{q1,q2}U2U1U2

twQhiy

Question 2

Let Σ={a,b}. Give a regular expression for each of the following language. (10 pt for each)


2.a. L1={anbm|n4,m3}.

aaaaa(ϵ|b|bb|bbb)

2.b. L2={w|w does not have aaa as a substring}.

(b|ab|aab)(ϵ|a|aa)


Question 3

Determine whether the following languages over Σ={a,b} are regular. Prove your answer. Each question has two languages. You don’t need to do both, select one at your favor. In general, the original languages are difficult, the alternative ones are easy. You have your own choice. If you do both, we mark the easy one. (10 pt for each subquestion)

3.a. L3={anbman|n,mN}

L3 is not regular.

Assume L3 is regular. Suppose n=m=p, Let w=apbpap , which is a string in L3

By the pumping lemma, w is in the form xyz. The substring y can be of the following three cases.

  1. If y only consists a's

    • Suppose y consists of k as.
      • Then xyyz=ap+kbpap or xyyz=apbpap+k
      • p+kp, which is not in L3.
  2. If y only consists b's

    • Suppose y consists of k bs.
      • Then xyyz=apbk+pap
      • k+pp, which is not in L3.
  3. If y consists both a's and b's

    • Then as and bs in xyyz are intersecting with each other, which is not in the form of apbpap Thus, xyyzL3.

3.b. L4={anbmaj|m>j}

L4 is not regular.

Assume L4 is regular. Suppose j=p,m=n=p+1, Let w=ap+1bp+1ap , which is a string in L4

By the pumping lemma, w is in the form xyz. The substring y can be of the following three cases.

  1. If y only consists of a's

    • Suppose y consists of k as.
      • Then xyyz=ap+k+1bp+1ap ,
        • p+1+kp+1, which is not in L4.
      • Or xyyz=ap+1bp+1ap+k
        • p+kp+1, which is not in L4.
  2. If y only consists of b's

    • Suppose y consists of k bs.
    • then xyyz=ap+1bp+1+kap
      • p+1+kp+1, which is not in L4.
  3. If y consists of both a's and b's

    • Then as and bs in xyyz are intersecting with each other, which is not in the form of apbpap Thus, xyyzL4.

3.c. L5={anbmaj|m<nm<j}

L5 is not regular.

Assume L5 is regular. Suppose m=p, n=p+1,j=p+1, Let w=ap+1bpap+1 , which is a string in L5

By the pumping lemma, w is in the form xyz. The substring y can be of the following three cases.

  1. If y only consists of a's

    • Suppose y consists of k as.
      • Then xyyz=ap+1+kbpap+1 ,
        • p+1+kp+1, which is not in L5.
      • Or xyyz=ap+1bpap+1+k
        • p+1+kp+1, which is not in L5.
  2. If y only consists of b's

    • Suppose y consists of k bs.
      • Then xyyz=ap+1bp+kap+1
      • p+kp+1, which is not in L5.
  3. If y consists of both a's and b's

    • Then as and bs in xyyz are intersecting with each other, which is not in the form of apbpap Thus, xyyzL5.

3.d. L6={anbm|nm}{anbm|mn}

L6 is regular.

Since  L6  contains every possible string of  anbm  (all strings with some number of  as followed by some number of  bs), this language is equivalent to:

L6={anbmn,mN}

Therefore, I can construct a NFA that accepts this language.

3.d.


Question 4

Are the following languages regular? Prove your answer. (10 pt for each)

4.a. L7={anbn|n1}{anbm|n1,m1}

L7 is not regular.

L7 can be divided into two parts. {anbn|n1}=L9 and {anbm|n1,m1}=L10

L9 is not regular. Assume L9 is regular. Suppose n=p, Let w=apbp , which is a string in L9

By the pumping lemma, w is in the form xyz. The substring y can be of the following three cases.

  1. If y only consists of a's

    • Suppose y consists of k as.
      • Then xyyz=ap+kbp
      • p+kp, which is not in L9.
  2. If y only consists of b's

    • Suppose y consists of k bs.
      • Then xyyz=apbp+k
      • k+pp, which is not in L9.
  3. If y consists of both a's and b's

    • Then as and bs in xyyz are intersecting with each other, which is not in the form of apbp Thus, xyyzL9.

L10 is regular, because L10=a+b+

Although L10 is regular, L7 is the union of L9 and L10, and L9 is not regular.
we can not construct a NFA for L7. Thus, L7 is not regular.


4.b. L8={anbn|n1}{anbn+2|n1}

L8 is not regular.

L8 can be divided into two parts. {anbn|n1} and {anbn+2|n1}. Let L9={anbn|n1} and L11={anbn+2|n1}

L9 is not regular, the proof has been shown in the previous question.

L11 is not regular. Assume L11 is regular. Suppose n=p, Let w=apbp+2 , which is a string in L11

By the pumping lemma, w is in the form xyz. The substring y can be of the following three cases.

  1. If y only consists of a's

    • Suppose y consists of k as.
      • Then xyyz=ap+kbp+2
      • (p+2)(p+k)2, which is not in L11.
  2. If y only consists of b's

    • Suppose y consists of k bs.
      • Then xyyz=apbp+2+k
      • (p+2+k)p2, which is not in L11.
  3. If y consists of both a's and b's

    • Then as and bs in xyyz are intersecting with each other, which is not in the form of apbp+2 Thus, xyyzL11.

L9 is not regular. L11 is also not regular.

L8=L9L11 is not regular, we can not construct a NFA for L8. Thus, L8 is not regular.