{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

csci3255 HW 5 and 6

# csci3255 HW 5 and 6 - 1 Complete the arguments in Example...

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

1. Complete the arguments in Example 5.2, showing that the language given is generated by the grammar. ( S abB , A aaBb , B bbAa , A λ ) We are forced to start with abB and then we must repeatedly generate an A using the second rule and a B using the third rule. This will end only when the fourth rule is used. Note that the use of the second and third rules can be simplified by combining them into the simpler rule B bbaaBba , which will generate ( bbaa ) n B ( ba ) n . But combining the third and fourth rules gives us bb λ a , or more simply, bba . Given the ab that is generated at the beginning, this leaves us with ab ( bbaa ) n bba ( ba ) n , where n 0 because we never actually have to use the second rule. 2. Draw the derivation tree corresponding to the derivation in Example 5.1. 3. Give a dervation tree for w = abbbaabbaba for the grammar in Example 5.2. Use the derivation tree to find a leftmost derivation. Leftmost derivation: S abB abbbAa abbbaaBba abbbaabbAaba abbbaabbaba 4. Show that the grammar in Example 5.4 does in fact generate the language described in Equation 5.1. Let’s not actually do that. The argument is long and cumbersome. Instead, let’s memorize this particular grammar, because it’s an important one. If you use the symbos ( and ) instead of a and b , then this grammar generates what is called the language of well-balanced parentheses, as you might find in C++ expressions, regular expressions, or any expression that uses parentheses in the normal manner. The reason this is the language of well-balanced parentheses is that every time you use the first rule you are nesting within a ’s and b ’s (or the corresponding left and right parentheses). Every a has a matching b to its right. The other production S SS, allows us to generate a series of two or more such expressions. This is exactly how we form well-balanced expressions. 5. Is the language in Example 5.2 regular? No. Because the bbaa groups much match the number of ba groups, which we know is not regular. S S S S λ b b a a a a S A b a B a b B b a a b A b b a λ

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

View Full Document
7. Find context-free grammars for the following languages with n 0, m 0.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

csci3255 HW 5 and 6 - 1 Complete the arguments in Example...

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

View Full Document
Ask a homework question - tutors are online