Learn My Language

Description

Students act out the operation of a finite state machine that has been drawn with masking tape on the classroom floor. Students receive (or make) tickets that serve as inputs to the machine. The tickets tell them which lines on the floor to follow and which circles or states to pass through. If they end up in an accept state they receive a prize. This means that what was printed on their ticket was recognized by the machine as a word in its language .

Materials

Instructions

Ideas for discussion

For further Investigation

Materials

Preparation and Set-Up

Draw a large copy of a finite state machine on the classroom floor with masking tape.

is a good one to begin with.

A smaller and simpler machine that might be more appropriate for very young or inexperienced students is

Instructions

  1. Tell the students that the diagram on the floor is what computer scientists call a finite state machine . This machine has a language of its very own. It's kind of a silly language by our standards. It doesn't have sentences, just words, and the only letters it uses to make it's words are a and b . The language that we speak can't make very many words with just a and b in them, but the words in the language of this Finite State Machine are different from our a and b words. Many different combinations of a's and b's are words in the language of the Finite State Machine. When you come to the machine with a word, the machine can check to see if the word is in it's language. If it's not, the machine isn't really very interested in you. But if you bring the machine a word that is in it's language, it accepts that word and you win a prize.
  2. Have each student take a strip of paper and write down a word made up of a's and b's. Then they will be able to to test to see if their word is in the machine's language. There are two important things to remember while doing this:
  3. It is best when just starting to use words that are no longer than 8 letters.
  4. For the first round you may want to supply students with words to try, and then let students make up their own words afterwards.
  5. Invite a student to try a word by walking through the machine. Have the student read off the letters in the word to the other students. Here is how a word is tested in the machine:
  6. Invite a few more volunteers to walk through the machine slowly with their tickets in hand. When all of the students understand what to do, they can begin walking though the machine more quickly.
  7. Allow each student to try several words. When students catch on to how to make a winning word, suggest that they try making a word that is very long--a dozen letters, or even more.
  8. Have students keep playing until everyone catches on to how to put together words that will win a prize.

Ideas for Discussion

The debriefing and discussion can proceed through the following topics:

How the finite state machine works

  1. Students can think about and discuss the following questions:
  2. Make two columns on the board and labeled Accepted and Not Accepted. List words that the students tried in the appropriate columns. There is a shorthand notation for writing down words so that they don't have to be unnecessarily long. One aspect of this notation which will probably be useful at this point is:

Strategies for discovering words that the machine will accept

The chart above may resemble the lists of words that did and did not accept. Here are some things to consider after you have tried out a series of words and listed whether they were accepted or not:

  1. What strategies did you use to think up words to try?
  2. Look for patterns in the words in the two lists. Make a new list labeled Patterns and list the patterns that the students describe. Help students to continue referring to the machine as well as the lists of words when they talk about patterns. Have all the students agree on the description and the wording of the patterns as they are written down. If agreement can't be quickly reached for a statement, put question marks by it as reminder to think about it some more and return to it later.
  3. How does understanding patterns in the words that are accepted help you to think up more words that will be accepted?

Developing a shortcut notation for writing long words

There is a simple, but powerful notation for writing down the words of a finite state machine's language. For the following discussion, as you choose words to use for examples, use as many words as possible that were on the students' list of accepted words.
  1. The following words are all in the language of this finite state machine: .
    What else do they all have in common? (Hint: Look for patterns in the letters.)

  2. We could think of hundreds of words that follow the same pattern that is in these words. If we want to talk about all of them, we can write: ab*ab. The * after the first b means, "Put in as many b's as you want. It won't change the results." (This even means that the result doesn't change if you put in zero b's.)

    If you look at the finite state machine itself, you can see that ab*ab represents many words in the language of Machine 1.

  3. Can you write a different expression for Machine 1's winning words that has a * in it? Collect examples from students and write them down. Help the students to verify (by looking at the finite state machine) that these are words that will be accepted.
  4. Sometimes part of a word repeats a string or sequence of letters over and over again.

    for example, accepts of all the following words:

    You can show this by writing (aaab)*. The * means that something is repeated, and the parentheses are used to show that you repeat the string aaab, and not just the b preceding the *.

  5. An even shorter way to write (aaab)* is:
    Can you explain what all the parts of this expression mean?

If you think this notation is interesting, see More About Notation

More Experimentation with Finite State Machines

After the discussion, give students time to experiment some more with the finite state machine on the floor. If it is well-understood by all students, the activity could be modified in any of the following ways:

For Further Investigation

Extending the Original Activity

Drawing Your Own Finite State Machines

Follow this sequence of steps to draw your ownfinite state machine to work with:

More About Notation

Here is a final addition to the shortcut notation for writing down the words of a finite state machine. (See also, Developing a Shortcut Notation for Writing Long Words.)

Notice that the inputs aaab and bab will both be accepted by .

Whether you start out with aa or b, if the rest of the word is ab you will have a winning ticket. Verify this by looking at the finite state machine.

In the shortcut notation, you can show this by writing (aa + b)ab. The + means "Pick one of these, but not both." Trace the route you would follow with each of the tickets, aaab and bab and explore how this aspect of the notation is works. Why is it useful?

With the addition of this final element, we have built a notation system which allows us to look at a finite state machine, and then write down an expression that describes all the tickets that will win as inputs to that machine. Such an expression is called a regular expression .

Take a look at a simple example, that uses . If you only consider tickets whose input it long enough for the person to arrive at the accept state (and not go beyond it), the machine could be described by the expression: (ab*a) + (ba*b) . Experiment with this, look at the finite state machine, and verify that it is true.

What would you have to add to this regular expression to take into account every possible input? It's not difficult to figure out, you just have to keep all the possibilities straight! (There is more than one regular expression that is correct, too.) The regular expression that takes into account every possibility for is (aba* + b)(aa*b + b)(ab*a(aa*b + b))* . Experiment with writing regular expressions for other finite state machines. If the whole, perfect regular expression seems too huge and difficult to draw, start with a regular expression that describes one part of the finite state machine and see what you can add to it.

Try to draw a finite state machine for which the regular expression will be very, very simple.

Mr. MacBuff's Breakfast

Every morning Mr. MacBuff gets up and prepares his breakfast in a certain way. The following expression shows what he does:

o(m + r + s)*t(p + j)

Each of the letters stands for the following:

Finite and Infinite

The finite state machine gets its name because it has a finite number of states (circles). Even if there are very many of them, you can count them, and you can say exactly how many there are. The same thing is true for the number of letters in its alphabet .

Can you see why Machine 1 will accept an infinite number of words?

We could work for a long time, get very tired, and still never finish the rather silly task of completing just this part of the list of words that this machine will accept:

Not only that, but there is an infinite number of inputs that you can invent that the machine is sure to reject!

The concept of infinity is explored further in Welcome to the Hotel Infinity .