2
$\begingroup$

I'm having trouble trying to find a language expressed by this automation. I have constructed a next-state table to help me understand better. From my understanding, any string that starts with 0 takes my automaton A to an accepting state but what if it doesn't start with 0 i.e a 1? The automation would need 14n to take us back to S0 enter image description here

I want to

  • Find the language accepted by the automaton
  • Find a regular expression that defines the same language
  • 0
    In addition to my answer notice that not every string starting with a $0$ will be accepted, e.g. $01$. However if you have a string that is already being accepted, it will still be accepted no matter how many $0$s you add **anywhere** to the string.2017-01-07
  • 0
    Doesn't that mean any string starting with 0 would be accepted then? Since you said if it is already being accepted (When its 0 the first time it becomes accepted) it will still be accepted@ChristianIvicevic2017-01-08
  • 0
    No, it does not. Let $w$ be a string that is already being accepted. That means that there is a sequence of states $(s_0,\ldots,s_1,s_2,s_3,s_0)$ which accepts the word. If we prepend a few zeros like $00w$ the sequence will be $(s_0,s_0,s_0,\ldots,s_1,s_2,s_3,s_0)$ hence the new word is still accepted. However the word $v=01$ isn't accepted since the sequence $(s_0,s_1)$ we obtain by reading $v$ does not end in a final state. Prepending zeros won't change that for your specific automaton.2017-01-08
  • 0
    In addition to my explanation be careful with the wording and the condition in my first comment. Let $L$ be the language described by the automaton then I claimed that $$w\in L \implies 0w \in L.$$ Prepending zeros will yield more words in $L$ **only if** the word $w$ was **already** in $L$. And to add a final remark with regards to my former comment about sequences: while reading a word using an automaton you might enter a final state, however you might leave it soon after! A word is only accepted once you have stopped in a final state after reading the entire word.2017-01-08

3 Answers 3

1

Converting NFAs to regular expressions

The theory of this method is very well described on the CS Stack Exchange. I am directly going to apply it since it is so simple in this case that you might follow without knowing the algorithm yet.


I am going to introduce a system of equations to describe the language $S_n$ that is being accepted starting from state $s_n$ with the following equations:

$$\begin{align*}S_0 &\equiv 0S_0~\mid~1S_1~\mid~\epsilon\\ S_1 &\equiv 0S_1~\mid~1S_2\\ S_2 &\equiv 0S_2~\mid~1S_3\\ S_3 &\equiv 0S_3~\mid~1S_0\end{align*}$$

An expression of the form $S_m\equiv aS_n$ represents a transition from $s_m$ to $s_n$ by reading $a$ and the $\epsilon$ marks a state as a final state. We are looking for a final expression for $S_0$ (the language accepted starting from state $s_0$) and need some tricks to get to that point.

Now I am going to use Ardens Lemma which states (written using regular expressions and not sets of languages) that $$X\equiv \alpha X~\mid~\beta\implies X\equiv \alpha^*\beta$$ which helps to solve equations of the the form that is described on the left side. We can apply this to all four rules which yields the following (I am doing this backwards):

$$\begin{align*} S_3 &\equiv 0S_3~\mid~1S_0\color{red}{\equiv 0^*1S_0}\\ S_2 &\equiv 0S_2~\mid~1S_3\color{red}{\equiv 0^*1S_3}\\ S_1 &\equiv 0S_1~\mid~1S_2\color{red}{\equiv 0^*1S_2}\\ S_0 &\equiv 0S_0~\mid~1S_1~\mid~\epsilon\\ &\equiv 0S_0~\mid~(1S_1~\mid~\epsilon)\\ &\;\color{red}{\equiv 0^*(1S_1~\mid~\epsilon)} \end{align*}$$

Now we have to plug in $S_3$ into $S_2$ into $S_1$ into $S_0$:

$$\begin{align*} S_0 &\equiv 0^*(1S_1~\mid~\epsilon) \\ &\equiv 0^*(10^*10^*10^*1S_0~\mid~\epsilon) \\ &\equiv 0^*10^*10^*10^*1S_0~\mid~0^* \\ &\;\color{red}{\equiv(0^*10^*10^*10^*1)^*0^*}. \end{align*}$$

The very last equivalence in red follows from Ardens Lemma once again - just be careful how to handle the expression preceeding it.

My result supports J.-E. Pins solution and disproves Globe Theatres solution as well.

0

The language accepted is of the form $\{0^{*} | ~(10^{*}10^{*}10^{*}10^{*})^{*}\}$. That is, any string which has the digit 1 exactly $4n$ times for some integer $n\geq 0$, and any number of $0$s.

To see this, first observe that any number of $0$s is part of this language. That's how you get the first part of the regular expression.

If however, the string has a $1$, it must traverse the entire square in your diagram and reach the start state again for it to be accepted. This means that if a $1$ occurs, it must occur exactly $4n$ times, where $n$ is some integer. Moreover, observe that at each state, an input of $0$ does not change the state. Hence, our language can have any number of $0$s anywhere within a word.

Thus, the condition of there being $4n$ 1s in our string for some $n\geq 0$ is both necessary and sufficient.

  • 0
    I don't think it should be n ≥ 0 because if so at base case 0, we are implying that the string can go around the automation just once. It should be n ≥ 12017-01-05
  • 0
    If $n=0$, the string contains no $1$s and hence contains only $0$s. Thus, the string begins at state $S_0$ and will continue to remain there, which means the string will be accepted. So, $n=0$ works too.2017-01-05
  • 0
    Are you looking at it in { 1^4n| n ≥ 0 } and not just 4n?2017-01-05
  • 0
    I don't know what you mean? Basically, the overall string should have the digit $1$ exactly $4n$ times. The corresponding set is $\{ ( 0^{*}1 )^{4n} | n \geq 0 \} $. Besides that set, it is also possible to have just $\{ 0^r | r \geq 0\}$.2017-01-05
  • 0
    @GlobeTheatre Please refer to J.-E. Pins suggested example $01111$ which is not in your described set. In my solution I deduced a different language as well.2017-01-07
  • 0
    @GlobeTheatre Your language is correct if you "factorize" and move the Kleene star from the inside of both expression to the outside.2017-01-07
  • 0
    Yes, that's right! I missed that. My second term should be $(0^*10^∗10^∗10^∗10^∗)^∗$2017-01-07
0

A possible answer is $(0 + 10^*10^*10^*1)^*$. There are other equivalent solutions, but the answer proposed by Globe Theatre does not match for instance $01111$, and hence is incorrect.

  • 0
    My solution is supporting your result as well - this seems to be another representation of the same language.2017-01-07
  • 0
    @christian-ivicevic Yes, the two representations are equivalent. More generally, if $r$ and $s$ are regular expressions, $(r + s)^*$ and $(r^*s)^*r^*$ are equivalent.2017-01-07