381hw10solns - Exercise 7.3.1 Show that the operation cycle...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Exercise 7.3.1 Show that the operation cycle preserves context-free 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

Page1 / 5

381hw10solns - Exercise 7.3.1 Show that the operation cycle...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online