<p> CmSc 365 Theory of Computation</p><p>Homework 03 Solution</p><p>1. Indicate the correspondence between the regular expressions to the left and the language properties to the right (the correspondence may be many-to-many, i.e. a language generated by a given regular expression may have several of the properties listed on the right side, as well as two or more expressions may generate languages having common properties).</p><p>(a*b U a)ab 2, 3 1. Each string starts with a b b((ac)*a)* 1, 2 2. Each string contains no more than two b's (bc*a Ua*ba*) b 2, 5 3. Each string ends with ab bb*a U bab*ab* 1, 4 4. Each string contains ba as a substring a*(a*ba*b) 2, 5 5. Each string contains at least two b's</p><p>2. True or False?</p><p> a. abb є L (a*b*a*b* ) True a1b2a0b0</p><p> b. L (b*a*) L (a*b*) = L (a* b* ) True</p><p> c. L (a*) L(b*) = Ø False - the empty word is in the intersection</p><p> d. ab є L (a*) L(b*) False</p><p> e. abab є L (a*(aba*bb)*) False</p><p>3. In each case, find a string of minimum length in {0, 1}* not in the language corresponding to the given regular expression</p><p> a. 1*(01)*1* 0 b. (0* U 1*)(0* U 1*)0 e c. 0*(101*)*0* 1 d. 1*(0 U 01)*1* 0110</p><p>1 4. Find a regular expression corresponding to each of the following subsets of {0,1}*:</p><p>Note: Below, for each language only one regular expression is given. However there may be other regular expressions that generate the same language.</p><p>Example 1: The regular expression for the language that contains at least two occurrences of the substring “11” will be (0 U 1)*11(0 U 1)* 11(0 U 1)* First write what is required and then surround and insert in between all possible strings</p><p>Example 2: The regular expression for the language that contains two types of strings: starting with one or more 1’s and ending with zero or more 0s, and starting with one or more 0s and ending with zero or more 1s is 11*0* U 00*1*</p><p> a. The language of all strings containing exactly two 1’s 0*10*10*</p><p> b. The language of all strings containing at least two 1’s</p><p> b1) (0 U 1)*10*1(0 U 1)*, </p><p> b2) (0 U 1)* 1 (0 U 1)* 1 (0 U 1)*</p><p> b2) generates the same strings as b1), b1) is shorter.</p><p> c. The language of all strings that end with 01 (0 U 1)* 01</p><p> d. The language of all strings that begin with 11 and/or end with 00</p><p> d1) 11(0 U 1)* U (0 U 1)*00</p><p> d2) 11(0U1)* U (0U1)*00 U 11(0U1)*00</p><p> d2) generates the same strings as d1) because 11(0U1)*00 is contained in 11(0U1)* U (0U1)*00</p><p> e. The language of all strings in which every 0 is followed immediately by 1</p><p> e1) (1 U 01)* e2) 1*(011*)* e3) 1*(011*)*1*</p><p>2 In e3) the last 1* is not necessary because the 1’s at the end of a string can be generated by 1* in (011*)</p><p> f. The language of all strings containing 1111 as a substring (0 U 1)* 1111 (0 U 1)* </p><p>5. Given and alphabet , the set of all possible strings over including the empty string is denoted by *. Let L = {a,b}* . The regular expression that describes all strings in L is (a U b)*</p><p>Apply the above definitions to solve the following problems:</p><p> a. The languages below are described as sets. Write the corresponding regular expressions for each of them</p><p>L = {ab,ba}* (ab U ba)* L = {ayb: y {a,b}*} a(a U b)*b</p><p>Note that (ab)* is different from a*b*</p><p> b. For each regular expression below, give the set description of the corresponding language </p><p> ab(a U b)* L = {abw | w {a,b}*}</p><p>(a U ab)* L = {a, ab}*</p><p>6. Given and alphabet , and two languages L1 , L2 *, L1 L2 is defined in the following way;</p><p>L1 L2 = {xy : x L1 and y L2} a. Let L1= {hope, thought}, L2 = {less, ful}. Write down the elements of L1 L2.</p><p>L1 L2. = {hopeless, hopeful, thoughtless, thoughtful} b. Let L1 be represented by the regular expression (a* U b*), and L2 be represented by ab. Write down the regular expressions that represent the following languages:</p><p>L1 L2 (a* U b*)ab</p><p>L1 L2 a* U b* U ab</p><p>L1 L2 </p><p>3</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages3 Page
-
File Size-