• retagged by
6,304 views
1 1 vote

Let sigma = { 0,1 } . Construct a minimal DFA which accepts set of all strings in which

"Every substring of four symbols has at most two 0’s". For example, 001110 and 011001 are
in the language, but 10010 is not since one of its substrings, 0010, contains three zeros.

3 Answers

3 3 votes

We add the substring $1111$ as prefix to every $w\,\epsilon \, L$ (to fullfill the below assumption for characters at index 0,1,2)

The state of an automata which checks if a word $w\, \epsilon \,L$,  denotes a substring of length $4$ ending at the current character. So, if we are at index $i$ of the string it denotes that the string upto this index is valid and when we make a transition for index $i+1$ there is only one substring that we have to check for this string to be valid $i.e$ the substring of length $4$ ending at the $\left ( i+1 \right )$th index.

$q$d is the dead state for the automata and all the other states are final states, $q$0 is the start state.

$q$0 $= \, 1111$  , $q$1 $= \, 1110$ , $q$2 $= \, 1100$ , $q$3 $= \, 1001$ , $q$4 $= \, 0011$ , $q$5 $= \, 1101$ , $q$6 $= \, 1010$

$q$7 $= \, 1011$ , $q$8 $= \, 0110$ , $q$9 $= \, 0101$ , $q$10 $= \, 0111$ , $q$d $= \, \left \{ 0010,1000, 0100, 1001\right \}$

The transition table for the automata is 

                       State                         0                     1
                        $q$0                     $q$1               $q$0
                        $q$1                     $q$2               $q$5
                       $q$2                     $q$d               $q$3
                       $q$3                     $q$d               $q$4
                       $q$4                     $q$8               $q$10
                       $q$5                     $q$6               $q$7  
                       $q$6                     $q$d               $q$9
                       $q$7                     $q$8               $q$10
                       $q$8                     $q$2               $q$5
                       $q$9                     $q$6               $q$7
                       $q$10                     $q$1               $q$0
                       $q$d                     $q$d               $q$d

For Example : 

0010 : $q$0 $\rightarrow$ $q$1 $\rightarrow$ $q$2 $\rightarrow$ $q$3 $\rightarrow$ $q$d

101001 : $q$0 $\rightarrow$ $q$0 $\rightarrow$ $q$1 $\rightarrow$ $q$5 $\rightarrow$ $q$6 $\rightarrow$ $q$d

0011 : $q$0 $\rightarrow$ $q$1 $\rightarrow$ $q$2 $\rightarrow$ $q$3 $\rightarrow$ $q$4

 

Correct me if I'm wrong

1 1 vote

The above dfa will always go to  dead state if there are more than 2 0s in any substring of length 4.

0 0 votes

Except trap state all other states are final states

Position:
Show:

Related questions

1 1 vote
1 1 answer
114
114 views
GO Classes asked Sep 19
114 views
Consider,Statement $1:$ If a language family is closed under union and complement, then it must also be closed under intersection. Statement $2:$ An NFA can be constructe...
2 2 votes
1 1 answer
162
162 views
GO Classes asked Sep 5
162 views
Consider the right-linear grammar,$$\begin{aligned}A &\to fB \mid gA \\B &\to gA \mid fC \mid f \\C &\to gA \mid fC \mid f\end{aligned}$$When this grammar is converted in...
2 2 votes
1 1 answer
115
115 views
GO Classes asked Sep 5
115 views
Which of the following statements are correct for converting a finite automaton into an equivalent right-linear grammar?Each automaton state becomes a non-terminal. The s...
2 2 votes
1 1 answer
109
109 views
GO Classes asked Sep 5
109 views
Consider the NFA given below: Which right-linear grammar is obtained by the standard NFA-to-grammar construction?$q_0 \to aq_1$,$q_1 \to aq_0 \mid bq_1 \mid \epsilon$ $q_...