2
$\begingroup$

I am looking for the regular expression for binary strings consisting of $1$ and $0$ and containing $111$ exactly once to find their generating functions. For example, $101100001110,000111000,01010111,11100000000...0$ are valid, but $000000,010101111000,111000000111,11111111...1$ are invalid.

I thought that I should firstly write $(\epsilon |0)111(\epsilon |0)$ for strings $111,0111,1110,01110$. Moreover, I can add two strings that do not contain $111$ to both sides of $01110$. I wrote $01110$ instead of $111$, because we cannot put any $1$ adjacent to $111$.

Now, for the strings not containing $111$, which is equal to $0^*(10^+|110^+)^*(\epsilon|1|11)$

So, our expression is equal to $$\color{blue}{[}(\epsilon |0)111(\epsilon |0)\color{blue}{]}+\color{blue}{[}0^*(10^+|110^+)^*(\epsilon|1|11)\color{blue}{]}\color{red}{01110}\color{blue}{[}0^*(10^+|110^+)^*(\epsilon|1|11)\color{blue}{]}$$

Its G.F form will be $$(1+x)x^3(1+x)+ \frac{1}{1-x}\bigg(\frac{1}{1-\frac{x^2+x^3}{1-x}}\bigg)(1+x+x^2)\color{red}{x^5}\frac{1}{1-x}\bigg(\frac{1}{1-\frac{x^2+x^3}{1-x}}\bigg)(1+x+x^2)$$

However, we count the case $01110$ two times in both cases,so subtract one of them :

$$(1+x)x^3(1+x)+ \frac{1}{1-x}\bigg(\frac{1}{1-\frac{x^2+x^3}{1-x}}\bigg)(1+x+x^2)\color{red}{x^5}\frac{1}{1-x}\bigg(\frac{1}{1-\frac{x^2+x^3}{1-x}}\bigg)(1+x+x^2)- \color{blue}{x^5}$$

$$(x^3+2x^4+x^5)+ \bigg(\frac{1+x+x^2}{1-x-x^2-x^3}\bigg)x^5\bigg(\frac{1+x+x^2}{1-x-x^2-x^3}\bigg)-x^5$$

Is my deducation right ? If so, how can I simplify my expression ? I think there may be some simpler version. If my answer is wrong, can you please help to find the correct one ?

$\endgroup$
4
  • $\begingroup$ To help check correctness, it is a good idea to explicitly count such strings for small $n$. $\endgroup$
    – RobPratt
    Commented Jul 7 at 19:40
  • $\begingroup$ Doing so can also lead you to oeis.org/A073778 $\endgroup$
    – RobPratt
    Commented Jul 7 at 19:45
  • $\begingroup$ it seems they are not matching here $\endgroup$ Commented Jul 7 at 20:07
  • $\begingroup$ Suggestion: First see if you can find the GF for the number of binary strings with no 111. Then maybe you can use this GF to construct the one you seek. $\endgroup$
    – awkward
    Commented Jul 13 at 12:40

0

You must log in to answer this question.