0% found this document useful (0 votes)
38 views3 pages

CS375 Sol2 2023f

This document contains the solution to a homework assignment on regular expressions and finite automata. It involves: 1) Finding languages for given regular expressions 2) Writing regular expressions for given languages 3) Using properties of regular expressions to prove equivalences 4) Drawing DFAs and filling out transition tables for given regular expressions

Uploaded by

Seung Jun Lee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

CS375 Sol2 2023f

This document contains the solution to a homework assignment on regular expressions and finite automata. It involves: 1) Finding languages for given regular expressions 2) Writing regular expressions for given languages 3) Using properties of regular expressions to prove equivalences 4) Drawing DFAs and filling out transition tables for given regular expressions

Uploaded by

Seung Jun Lee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Solution to CS375 Homework Assignment 2 (40 points)

Due date: September 08, 2023

1. For each of the following regular expressions find a language (i.e., a set of strings) that can be
represented/described by that expression. (4 points)

a. a*bc + bc* b. b*aaac*

Solution:

a. L(a*bc + bc*) = L(a*bc) ∪ L(bc*) = L(a)*L(b)L(c) ∪ L(b)L(c)* ={a}*{b}{c} U {b}{c}*


= {Ʌ, a, aa, …, 𝑎𝑚 , … }{bc} U {b}{Ʌ, c, cc, … , 𝑐 𝑛 , … }
= {𝑎𝑚 𝑏𝑐 | 𝑚 ∈ 𝑁} ∪ {𝑏𝑐 𝑛 | 𝑛 ∈ 𝑁 }

b. L(b*aaac*) = L(b*)L(aaa)L(c*) = L(b)*L(a)L(a)L(a)L(c)* = {b}*{a}{a}{a}{c}*


= {˄, b, bb, ...., bn, ... }{aaa}{˄, c, cc, ...., cm, ... }
= { 𝑏𝑛 𝑎𝑎𝑎𝑐 𝑚 | n, m ϵ N}

2. Find a regular expression to describe the given language:

{𝑏𝑐, 𝑏, 𝑎𝑏𝑐, 𝑏𝑐 2 , … , 𝑎𝑛 𝑏𝑐, 𝑏𝑐 𝑛 , … } (2 points)

Solution:
{𝑏𝑐, 𝑏, 𝑎𝑏𝑐, 𝑏𝑐 2 , … , 𝑎𝑛 𝑏𝑐, 𝑏𝑐 𝑛 , … }
= { 𝑏𝑐, 𝑎𝑏𝑐 … , 𝑎𝑛 𝑏𝑐, … } ∪ {𝑏, 𝑏𝑐, … , 𝑏𝑐 𝑛 , … }
= {Λ, 𝑎, 𝑎𝑎, … , 𝑎𝑛 , … }{𝑏𝑐} ∪ {𝑏}{Λ, 𝑐, 𝑐𝑐, … , 𝑐 𝑚 , … }
= L(𝑎∗ )L(𝑏𝑐) ∪ L(𝑏)L(𝑐 ∗ )
= L(𝑎∗ 𝑏𝑐) ∪ L(𝑏𝑐 ∗ )
= L(𝑎∗ 𝑏𝑐 + 𝑏𝑐 ∗ )
Hence, the regular expression that describes the given language is: 𝑎∗ 𝑏𝑐 + 𝑏𝑐 ∗

3. A regular expression for the language over the alphabet {a, b} with each string having an even
number of a’s is (b*ab*ab*)*b* or b*(b*ab*ab*). Use this result to find regular expressions for the
following languages
a. a language over the same alphabet but with each string having 4n (n>=0) a’s.
(3 points)

b. a language over the same alphabet but with each string having 4n+1 (n ≥ 0) a’s.
(3 points)

Solution:
a. Either one of the following expressions works:
(b*ab*ab*ab*ab*)*b* b*(b*ab*ab*ab*ab*)*

b. Either one of the following expressions works:

b*(b*ab*ab*ab*ab*)*ab* b*a(b*ab*ab*ab*ab*)*b*

4. If a regular expression for the language over the alphabet {a, b} with no string containing the
substring bb is (a+ba)*(Ʌ+b), then what is the regular expression for the language over the same
alphabet with no string containing the substring bbb or bbbb ? (3 points)
Solution:

If a string does not contain the substring bbb, it would not contain the substring
bbbb either, so we only have to consider the first case. The regular expression
for the language over the same alphabet with no string containing bbb is:

(a + ba + bba)*(Ʌ + b + bb)
5. The following proof shows that

a(a+b)* + aa(a+b)* + aaa(a + b)* = a(a+b)*

Put the reason for each step in the blank on the right-hand side of that step. If an example in the
notes can be used for a step, quote that example. (5 points)

a(a+b)* + aa(a+b)* + aaa(a+b)*

= a(a+b)* + (aa+aaa)(a+b)* · distributes over +


= a(a+b)* + a(a+aa)(a+b)* · distributes over +
= a(a+b)* + aa(a+b)* Example in slide 53 of the notes (Formal Languages and Finite Automata I)
= (a+aa)(a+b)*
· distributes over +
= a(a+b)*
Example in slide 53 of the notes (Formal Languages and Finite Automata I)

6. Fill out the blanks in the following figure to make it a DFA that recognizes the expression a + ba*b. (4
points)

7. Fill out the blanks in the following figure to make it a DFA for the expression a*bc* + aac + ac (4 points)

8. Fill out the blanks in the following table to make it the transition function of the given NFA. (3 points)

9. Fill out the blanks in the following figure to make it an NFA for the expression b*a* + b(a+b)* (9 points)

You might also like