Let $L_1$ be the language over alphabet $\{0, 1\}$ defined by $L_1 = \{x : \#_{01}(x) \bmod 3 = 0\}$. Give a regular expression that denotes $L_1$

84 Views Asked by At

Let $L_1$ be the language over alphabet $\{0, 1\}$ defined by $L_1 = \{x : \#_{01}(x) \bmod 3 = 0\}$.

Give a regular expression that denotes $L_1$, and justify its correctness


attempt

Need 010101 such that mod 3 = 0

How would I make a regex for this?

$R_1 = (01)^*$. How would I do the mod condition?

1

There are 1 best solutions below

0
On BEST ANSWER

Our regular expression must include every string that has a multiple of $3$ occurences of the string $(01)$. This includes $$ (01)(01)(01)\\ 10(01)(01)(01)10\\ 1100(01)1100(01)1100(01)1100\\ 10(01)(01)(01)(01)(01)(01)10\\ 1()00 $$ Notice that we can regroup some of the above expressions as$$ (01)(01)(01)\\ 1(001)(01)(011)0\\ 11(000111)(000111)(000111)00\\ 1(001)(01)(01)(01)(01)(011)0\\ 1()00 $$

so that each set of parentheses includes as many $0$'s as it can on the left and as many $1$'s as it can on the right. We will denote $aa^*$ as $a^+$. We can rewrite the strings as $$ (0^+1^+)(0^+1^+)(0^+1^+)\\ 1(0^+1^+)(0^+1^+)(0^+1^+)0\\ 11(0^+1^+)(0^+1^+)(0^+1^+)00\\ 1(0^+1^+)(0^+1^+)(0^+1^+)(0^+1^+)(0^+1^+)(0^+1^+)0\\ 1()00 $$

The regular expression that captures exactly these strings is $$ 1^*((0^+1^+)(0^+1^+)(0^+1^+))^*0^* \\ = 1^*(((0^+1^+)^3)^*)0^* $$