What is the regular expression for the following language?
$$L = \{acbc: a,b,c \in \{0,1\}^+ \}$$
maybe we can say $$L = ((0 + 1)^+ 0 (0 + 1)^+ 0) + ((0 + 1)^+ 1 (0 + 1)^+ 1)$$
Is it true??
- 121
- 3
2 Answers
I claim that $L$ is equal to the set of all strings of the form $a\gamma b\gamma$, where $a,b \in \{0,1\}^+$ and $\gamma \in \{0,1\}$. Indeed, a string of this form clearly belongs to $L$. Conversely, if $acbc \in L$ and $c=d\gamma$, then $acbc = ad\gamma bd\gamma$ belongs to the new set. The new set is clearly described by the regular expression $$ (0+1)^+0(0+1)^+0 + (0+1)^+1(0+1)^+1. $$
- 280,205
- 27
- 317
- 514
The question seems a bit less detailed. Note that, you have defined, a, b and c belong to {0,1}+ . Here, there is no upper bound for the length of c. We know that, regular expressions can only express regular languages, i.e. languages which are recognized by any Finite State Machine, like DFA. Finite State Machines have finite memory. To recognize the above language, machine needs to store the contents of first 'c' to match with the second 'c'. As the length of 'c' can be infinite, a Finite State Machine can not recognize this language.
However, if we introduce an upper bound to the length of 'c', then it will be regular language and can be expressed by a RE. For |c| = 1, your RE is correct.
- 569
- 1
- 3
- 12