Você está na página 1de 18

BABU BANARASI DAS

National Institute of Technology and Management, Lucknow

LAB MANUAL
OF
TAFL LAB (RCS 453)
Introduction
What is JFLAP?

JFLAP program makes it possible to create and simulate automata. Learning about automata
with pen
and paper can be difficult, time consuming and error-prone. With JFLAP we can create
automata of
different types and it is easy to change them as we want. JFLAP supports creation of DFA
and NFA,
Regular Expressions, PDA, Turing Machines, Grammars and more.

Setup
JFLAP is available from the homepage: (www.JFLAP.org). From there press “Get FLAP” and
follow
the instructions. You will notice that JFLAP have a .JAR extension. This means that you need
Java to
run JFLAP. With Java correctly installed you can simply select the program to run it. You can
also use
a command console run it from the files current directory with, Java –jar JFLAP.jar.

Using JFLAP
When you first start JFLAP you will see a small menu with a selection of eleven different
automata and
rule sets. Choosing one of them will open the editor where you create chosen type of
automata.
Usually you can create automata containing states and transitions but there is also creation
of
Grammar and Regular Expression which is made with a text editor.
Experiment 1

AIM: To make a Deterministic Finite Automata (DFA).


For this experiment, we’re building a DFA for the following language L over the alphabet
over ∑= {a,b} ; L ={w € ∑*| W has an even number of a's and an odd number of b's}

1. 1.In JFLAP, let's create a new DFA. Create an initial state q0. There are no a's and no
b's. Thus an even number of a's and an even number of b's. Let's label this state
even-even.

2. If the first symbol is an a, we have an odd number of a's and still an even number of
b's. Create a new state q1 to represent this scenario. Label this state odd-even. Add
a transition labelled a from q0 to q1,

3. If the symbol in state q0 is a b, you then have an even number of a's and an odd
number of b's. Follow the steps as in 2. above to get the following.
4. Now let us look at q1, which represents an odd number of a's and an even number of
b's. What happens when we read an a? Does it go to a new state?

5. Also, in q1, what happens when we read an b? Does it go to a new state?

6. Proceed with the DFA construction by adding all the required transitions at all states.
Finally, since we are interested in the language L, what state (or states) should be
accept states?
RESULT:

We’ve tested the DFA with multiple inputs as shown below and verified that the results are
correct.
Experiment 2

AIM: To make a Non Deterministic Finite Automata (NFA).


For this experiment, we’re building a NFA for the following language L over the alphabet ∑=
{a,b} ; L ={w € ∑* | W starts and ends with different symbols }

1. In JFLAP, create a new FA with initial state q0. Since the string can start with ‘a’ or
‘b’, we’ll show two different transitions for each input to a new state q1 and q3
respectively.

2. Now, for the string to end with different symbols with respect to its starting, we’ll
have a transition of ‘b’ from q1 and ‘a’ from q3 to a common final state q2.

3. Since it is a NFA, we can have multiple transitions for any symbol. So, we’ll make a
self-loop of both, ‘a’ and ‘b’ on the states q1 and q3 so that it scans the whole string.

4. Now, the NFA is complete. We’ll run multiple inputs over the created NFA to test it.
To do so, click on Input and then click on Multiple Run.
RESULT:

The NFA has been created and the above shown inputs were ran and verified.
Experiment 3

AIM: Conversion of NFA to DFA


For this experiment, we’re building a NFA for the following language L over the alphabet
∑={a,b} L ={w € ∑* | W starts and ends with different symbols }
and will convert it to an equivalent DFA using JFLAP.

1. As the NFA was constructed in the last experiment, we’re using the same NFA to
convert into the equivalent DFA. The NFA is shown below.

2. To convert the NFA to DFA, click on Convert and then Convert to DFA.
3. Now, click on the ‘Complete’ button to complete the DFA.

4. Now, click on ‘Done?’ button to place the newly created DFA in a new window.
RESULT:
The newly converted DFA is placed on a new window. To test it, we’ll click on Input and
then on Multiple Run.

The newly created DFA is tested with the string shown above and verified.
Experiment 4

AIM: Conversion of NFA to DFA


For this experiment, we’re building a DFA for the following language L over the alphabet
∑={a,b}; L ={w € ∑* | W starts and ends with different symbols } and will convert it to an
equivalent DFA using JFLAP.

1. In this, we’ll use the same DFA we built in the last experiment.

2. To convert the DFA, click on Convert button. Now, click on the ‘Minimize DFA’ option
RESULT:
The DFA is converted to its equivalent minimized DFA and placed on a new window as
shown below.
Experiment 5

AIM: Regular Expression (RE) to Deterministic FA (DFA).


For this experiment, we’re converting a Regular Expression to a DFA accepting the language
which is given by the corresponding RE.

1. To enter a RE in JFLAP, choose the Regular Expression option rom the main window.

2. Next, enter the RE and click on Convert and then, click on Convert to NFA.
3. Now, the NFA corresponding to that particular RE will be made and shown in a new
window. Click on Export to open the same in new window. Now, click on convert and
then on convert to DFA.

4. Now, click on Complete to complete the DFA.

5. Now click on ‘Done?’ to finish building the DFA and place it in a new window.
RESULT:
The final resultant DFA is placed in a new window and is tested with the possible inputs to
verify it as shown below.
Experiment 6

AIM: Convert DFA to Regular Expression (RE).


For this experiment, we’re converting a Deterministic Finite Automata (DFA) to the
corresponding Regular Expression (RE) using JFLAP. For DFA, we’re using the same DFA built
in the last experiment as shown below.

1. The DFA shown either accepts just ‘c’ or strings starting with ‘a’ and ending with ‘b’.
The same is shown below. To convert it to RE, click on ‘Convert’ button and then
click on ‘Convert to RE’ option.

2. The FA is placed in a new tab. Now, click on ‘Do it’ button. It asks to build a new
state.
3. Now, make λ (empty) transitions from the highlighted states (q2, and q3) to the
newly created state q4 as shown in the image below.

4. Now, click on ‘Do It’ repeatedly times until a done message is shown.
RESULT:
Now finally, the FA is minimized for the RE and it is shown.

To further view the RE, click on ‘Export’ button and the corresponding RE for the DFA is
shown in a new RE window as shown below.

The RE is same as the RE we used in the previous experiment to convert it into DFA.
Hence, the converted RE is verified.

Você também pode gostar