COM S
381hw10solns

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

• Homework Help
• 501844684_ch
• 5

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

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 , we’ll 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 we’ll 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 0 Mark the stack # Z 0 Guess top symbol A # AZ 0 Arbitrary build up DEFA # AZ 0 . . . Eventually pop A # AZ 0 On return to the marker, one thing we can do is guess the next symbol to pop and repeat the step described above: Guess B B # BAZ 0 . . . . . .

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

This is the end of the preview. Sign up to access the rest of the document.
• Fall '05
• HOPCROFT
• Formal language, CFL, context-free language, Transition function

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern