[FrontPage] [TitleIndex] [WordIndex

Notes for Lecture 7 - Friday September 24th, 2004

Administrivia

Finite State Automata / Machine (FSM, FSA)

The FSM is a working computational model that keeps track of where you've been. For instance, parsing HTML you need to remember which tags have been opened and closed, etc. The entire state can be represented in one (big) picture, as shown by ascii below.

Pretend we're doing a... say, bubble sort. There is:

C

A

B

-

-

We can represent these with pretty pictures. (Geez, these are PAINFUL to ascii.)

Bubble Sort FSA

The bits in (parentheses) represent states; words in arrows are inputs.

-#(start state)#-> (CMP) <-----------
                   /   \             \
                  /     \             \
                 /       \            OK
                /         \             \       
               /           V             ^
              |        (shift right)->---|-----END input-----> #(DONE)#----->-------V
              |                                              final accepting        OK
              |                                                  state               \
              V                                                                       V
  >--->(swap & shift)->---END input----> (RESET + CMP)-->------END----------------> #(FAIL)#<----
  |          /^                                   |  ^                                 |         ^
greater     / |                                   |   \                                |         |
than       OK  ^----<------greater - than ----<---V    \                               >---OK----^
  |       /                                            END 
  |      V                                               \
  ^---<-(CMP)------->------------OK---------(SHIFT)-->----^   
          ^                                    |
          |                                    |
          ^---<---less than or equal to--------<

Bubble Sort Instructions

Every state and token combination has an outgoing transition (or an implicit transition to FAIL). Let's feed our machine a series of inputs.

> OK > END < OK < END > > < < 

Follow the flowchart according to the instructions, and you'll end up with the right result (trust Lynn).

ASCII no more!

http://www.cs.duke.edu/~rodger/tools/jflap/

The JFLAP files (which turn out to be xml) for the deterministic bubblesort machine and the nondeterministic machine are available online. They're not very useful without JFLAP, though.

Ooh...ooh...pdfs! the deterministic bubblesort machine and the nondeterministic machine.

Transition Table Representation

Given...

We didn't go through the whole thing, but the idea is you fill in all the tables and hop around through them.

Initial state

input

Next state

q CMPnosw

>

q3 swapshift

q

<

q1 shiftright

q

=

q1

q1

OK

something

q1

END

something else

Another way to represent transitions in a table is a bit more "tabular"(?). This works best for deterministic finite automata, though it can be munged to work with nondeterministic ones too.

OK

END

<

=

>

q0 CMPnosw

/

/

q1 ShiftR

q1 ShiftR

q3 SW-Shift

q1 ShiftR

CMPnosw

q2 DONE

/

/

/

q2 DONE

/

/

/

/

/

q3 SW-Shift

q4 CMPsw

q5 Reset,Cmp

/

/

/

...

Deterministic FSM

The finite automata encountered above is a Deterministic Finite State Machine. That means at any given time, you know exactly what it is doing/what state the machine is in.

The mathy way to define an FSM:

Also notated:

The DFSM "accepts" its input iff when all of the input has been consumed, the DFSM is in one of its final states (i.e., some q \in F)

Nondeterministic FSM

Wherein you can have multiple options for each state-input combination, leading to multiple variations on what you can end up with on the same input. Some variations will be invalid because they lead down paths that you can't follow according to the rules you've set. (insert JFLAP example from Lynn here)

For instance: we want a nondeterministic FSM (NFSM, or NDFSM) that will accept strings that have either the substring "aba" or the substring "ab", and as many of either in a row as you'd like. We can represent this in math as:

So it will accept strings like "ababab" or "abaabababa".

A picture: (also in pdf)

The important thing to notice here is that there are two arrows coming out of q1 labeled "b" -- when in q1 and you get a "b", you take two transitions simultaneously. When one thread of transition encounters an illegal transition, it ends/discorporates/goes away/*poof*.

A nondeterministic finite automata is represented in math as follows:

There are two (equivalent) ways to think about acceptance in an NFSM:

An NFSM can be simulated by a DFSM that does this second computation, i.e., that keeps track of all of the states the NFSM might be in. This could, however, cause an exponential (2^n) blowup in the number of states required.

ACH! HELP FIX NOTES!

Lynn then went off discussing combinations and intersections of sets of states and inputs, which involved a lot of Greek letters that I frantically tried to type but couldn't. Does anyone have written notes that can be transcribed onto here?

Rant about lack of math support in html is at SideChatter

Homework


2013-07-17 10:43