38+Slides--CFLs%2C+Turing+Machines

# 38+Slides--CFLs%2C+Turing+Machines - CS103 HO#38...

This preview shows pages 1–3. Sign up to view the full content.

CS103 HO#38 Slides--CFLs, Turing Machines 5/4/11 1 Example 2.37. B = { a n b n c n | n 0 } is not context-free. Assume B is CF. Let s = a p b p c p , where p is the pumping length. a p b p c p We don’t know exactly where vxy falls, but |vxy| p and |vy| 0. Consider uv 2 xy 2 z If v and y each contain just one type of symbol, pumping s unbalances the number of a's, b's, and c's. If v or y contains 2 or more different symbols, pumping s gets symbols out of order. So s cannot be pumped, and B is not context-free. Suppose s = uvxyz Typo in Sipser: Page 125, third and fourth lines of the third paragraph. Change so it must contain a path from the root to a leaf of length to so its longest path from the root to a leaf has length Get the whole list at: http://www-math.mit.edu/~sipser/itoc-errs2.1.html More About Grammars How should we interpret a rule like A ε ? A rule is a variable [the LHS] and a string of variables and terminals [the RHS]. The rule above appears to be like A b where b is a terminal (i.e., b   ). But ε is not a symbol, it is the empty string. Some languages with " ε -productions " contain the empty string and some do not. The language S aS | ε is a* and contains the empty string. The language S Xa X aX | bX | ε does not contain the empty string. More About Grammars The following theorem is due to Bar-Hillel, Perles, and Shamir: If L is a CFL generated by a CFG that includes ε -productions, then there is a different CFG that has no ε -productions that generates either the whole of L (if ε is not in L) or the language of all strings in L that are not ε . Example: S Xa X aX | bX | ε The language generated is (a b)*a Alternate grammar: S Xa | a X aX | bX | a | b More About Grammars We can separate the terminals and non-terminals in productions. If L is a CFL generated by a CFG, then there is a another CFG that generates all strings in L that are not ε and whose productions are of one the following two forms: Non-terminal string of only non-terminals Non-terminal one terminal We can do this by adding a rule of the second form for each terminal, with a new non-terminal on the left in every rule with both terminals and non-terminals on the right, replace the terminals with the appropriate non-terminals More About Grammars Example: S Na N c | b Becomes S NA N c | b A a

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS103 HO#38 Slides--CFLs, Turing Machines 5/4/11 2 More About Grammars A more useful form of grammar is Chomsky Normal Form (CNF) If L is a CFL generated by a CFG, then there is a another CFG that generates all strings in L that and whose productions are of one the following three forms: Non-terminal string of two non-terminals Non-terminal one terminal Start variable ε Theorem 2.9 Any context-free language is generated by a context-free grammar in Chomsky Normal Form.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

38+Slides--CFLs%2C+Turing+Machines - CS103 HO#38...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online