5

I'm really confused about this, can some one please help me understand this better.

If r and s are regular expressions then is it always true that (r+s)=r+s*?

Are r and s sets and does the plus mean the union?

MJD
  • 68,126
  • 44
  • 311
  • 628
  • This is exercise 3.4.2 a) and problem 3.5 d) of Hopcroft, Motwani, Ullman's Introduction to Automata Theory, Languages, and Computation 3rd Ed. – 19021605 Nov 30 '25 at 06:42

2 Answers2

5

Let $R$ be the set of words described by the regular expression $r$, and let $S$ be the set of words described by the regular expression $s$. Then the regular expression $(r+s)^*$ describes the words in the set $(R\cup S)^*$, and $r^*+s^*$ describes the words in the set $R^*\cup S^*$. Thus, the question boils down to asking whether it’s necessarily true that $(R\cup S)^*=R^*\cup S^*$. (Looking at some very simple regular expressions should give you the answer pretty easily.)

Brian M. Scott
  • 635,418
  • so say r = {0} and s = {1} – Supernatural May 13 '13 at 23:51
  • does that mean that essentially r + s in this case is any number of repetitions of 01? – Supernatural May 13 '13 at 23:52
  • @Supernatural: Make that $r=0$ and $s=1$; ${0}$ and ${1}$ are then the sets $R$ and $S$, respectively. (The point is that the braces have no place in the regular expressions. // No, $r+s$ is then $0+1$, which represents the two-word set ${0,1}$. To get any number of repetitions of $01$, you’d use $(01)^*$. – Brian M. Scott May 13 '13 at 23:52
  • for two general expressions to be the same they have to generate the same language right?. if i take a word 01, this can be generated by (r+s)* but not by r+s, because r* or s* could contain nothing right? – Supernatural May 13 '13 at 23:55
  • 1
    @Supernatural: Yes, $01$ can be generated by $(0+1)^$; $0\in R$ and $1\in S$, so $01\in(R\cup S)^$. And yes, it’s not generated by $0^+1^$, but not because $0^$ and $1^$ generate the empty string: the empty string is generated by $(0+1)^$. $01\notin R^\cup S^$ because the $R^$ contains only strings of $0$’s (including the empty string), and $S^*$ contains only strings of $1$’s (including the empty string), and $01$ is neither. – Brian M. Scott May 13 '13 at 23:59
  • I understand the union bit (i've done set theory) but how does the star come into play? i've always thought about it as any number of repetitions – Supernatural May 13 '13 at 23:59
  • 1
    @Supernatural: It is: for regular expressions $r^=\epsilon+r+rr+rrr+\ldots$, and for regular sets $R^=\varnothing\cup R\cup R\oplus R\cup R\oplus R\oplus R\oplus\ldots$, where $\oplus$ stands for concatenation. – Brian M. Scott May 14 '13 at 00:00
  • thank you very much for the detailes explanation! – Supernatural May 14 '13 at 00:04
  • 1
    @Supernatural: You’re very welcome. – Brian M. Scott May 14 '13 at 00:05
3

$r$ and $s$ are regular expressions, which represent regular sets. If $r$ and $s$ are regular expressions that represent sets $R$ and $S$, then the regular expression $r+s$ denotes the set $R\cup S$.

If $r$ is a regular expression denoting the set $R$, then $$r^*$$ is a shorthand for $$\epsilon + r + rr + rrr + \cdots .$$

MJD
  • 68,126
  • 44
  • 311
  • 628