Constructing a Moore Machine

1.3k views Asked by At

I have a homework question:

Construct a Moore machine that takes a string consisting of a's b's and c's as input and outputs a string containing 1 at the end of each substring abc and a 0 in all other positions. e.g. input, aabcb produces output, 000010

I tried constructing, but I have come to a dead end. Here is my attempt: enter image description here

As you can see, I can't create a string cccb and an 'abc' can output a 0. I feel like I overcomplicated this simple problem.

EDIT: Took a break and redid it. I think this is right, unless someone can tell me otherwise:

enter image description here

2

There are 2 answers

1
Leo On BEST ANSWER

The solution. Just needed to think clearly.

The solution

7
Bruno Kim On

I'll try to help you without spoiling an answer:

  • Why do you use a second cycle (the lower triangle)?
  • How would you implement a machine that halts successfully after finding a subsequence?
  • What do you need to do to keep it running indefinitely? Convince yourself that an error to match a subsequence is equivalent to the initial state.

I've solved it using only four states, but maybe there's a solution with just three. It should be clear that you can't get better than that.