Theory Lab#2
Theory Lab#2
Lab#2
➞ Solution :
1. L1 U L2 = {a, bc, x, yz}
2. ∅
3. L1 L2 = {ax, ayz, bcx, bcyz}
4. L1 * = {λ, a, bc, aa, bcbc, abc, ….}
Section#2: Describe the language, given a RE:
1. (a+bc) *
2. (a+b) . a*
3. (a+b)*a(a+b)*
➞ Solution :
1. {λ, a, bc, aa, abc, bca, …}
2. {a, aa, aaa,..., b, ba, baa,...}
Language will start with a single a or b, then zero or more (𝑎)𝑠
➞ Solution :
𝑛 𝑛
1. L(G) = {𝑎 𝑏 : n>= 0}
𝑛 𝑚 𝑛
2. L(G) = {𝑎 𝑐 𝑏 : n>=0 and m>=0}
𝑛
3. L(G) = {𝑎 : n>0}
Section#4: Convert to RE:
When Σ ={a, b}
1. all words starts with “a” followed by any number of b’s
2. all words starts with “a” followed by one or more b’s
3. the language that contains nothing and contains words where any “a”
must be followed by one or more b’s
4. all words where a’s (if any) followed by b’s (if any) .
5. all words with length three and find their count
6. all words with exactly two a's
7. all words with at least two a's
When Σ = {a, b, c}
8. all words where single “a '' or “c” comes in the start then an odd
number of b’s.
9. all words where a single “a '' or “c” comes in the start then an odd
number of b’s in case of “a'' and zero or even number of b’s in case of
c.
10. all words where one or more “a” or one or more “c” comes in the
start then one or more b’s.
When Σ ={0, 1}
11. all strings with no two consecutive 0’s
12. all strings with at least two consecutive 0’s
➞ Solution :
➞ Solution :
1. Accepts any of the three strings
2. Any word ends with a , Λ is included (empty word)
3. Any word has at least one “a” and ends with “a” or “bbbb”
4. Any word has the substring “aa” or “bb”
Section#6: State whether each pair of regular
expressions are equivalent or not:
1. (a+b*)* and (a+b)*
2. a*b* and (ab)*
3. bb*aa* and b*a*
4. (a+b)*b(a+b)*a(a+b)* and bb*aa*
➞ Solution :
1. True
2. False, abab from (ab)* can’t be generated from a*b*
3. False, aaa from b*a* can’t be generated from bb*aa*
4. False, aba from (a+b)*b(a+b)*a(a+b)* can’t be generated from bb*aa*