SmithLogo

CSC 250

Theory of Computation

Smith Computer Science



Lecture Notes 07:
Finite Automata and Nondeterminism


Outline

This class we'll discuss:




Recap: FAs

Example Finite Automaton:
Zero-Followed-By-1



very formal



Activity 0 [2 minutes]:

What is the Language that this FA accepts?



Useful Properties

These are some properties that can help you deduce, generalize, or analyze FSMs with respect to their RegEx and Regular Languages.

Complement

IF a Language L1 is recognizable by an FA M1,
is language (L1)c also recognizable by some FA?

Or in other words, βˆƒM2|L(M2)=L(M1)c

Example: {w|w doesn’t contain either 00 or 11 as a substring}


ORRRRRR!



If the property in question is "Containing either 00 or 11 as a substring", then the Complement is:
the set of words that do have the property, or:
Complement: {w|w contains either 00 or 11 as a substring}


complement!



Intersection



interX!

Activity 4 [2 minutes]:
How would you prove this (by construction)?
(Wait; then Click)



  1. run both machines β€œin parallel”
  2. accept if (and only if) both reach an accepting state


Example: word w=0111

interX Exmpl!



Intersection: General Rule



inX rule!

The set of possible states
Q3={AD,BD,CD,AE,BE,CE}


Look at the rule for the transition function:
Ξ΄3((q1,q2),a)=(Ξ΄1(q1,a),Ξ΄2(q2,a)) That means:

Ξ΄3((q1,q2),a) : the transition for M3 starting at the combo state: q1q2 and input symbol a.
the combo state resulting from the output of M1 when starting at state q1 and input symbol a,
and the state resulting from the output of M2 when starting at state q2 and input symbol a
or Ξ΄1(q1,a),Ξ΄2(q2,a))

The set of starting states q03=(q1,q2)
Which is the combination state of the starting states of each of the machines: q1 from M1 and q2 from M2.

The set of Accepting states F3=(q1,q2)
Where each one is the combination state of states where both are accepting states in each of the machines:
C from M1 AND E from M2.



inX Exmpl!

Notice that for the example word w=0111 , the sequence of states is:
AD→0BD→1CE→1CD→1CE (Accept)



Union




uni | on!



uni | on!



Union: General Rule





uni | on!



NOW, the set of Accepting states F3=(q1,q2)
Where each one is the combination state of states where either are accepting states in each of the machines:
C from M1 OR E from M2.



uni | on!





Set Difference

L3=L1βˆ’L2

uni | on!

Activity 1 [2 minutes]:
How would you prove this (draw the Venn Diagram and use previous properties)?
(Wait; then Click)



L3=L1βˆ’L2=L1∩(L2)c

L1 - L2

L1 - L2

L1 - L2

L1 - L2





Concatenation



con Kat

Activity 2 [2 minutes]:
How would you prove this (by construction)?
(Wait; then Click)



  1. Let’s say we have two FAs M1 and M2, both with the same Ξ£
  2. Want to build another FA M3 with L(M3)=L(M1)∘L(M2), which is {π‘₯1π‘₯2|π‘₯1∈𝐿(𝑀1) and π‘₯2∈𝐿(𝑀2)}
  3. Just need to attach the accepting states of M1 to the start state of M2
  4. Caution: since we don’t know when we’re done with the L(M1) part of the string; could go through accepting states of M1 several times!




Example: word w=000

concat Exmpl!

Notice that for the example word w=000 , the sequence of states might be:
A→0 "invisible reject state" (Reject)
or
A→B→0C→0C→0C (Accept)


How to combine them?

We seem to need to be able to β€œguess” when to shift to the second machine.

And we can't do that yet.

Another example of the logic and the issue:
  1. Say we have: M1: all strings with an odd number of 1's
  2. And M2: all strings with alternating 0s and 1s
  3. Is L(M3)=L(M1)∘L(M2) FA-recognizable?
  4. Say we have the string 101001101010101
  5. is this recognizable if we split the string into x1 and x2
  6. such that M1 recognizes x1, and
  7. such that M2 recognizes x2
  8. What happens if x1=101001101 and x2=010101?
  9. What happens if x1=1010011 and x2=01010101?


Kleene Star



Kleeeeeeneeee

  1. Start with FA M1
  2. Build another FA M2, with L(M2)=L(M1)βˆ—
  3. Same problem as with concatenation: we need to guess...




Nondeterminism

Let's check a small video fragment from MinutePhysics.

The part we are interested in is the fact that there is a way to:

  • Let multiple parallel options happen at the same time!
  • As long as any of them succeeds, all "timelines" collapse and the word is accepted.






  • Nondet



    Think of it as having the option of "cloning yourself" into multiple word checkers... each checking one possible path.

    We "split" or "clone" each time we:


    Example

    Notice that for the example word w=011 , the sequence of states is:
    Dβ†’0Dβ†’1E… and then we have a split!!




    NFAs Formal Definition



    NonDeF

    Activity 3 [2 minutes]:

    Why would this be useful at all?


    Remember Union?



    Union

    With an NFA:



    NFA-union

    So how do NFA's Compute?

    How to NFA




    NFA computation (tree)

    We can visualize what happens with the computation of a string with an NFA by building a NFA computation Tree.

    This is like "unrolling an FA as we walk it into paths", except with two extra rules:

    1. You add a possible path into a "next" state for every outgoing symbol option, and
    2. You add a possible path into a "next" state any states we might get to through an arrow labeled with Ο΅


    An Example:

    tree!

    Activity 4 [2 minutes]:
    Does the above example Accept or Reject string:   01?


    Activity 5 [2 minutes]:
    Build the computation tree for the Union example for the string   10

    The example is repeated here for your convenience (you're welcome)

    M1 u M2 again

    "Walk" the NFA and add a path for every possible choice (given the symbol read)
    (Wait; then Click)



    M1 u M2



    Remember Concatenation?



    The problem was we could not "guess" at which part of the string one Machine should accept (reject) and the next begin processing.

    With an NFA:



    con Kat

    Activity 6 [2 minutes]:
    Build the computation tree for the Concatenation example above, given the string:
    1110




    Next class: Are NFAs stronger than DFAs?




    Homework


    [Due for everyone]
    Remember: Problem Set 2 (Moodle) [Due Friday 02/11] Start Early!

    [Optional]
    TODO