views:

147

answers:

2

I know that a FSM can transition to the next state and even to the current state, i.e. a state that transitions to itself, but is it legal to have a state transition to a previous state (state C transition to state B)?

+8  A: 

Yes, many practical FSMs will in fact do this. Consider an FSM that identifies valid strings of number separated by one or more spaces. This would start in the "digit" state and at some point transition to the "space" state from which it might well transition back to the "digit" state.

anon
Could you kindly provide a source for your answer?
Brandon
Thirty years of programming experience?
anon
In fact, there are examples of this in any automata theory book.
Vinko Vrsalovic
+5  A: 

The "next state" of an FSM is defined as the state the machine will transition to in the next "time slice" or when the next input arrives, or whatever.

Thus defined, the next state of C can be C itself, B, A, D, ZORG or whatever state you have in the machine. Alphabetical letters don't define what's previous and what's next, only the logical flow of the FSM.

This state machine from the Wikipedia page:

SVG Image, use the link below if you can't view here
http://en.wikipedia.org/wiki/File%3AFinite%5Fstate%5Fmachine%5Fexample%5Fwith%5Fcomments.svg

Eli Bendersky