Questions tagged [fsm]

Acronym for Finite State Machine.

Finite state machine, finite state automata, or state machine, is used in computer science or logic theory to represent a finite number of states and the transitions between states.

Finite state machines are commonly used in parsing and matching strings, so it accepts certain types of strings (such as those representing an integer), and a language (set of strings) is regular if and only if it can be represented as a finite state machine.

An example of a finite state machine implementation in pseudocode, accepting all decimal integers:

state = 0;
digits = "152341264"; // Some sequence of decimal digits
for (k = 0; k < len(digits); k++) {
    switch (state) {
    case 0: // Initial state
        if (digits[k] is a decimal digit)
            state = 1;
        else
            state = 2;
        break;
    case 1: // Digit found, also an accepting state
        if (digits[k] is a decimal digit)
            state = 1;
        else
            state = 2;
        break;
    case 2: // Dead state
        break;
    }
}
FSM accepts the string digits if it finishes at state 1.

Finite state machines represent all the regular languages, or Type 3 languages, which are the lowest in the Chomsky hierarchy, below the context-free (Type 2) languages, which is below the context-sensitive (Type 1) languages, which is below the recursively enumerable (Type 0) languages.

Wikipedia page

The tag is also known like on stackoverflow.

533 questions
3
votes
1 answer

Template base class implementation a default implementation

I am trying to make a simple templated FSM library that would allow: machine.react(Event1{}); which would call the implementation SomeState.react(std::shared_ptr machine, Event1 event) without the need to know all possible events in…
Alexis Paques
  • 1,885
  • 15
  • 29
3
votes
1 answer

Can finite state machines with conditional transitions be expressed as Markov chains?

I'd be curious to know whether finite state machines that have conditional transitions can be expressed as Markov chains? If they can't, what would be a good counterexample?
Szemeredi_31
  • 131
  • 2
3
votes
1 answer

Using xstate, is it possible to configure an event that is applicable under all states and is handled in the same way across all states and substates?

I am new to xstate, and I'm trying to use it in an application where a user can request different things in an application, based on parent state and/or sub-state. However, there are some requests that the user should be able to make, no matter…
3
votes
2 answers

Encoding state machines in VHDL

I'm looking into creating a system in VHDL that filters an image after receiving it through an FTDI usb-to-serial device. As part of this, I believe I've identified the states that my CPLD should be in, but I have never created a complex state…
shieldfoss
  • 886
  • 2
  • 12
  • 22
3
votes
0 answers

Simplifying flat state machine using hierarchical state machine

I am new to finite state machines and I'm trying to understand if I should use a hierarchical state machine, or stick with the flat structure I've got to model my problem in the simplest way. I have an "analyzer" which can be either stopped,…
keith
  • 5,122
  • 3
  • 21
  • 50
3
votes
1 answer

How to determine if one regex is subset of another?

Give the two regex, A = 0*1* U 1*0* and B = (01 U 10)*, how do I determine if one is subset of the other. I guess one approach is to list some examples out and see if they have anything in common. In this case, I see strings 01, 10 are shared in…
Rippyae
  • 176
  • 2
  • 14
3
votes
1 answer

Are L1 = {a^n b^n | n < 4 } and L2 = {a^n b^n | n < 10^10^10 }, regular languages?

Is L1 = {a^n b^n | n < 4 }, a regular language ? In my opinion, it is regular, as I could draw an FSA for it, however, in class, my professor had taken an example, L2 = {a^n b^n | n < 10^10^10 } and said, this is not regular... so, my question is,…
3
votes
3 answers

Implementing event conditions in a C++ state machine

I'm using an hierarchical FSM for an embedded C++ application interface. I'd like to use small functions to determine whether certain inter-state events can be triggered, as well as use them to effect changes in the database: however, making a new…
zaratustra
  • 8,148
  • 8
  • 36
  • 42
3
votes
1 answer

Regular Languages and Concatenation

Regular languages are closed under concatenation - this is demonstrable by having the accepting state(s) of one language with an epsilon transition to the start state of the next language. If we consider the language L = {a^n | n >=0}, this language…
CharlotteA
  • 41
  • 1
  • 1
  • 3
3
votes
1 answer

Waiting on multiple Akka FSM messages

I have an Akka FSM actor that runs the following pseudocode after receiving a message while in ReadyState lookupA ! Wrapper(Lookup("A")) lookupB ! Wrapper(Lookup("B")) lookupC ! Wrapper(Lookup("C")) goto(LookingUpDataState) using DataFound(a = None,…
pkinsky
  • 1,718
  • 2
  • 23
  • 28
3
votes
1 answer

Instrumenting Akka FSM

I like to take the metrics a FSM needs till it reaches a certain state. Instead of spamming my classes with metrics code I would like to add a trait which overrides certain methods and emits a message when the method is called. For example: trait…
Andreas Neumann
  • 10,734
  • 1
  • 32
  • 52
3
votes
2 answers

State machine; why only last state is working?

I have a state machine with 6 states(3 main states). Only the last state is working but the first 2 doesn't(out of 3).Only the last state is working. I found out the problem, when I remove the debounce circuit it works, but I need the debouncing…
Anarkie
  • 657
  • 3
  • 19
  • 46
3
votes
1 answer

Akka FSM actor and round-robin routing

I want to convert some set of actors into FSM using Akka FSM. Currently system is designed in the way that every actor knows what to do with results of it's action and which actor is next in sequence of processing. Now I want to have some sort of…
jdevelop
  • 12,176
  • 10
  • 56
  • 112
3
votes
2 answers

How to connect two state circles with an arrow in tkinter?

I am currently writing a fsm editor with tkinter. But, I stuck on connecting two states. I have two questions: 1) How can make the transition arrow growable according to mouse movement? 2) How can I stick the starting point of the arrow on a state…
israkir
  • 2,111
  • 7
  • 30
  • 39
3
votes
3 answers

Simple enum for java automaton

I'm trying to implement this automaton example : http://www.javacodegeeks.com/2012/03/automaton-implementation-in-java.html. However, an error keeps on being displayed while running the program : Exception in thread "main"…