# hw3sol - Problem Set 3 Solutions CS373 - Spring 2011 Due:...

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Problem Set 3 Solutions CS373 - Spring 2011 Due: Thursday Mar 17 at 2:00 PM in class (151 Everitt Lab) 1. Mirrors [ Category : Proof, Points : 18] Let A = { w { a,b } * | w = w R } . (a) Determine the set of equivalence classes of A on A . Using this, conclude that A is not regular. (4 Points) [SOLUTION] Every string has its own equivalence class. We will show that two strings w and x , w 6 = x , have distinguishing strings. If | w | = | x | , then ww R A but xw R 6 A since w R 6 = x R . Thus w R is distinguishing. Otherwise, wlog let | w | > | x | and write w = w 1 w 2 where | w 1 | = | x | . ww R = w 1 w 2 w R 2 w R 1 A , so consider xw R = xw R 2 w R 1 . w 2 must be a palindrome for xw R to be in A , so w R is distinguishing if w 2 6 = w R 2 . If w 2 is a palindrome, then w 2 is not, where is di erent than the rst symbol of w 2 . ww R = w 1 w 2 w R 2 w R 1 A , but xw R = xw R 2 w R 1 6 A since w R 2 6 = w 2 . Hence, w R is distinguishing. (b) Prove that A cannot be generated by any CFG in which S aSa | bSb are the only production rules that have terminals on the right side. (6 Points) [SOLUTION] Let n a ( w ) be the number of a 's in w , and let n b ( w ) be the number of b 's in w . If S aSa | bSb are the only production rules that have a terminal on the right side, then n a ( w ) and n b ( w ) must both be even. The string aaab is in A , but the number of a 's is not even. Therefore, aaab cannot be generated by a grammar where S aSa | bSb are the only production rules that have a terminal on the right side. Therefore, such a grammar cannot generate A . (c) A mirror grammar is a CFG ( V, ,R,S ) where the only production rules are of the form X aY b X a X for X,Y V , a,b . Prove that every regular language has a mirror grammar, but not all CFLs with mirror grammars are regular. Hint : Recall that a rule of the form X aY can be seen as a transition from X to Y in a nite automaton. For mirror grammars, think of Y as being more than just one state. (8 Points) [SOLUTION] To show that not all mirror grammars generate regular languages, here is a gram- mar for { n 1 n | n } : S S 1 | 1 We can construct a mirror grammar G = ( V, ,R,S ) for a regular language by considering its DFA M = ( Q, ,,q ,F ) . On input w , a rule X aY b will correspond to reading a symbol each from the start and end of w simultaneously. Reading backwards in a DFA requires tracking a subset of possible states. Thus each variable will correspond to a pair ( q,P ) where q is the current state while reading forwards and P is the subset of states reading backwards. The grammar will stop when q and P meet in the middle. Formally, V = Q Pow ( Q ) S = ( q ,F ) R contains ( q,P ) a ( q ,P ) b if ( q,a ) = q and P = { p Q | ( p,b ) P } ....
View Full Document

## This note was uploaded on 04/28/2011 for the course CS 373 taught by Professor Viswanathan,m during the Spring '08 term at University of Illinois, Urbana Champaign.

### Page1 / 13

hw3sol - Problem Set 3 Solutions CS373 - Spring 2011 Due:...

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

View Full Document
Ask a homework question - tutors are online