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 \(L_1\) is recognizable by an FA \( M_1\),
is language \( (L_1)^{c} \) also recognizable by some FA?

Or in other words, \[\exists M_2 \quad | \quad L(M_2) = L(M_1)^{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
\( Q_3 = \{ AD, BD, CD, AE, BE, CE \}\)


Look at the rule for the transition function:
\[ \delta_3 ( (q_1, q_2), a ) = (\delta_1(q_1,a), \delta_2(q_2,a)) \\ \] That means:

\( \mathbf{ \delta_3 ( (q_1, q_2), a ) }\) : the transition for \(M_3\) starting at the combo state: \(q_1q_2\) and input symbol \(a\).
the combo state resulting from the output of \(M_1\) when starting at state \(q_1\) and input symbol \(a\),
and the state resulting from the output of \(M_2\) when starting at state \(q_2\) and input symbol \(a\)
or \( \mathbf{ \delta_1(q_1,a), \delta_2(q_2,a)) }\)

The set of starting states \( q_{03} = (q_1,q_2) \)
Which is the combination state of the starting states of each of the machines: \(q_1\) from \(M_1\) and \(q_2\) from \(M_2\).

The set of Accepting states \( F_3 = (q_1,q_2) \)
Where each one is the combination state of states where both are accepting states in each of the machines:
\(C\) from \(M_1\) AND \(E\) from \(M_2\).



inX Exmpl!

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



Union




uni | on!



uni | on!



Union: General Rule





uni | on!



NOW, the set of Accepting states \( F_3 = (q_1,q_2) \)
Where each one is the combination state of states where either are accepting states in each of the machines:
\(C\) from \(M_1\) OR \(E\) from \(M_2\).



uni | on!





Set Difference

\[ L_3 = L_1 - L_2 \]

uni | on!

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



\[ L_3 = L_1 - L_2 = L_1 \cap (L_2)^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 \(M_1\) and \(M_2\), both with the same \(\Sigma\)
  2. Want to build another FA \(M_3\) with \( L(M_3)=L(M_1) \circ L(M_2) \texttt{, which is } \{ 𝑥_1 𝑥_2 | 𝑥_1 \in 𝐿(𝑀_1) \texttt{ and } 𝑥_2 \in 𝐿(𝑀_2) \} \)
  3. Just need to attach the accepting states of \(M_1\) to the start state of \(M_2\)
  4. Caution: since we don’t know when we’re done with the L(\(M_1\)) part of the string; could go through accepting states of \(M_1\) several times!




Example: word \( w = 000 \)

concat Exmpl!

Notice that for the example word \( w = 000 \) , the sequence of states might be:
\( A \xrightarrow{0}\) "invisible reject state" (Reject)
or
\( A \rightarrow B \xrightarrow{0} C \xrightarrow{0} C \xrightarrow{0} C\) (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: \(M_1\): all strings with an odd number of 1's
  2. And \(M_2\): all strings with alternating 0s and 1s
  3. Is \(L(M_3) = L(M_1) \circ L(M_2)\) FA-recognizable?
  4. Say we have the string \(101001101010101\)
  5. is this recognizable if we split the string into \(x_1\) and \(x_2\)
  6. such that \(M_1\) recognizes \(x_1\), and
  7. such that \(M_2\) recognizes \(x_2\)
  8. What happens if \(x_1 = 101001101\) and \(x_2 = 010101\)?
  9. What happens if \(x_1 = 1010011\) and \(x_2 = 01010101\)?


Kleene Star



Kleeeeeeneeee

  1. Start with FA \(M_1\)
  2. Build another FA \(M_2\), with \(L(M_2) = L(M_1 )^∗\)
  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 \xrightarrow{0} D \xrightarrow{1} E \dots \) 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 \(\epsilon\)


    An Example:

    tree!

    Activity 4 [2 minutes]:
    Does the above example Accept or Reject string:   \( 0 \; 1 \)?


    Activity 5 [2 minutes]:
    Build the computation tree for the Union example for the string   \( 1 \; 0 \)

    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:
    \( 1 \quad 1 \quad 1 \quad 0 \)




    Next class: Are NFAs stronger than DFAs?




    Homework


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

    [Optional]
    TODO