Finite State Automata: Examples

CS390, Fall 2021

Last modified: Sep 21, 2021
Contents:

Abstract

This lesson presents a series of sample problems designed to familiarize the reader with common patterns and styles of writing FAs, as well as with the use of the JFLAP tool for creating, editing, and testing automata.

1 JFLAP

JFLAP is a Java program that allows you to edit and manipulate a number of automata that we will be discussing in this course. JFLAP is free and will run on almost any PC with a reasonably up-to-date Java runtime environment.

JFLAP lets you create, edit, & view automata. It can simulate “running” an automaton on inputs that you supply. It can also demonstrate some of the manipulations and algorithms that we will learn to do on some automata.

JFLAP can be useful to you as a means of studying some of the automata discussed in your textbook. To facilitate this, I will offer links to many of the examples from the textbook that you can download and run.

If I ask you to create automata for an assignment, quiz, or exam, you will submit them for grading as a JFLAP file.

  1. Get JFLAP for your own use here. (This is a version with my own patches to fix bugs in some of the features I wanted for this course.)

    Once you have downloaded the JFLAP.jar file, you can run it on many operating systems by using your directory/file viewer to view the directory where you downloaded it and double-clicking on the file’s icon.

    • If that does not work, you can run it from the command-line:

      java -jar path-to-where-you-placed-JFLAP.jar

    • If you cannot run this on your own PC for some reason, you can run it on the CS Linux servers via X2Go.

  2. Read the Finite Automata section of the Tutorial, specifically the sections titled “Construct and Run”, “Manipulating Transitions”, and “Add a Trap State to DFA”. You may want to skim the section on “Layout Commands”.

    Ignore, for now, any discussions of “nondeterministic” automata. The automata we are studying in this chapter are deterministic. We’ll discuss their nondeterministic cousins in a later chapter.

  3. Here is an FSA over the alphabet $\{0, 1\}$, the set of binary numbers. Given a non-empty input string, it accepts only states representing a binary number that is evenly divisible by 3.

    Try running this FSA on the inputs:

    • 0
    • 1
    • 10
    • 11
    • 100
    • 101
    • 110
    • 111
    • 1110
    • 1111
    • 11110

    Use the both the step and trace functions of JFLAP until you are comfortable with both.

  4. Exercise 2.2.5 in your text suggests drawing a number of FAs. Pick a few of them and create them in JFLAP. Run a handful of inputs through each one to convince yourself that you have done so correctly.

2 Sample Problems

Try to solve these on your own, first, then check my answer. If you don’t see where I got my answer from, the videos will walk you through my thought process. If you want to check my answer, my JFLAP files are provided.

2.1 Basic Patterns

Design an FSA to recognize the language consisting of…

  1. the string 101

    Reveal
  2. all strings beginning with 101

  3. all strings ending with 101

  4. all strings containing 101

2.2 Combining Smaller Machines into Larger Ones

2.2.1 Sequencing

Putting two FSAs together in a sequence is, roughly speaking, accomplished by “merging” each final state of the first FSA with the starting state of the second one. If the first has multiple final states, you may need to attach multiple copies of the second FSA.

Design an FSA to recognize the language consisting of…

  1. all strings beginning with and ending with 101

2.2.2 Alternation (Choice)

Often much trickier.

Design an FSA to recognize the language consisting of…

  1. strings beginning with 101 or 110

2.2.3 Repetition

Design an FSA to recognize the language consisting of…

  1. all strings containing 1 or more repetitions of 101

    Reveal
  2. all strings containing 0 or more repetitions of 101

    Reveal
  3. all strings composed of 1 or more (non-overlapping) occurrences of 101

  4. all strings composed of 0 or more occurrences of 101

  5. all strings that do not contain 101

  6. all strings containing exactly one occurrence of 101

2.2.4 Final Note

The combinations get easier when we have NFAs.

3 Moving on: Submitting Automata in Self-Assessments and Tests

In the upcoming self-assessments, quizzes, and exams, you will of ten be asked to submit an FSA or, in coming weeks, other kinds of automata.

When you encounter these questions in Blackboard, you will generally see a small button like this: embedded within the question.1

Prepare your automaton in JFlap, save it as a .jff file, and use that button to submit the file.

3.1 Self-Assessments

If you are in a Self-assessment, the final submission page will present a short report looking something like this:

Equivalence

Your automaton is not equivalent to the instructor’s.

Your automaton has 7 states.

The instructor’s automaton has 6 states.

Examples

Some inputs that you should have accepted, but did not:

""
"0100"
"0111"
"1000"
"1011"

3.2 Quizzes and Exams

On quizzes and exams you will encounter the same button, and should prepare and submit your automaton in the same way.

You will not, however, be given the report on how well your automaton appears to behave. The instructor or TA will determine that when grading the quiz/exam.

Quiz and exam questions will also often ask you to supply additional plain-text information describing your answer. That information should be entered into the text boxes provided by Blackboard in the test interface.


1: If you should see, instead, a block of text that looks something like "`%ifnot _slidessubmit:cs390:whatever%endif)’", that may be a problem with the way the question is set up in Blackboard or a problem with the Javascript support in your web browser. Try a different browser and, if the problem persists, notify the instructor.