Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 44 – Aug. 29 Regular operations –Union construction Section 1.2 - Nondeterminism –2 kinds of FAs –How to trace input –NFA design makes “union” operation.

Similar presentations


Presentation on theme: "CS 44 – Aug. 29 Regular operations –Union construction Section 1.2 - Nondeterminism –2 kinds of FAs –How to trace input –NFA design makes “union” operation."— Presentation transcript:

1 CS 44 – Aug. 29 Regular operations –Union construction Section Nondeterminism –2 kinds of FAs –How to trace input –NFA design makes “union” operation easier –Equivalence of NFAs and DFAs

2 Wolf, Goat, Cabbage A man would like to cross a river with his wolf, goat and head of cabbage. Can only ferry 1 of 3 items at a time. Plus: –Leaving wolf & goat alone: wolf will eat goat. –Leaving goat & cabbage alone: goat will eat cabbage. Yes, we can solve this problem using an FA! –Think about possible states and transitions.

3 Operations on sets We can create new regular sets from existing ones, rather than starting from scratch. Binary operations –Union –Intersection Unary operations –Complement –Star: This is the concatenation of 0 or more elements. For example, if A = {0, 11}, then A* is { ε, 0, 11, 00, 1111, 011, 110, …} “Closure property”: you always get a regular set when you use the above operations.

4 Union Book shows construction (see handout) We want to union two languages A 1 and A 2 : M 1 accepts A 1 and M 2 accepts A 2. The combined machine is called M. M pretends it’s running M 1 and M 2 at same time! δ((r 1,r 2 ),a) = (δ 1 (r 1,a),δ 2 (r 2,a)) # states increases because it’s the Cartesian product of M 1 and M 2 ’s states. Next section will show easier way to do union.

5 Union Book shows construction (see handout) We want to union two languages A 1 and A 2 : M 1 accepts A 1 and M 2 accepts A 2. The combined machine is called M. M pretends it’s running M 1 and M 2 at same time! δ((r 1,r 2 ),a) = (δ 1 (r 1,a),δ 2 (r 2,a)) # states increases because it’s the Cartesian product of M 1 and M 2 ’s states. Next section will show easier way to do union.

6 Non-determinism There are 2 kinds of FA’s –DFA: deterministic FA –NFA: non-deterministic FA NFA is like DFA except: –A state may have any # of arrows per input symbol –You can have ε-transitions. With this kind of transition, you can go to another state “for free”. Non-determinism can make machine construction more flexible. At first the theory seems more complex, but NFA’s will come in handy.

7 Example s1s2s3 s4 10, ε1 0, 1 From stateInput 0Input 1Input ε s1 s1, s2 s2s3 s4

8 continued See the non-determinism? Remember, any time you reach a state that has ε-transitions coming out, take it! It’s free. Let’s trace input s1s2s3 s4 10, ε1 0, 1

9 s1s2s3 s4 10, ε1 0, 1 StartRead 0Read 1Read 0Read 1 Read 0 s1 s2s3 [dies] s2[dies] s3s4 s2s3s4 s3[dies]

10 Moral When tracing a word like , we just want to know if there is any way to get to the accept state. Language is anything containing 11 or 101. Corresponding DFA would have more states.


Download ppt "CS 44 – Aug. 29 Regular operations –Union construction Section 1.2 - Nondeterminism –2 kinds of FAs –How to trace input –NFA design makes “union” operation."

Similar presentations


Ads by Google