Scribe: April Carvalho Review for the First Quiz Quiz 1 will cover only Chapter 1; no questions will be asked from Chapter 0. There will be proofs on the test. Problems will not come directly from textbook exercise problems; however, they will be similar to the homework problems and the examples given in lectures. To study for the quiz, read Chapter 1 and all the lecture notes posted on the website, and redo all the hw assignments. The following topics are particularly important. You will need to know: What Finite Automata are What languages are accepted by Finite Automata What are DFAs (Deterministic Finite Automata), what are NFA's (Nondeterministic Finite Automata) and what is the difference between the two? NFAs do not increase computing power over DFAs, but NFAs agive more flexibility; also it is easier to use NFAs to prove certain properties, such as closure properties of regular languages. How to convert a NFA to a DFA (you should know how to eliminate -links). What regular languages are; what properties they have; and how do we represent them? We have three basic regular operators: 1. Union (represented as U or +); 2. Concatenation (sometimes represented as . , but it is often omitted); 3. Kleene star ( represented as *). How to convert Regular Expressions to Finite Automata and to convert Finite Automata to Regular Expressions: A regular expression is simply a representation of a language recognized by a Finite Automaton. One can have different regular expressions for the same language, but all regular expressions that do so are equivalent. Use state elimination technique to convert a FA to a regular expression that represents the language it accepts. This technique applies to DFA and NFA. Under what operations on a regular language do you still get a regular language? (Answer: union, compliment, concatenation, Kleene Star (*) and intersection.) You should know how to prove them, and make use of them as building blocks to prove new results. There are two ways to prove that regular languages are closed under intersection, assuming we know that regular languages are closed under union and complement. 1. Using set notation: Let L1 and L2 be regular languages. We want to prove that L1 L2 is regular. Proof: We know that L1 L2 = ( L1 L2) Since L1, L2 are regular, so are L1 and L2 (because regular languages are closed under compliment). Thus, L1 U L2 is regular (because regular languages are is closed under union) L1 L2 is regular ( the compliment of L1 L2 is also regular) Thus L1 L2 is also regular. (Proofs don’t have to be very long.) 2.Using proof by construction. We can construct a Finite Automaton to accept a new language. Since L1 and L2 are regular, by definition there exist DFA A1 and A2 such that L1 = L(A1) and L2 = L(A2), where A1= (Q, , ,q01, F1), A2 = (Q, , ,q02, F2) Now consider what L1 L2 means: x is a member of L1 L2 iff x is a member of L1 and is also a member of L2. We want to construct a new DFA A to simulate A1 and A2 simultaneously and accept an input x if both A1 and A2 accept x. This can be done as follows. Let A = {Q1 x Q2, , , (q01,q02 ), F1 x F2 } where ((p, q), a) = ( (p, a), (q, a)). You need to know how to use the Pumping Lemma to prove that languages are not regular. If your string in a regular language is long enough, then you will have the pumping property on that string: Y X Z Note: We can use the pumping lemma to prove a language is not regularity, but we cannot prove that a language is regular via the Pumping Lemma. Converting an NFA to a DFA : One should be able to do this without much thinking, for it is a straightforward algorithm. The key to conversion is to always consider the -closure of every new set of states that are reachable from the initial state. Suppose you were given a description of a language. Can you write a description of that language? You could be asked to prove something new about regular languages. Intuition and a good knowledge of properties of languages will be required (for example, closure rules). That is the all the subjects/types of questions that could be on the test. Pumping Lemma Examples Pumping Lemma: Let L be a regular language. Then there exists an integer p > 0 such that for any string w in L, if |w| >= p, then there exist strings x, y, z such that w = xyz, |xy| <= p, |y| > 0, and for every i >= 0, string xyiz is in L How can you prove that languages are not regular using the pumping lemma? Example 1 Let L = {0n1n: n >= 0}. We shall prove that L is not regular. Proof (by contradiction): Suppose that L is regular. Then by the pumping lemma, there exists a p > 0 such that for any string w in L, if |w|>= p, then there exist x, y, z such that the following statements are true: w = xyz, |xy| <= p, y is not empty, and for every i >= 0, string xyiz is in L. Pick some string that will violate the last property (the pumping part). Here is one string: Let w = 0p1p, then |w| = 2p > p. So by the pumping lemma there exist x, y, z with the following properties: w = xyz; |xy| <= p, |y| > 0, and xz = xy0z is in L. Since |xy| <=p, xy must be prefix of 0p . Since y does not equal , there exists r >=1 such that y = 0r . Thus, xz = 0p-r1p. Since p-r < p, xz cannot be a member of L. A contradiction. This contradiction comes from what we assumed about L, so we have come to the conclusion that L is not regular. Example 2 Let L = {am: m = 2n and n >= 0}. Show that L is not regular. Proof (by contradiction): Assume that L is regular. Then we have the pumping lemma. I.e., there exists a p > 0 such that for any string w in L, if |w|>= p, then there exist strings x, y, z such that the following statements are true: w = xyz, |xy| <= p, y does not equal , and for each i >= 0, string xyiz is in L Pick some string that will violate the pumping part. Let q = max{3, p} (so we have q >= 3 and q >=p). Let m = 2q . Consider a particular string w = am . We have |w| = 2q > q >= p. Thus, there exist strings x, y, and z such that am = xyz, |xy| <= p, y is not empty, and xz is in L. Since y is not empty, there exists r with 1 <= r <= p such that y = ar. We have 2q – r >= 2q – p >= 2q – q. Since q > 2, we have 2q < 2q, which implies that q < 2q-1, and so 2q – q > 2q – 2q-1 = 2q-1. Thus, we know that 2q > 2q – r > 2q-1, which means that 2q – r cannot be the power of 2. Since |xz| = 2q – r, we conclude that xz cannot be in L, a contradiction. Thus, L is not regular. Student Homework Questions Page 89/problem 1.29 Let Bn = {a k: where k is a multiple of n} We can prove this by creating a Finite Automaton A as follows: Q0 a Q1 a Q2 …….. a Qn Thus Bn = L(An) Page 84/1.4h Write the regular expression which describes the following language: All strings except for 11 and 111. ( = {1,0}) First we can write the expression that will represent strings of length greater than three : (0 + 1)4 (0 + 1)* Then we can represent strings of length 3,excluding 111: 0(0+1)2 + 10(0+1) + 110 Represent strings of length 2, excluding 11: 0(0+1) + 10 Represent strings of length 1: 0+1 Represent strings of length 0: Now we can put this all together to form the regular expression: (0 + 1)4 (0 + 1)* + 0(0+1)2 + 10(0+1) + 110 + 0(0+1) + 10 + 1 + 0 + (Don’t forget the empty string!!) Page 84/1.4 h Answer: (1* 01* 01*)* + 0*10*10*