fsm


about states of finite state machine


the question is let sigma =(1,2,3,$). I need to draw its diagram which outputs 1 when sum is >_5. if it is over 5, the amount will be carried over.
Im wondering what would be the state in this case. Can I let A = ive seen 1 B=ive seen 2, C=ive see 3 and D = accepted state?
No, you cannot use just three states. Your FSM must, somehow, keep counting the current sum of the input values so far. The problem is that a FSM has no memory (that would be another kind of automata) so it has to be one state for every possible combination of numbers that evaluate to all possible sums.
That is: you need a state that means ("the current sum is 0").Let that state be state 0. That would be your initial state. Other states would be "the current sum is 1" (state 1), "the current sum is 2" (state 2), .... , "the current sum is 5" (state 5), "the current sum is 6" (state 6), etc (no, you won't need an inifinite number of states, as for example, from state 5, a transition with value 1 leads you again to the state 1.
From state 0, a transition with 1 leads you to state 1. Transition with 2, to state 2 and transition with 3 to state 3. Easy, isn't it?
From state 3, for example, a transition with 1 leads you to transition 4, Transition with 2 to state 5, which is an accept state, and transition with 3 to state 6, which is also an accepted state.
To put another example: from state 6, a transition with 1 leads you to... state 2. That's right: state 6 means that the current sum is 6, which exceeds 5 in 1. So this is like transition 1, but it is an accepted state, so transitions from state 6 go to the same places as transitions from state 1 would go. This will help you building your FSM.
In fact, the larger state number is determined by the largest value you can sum with 1,2 and 3 that overflows 5 for the first time. That would be 1+1+1+1+3 = 7. So you need to define from state 0 to state 7, and of course, a final state when $ is detected.
You don't need to keep track of the current sum. You just need to keep track of the total sum modulo 5.
One way of doing this is to let your state space be A0, A1, A2, A3, A4, and B0, B1, B2. If you enter an "A" state, you output 0, and if you enter a "B" state, you output 1.
Your state transitions depend on the next digit that you see. For example:
If you are in A1, and the next digit you see is 2, you transition to A3, and output 0.
If you are in A4, and the next digit you see is 1, you transition to B0, and output 1.
If you are in B2, and the next digit you see is 1, you enter A3, and output 0.
If you are in B2, and the next digit you see is 3, you enter B0, and output 1.
In general, suppose you are in state XY, where X is either A or B, and Y is 0, 1, 2, 3, or 4. Let D be the next digit you see. The next state you will enter will be X'Y', where:
X' is A if D + Y < 5.
X' is B if D + Y >= 5.
Y' is D + Y modulo 5.

Related Links

What is the DEF state in the Ragel (6.10) document illustrations
Converting a system model into transition system for model checking
Programming a bubblesort in NuSMV
about states of finite state machine
Controlling finite-state machines
What are steps for generating fsm code in C or C++ with NunniFsm?
Compile Finite State Machine to UML(-like) Diagram
JountJS - Creating FSM Dynamically through PHP
Large DFA examples?
implementation of an Moore Automaton in digital electronics
Finite State Machine of concurrent system
Syntax for Describing DFA or NFA
Combined states, FSM
How to Build finite state machine that show modulus 4 in binary
FSM data structure design

Categories

HOME
arduino-uno
vim
cloud
reflection
kde
angular-material
cplex
binary-tree
datastax-java-driver
django-imagekit
fancybox-3
kentor-authservices
orchardcms
hapi
iron-router
ghc
tostring
pc
invantive-sql
oracle-coherence
openedx
paging
wkwebview
crystal-reports-2010
p-value
centos6.5
web-api-testing
social-media
minitab
ejabberd-module
instant-messaging
fabric8
media-queries
stormpath
.net-4.0
webtest
uiswipegesturerecognizer
azure-sql-database
sequential
appfabric
lto
multilingual
temporary-files
cookiecutter-django
grid.mvc
dynamic-reports
estimote
long-polling
fault
komodoedit
rails-routing
elgg
brightcove
drupal-6
sqldf
nbconvert
synchronous
nxt
grails-tomcat-plugin
multi-level
trash
mongocsharpdriver
flash-cs5
yaws
itextpdf
xpath-1.0
wapiti
pyke
freedesktop.org
r-tree
metaclass
quicklisp
kcachegrind
embedded-code
splash
sonarqube5.1.2
winddk
android-imagebutton
googlemock
doskey
resty-gwt
gnu-smalltalk
commoncrypto
spring-io
back-stack
yui-compressor
eventlistener
anonymous-methods
bitsharp
tridion-worldserver
ocx
xmemcached
xdomainrequest
yetanotherforum
table-footer
web-application-design
dbal
javap
avatar
mediarss
commodore

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App