4 ms·
Mind elaborate on the next state predicate approach? By next, I imagine the focus is on transition rather than state; however, if you have multiple transitions
by teacpde 6y ago
Mind elaborate on the next state predicate approach? By next, I imagine the focus is on transition rather than state; however, if you have multiple transitions arriving at the same state, what makes the next approach better? At the end of day, the state machine is the same regardless how it is implemented.
- nitrogen 6y agoEdit: looks like they're talking about this: https://en.wikipedia.org/wiki/TLA%2B https://en.wikipedia.org/wiki/TLA%2B What I describe below is not related. ---- Not the OP, but here's a stab at it... In state machines commonly used in embedded C code, each state is represented either by a function or by a struct that contains a function pointer. The state machine calls the current state function in a loop or whenever relevant events happen, and that function returns a pointer to the next state, calculated based on inputs. If there is no state transition, then the function returns NULL or returns its own state.
- amw-zero 6y agoSee the above reply where I gave an example with both representations. Agreed, the machine representation is independent of the machine itself, it's the same mathematical object. So what I was talking about was how to represent using only a relation which describes the possible next states given the current one. This is the most common definition of a state machine, and for me, it's a cleaner representation since you avoid referring to each edge in the state graph explicitly.