0% found this document useful (0 votes)
12 views

Assignment 1

This document is an assignment for the course CS224 on Formal Languages and Automata Theory, instructed by Muhammad Sajid Ali, with a total of 115 marks. It includes a series of tasks related to formal languages, automata, and regular expressions, requiring students to solve problems, prove statements, and construct regular expressions. Students are advised to collaborate verbally but must submit individual work and list collaborators, adhering to the course's collaboration policy.

Uploaded by

rafay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Assignment 1

This document is an assignment for the course CS224 on Formal Languages and Automata Theory, instructed by Muhammad Sajid Ali, with a total of 115 marks. It includes a series of tasks related to formal languages, automata, and regular expressions, requiring students to solve problems, prove statements, and construct regular expressions. Students are advised to collaborate verbally but must submit individual work and list collaborators, adhering to the course's collaboration policy.

Uploaded by

rafay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FL&TA CS224 PAGE 1

FORMAL LANGUAGES AND AUTOMATA THEORY


ASSIGNMENT # 1
NAME: ___________________________ REG#: ____________________________

COURSE CODE: CS224 INSTRUCTOR: MUHAMMAD SAJID ALI

TOTAL MARKS: 115


------------------------------------------------------------------------------------------------------------------------------

Instructions

• You are free to consult each other for verbal help. However, copying or sharing the
soft/hard copy with each other will not only result in the cancellation of the current
assignment, but it may also impact your grade in all the future assignments and
exams as well.
• List your collaborators on the last page of your assignment. Collaborators are any people
you discussed this assignment with. This is an individual assignment, so be aware of the
course's collaboration policy.
• You must attach this assignment at the top of your solution.

Tasks

Solve the following problems. The solutions may or may not be available online. If they are
available, try to understand them before re-phrasing them in your own words.

Task 1: Consider the language S*, where S = {aa, b}. How many words does this language have of
length 4? of length 5? of length 6? What can be said in general (5 Marks)

Task 2: Consider the language S*, where S = {ab, ba}. Write out all words in S* that have seven or
fewer letters. Can any word in this language contain the substrings aaa or bbb? What is the smallest
word that is not in this language? (5 Marks)

Task 3: Consider the language S*, where S = {a, ab, ba}. Is the string (abbba) a word in this
language? Write out all words in this language with six or fewer letters. What is another way in
which to describe the words in this language? Be careful, this is not simply the language of all
words without bbb. (5 Marks)

Task 4: Consider the language S*, where S = {aa, aba, baa}. Show that the words aabaa, baaabaaa,
and baaaaababaaaa are all in this language. Can any word in this language be interpreted as a string
of elements from S in two different ways? Can any word in this language have an odd total number
of a’s? (5 Marks)

Task 5: (12 Marks)

1. Let S = {ab bb} and let T = {ab bb bbbb}. Show that S* = T*.
2. Let S = {ab bb} and let T = {ab bb bbb}. Show that S* ≠ T* , but that S* ⊂ T*
3. What principle does this illustrate?
FL&TA CS224 PAGE 2

Task 6: How does the situation in Task 5 changes if we replace the operator * with the operator +
as we discussed in class? Note the language S+ means the same as S*, but does not allow the
“concatenation of no words” of S. (5 Marks)

Task 7: Consider the language PALINDROME over the alphabet {a, b} (20 Marks)

1. Prove that if x is in PALINDROME, then so is xn for any n.


2. Prove that if y3 is in PALINDROME, then so is y.
3. Prove that if zn is in PALINDROME for some n (greater than 0) then z itself is also.
4. Prove that PALINDROME has many words of length 4 as it does of length 3.
5. Prove that PALINDROME has many words of length 2n as it has of length 2n – 1. How many
words is that ?

Task 8: Prove that for all sets S. (12 Marks)

1. (S+)* = (S*)*
2. (S+)+ = S+
3. Is (S*)+ = (S+)* for all sets S?

Task 09: Construct a regular expression defining each of the following languages over the
alphabet ∑ = {a, b} (18 Marks)

1. {w | w contains all strings that do not end with aa }


2. {w | w contains all strings that contain an even number of b’s }
3. {w | w contains all strings which do not contain the substring ba}
4. {w | w contains all strings that contain exactly two b’s or exactly three b’s, not more}
5. {w | w contains all strings that have exactly one double letter in them}
6. {w | w contains all strings in which the letter b is never tripled. This means that no word
contains the substring bbb}

Task 10: Let r1, r2 and r3 be three regular expressions. Show that the language associated with (r1+
r2)r3 is the same as the language associated with r1r3 + r2r3. Show that r1(r2 + r3) is equivalent to
r1r2 + r1r3. This will be the same as proving a “distributive law” for regular expressions. (10 Marks)

Task 11: Show that (9 Marks)

1. Expression (a + b)* a (a + b)* b (a + b)* and (a + b)* ab (a + b)* are equivalent in a sense
that they define same language.
2. (a + b)* ab (a + b)* + b*a* = (a + b)*
3. (a + b)* ab [(a + b)* ab (a + b)* + b*a*] + b*a* = (a + b)*

Task 12: Show that the following pairs of regular expressions define the same language over the
alphabet ∑ = {a, b} (9 Marks)

1. (ab)*a and a(ba)*


2. (a* + b)* and (a + b)*
3. (a* + b*)* and (a + b)*

You might also like