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
4
votes
1 answer

Syntax for Describing DFA or NFA

Do there exists any Standard Syntax for Describing the Transition Table for an NFA or DFA ?
Neel Basu
  • 12,638
  • 12
  • 82
  • 146
4
votes
4 answers

Entry actions with Akka FSM

Any state machine of reasonable complexity requires some entry actions to be performed upon entry to a state. For instance, UML State Machine diagrams have a special action for this purpose. Unfortunately I don't see how I can model such entry…
Jacob Eckel
  • 1,633
  • 1
  • 13
  • 22
4
votes
1 answer

python FSM Fysom callbacks on the other way

I am using Fysom to create FSM. I want to use callbacks in an other way: TABLE = { 'initial': 'OFF', 'events': [{'name': 'load', 'src': 'OFF', 'dst': 'LOADED'},], 'callbacks': {'onload': myfunction,}} fsm = Fysom(TABLE) Here if I launch…
Katsu
  • 1,868
  • 4
  • 19
  • 28
4
votes
2 answers

how to send parameter in stateless4j trigger

I'm using stateless4j as a Finite State Machine library for my app, but I can't understand how to use parameters when firing triggers. I have the following code: gameFSM.Configure(GameState.LOOKING_FOR_A_QUEST) .OnEntry(Actions.lookForQuest) …
Délisson Junio
  • 1,296
  • 4
  • 21
  • 43
4
votes
0 answers

Convert coroutine to finite state machine (FSM) and vice versa?

I'm trying to find a generalized way to convert a coroutine written in a language like go, python or javascript to a finite state machine (FSM). I need this in order to integrate several state machines into one large one, because humans tend to be…
Zack Morris
  • 4,727
  • 2
  • 55
  • 83
4
votes
1 answer

vhdl-fsm with timer- clock cycle delay

i have to write in vhdl an FSM with timer. I think that,there is no need you to get tired of understanding what my circuit will do. I just wanted to help me with this: Every change from a state to another state, there is one (or more) clock cycle…
maria
  • 467
  • 1
  • 5
  • 19
4
votes
1 answer

How does a finite state machine perform division?

I am taking a course on models of computation and currently we are doing finite state machines. One my tasks is to draw out a FSM that performs division of 3; to simplify the model the machine only accepts numbers multiple of 3. I am not sure how…
Shagster
  • 43
  • 1
  • 5
4
votes
3 answers

State management in VHDL FSMs

A lot of the FSMs I see in VHDL work by setting a variable "next_state" in the FSM logic and then assign this seperately to the state variable outside of the process. If there anything wrong with simply writing "state <= state_five;" to set the next…
jcoder
  • 29,554
  • 19
  • 87
  • 130
4
votes
1 answer

Guaranteeing log output flush in Akka upon system shutdown?

I'm using Akka FSM with Scala and logging using the log member of the FSM trait, i.e. an instance of akka.event.Logging. When calling context.system.shutdown() to shutdown the actor system when the application wants to terminate normally, it seems…
akisaarinen
  • 111
  • 1
  • 5
3
votes
1 answer

An attempt at non-deterministic finite state machine (C++), is a static std::map a good idea?

I need to implement a non-deterministic FSM, so I came up with the idea of defining an FSM class that holds states and transitions (that may or may not depend on the states of other FSMs, but must depend on events/input) for each object and adding a…
albizgil
  • 103
  • 6
3
votes
1 answer

Golang Telegram Bot

I'm writing a bot on telego, I don't understand how to implement fsm into the bot. Before that, I wrote bots in python aiogram where fsm was built in. How to do it in golang? package main import ( "fmt" "os" …
John
  • 43
  • 2
3
votes
2 answers

VHDL: Mealy FSM not producing state changes at clock edges?

I am fairly new to VHDL and am following this tutorial to implement the following Mealy Finite State Machine: and have written the following code in VHDL: library ieee; use ieee.std_logic_1164.all; entity fsm is port(clk, rst, in1 : in…
First User
  • 704
  • 5
  • 12
3
votes
2 answers

VLC libvlc_state_t State Machine?

Does anyone know if the VLC project has a defined state machine for the libvlc_state_t states? The state machine states are exposed via libvlc and then again via bindings into other languages (for example, LibVLCSharp). The enum is documented here,…
J Trana
  • 2,150
  • 2
  • 20
  • 32
3
votes
2 answers

How to do Perl state machine (FSM) to parse bitstream (byte sequence)?

I'm currently using Perl to parse incoming command sequences which comes from RS232 serial port. I try to use state machine, and its expected behavior is: (1) Receive a series of bytes from serial port; (2) The state machine uses the bytes as input,…
katyusza
  • 325
  • 2
  • 12
3
votes
1 answer

transition with same start/end in UML state diagram

I am new to UML, regrading FSM diagram, how to represent two transitions that lead to same state, for example, I'm in state1: when(event1)-->action1-->state2 when(event2)-->action2-->state2 I mean do I need to draw two lines from state1 to state2?
Hakim83
  • 59
  • 4