This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Theory of Computation — CSE 105
Regular Languages Study Guide and Homework I
Homework I: Solutions to the following problems should be turned in class on July 12, 1999. Instructions: Write your answers clearly and completely. Please use 8.5 11 inches paper. Use a stapler or a clip to attach the individual pages. Write your name. ¡ When presenting any construction, for example, an algorithm or an automaton, please give an overview of the main ideas and then present the construction. Always support the correctness of your construction with a short informal proof.
© § ¥ £ ¨¦¤¢ 1. For each of the languages given below, design ﬁnite state automata and regular expressions . to recognize them. In all cases the alphabet is
6 (a) (b) does not contain the substring 110 contains an even number of 0’s, or exactly two 1’s 2. Problem 1.26, Page 88. 3. Problem 1.42, Page 90. Provide a short proof of the correctness of your construction. 4. Prove the following languages nonregular:
) ' % # ! 10(&$" (a) is a prime ;
§ 8 ¥ @C£ @ B§ @ A£ ¥ ¥ § 8 £ 8 £ 97 8 6 (b) Let
6 Here, contains all columns of 0’s and 1’s of height two. A string of symbols in gives two rows of 0’s and 1’s. Consider each row to be a binary number and let
G the bottom row of is the reverse of the top row of 1 © " © G E @ 9FD§ © © 5 4¤¢ 3 2 6 I (¨¢ ¨¢ ¨¢ H' Study Guide: In the following, the material on regular languages (chapter 1) is broken down into a number of short topics. For each topic, a list of speciﬁc items and problems are provided. If you understand these items and solve the problems, you would do very well in the course. 1 Deterministic Finite Automata (DFA) Topics: The notion and deﬁnition of DFA, presentation of DFA by transition diagrams, the notion of acceptance by a DFA, the class of regular languages, techniques for designing DFAs, and closure operations. Designing DFAs 1. 1.1, 1.2, and 1.3, pages 83 and 84. 2. Exercise 1.4, Page 84. 3. For each of the following regular expressions, draw a DFA recognizing the corresponding language.
U &XC`W§ T £ § Q § P P P 4. Draw a DFA that recognizes the language of all strings of 0’s and 1’s of length that, if they were interpreted as binary representations of integers, would represent integers evenly divisible by 3. Leading 0’s are permissible.
b c 0d b b 5. Show that if is a regular language and are regular.
b e ff b e ff is ﬁnite language, then
b , , and and
b 7. Problems 1.25 and 1.27, Page 88. 8. 1.29, 1.30, 1.41 Closure Properties of Regular Languages 1. For each statement below, decide whether it is true or false, If it is true, prove it; if . not, give a counter example. All parts refer to languages over
r i p qii © g ¥ 2 ¤h4¤¢ Q p qii (a) If (b) If (c) If and is not regular, then is not regular. is not regular, then is regular. and are nonregular, then is nonregular. 6. Show that if is a non–regular language and are non–regular. is a ﬁnite language, then § a Q Q £ U &XWS`§ T £ § § Q (a) (b) (c) U £ § § U T § Q YXWWV¤SR£ 2. Problem 1.24, 1.42 2 Nondeterministic Finite Automata (NFA) Topics: The notion of nondeterminism, deﬁnition of acceptance for NFAs, economy of states by using NFA, equivalence of DFAs and NFAs, and examples that illustrate the conversion of an NFA to an equivalent DFA. Notion of Nondeterminism 1.9, 1.10, page 85 Practice in Designing NFAs 1.5, 1.6, 1.7, 1.8, pages 84 and 85. Practice in converting an NFA to an equivalent DFA 1.12, page 85. 3 Regular Expressions (RE) Topics: The deﬁnition of regular expressions, writing regular expressions, equivalence with ﬁnite automata: every regular expression has an equivalent ﬁnite automata and every ﬁnite automata has an equivalent regular expression. Basics of Regular Expressions 1. What is the shortest string of ’s and ’s not in the language corresponding to the regular expression ?
! ! g 2 P U 2 U T U g g U ¦V¨2 g 2. Consider the following two regular expressions .
! and 3. Simplify the following regular expressions:
! !
!
! ! ! ! (a) (b) (c) (d) Find a string corresponding to but not to . Find a string corresponding to but not to . Find a string corresponding to both and . Find a string corresponding to neither nor . U 2 g U g ¦S¦2 Q i U g U S¦2 r c rSi Q sc x w yw v FQ t r r u u u XXX¥ i ¥ U Xg U 2 T i i (d) (e) (f) (g) If and are nonregular, then is nonregular. If is not regular, then , the complement of , is not regular. If is regular and is nonregular, then is nonregular. If is regular, is nonregular, and is nonregular, then nonregular. (h) If are regular, then is regular. is P $2 U g 4. What is true of the language corresponding to a regular expression that does not involve the operators or ? Why? Designing Regular Expressions 1. 1.13, page 86 2. Find regular expressions corresponding to each of the languages deﬁned recursively below. ; if , then and are elements of ; nothing is in unless it can be obtained from these two statements. (b) ; if , then , , and are elements of ; nothing is in unless it can be obtained from these two statements. 3. Find a regular expression corresponding to each of the following subsets of (a) (b) (c) (d) (e) (f) (g) (h) (i) The language of strings containing exactly two 0’s. The language of strings containing at least two 0’s. The language of strings that do not end with 01. The language of strings that begin or end with 00 or 11. The language of strings containing no more than one occurrence of the string 00. (The string 000 should be viewed as containing two occurrences of 00.) The language of strings in which the number of 0’s is even. The language of strings in which every 0 is immediately followed by 11. The language of strings that do not contain the substring 110. The language of strings that do contain both the substring 11 and the substring 010.
U ¨¦¤¢ © § ¥ £ g g g 2 2 g 2 2 I (a) Interpreting Regular Expressions Describe as simply as possible the language corresponding to each of the following regular expressions. 1. 2.
P P P T¤§CQR£se U ¤d¤CR£ Q T T § Q P U £ U ¤§ U X§ U £ § U £ T £ P P P P U T&X§ U T¤£ Q U T¤§£DQ£X§ §£WX§ U ¤DRX§ £ § £ T § £ Q £ P U D`£ T Q § P P P P U T¤§£ QT U ¤§£ Q£ U ¤£ £ T § T § § P P T § Q VT U ¤CR£ £ P g g g 2 ¦2 I I C2 I (a) (b) (c) (d) (e) U T § £ £ § Q £ § § £ Q £ § Q § V¤WXC
XWDXC`£ . 3. 4. Practice the Translation Algorithm from REs to NFAs 1.14, page 86 Practice the Translation Algorithm from DFAs to REs 1.16, page 86 4 Non–regular Languages Topics: Pumping lemma, examples of nonregular languages and applications of pumping lemma. Application of Pumping Lemma 1. Using the Pumping Lemma show that each of these languages is not regular.
f f ©¦r1qopDm ¨Vi¤¢ n l k j gh 2 a g w g w ¤¢ 2 2 © £ where ( ) is the number of occurrences of the letter ( ) in . (d) no initial substring of has more ’s than ’s (e) is a palindrome (f)
2 © 2 xP g xP s f f f g 2. Here is a ‘proof’ using the pumping lemma, that the language of all strings of ’s and ’s of length 100 is not regular. Since the result being ‘proved’ is false (all ﬁnite languages are regular), the proof cannot be correct. What is the ﬂaw in the proof? Assume that is regular. By the pumping lemma, if we choose an element of , say , there are string , and , with , so that every string of the form (where ) is in . Since there are inﬁnitely many different strings of this form, this contradicts the fact that is ﬁnite. Therefore, is not regular. 3. 1.17, page 86. 4. 1.23, 1.28, 1.33, 1.36, pages 88 and 89 5. 1.38, page 90 6. 1.40, 1.43, page 90 Regular or Nonregular Below are a number of languages over . In each case, decide whether the language is regular or not, and prove that your answer is correct.
© g ¥ 2 ¤h4¤¢ £ n ~ ~ ¥ £ a m £ W£ 2 l ~ T  0v T w 0v © hT © U © g ¥ 2 ¢ I u¤h4¤As }¨¢ © U ¤h4¤1I ¢ © g ¥ 2 ¢ U ¤h4¤1I ¢ © g ¥ 2 ¢ g 2 xP xP  v z y 0y{T w U © g ¥ 2 ¢ 0v Yu¨h¤tI ¢ P P P UVT¤§CQR£ T § £ §SQ £ § £ V¤SR£ U T § Q P P U T § £ Q V¤D£ V¤s`§ U T § £ Q (a) (b) (c) 5 Decision Algorithms
Describe decision algorithms to answer each of the following questions.
% % 1. Given two DFAs
% and , are there any strings that are accepted by neither? accept ?
% 2. Given an NFA and a string , does 3. Given two NFAs, do they accept the same language?
% 4. Given an NFA corresponding to
% and a string , is there more than one sequence of transitions that causes to accept ? 6 Miscellaneous Problems
1. 1.31 2. MyhillNerode Theorem: 1.34 and 1.35 3. Number of states: 1.39 and 1.44 4. Transducers: 1.19, 120, 1.21 and 1.22 xP xP © m f 10. there is some integer are both divisible by so that and T  0v T w 0v § n Dm xP xP U © g ¥ 2 ¢ &u¤h4¤1I ¢ f 9. and are both divisible by 5 © © T  0v T w 0v U ¤h4¤1I © g ¥ 2 ¢ g ¢ f 8. in every substring of , the number of ’s and the number of ’s differ by no more than 2 2 © U © g ¥ 2 ¢ &u¤h4¤1I ¢ f 7. in every initial string of the number of ’s differ by no more than 2 the number of ’s and 2 ¥ f 6. is a perfect square a © T g U © g ¥ 2 ¢ &u¤h4¤1I ¢ xP v U © g ¥ 2 ¢ w
&u¤h4¤1I ¢ f 5. begins with a palindrome of length 3 © U ¤h4¤1I © g ¥ 2 ¢ ¢ f 4. is not a palindrome © U ¤h4¤1I © g ¥ 2 ¢ ¢ 3. is the set of strings having some non–null substring of the form 2. is the set of all strings having some non–null string of the form 1. is the set of strings beginning with a nonnull string of the form . . . ...
View
Full
Document
This homework help was uploaded on 02/08/2008 for the course CSE 105 taught by Professor Paturi during the Summer '99 term at UCSD.
 Summer '99
 Paturi

Click to edit the document details