When you create DFA in JFLAP, you do not need to specify the trap state. When there is no out-going transition from a state with given input, JFLAP assumes that it goes to trap state and end parsing input string. In order to complete DFA, there is now new feature in JFLAP that adds trap state and necessary transitions to complete DFA.
Add a Trap State to DFAEdit
First, load DFA from <A HREF="ADD_TRAP.jff">ADD_TRAP.jff</A>. We will now complete this DFA by adding a trap state. Click on the “Convert → Add Trap State to DFA” menu option, and this screen should come up:
<IMG SRC="images/images_1.png" NAME="Graphic2" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0>
Now, we need to create a single trap state. Click on the state icon (next to the arrow icon) and click on the location where you want your trap state to be created. tice the labels on the states in the picture. After creating a trap state, your window should look like this :
<IMG SRC="images/images_2.png" NAME="Graphic3" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0>
Since we now have created our trap state, we need to add appropriate transitions. Our readable string in this DFA is “a” and “b”. Therefore, in order for this DFA to be complete, every state must have outgoing transition on input string “a” and “b”, Obviously, it is not the case in current DFA. Let's add transition from state q0 to the trap state. Since we already have outgoing transition from state q0 on alphabet “a”, we need an outgoing transition on alphabet “b”. Click on transition creator icon, and create transition from q0 to q3 (trap state). Now, JFLAP asks for the terminal. If you have followed the steps correctly, your window should look like this :
<IMG SRC="images/images_3.png" NAME="Graphic4" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0>
If you type in other terminal than “b”, JFLAP will complain, because that is incorrect transition to the trap state. Let's type in input string “a” for the terminal. Since it is not valid, JFLAP will complain like in the below window.
<IMG SRC="images/images_4.png" NAME="Graphic5" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0>
However, if you type in the correct terminal (“b” in this case), your window should look like this :
<IMG SRC="images/images_5.png" NAME="Graphic6" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0>
Now, we can complete our DFA by either manually creating transitions or by clicking Do All button. When we click Do All button, JFLAP automatically adds remaining transitions to DFA and export the complete DFA to the new window.
<IMG SRC="images/images_6.png" NAME="Graphic6" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0>
NOTE: If your DFA already contains a trap state and complete, “Add Trap State to DFA” would not work and JFLAP will notify you that your DFA is already in complete form.
This concludes our brief tutorial on adding a trap state to DFA. Thanks for reading!