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

Click For Summary

Discussion Overview

The discussion revolves around the design and analysis of a finite state machine (FSM) that is intended to detect overlapping strings. Participants explore the completeness of the FSM specification and address potential oversights in the state transitions and outputs.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses uncertainty about the completeness of their FSM design, suggesting that they believe all cases are considered.
  • Another participant points out a specific overlapping string (ABCABC) that was missed in the initial analysis and questions the handling of inputs starting with the character C.
  • A suggestion is made to use a table format for FSM specifications, emphasizing the importance of having entries for every possible input in each state.
  • There is a discussion about the distinction between completing the table and ensuring the correctness of the FSM specification, with a participant noting that completing the table does not guarantee correctness.
  • Anecdotal evidence is provided regarding the practical application of FSMs in real-world scenarios, highlighting the importance of accurate state management.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the completeness of the FSM design, as multiple potential oversights are identified, and the discussion remains unresolved regarding the correctness of the specification.

Contextual Notes

Participants acknowledge that there may be additional overlapping strings not yet considered and that the specification may require more states to be fully accurate.

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: 277
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
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 21 ·
Replies
21
Views
3K
Replies
3
Views
2K