Add a Trap State to DFA

Introduction
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 DFA
First, load DFA from ADD_TRAP.jff. 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:  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 :   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 :  <P ALIGN=CENTER><IMG SRC="images/images_3.png" NAME="Graphic4" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0></P> <P STYLE="margin-bottom: 0in">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.</P> <P STYLE="margin-bottom: 0in"><BR> </P> <P ALIGN=CENTER><IMG SRC="images/images_4.png" NAME="Graphic5" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0></P> <P ALIGN=LEFT STYLE="margin-bottom: 0in">However, if you type in the correct terminal (“b” in this case), your window should look like this : </P> <P ALIGN=CENTER><IMG SRC="images/images_5.png" NAME="Graphic6" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0></P> <P ALIGN=LEFT STYLE="margin-bottom: 0in">Now, we can complete our DFA by either manually creating transitions or by clicking <B>Do All</B> button. When we click <B>Do All</B> button, JFLAP automatically adds remaining transitions to DFA and export the complete DFA to the new window.</P> <P ALIGN=CENTER><IMG SRC="images/images_6.png" NAME="Graphic6" ALIGN=MIDDLE WIDTH=600 HEIGHT=435 BORDER=0></P> <P ALIGN=CENTER><BR><BR> </P> <P ALIGN=LEFT><B>NOTE:</B><SPAN STYLE="font-weight: medium"> 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.</SPAN></P> <P STYLE="margin-bottom: 0in"><B>This concludes our brief tutorial on adding a trap state to DFA. Thanks for reading!</B></P> </BODY> </HTML>