How to match this language with variables?

39 Views Asked by At

How can i go about representing this language in variables?

(a) The language of all strings containing exactly two 0's.

(b) The language of all strings containing 010 as a substring.

My Approach:

a) L = {0a0 v 0a0b v a0b0c : a,b,c $\in$ {1}* }

b) L = {a010b : a,b $\in$ {0,1}* }

I'm trying to represent these variables as a string that would always match the description of a) and b).

I'm sure its not the correct way because for a) it can be done with just 1 group of variables but i have 3 group of variables.

1

There are 1 best solutions below

0
On

The language (a) corresponds to the regular expression $1^*01^*01*$. If you’re going to use variables like your $a,b$, and $c$, all you need is $a0b0c$ with $a,b,c\in\{1\}^*$: that covers your other two cases, since $a$ and $c$ can be the empty string. Your (b) is okay.