find automata that accepts following language

55 Views Asked by At

Find automata, that accepts following language: $L\subseteq\{0,1\}^* $ $$L=\{w|w\ \text{doesn't contain four 1's in 7 consecutive symbols}\} $$

My only proposition is: enter image description here

It is only a fragment, but it will be too large to upload it here. But general idea is clear.

How to do it better ?

1

There are 1 best solutions below

0
On

A simple machine would have $2^6$ nodes, one for every string of length seven at most $3$ ones, plus one node for every string of length less than length $7$, plus a failure node. Basically, we "keep track" of the last $7$ digits, unless we fail.

I think you can probably prove that you can't do much better than this, in terms of reducing the number of nodes. You can do one reduction to cut the nodes a little.

Start at the node representing the empty string.

Transition on the next digit by appending the current digit to the current string, and then, if the string is longer than $8$, take the last $7$ digits. If the new string is length $7$ and has $4$ ones, go to the failure node. Otherwise, go to the node corresponding to the new string.

Once you are on the failure node, you always remain on the failure node.

All other nodes are success nodes.

Basically, you are keeping the last $7$ digits in "memory," which is possible because there are only finitely many such strings. You also have to keep track at the beginning separately.

Incidentally, I'm assuming that $11011$ is in your language, since it has no seven consecutive digits. But the author may have intended to exclude that, too. The answer actually becomes easier if that was meant to be excluded, since you can only use the $2^6$ success nodes and one failure node, and start on the node corresponding to $0000000$.

in theory, you can keep just the last $6$ digits.

The alternate reading of the question would have a transition table looking something like:

$$\begin{array}{r||r|r} \text{Node}& 0 & 1\\ \hline \text{Fail}&\text{Fail}&\text{Fail}\\ 000000&000000&000001\\ 000001&000010&000011\\ 000010&000100&000101\\ 000011&000110&000111\\ 000100&001000&001001\\ 000101&001010&001011\\ 000110&001100&001101\\ 000111&001110&\text{Fail}\\ 001000&010000&010001\\ 001001&010010&010011\\ 001010&010100&010101\\ 001011&010110&\text{Fail}\\ 001100&011000&011001\\ 001101&011010&\text{Fail}\\ 001110&011100&\text{Fail}\\ 010000&100000&100001\\ 010001&100010&100011\\ 010010&100100&100101\\ 010011&100110&\text{Fail}\\ 010100&101000&101001\\ 010101&101010&\text{Fail}\\ 010110&101100&\text{Fail}\\ 011000&110000&110001\\ 011001&110010&\text{Fail}\\ 011010&110100&\text{Fail}\\ 011100&111000&\text{Fail}\\ 100000&000000&000001\\ 100001&000010&000011\\ 100010&000100&000101\\ 100011&000110&\text{Fail}\\ 100100&001000&001001\\ 100101&001010&\text{Fail}\\ 100110&001100&\text{Fail}\\ 101000&010000&010001\\ 101001&010010&\text{Fail}\\ 101010&010100&\text{Fail}\\ 101100&011000&\text{Fail}\\ 110000&100000&100001\\ 110001&100010&\text{Fail}\\ 110010&100100&\text{Fail}\\ 110100&101000&\text{Fail}\\ 111000&110000&\text{Fail} \end{array} $$

That would be $43$ nodes.

There are still some reductions that you can make here. For example, you can make all the nodes that end in $4$ zeros equivalent, since the only way to fail is by "clearing" those two first digits. That would also require you to identify the two strings ending in $00001$, but you can identify all nodes for pairs of strings with the same last five digits having at most $1$ one. For example, $100010$ and $000010$ are essentially the same state. These can reduce the machine to $36$ nodes.

This machine assumes the question wants you to exclude strings shorter than $7$ characters with $4$ ones. You'd need to keep $128$ nodes if you want to allow the strings under $7$ characters.