Finite state machine that doesn't terminate and detects overlapping strings

Click For Summary
SUMMARY

This discussion focuses on the implementation of a finite state machine (FSM) that does not terminate and is capable of detecting overlapping strings. Key insights include the importance of creating a comprehensive state transition table that accounts for all input variables and states. The conversation highlights the necessity of ensuring that every table entry specifies both the output value and the next state to avoid incomplete specifications. Additionally, real-world applications of FSMs, such as controlling fluid transfer in industrial settings, demonstrate their practical significance.

PREREQUISITES
  • Understanding of finite state machines (FSMs)
  • Familiarity with state transition tables
  • Knowledge of input-output mapping in FSMs
  • Experience with implementing FSMs in programming or hardware
NEXT STEPS
  • Research how to construct state transition tables for FSMs
  • Learn about debugging techniques for FSM specifications
  • Explore real-world applications of FSMs in industrial automation
  • Study the implementation of FSMs in programming languages like Python or C++
USEFUL FOR

Software developers, systems engineers, and anyone involved in designing or implementing finite state machines in software or hardware applications.

r0bHadz
Messages
194
Reaction score
17
Homework Statement
Create a finite state machine that recognizes the input strings “a”, “abc” and “cab” by
outputting a 1 (otherwise output 0 for the input).
The input alphabet is {a, b, c}. The output alphabet is {0, 1}.
The input stream may be any length, beginning with any arbitrary sequence of the input
alphabet.
The FSM should be completely specified. The FSM must include both inputs and outputs
for each transition.

The FSM should not terminate.
The FSM should recognize overlapping tokens (input strings).
Relevant Equations
An FSM is an abstract representation of behavior
exhibited by some systems.
Attached is what I have so far. I believe it is done but I am not 100% sure.

It seems to me like every case is considered. For each state, and output of a,b, or c is possible.
 

Attachments

  • finiteStateMachine.png
    finiteStateMachine.png
    31.7 KB · Views: 267
Last edited by a moderator:
Physics news on Phys.org
I like your colored state diagram, makes it much easier to follow.

I think you missed ABCABC.
You correctly found the overlapping:
A...Q1
ABC...Q1,Q2,Q3,Q5
.AB... Q6

But missed the second ABC at Q6
Also what happens if the first character is C?

There may be others, I haven't looked.

A trick I learned for complex FSMs is to create a table. There is a column for each input variable and a row for each state.

Every table location must have an entry for the Output Value when that entry is matched and the Next State to branch to. If there is an empty entry you have not completed the specification.

Cheers,
Tom
 
  • Informative
  • Like
Likes   Reactions: anorlunda and r0bHadz
You are a legend Tom. I was just going through it but I don't think I would have caught that. Good eye, man. I appreciate ya!

edit: I'm not sure what you mean exactly if the first character is C. If you mean the input string starts with a c, then it goes from state q_0 to state q_4

Also, if you complete the table, that does not mean that your specification is correct, right?

edit:
Just found out there is a lot more actually.
 
Last edited:
r0bHadz said:
edit: I'm not sure what you mean exactly if the first character is C. If you mean the input string starts with a c, then it goes from state q_0 to state q_4
So it does! I missed that one.

r0bHadz said:
Also, if you complete the table, that does not mean that your specification is correct, right?
Right. You still may not have created enough states. It does encourage taking account of every possible input in every state though. When implementing an FSM in computer code, or even in dedicated hardware, table look-ups are fast and easy to change.

One project I was on was controlling fluid transfer on a medium sized tank farm. There was an instance where I had the pumps starting before all the valves were open. You could hear the pipes knocking and pressure relief valves banging all over the several acre property. Oops! The on-site fix took less than a half hour, just changed three table entries to open the valves first. Much easier than trying to patch a string of IF-THEN statements. The documentation and source code updates back in the office took rather longer. :sorry:

Cheers,
Tom
 
  • Like
Likes   Reactions: r0bHadz
Tom.G said:
Cheers,
Tom

Sounds intense Tom! Cool to see that this stuff is used in the real world.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 17 ·
Replies
17
Views
6K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 21 ·
Replies
21
Views
2K
Replies
3
Views
2K