What to submit and when:

- All submissions are electronic: by e-mail to elenam at morris.umn.edu and CC to all lab partners. Please do not delete your e-mail from "Sent mail" or your mailbox until the end of the semester.
- When working on the lab, please comment your work so that it is clear what contributions of each person are.
- At the end of the lab each group should send me the results of their in-class work. Please indicate if this is your final submission.
- If your submission at the end of the lab time was not final, please send me(CC to the lab partner(s)) a final copy before the due time. Please use the subject "3501 Lab N", where N is the lab number.

Work in pairs

The goal of the lab is to practice with JFLAP (a tool for experimenting with finite automata and other computability topics) and to design and test finite automata (DFAs and NFAs).

- Please save your automata files as .jff files and your data as
.txt files.
**Files names must be as follows**: names of those in the group followed by question name, e.g.`SmithAdams3.jff`

(where 3 refers to the question number). This will help me in running test data - To load test data from a file, go to
`Input -> Multiple Runs -> Load Inputs`

- When adding multiple transitions between the same two states, add them one by one. Typing "0, 1" in a label for an arrow will give you a wrong result since the automaton will try to match this input exactly, including the comma.
- When writing DFA, check that every state has a transition on every symbol. JFLAP does not check it.
- Use
`Convert -> Combine Automata`

to copy one automaton into a file for another one. - Do not use "convert to DFA" or "minimize DFA" options.
- Consult the JFLAP tutorial as needed.

Use the tutorial Regular Expressions and Converting to an NFA to convert the regular expressions given below to NFAs. Note that JFLAP uses + as a symbol for union and * for the star operation. Also make sure to set parentheses correctly in your expression.

JFLAP gives you hints on the steps and provides a button "(De)-expressionify Transition" to break down regular expressions into smaller subexpressions. You need to add the empty transitions to complete each step.

As you are converting a regular expression to an NFA, write down the
intermediate expressions as a note on the JFLAP screen: use the
selection tool (the one that you use to mark initial and final
states), right-click anywhere on the JFLAP screen, and choose "add
note". For instance, if you are breaking down an expression
`00+11`

into `00`

and `11`

, write
`00+11 -> 00, 11`

.

Below are two regular expressions to convert:

- ((0+1)0)*
- (00)*+(10)*

Please export and submit your NFAs.

JFLAP guides you through the process of converting a DFA to a regular expression via a generalized NFA (GNFA), as described in the tutorial Converting a FA to a Regular Expression. JFLAP uses a slightly different version of a GNFA: it allows self-loops in the starting and the final state. The empty set transitions are added just like in the book, and the number of states is reduced by the procedure described in the book. The resulting regular expression then is combined as R1*R2R3*, where R1 is the self-loop expression in the start state, R2 is the expression on the transition from the start state to the final state, and R3 is the loop in the final state.

As you are transforming your DFA to a 2-state GNFA, write down (in a plain-text file) all transition changes that result in non-empty-set expressions.

Below is the DFA to convert:- The language of all strings with 00 pattern
- The language of all strings that either start with 0 and don't have any more 0s, or start with 1 and don't have any more 1s. Note that as the first step you would need to create a single final state and connect the old final states to it by empty-string transitions.

Please export and submit your resulting expression.

Study the Java
regular expressions tutorial (ignore the Test Harness section, we
use our own testing class). Note that instead of using the
Pattern and Matcher classes directly, you will be using the class RegExTester that
provides methods for
searching, splitting, and replacing strings based on regular
expressions. Study examples in `main`

in that class.

**Important:** by default regular expressions will
find a matching sequence within the given input; they do not match
the entire input. For instance, a regular expression "DFA" will find a
match in an input "DFAs are cool".

**Also important:** Java strings use \ as a special
character. Therefore you need \\ for predefined regex classes,
e.g. "\\d+" matches one or more digit. See a link to more predefined
classes in question 2 below.

Your tasks are as follows. Assume case-insensitive matches, unless specified otherwise.

- Find all occurrences of letter combinations "dfa" and "nfa" in a text.
- Find all integer numbers (i.e. sequences of digits with no other characters) in a text. Use a predefined class \d to match a single digit (see example here: http://java.sun.com/docs/books/tutorial/essential/regex/pre_char_classes.html ). Ignore the negative sign.
- Find all negative integer numbers, i.e. numbers preceded by a - sign
- Find all words that start with a letter t (hint: use boundary matches http://java.sun.com/docs/books/tutorial/essential/regex/bounds.html
- Find all words in a text that have letters t and/or i in the them (in any order)
- Use the doRegExSplit to split a string into items separated by |
- Use the doRegExReplace method to replace all occurrences of "today" by "yesterday".

Make sure to submit your code (with some method calls commented out) and a copy of your test data for each regular expression (as a separate file or in comments).

- Submit your JFLAP files as attachments, CC your group. Make sure to submit your DFA files (as .jff) and your input data (as .txt). Make sure to follow the naming requirements! Make it clear which data refers to which automaton.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.