Professional Documents
Culture Documents
DNortonUsersGuide02 2008
DNortonUsersGuide02 2008
Feedback/Grading Tool
Daphne A. Norton
dan0337@cs.rit.edu
February 14, 2008
Preface
This tool is intended for use with JFLAP, the Java Formal Language and Automata Package (see http://jflap.org). It provides feedback to the user regarding their solutions to problems involving Deterministic Finite Automata
(DFAs) and Nondeterministic Finite Automata (NFAs). The program can simply state that an answer is correct or incorrect; this option may be useful for
instructors grading homework assignments or take-home examinations. Alternatively, when equivalence is checked to determine if the students model accepts
the same language as the instructors answer key, but the student has an incorrect solution, the feedback may include a specific witness string which is
accepted by exactly one of these two automata. This feature can even be useful
outside the classroom, when looking for a string demonstrating inequivalence.
There are a few ways to run the program:
1. Within JFLAP, an added menu option can used to check two finite
automata for equivalence. Unlike the existing menu option, if the automata
are NOT equivalent, this program provides extra feedback. It displays a short
witness string which is accepted by one automaton, but not by the other.
2. This program can also be run standalone, without the JFLAP GUI. This
allows the user the option to see verbose output, if they want to follow exactly
what the algorithm is doing as it compares the automata. The witness can be
turned on or off, as desired. Two different equivalence-checking algorithms are
currently available. One is the Hopcroft O(n lg n) partitioning algorithm, which
actually runs more slowly if a witness is created. The other is a faster, nearly
linear merging algorithm by Hopcroft and Karp; it remains nearly linear even
if a witness is produced. For small automata of the size typically created in
JFLAP, users will not notice a significant performance difference. However, the
merging algorithm has an added advantage, in that it always produces (one of)
the shortest possible witness string(s).
3. It can be used as a grading tool. For instance, it can be run via try,
the homework submission system which is used frequently at RIT. Instructors
1
who are familiar with try will find that it is easy to set it up to accept and
grade JFLAP assignments.
Instructions
2.1
Getting Started
You will need to ensure that the Java JRE version 1.5 or higher has been
installed on your computer. Java is available for download on the Sun site
at java.sun.com.
To download JFLAP, browse to jflap.org and click on Get JFLAP. Since
the grading code was written to work with JFLAP 6.4, it is recommended that
you download version 6.4. This file is named JFLAP.jar.
For the customized feedback/grading code: Obtain JFLAP_grade_dn.jar
from http://www.cs.rit.edu/~dan0337. If this site is no longer available, the
code should be available from the RIT Computer Science Graduate Projects/Theses
site, or contact Edith Hemaspaandra (http://www.cs.rit.edu/~eh).
If you wish to use the new menu option within JFLAP, the easiest approach is
to update the JFLAP jar with the class files contained in JFLAP_grade_dn.jar.
To do this in Unix, put both jars in the same directory, extract the contents of JFLAP_grade_dn.jar (jar -xvf JFLAP_grade_dn.jar), and update
JFLAP.jar:
jar -uvf JFLAP.jar equivalence/*.class
gui/action/FAWitnessAction.class
gui/menu/MenuBarCreator*.class
To start the JFLAP program in a Windows environment, simply double-click
on the jar file. To start it in Unix, use:
java -jar JFLAP.jar
For more information, see the directions and Useful References below.
2.2
JFLAP has a lot of nice features, including the ability to determine if two finite
automata are equivalent. However, what if you have two NFAs (and/or DFAs),
and you would like a simple example string to show exactly what makes them
different? The code in this package provides a convenient Get Distinguishing String menu option. To access it, make sure you have done the setup in
Getting Started above. Then:
1. Start up JFLAP.
2
2.3
Normally, the Unix command to run the jar for grading purposes is:
java -jar JFLAP_grade_dn.jar
studentfile.jff answerkey.jff true
where the two .jff files are the students answer and the instructors answer
key. The order of these two files does not matter. The last parameter, true,
can be changed to false if the instructor does not want to display a witness
if the answer is wrong. No additional detailed output is provided. A fourth
parameter of false may be added to this command if you wish to use the
Hopcroft partitioning algorithm behind the scenes instead of the default merging
algorithm.
However, to study the equivalence-checking algorithms in more depth, see
the authors paper and the Java source code which is included in the .jar file. If
you are interested in tracing exactly what the near-linear merging algorithm or
the n lg n Hopcroft partitioning algorithm is doing as it compares two automata,
you can save any two finite automata as .jff files and then run the tool in
verbose mode. For example, if you run the partitioning algorithm, then the
3
Figure 1: The menu option to get a sample string that distinguishes two automata.
Figure 2: The witness string demonstrating why two automata are different.
inverse transition function, processing lists, partition blocks, and so forth will
be printed to standard out. It will also show the details of how a witness string
is produced, if the witness option is turned on. Moreover, the witness string
from the partitioning algorithm will be a relatively short string, but it is not
guaranteed to be the absolute shortest possible string. If you run the program
multiple times and look at the output, you may see varying results. To set this
up, the main method from EquivalenceNlgNWitness.java needs to be executed.
The executable jar file JFLAP_grade_dn.jar is set up to use the Grader.main()
method by default. Therefore, if you want an executable jar, one way to set
this up is to change the main class in the manifest:
1. Extract the contents of the jar (jar -xvf JFLAP_grade_dn.jar).
2. Create a Manifest.txt file formatted as follows:
(a) For the merging equivalence-checking algorithm:
Main-Class: equivalence.EquivalenceMergeWitness
Class-Path: JFLAP.jar
(b) Alternatively, for the partitioning algorithm:
Main-Class: equivalence.EquivalenceNlgNWitness
Class-Path: JFLAP.jar
3. Build a new jar file, using a command such as this one to create a file
named JFLAP_equiv_dn.jar.
4. Then if you have two automata in files nfa1.jff and nfa2.jff, the program
can be run with a command like
where the first boolean turns on the witness, and the second turns on
verbose mode. Either one (or both) can be set to false, if preferred.
Another alternative is to execute the class files directly, outside of the jar.
Simply extract the JFLAP 6.4 jar (jar -xvf JFLAP.jar), then extract the
grading tool jar on top of it (jar -xvf JFLAP_grade_dn.jar). (This will overwrite a couple of the class files from the original JFLAP jar file; see the description of the new and modified classes in the appendix of this Users Guide.) Now
it is feasible to get verbose output via syntax such as:
java equivalence.EquivalenceMergeWitness
nfa1.jff nfa2.jff true true
. . . or
java equivalence.EquivalenceNlgNWitness
nfa1.jff nfa2.jff true true
. . . or to grade files via:
java equivalence.Grader studentfile.jff answerkey.jff true
2.4
2.5
This section provides instructions on how to configure try to use the JFLAP
automata grading program.
6
2.5.1
The following steps assume that the user is an instructor with a Unix account on
a system where try has already been installed. (At RIT, professors typically
have a special grading account so that try is isolated from their personal
account. Refer to Reeks documentation for a discussion of the potential security
issues.)
First, an entry must be placed in a .tryrc file in the grading home directory
to configure the try project. For example:
/home/stu13/s8/dan0337/tryDir/projDir/JFLAP.jar
# For statistics on the answers
correct=0
incorrect=0
submitted=0
missing=0
for T in 1 2 3
do
echo Checking problem $T
#
#
#
#
#
fi
done
# try_log can only be executed once, so summarize the
# results on one line.
try_log JFLAP FAs correct $correct, incorrect $incorrect,
submitted $submitted, missing $missing
exit 0
This run script simply tracks the number of correct, incorrect, submitted,
and missing files. The instructor could modify the script to assign a specific
number of points to each problem, change file names, and so forth. In this
example, the files from the latest submission will be stored in the working directory for the student (since save is indicated in .tryrc), and the log entry
for this student might say:
student-acct jflap-submit 08/10/12 16:59:16 Completed:
JFLAP FAs correct 1, incorrect 1, submitted 2, missing 1
In this case, the student submitted one correct answer and one incorrect
answer. Moreover, apparently the instructor was expecting a third file which
the student was missing. With the current configuration in this example, the
student can execute the try command again until everything is correct.
Useful References
10
For those who are curious, here is a description of the code behind the grading
tool.
This program was written in Java, so it is cross-platform. As the original
JFLAP 6.2 source code documentation indicates, Java versions 1.4 and 1.5 are
required to compile and run the main JFLAP program. JFLAP 6.4 requires 1.5,
and the additional features for the grading tool have been coded in Java version
1.5. This version allows for type checking on generics at compile time, prior to
running the program. In an IDE such as Eclipse, which automatically builds the
program as you write, this means errors can be found while you code. This kind
of type-checking is an invaluable time-saver to the programmer, particularly
when implementing and debugging complex algorithms (such as equivalence
checkers) that involve numerous containers like vectors and HashSets, which
can hold any type of Object whatsoever.
The classes used for grading are all in the equivalence package. These
include:
EquivalenceWitness: An abstract class used for testing two JFLAP finite
automata for equivalence. Contains useful methods for reading .jff files,
setting options, getting output, etc. Superclass of the two equivalencechecking algorithms described next.
EquivalenceNlgNWitness: This class uses the n lg n Hopcroft algorithm to
compare two finite automata to determine if they recognize the same language. The deciding factor is whether or not the start states of the two
automata can be distinguished from each other via partitioning. This particular implementation of the algorithm halts immediately if it finds at any
point that the start states are distinguishable (meaning that the automata
are not equivalent and do not recognize the same language). Moreover,
the user can supply a boolean (true/false) to request extra feedback (or
not). Specifically, if the automata are not equivalent and this boolean is
set to true, the program provides the user with a witness string which is
accepted by one automaton, but not by the other. This setting is good for
11
Manifest.txt: A text file which is used to create a manifest file for the jar.
It specifies the main class to use when the jar is executed (the Grader
class, although this can be changed to run one of the algorithms directly
instead, as described earlier in this guide). It also puts the JFLAP.jar into
the classpath for this jar. Here is what it looks like:
Main-Class: equivalence.Grader
Class-Path: JFLAP.jar
4.1
Copyright
Programmers are welcome to modify and reuse the code written by Daphne
Norton for this project, as long at it is not sold for commercial purposes. Please
be sure to acknowledge the author.
The original JFLAP code is copyrighted as follows:
13
14