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

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

View Full Document Right Arrow Icon
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 .
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 .
Background image of page 2
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 .
Background image of page 3

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

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

This homework help was uploaded on 04/02/2008 for the course COM SCI 181 taught by Professor Griebach during the Spring '08 term at UCLA.

Page1 / 7

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

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

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