How does a finite state machine work if it is ambiguous? - state-machine

The finite state machine in question:-
If I am at S0, and the input is a, do I repeat to S0 again or do I move onto S1? I don't know how to determine this. Is this kind of FSM even valid?
Which of these input combinations will end in the halting state?
aaabc
ccc
bc
bbc

This is a NFA (non-deterministic automata).
The words accepted by the automata are:
aaabc
bc
https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton

August
Only the "aaabc" is valid, the rest are halting as the FSM has "a" as the legitimate S0 entry.

Related

How to simplify/generalize a Finite State Machine (FSM) for a vending machine?

I have enrolled into course of computational methods, and currently we are reviewing automata and regular expressions. In one of the course assignments we were asked to design a finite state automata that models the payment process of a vending machine.
For our base model they told us that the vending machine works with coins of $1, $2, $5, $10, $20, and $50, and that the final state is a product worth $80. At first I was very shocked because I thought that I would have to draw all the possible paths (combinations) of coin insertions; for example, if someone wants to pay the $80 with only $1 coins I would need an automaton with over 80 states.
Now, here's the deal. Our teacher told us that of course it is a valid way of doing the automaton, but a rather overcomplicated and inefficient one. What he really expects is that we make a generalization of the automaton and he gave us the following hint:
"If the design of the automaton works with the numbers of the coins (denominations) so that the state you are in also tells you how much money you have accumulated, then you have already found a way to generalize for any scenario".
Note: He also gave us this image, he told us that it might give a little push towards the solution:
Our automaton's final test is that it can work with ANY currency system, fictional or real. For example a currency that has coins of $3, $16 $47 $64, or Japanese currency system: ¥1, ¥5, ¥10, ¥50, ¥100, ¥500, ¥1000, ¥2000, ¥5000, and ¥10000.
Any ideas/suggestions on how to draw/design the automaton? I mean, I seriously don't believe I would have to draw more than 10000 states if I want to represent Japan's currency system.
You need exactly 81 states to solves this problem.
Consider each state corresponds how much money is deposited so far.
The final state is actually shows that there is at least $80 in the machine, it could be more. But we are not going to give change.
There will be 6 arrows going out from each state, one for each type of coin. For instance from state 0, There will be arrows to state 1, state 2, state 5, state 10, state 20 and state 50.
In the final state, the arrows will be self loops.
And you cannot do this with less than 81 states. Basically, in the machine at any time there could be money equal to 0,1,...,80+. Which is in total 81 different case. If you have less than 81 states, it means due pigeon hole principle, at least two cases will be represented by the same state. And there is no way to distinguish them.

Is this FSA Transition Diagram correct?

I had this problem I had to solve where I have to design a transition diagram to accept a string A, where A is any string with a substring of 101 in any position over the set {0,1} (RE of (1+0)*101(1+0)*). I solved it and designed the machine and drew it on an online tool but unfortunately the material I'm studying from does not have any written solution to this problem for me to check, so I wanted to check if my answer is correct here, since google gave me various answers none of which were like mine.
Now the idea here is that the diagram keeps going on forever, alternating between states until it encounters a consecutive input of 101, then it ends up in the final state q4, in which it's free to continue receiving whatever input until the end of the string. Is what I have done correct?
Thank you in advance.
No. Consider the string 1101. It is valid, but your machine will end in state q1 and reject it.

State Transition Table for a Finite State Machine

I would like to ask for your help in understanding this question:
A finite state machine M with 1-bit input and 1-bit output and the output is given by these logic functions:
O(0) = 0
O(1) = I(0).I(1)
O(t) = I(t).I(t-1)+I(t).I(t-2)+I(t-1).I(t-2), t>=2
The question asks to show the transition table of M with minimum number of states. I(t) and O(t) denote the the values of input and output at time t.
i really do not understand how to consider the time factor in building the state transition table.
Also, if it happens that you know some resources (books, ..) that will help me to understand and solve questions like this one, would you suggest some of them?

Creating a diagram for a PDA that recognizes each L

Trying to understand PDAs, but don't really grasp how to draw them.
first of all, I don't really understand how a PDA would look different if the restrictions say that the #a, or #b, or #c would be "greater than zero" or "greater than or equal to zero." I drew the following PDA diagrams for each of the textbook questions they seem right enough to me. Just want a second hand look.
So the logic for my first PDA is that for every "a" input, there will be a multiple of four "a" moved onto the stack. When a "b" input is entered, every "a" from the stack will result in one empty string, clearing the stack.
For the second PDA I created a non deterministic PDA because there can be zero "a" or zero "b". Therefore for every even input of "bb" there will be no change to the stack since there can be an infinite number of "bb", but the "a" will be preserved on the stack because it will have to be called again after the "bb" if there are "a".
If I understand your diagrams correctly, they are not correct and seem to betray a basic misunderstanding of how PDAs work. Rather than try to work with you to understand your thought process in producing these, I will derive new PDAs and let you reconcile them to what you have attempted. I will not provide drawings but I will describe what the drawings would look like; I'll provide tables as these are easier to render.
1) L = {a^i b^j | i > 0, j = 4i + 2}
When you make any automaton, you are trying to find states and transitions. A good first place to start is to wonder about the initial state, since we know we'll need one. Is it the only one we need, or will we need more? Is it accepting? For this language, we can see that it is not accepting (since, if the initial state were accepting, the PDA would accept the empty string, which can't be in our language since we require i > 0). Since our language does contain strings, we know we need an accepting state so we know we need at least two states; call them q0 for the initial state and q1 for the other state we know we'll need. Now that we have a couple of states, we can turn out attention for a moment to the first transitions.
Now, we know we need to allow for some a's at the beginning of our strings. Indeed, we must require at least one a. Let us think for a moment about what this means. Suppose we add a transition from q0 back to q0 accepting a. If we don't put anything on the stack, we lose information about whether we have seen any a's or not. However, we do have a stack, and so we can remember what we need to know: that we have before seen an a. Therefore, we can add an ability to transition from q0 to q0 upon reading an a and record that fact upon our stack. We will later require the ability to check the stack to see if we have seen some a's. Now we can ask what we shall put on the stack.
We have some options here, and there are no right or wrong answers. What you choose will depend on what automaton formulation you're relying on and what your design goals are for the automaton. Yes, an automaton is designed in the same way as a real machine or a computer program. We want to make a design choice that obeys the rules of our formalism and that is simple and easy to work with. One approach is to add what we later are expecting to see corresponding to the symbol we have consumed; for each a we see now, we need to see four b's later; so we can add bbbb to the stack now, and later pop one b from the stack for each b read from input. This is convenient. Notice that when we read the first a, we can take care of the "+2" requirement by adding bbbbbb instead of bbbb, so long as we know when we are reading the first a - which we know by examining the stack.
Based on all of these considerations, we can produce a partial table for the PDA we have been designing, and then we can assess our progress and see where left we have to go:
q e S q' S'
--- --- --- --- ---
q0 a Z q0 bbbbbbZ
q0 a b q0 bbbbb
We use Z to represent the bottom of the stack. When we see the first a (we know it is the first because the stack is empty, i.e., the topmost symbol is the one representing the bottom of the stack) we add bbbbbb. Each successive a adds bbbb to the top of the stack (by replacing b with bbbbb).
Now we must consider how b's are to be handled. Can we process a b by looping from q0 to q0? A moment's thought should convince you that this is not a good idea. If we loop from q0 to q0 upon seeing a b, then we have no easy facility for preventing the PDA from accepting further a's. But this would result in a string that cannot possibly be in our desired language, since in our language no a's can come after a b. It seems therefore necessary that whatever transition accepts b's, not have as its target the state q0. We therefore choose q1 as the target of the transition under discussion. What shall be the source? So far, only q0 has been reached in our PDA, and we only have q0 and q1 to choose from. We have two choices now: either we provide a mechanism for transitioning from q0 to q1 without seeing a b, or we provide a mechanism for transitioning on a b. The first of these approaches requires indeterminism based on our previous design choices, so we might prefer the latter as being more explicit and easier to reason about. This leads to the following transition (added to our previous table):
q e S q' S'
--- --- --- --- ---
q0 a Z q0 bbbbbbZ
q0 a b q0 bbbbb
q0 b b q1 -
This transition says that when we see a b in q0 and we have seen a's before on the stack, transition to q1 and throw away the topmost stack symbol. Remember, we designed the stack in such a way that we should always throw away one b on the stack for each b we read in the input.
Now that we have arrived at state q1, a natural question to ask is whether this state should be accepting or not. The answer is that it must not be, otherwise we could accept a string without enough b's to clear its stack; that is, we would have j < 4i + 2. So we will need a new state, call it q2, and q1 will not be accepting. What shall we use q1 for? We can easily use it to read the remaining b's and pop from the stack by adding this transition:
q e S q' S'
--- --- --- --- ---
q0 a Z q0 bbbbbbZ
q0 a b q0 bbbbb
q0 b b q1 -
q1 b b q1 -
This fourth transition can be taken as long as we have b's to read and b's on the stack. There are three things that can happen during this process:
We run out of b's on the stack, but still have b's in the input
We run out of b's on the stack at the same time as we finish reading all b's in the input
We still have b's on the stack when the input is exhausted
Only in the second case should we accept, and we can reach the second case by repeated applications of the fourth transition. However, q1 is not accepting. Therefore, we will require a way to transition from q1 to an accepting state - we might as well call q2 this state - when we might be in it. If we are truly in that state, we require an epsilon transition when we see an empty stack in q1:
q e S q' S'
--- --- --- --- ---
q0 a Z q0 bbbbbbZ
q0 a b q0 bbbbb
q0 b b q1 -
q1 b b q1 -
q1 - Z q2 Z
Now, in q2, we might be in either case 1 or 2: the stack is empty, but do we have any more symbols to read? It turns out this is not problematic in the least since further input symbols will cause the PDA to crash immediately in state q2.
Second is left as an exercise.

Automaton that recognizes a language without 3 consecutive zeros

I would create a finite state automaton that recognizes the language of strings of 0 and 1 that don't contain 3 consecutive zeros.
I tried to do the following automaton but isn't complete as, for example, it doesn't recognize the string: 1001110
How can I change it? For the rest, my reasoning to solve the exercise is that correct?
Thanks so much
i made this in paint so not looking nice but,try below automation.
Your starting state, q0, is a state that is not reached by reading a zero. As you correctly modeled in your automaton, from the state q0 you must allow the automaton to read up to two zeros, hence you need states q1 (reached by reading exactly one consecutive zero) and q2 (reached by reading exactly two consecutive zeros).
Whenever you read a 1 you will be in a state that was not reached by reading a zero.
Now a question is, how many states do you need?
It is permissible to have more than one end state in a finite automaton. In this case you must have more than one end state, because any time you read a 1 you must reach a state that permits two subsequent consecutive zeros to be read, whereas every time you read a zero you much reach a state that does not permit two subsequent consecutive zeros to be read, and your language has strings that end in zero as well as strings that end in 1.

Resources