Can a regular language be defined using recursive regular expressions?

115 Views Asked by At

My problem is essentially that I can't find anything that explicitly prohibits or allows such definitions. To illustrate with an example:

Our teacher challenged us to create a definition for a language using only regular expressions (namely, using only Kleene closure, positive closure, union, and concatenation). The alphabet we are using is $\{0,1\}$, and the language we are to define is the language of all strings whose lengths are multiples of $4$, with no consecutive $1$'s.

If I understand correctly, it's not difficult to show that this is a regular language. From the Wikipedia article on regular languages, it's not too difficult to build a deterministic finite automaton that accepts this language.

My question, however, is whether or not I have formally defined this language correctly. The best answer I have come up with (so far) is the following recursive definition (where the target language is $A$): $$\begin{align*} A &= B \cup \{1010, 1000\}A \cup \{1001\}B\\ B &= \{\lambda\} \cup \{0000, 0010, 0100\}A \cup \{0001, 0101\}B \end{align*}$$

where $\lambda$ is the empty string, $\cup$ is union, and $B$ is another language I created to help define $A$. I'm reasonably confident that this a correct definition, though I can explain my reasoning further if anyone wants. However, I'm not sure it's a "good" definition, so if anyone could clarify that, it would be appreciated.

Edit: As per comment request, I've created an FSM that recognizes this language. I'm not sure that it can be represented by a deterministic finite automaton (which I only learned about in googling for this question), but I think it is. Also, I've never really used Latex, so I'm just using a code block.

Anyways, the FSM:

      |    v    |   w   |
State |  0 |  1 | 0 | 1 |
      |    |    |   |   |
   s0 | s1 | s5 | 0 | 0 |
   s1 | s2 | s6 | 0 | 0 |
   s2 | s3 | s7 | 0 | 0 |
   s3 | s0 | s4 | 1 | 1 |
   s4 | s1 | s8 | 0 | 0 |
   s5 | s2 | s8 | 0 | 0 |
   s6 | s3 | s8 | 0 | 0 |
   s7 | s0 | s8 | 1 | 0 |
   s8 | s8 | s8 | 0 | 0 |

Here's how it works: It starts at s0. s0 and s4 indicate that the length is a multiple of 4, s1 and s5 indicate that the length is 1 greater than a multiple of 4, etc. s0-s3 indicate that the last character is a 0, while s4-s7 indicate that it is a 1. s8 is a reject- and sink-state that is reached iff there are two 1's in a row. A 1 is output each time s0 or s4 are reached, which indicates the length is a multiple of 4 and there have been no consecutive 1's.

I honestly have no idea how to create a regular expression using an FSM, but if there is a way to do that, it would probably answer my question.