This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Exercise 7.3.1 Show that the operation cycle preserves contextfree languages, where cycle is defined by: cycle ( L ) = { xy  yx L } Informally, cycle ( L ) allows all strings constructed as follows: take a string w from L , and choose an arbitrary position in the middle. Take the second part (this is x ), then wrap around and concatenate the first part (this is y ). For example, if abcd L , then all of the following strings are in cycle ( L ): abcd,bcda,cdab,dabc . Solution We will prove this by PDA construction. Given a PDA P for L , well create PDA P c for cycle ( L ). Both accept by empty stack. P c simulates an accepting computation in P , but it starts in the middle and simulates P on x , then wraps around and simulates P on y . The difficulty lies in the stack. When P c begins consuming x , it is missing the stack symbols that P would have from consuming y . To resolve this, we allow P c to guess the top stack symbol and pop it by pushing a negated version. Later, when simulating P on y , we confirm these guesses: instead of pushing symbols, we confirm and pop the guesses. We use a stack marker # to delimit the guessed symbols from the rest of the stack. Start by guessing the top symbol (the first one well pop) left by y . Place a copy above and below the marker. Then begin consuming x by simulating P normally on the portion above the stack above the marker. Eventually we return to the marker, meaning we popped the symbol we guessed (note: it is now recorded below the marker). Here is an example where we guess that y left A as the top stack symbol: Start configuration Z Mark the stack # Z Guess top symbol A # AZ Arbitrary build up DEFA # AZ ......
View Full
Document
 Fall '05
 HOPCROFT

Click to edit the document details