How can I create a DFA automaton that will have every four digits (if they exist) at least two 1s for strings of languages with alphabet {0,1}? The expression at least two 1s seems easier than the expression every four digits
Asked
Active
Viewed 251 times
-1
-
Look at the solution by Rick Dekker for "DFA for a strings whose every subsequence of length five has at least two zeroes" where he explains that keeping a window of the most recently seen $k$ characters in the state can be used for DFA for languages of the form "All words over some alphabet $\Sigma$ where [some condition] is satisfied by all contiguous substrings of a fixed length, $k$". – Hendrik Jan Feb 04 '22 at 17:58
1 Answers
3
Create a DFA with 16 states, each corresponding to the last four letters possible.
For more details:
- the first three states will be special states with no turning back that will serve to count the number of $1$'s only in the three first letters;
- then you will navigate between states depending on the number of $1$'s read in the last four letters;
- each time you might reach a state describing zero or one $1$'s read in the last four letters, you can instead reach a non-final sink state that will loop on itself.

Nathaniel
- 15,071
- 2
- 27
- 52
-
-
1
-
1One also needs a "fail" state for this idea, for 17 states total. – Caleb Stanford Feb 02 '22 at 21:16
-
1This, however, is not optimal. For instance, storing only the previous 3 letters is enough ($2^3 + 1 = 9$ states). In fact, the minimal DFA has 7 states. – Caleb Stanford Feb 02 '22 at 21:16
-
@6005 Yes, you are right, I was only giving hints for the idea of the construction. – Nathaniel Feb 02 '22 at 21:34
-
So, how can I combine both? Every four states there will be a state that will go back to the first with 1? – wajaap Feb 03 '22 at 08:16
-
1