dfa.java starting, reading reg.dfa reading reg.dfa // reg.dfa machine coded for dfa simulation // // Machine Definition M = (Q, Sigma, alpha, q0, F) // Q = { q0, q1, q2, q3, q4 } the set of states // Sigma = { 0, 1 } the input string alphabet // q0 = q0 the starting state // F = { q2, q4 } the set of final states (accepting) // // inputs // alpha | 0 | 1 | // ---------+---------+---------+ // q0 | q3 | q1 | // q1 | q1 | q2 | // states q2 | q2 | q2 | // q3 | q4 | q3 | // q4 | q4 | q4 | // // L(M) is the notation for a Formal Language defined by a machine M. // Some of the shortest strings in L(M) = { 00, 11, 000, 001, 010, 101, 110, // 111, 0000, 00001, ... } // // The regular expression for the machine M above is // r = (1(0*)1(0+1)*)+(0(1*)0(0+1)*) // // See g_reg.g for equivalent regular grammar is constructed from M start q0 final q2 final q4 trace all limit 10 q0 0 q3 q0 1 q1 q1 0 q1 q1 1 q2 q2 0 q2 q2 1 q2 q3 0 q4 q3 1 q3 q4 0 q4 q4 1 q4 enddef tape 0110 key_tape=0110 tape 10100111 key_tape=10100111 tape 0111 key_tape=0111 tape 1000 key_tape=1000 reading input finished. start state q0 states: q0 q2 q4 q3 q1 final states: q2 q4 trace states q0 q2 q4 q3 q1 to_states: q3 q1 q2 q4 from_states: q0 q1 q2 q3 q4 sigma symbols: 0 for 1 transition table: q0 0 q3 q0 1 q1 q1 0 q1 q1 1 q2 q2 0 q2 q2 1 q2 q3 0 q4 q3 1 q3 q4 0 q4 q4 1 q4 input tapes: 0110 10100111 0111 1000 limit=10 trace_all=true DFA running on input tape: 0110 in state=q0 tape head at k=0 tsch=0 ts=0 q0 0 q3 state=q0 ts=0 tsch=0 at transition tj=0 in state=q3 tape head at k=1 tsch=1 ts=1 q3 1 q3 state=q3 ts=1 tsch=1 at transition tj=7 in state=q3 tape head at k=2 tsch=1 ts=1 q3 1 q3 state=q3 ts=1 tsch=1 at transition tj=7 in state=q3 tape head at k=3 tsch=0 ts=0 q3 0 q4 state=q3 ts=0 tsch=0 at transition tj=6 input tape accepted DFA running on input tape: 10100111 in state=q0 tape head at k=0 tsch=1 ts=1 q0 1 q1 state=q0 ts=1 tsch=1 at transition tj=1 in state=q1 tape head at k=1 tsch=0 ts=0 q1 0 q1 state=q1 ts=0 tsch=0 at transition tj=2 in state=q1 tape head at k=2 tsch=1 ts=1 q1 1 q2 state=q1 ts=1 tsch=1 at transition tj=3 in state=q2 tape head at k=3 tsch=0 ts=0 q2 0 q2 state=q2 ts=0 tsch=0 at transition tj=4 in state=q2 tape head at k=4 tsch=0 ts=0 q2 0 q2 state=q2 ts=0 tsch=0 at transition tj=4 in state=q2 tape head at k=5 tsch=1 ts=1 q2 1 q2 state=q2 ts=1 tsch=1 at transition tj=5 in state=q2 tape head at k=6 tsch=1 ts=1 q2 1 q2 state=q2 ts=1 tsch=1 at transition tj=5 in state=q2 tape head at k=7 tsch=1 ts=1 q2 1 q2 state=q2 ts=1 tsch=1 at transition tj=5 input tape accepted DFA running on input tape: 0111 in state=q0 tape head at k=0 tsch=0 ts=0 q0 0 q3 state=q0 ts=0 tsch=0 at transition tj=0 in state=q3 tape head at k=1 tsch=1 ts=1 q3 1 q3 state=q3 ts=1 tsch=1 at transition tj=7 in state=q3 tape head at k=2 tsch=1 ts=1 q3 1 q3 state=q3 ts=1 tsch=1 at transition tj=7 in state=q3 tape head at k=3 tsch=1 ts=1 q3 1 q3 state=q3 ts=1 tsch=1 at transition tj=7 input tape or DFA failed DFA running on input tape: 1000 in state=q0 tape head at k=0 tsch=1 ts=1 q0 1 q1 state=q0 ts=1 tsch=1 at transition tj=1 in state=q1 tape head at k=1 tsch=0 ts=0 q1 0 q1 state=q1 ts=0 tsch=0 at transition tj=2 in state=q1 tape head at k=2 tsch=0 ts=0 q1 0 q1 state=q1 ts=0 tsch=0 at transition tj=2 in state=q1 tape head at k=3 tsch=0 ts=0 q1 0 q1 state=q1 ts=0 tsch=0 at transition tj=2 input tape or DFA failed no more input tapes finished dfa.java