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

HW 1

This document outlines the questions and instructions for Homework 1 of the course CS476: Automata Theory and Formal Languages. It includes 6 questions assessing skills with statements about formal languages and automata, constructing DFAs, NFAs, and regular expressions to recognize specific languages, and proving languages regular/non-regular. It also includes an assignment to write a Perl script to analyze strings in a file based on regular expressions. Answers for questions 1-5 are due on paper and question 6's Perl script is due via email.

Uploaded by

Telat Abi
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)
39 views

HW 1

This document outlines the questions and instructions for Homework 1 of the course CS476: Automata Theory and Formal Languages. It includes 6 questions assessing skills with statements about formal languages and automata, constructing DFAs, NFAs, and regular expressions to recognize specific languages, and proving languages regular/non-regular. It also includes an assignment to write a Perl script to analyze strings in a file based on regular expressions. Answers for questions 1-5 are due on paper and question 6's Perl script is due via email.

Uploaded by

Telat Abi
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/ 1

CS476: Automata Theory and Formal Languages

Homework 1
Due: October 11, 2013 17.00

Questions
1. (12pts) State whether the following statements are true or not. You must give a brief explanation
or show a counter example to receive full credit.
(a) (3pts) If infinitely many subsets of a language are regular then the language itself is also
regular.
(b) (3pts) Any NFA with all accept states accepts Σ∗ .
(c) (3pts) r and s being regular expressions, (rs + r)∗ r = r(sr + r)∗ .
(d) (3pts) With pumping lemma, we can prove that L = {w : w = 1} is a regular language.
2. (16pts) Give a DFA for each of the following languages.

(a) (8pts) L = {w ∈ {0, 1}∗ : (2n0 (w) + 2n1 (w)) mod 3 < 1}.
(b) (8pts) L = {w ∈ {0, 1}∗ : w, when read, as a binary number, is a multiple of 3}.

3. (16pts) Give an NFA for each of the following languages.

(a) (8pts) L = {0101n : n ≥ 0} ∪ {010n : n ≥ 0}.


(b) (8pts) L = {w ∈ {0, 1, 2}∗ : The leftmost symbol of w is not equal to any other symbol of w}.

4. (16pts) Give a regular expression for each of the following languages.


(a) (8pts) L = {0m 1n : m, n ≥ 0, m + n is odd}.
(b) (8pts) L = {w ∈ {0, 1}∗ : n0 (w) and n1 (w) are both even}.
5. (20pts) Prove or disprove that the following languages are regular.
(a) (10pts) L = {wuw : w, u ∈ {0, 1}+ , w is the string obtained by taking bit-wise complement of
w}.
(b) (10pts) L = {w1n : |w| = n, w ∈ 0, 1∗ }.
6. Perl: (20pts) Perl is a language with a lot of scripting capabilities. It provides powerful text
processing facilities. In this exercise, you will use the regular expression capabilities of Perl. You
will write a script such that given a file the script displays the following information about the
strings in the file:

(a) The number of strings that does not contain 110.


(b) The number of strings that contains at least three 0s and at most two 1s.
(c) The number of strings that ends with the two symbols that it starts with.
(d) The number of strings that does not contain more than one occurence of the string 101. (The
string 10101 should be viewed as containing two occurences of 101.)

The alphabet is Σ = {0, 1}; hence the strings are binary strings. The strings can be separated by
any kind of whitespaces, i.e., tab, space, newline etc.

Answers for questions 1-5 should be returned in hard copy to your TA. The answer (perl script)
for question 6 should be e-mailed to your TA at acer@cs.bilkent.edu.tr, with the subject line
cs476hw1, as an attachment zip file named NameSurname.zip including NameSurname.pl. Good
luck to all.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy