Add a Trap State to DFA
Introduction
Add
a Trap State to DFA
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.
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 :
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.
However, if you type in the correct terminal (“b” in this case), your window should look like this :
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.
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!