CS 321 Fall 2014 HW2 - DFAs Due (on canvas) Thursday 10/8 at 5pm. Hint: problems 2 & 4 are harder than the rest; save them to the last. Note: debriefing (at the end) is required. 1. How do you know if a DFA M: (a) accepts the empty string (b) recognizes the empty language (c) accepts some (i.e., at least one) string 2. We defined in class \delta*(q, w) by decomposing w into w = xa where a \in \Sigma. However, as shown in class, we can also define \delta_L*(q, w) by w = ax instead. (a) write that definition. (b) prove (by induction) that these two definitions are equivalent, i.e.: for all q \in Q, for all w \in \Sigma*, prove that \delta*(q, w) = \delta_L*(q, w). (c) is there another way of decomposing w? how about w = xy where x, y \in Sigma*. write your full definition, and make sure it is correct! (test boundary cases) (d) prove (by induction) that your new definition is equivalent to \delta(q, w). Note again that \in means "element of" in LaTeX, ^ means superscript, and _ means subscript. 3. Read **only the first 7 pages** of DFA Equivalence and Minimization: https://www.cse.iitb.ac.in/~trivedi/courses/cs208-spring14/lec05.pdf Now read our slides 40--41 which showed two examples of testing whether two DFAs are equivalent using a variant of the above algorithm (table-filling of state-pairs (p,q) where p is from DFA1 and q from DFA2). (a) Now prove that the 4-state and 3-state solutions of "binary number divisible by 4" are equivalent. (b) Show a simple example where you draw two DFAs which are not equivalent according to the algorithm, and show a string that is accepted by one DFA and rejected by the other. 4. What if \delta is a partial function (omitting trap state)? How would you extend a partial \delta to \delta*? Write the full definition, and make sure it's correct. (Well, define "correctness" in the partial case first, and then prove by induction.) 5. Prove |uv| = |u| + |v| by induction on |u|. 6. Prove (uv)^R = v^R u^R by induction (on what?). x^R is the reverse language of x. First define reverse inductively. 7. What's wrong with this proof? Theorem(?!): All horses are the same color. Proof: Let P(n) be the predicate "in all non-empty collections of n horses, all the horses are the same color." We show that P (n) holds for all n by induction on n (using 1 as the base case). Base case: Clearly, P(1) holds. Induction case: Given P (n), we must show P (n + 1). Consider an arbitrary collection of n + 1 horses. Remove one horse temporarily. Now we have n horses and hence, by the induction hypothesis, these n horses are all the same color. Now call the exiled horse back and send a different horse away. Again, we have a collection of n horses, which, by the induction hypothesis, are all the same color. Moreover, these n horses are the same color as the first collection. Thus, the horse we brought back was the same color as the second horse we sent away, and all the n + 1 horses are the same color. 8. How about this one? Theorem(?!): n^2 + n is odd for every n >= 1. Proof: By induction on n (again starting from 1). For the base case, observe that 1 is odd by definition. For the induction step, assume that n^2 + n is odd; we then show that (n + 1)^2 + (n + 1) is odd as follows. (n+1)^2 +(n+1) = n^2 +2n+1+n+1 = (n^2 +n)+(2n+2). But n^2 +n is odd by the induction hypothesis, and 2n + 2 is clearly even. Thus, (n^2 + n) + (2n + 2) is the sum of an odd number and an even number, hence odd. Debriefing (required!): -------------------------- 1. Approximately how many hours did you spend on this assignment? 2. Would you rate it as easy, moderate, or difficult? 3. Did you work on it mostly alone, or mostly with other people? 4. How deeply do you feel you understand the material it covers (0%–100%)? 5. Any other comments?