COM SCI
hw3sol

# hw3sol - CS 181 Winter 2005 Formal Languages and Automata...

• Homework Help
• 7
• 100% (1) 1 out of 1 people found this document helpful

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

CS 181 — Winter 2005 Formal Languages and Automata Theory Problem Set #3 Solutions Problem 3.1. (8 points) Give a regular expression for the language ( rb ) * || ( br ) * , where || is the shuffle operator from Homework 2. (First construct an ε -move-free finite automaton that accepts this language; then transform the automaton into an equivalent regular expression. Hint: At each step of the construction, try to find the simplest automaton for the language). Solution In the previous assignment, we found how to construct an NFA for the shuffle of two languages A 1 and A 2 . We will perform that construction here to get a machine for their shuffle. We start by finding machines for A 1 = ( rb ) * and A 2 = ( br ) * . We’d like these machines to be as simple as possible, and it turns out two states suffice for each. Thus, NFAs for A 1 and A 2 are M 1 and M 2 , respectively, as shown below: B r b A D b r C M 1 M 2 Using our construction from the last homework, we build a machine that simulates running both machines and non-deterministically decides which letter to send to which machine. This gives the following NFA: BC r b AC AD BD r b r b r b We now take this machine an find a corresponding regular expression. We start by adding a new initial and final state, then one-by-one removing states BC , AD , then BD .

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

AC BC r b AD BD r b r b r b ε ε AC r b AD BD r b rb ε ε rb rb rb AC BD ε ε rb+br rb+br rb+br rb+br AC ε ε ( rb+br ) + [( rb+br )( rb+br )*( rb+br )] The resulting machine gives the regular expression. [( rb br ) ( rb br )( rb br ) * ( rb br )] * = ( rb br ) * . Let us check that this regular expression is reasonable. Notice that this regular expression gives the languages of strings that do not start or end with rr or bb nor contain rrr nor bbb .
If a word w is in the shuffle of w 1 A 1 and w 2 A 2 , and if it started with rr then none of these letters can be from w 2 since w 2 must start with b . Then they must both be w 1 letters. However, this means w 1 contains rr which cannot be the case. We can use similar logic to note that w cannot start with bb , and cannot contain rrr nor bbb .

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.
• Spring '08
• griebach
• Formal language, Regular expression, Nondeterministic finite state machine, Automata theory

{[ 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