# Explaining regular expressions

folks. My question is about explaining the each step of regular expressions. The task is to find the regular expression that contains 101 as a substring. I already know that the regular expression for this is

$$(0 + 1)^*101(0 + 1)^*.$$

The question is that how we should show each step for explaining the regular expressions.

• The regular expression 101 also contains 101 as a substring. I suspect you are looking for a regular expression whose language consists of all strings containing 101 as a substring. – Yuval Filmus Apr 11 '17 at 6:17
• Sorry, but what you mean by that? I already explained what I should do. – Nijat Mursali Apr 11 '17 at 6:38
• But you didn't explain it correctly. Also, what is your question to us? Be specific. Where do you get stuck? – reinierpost Apr 11 '17 at 19:45
• That was from my homework, actually. As far as know to show that regular expression accepts strings, we have to show some sample strings that are in that regular expression. What instructor wants from us is to mention how we came to the final result of that regular expression. That's the thing I really didn't understand. – Nijat Mursali Apr 12 '17 at 17:23

## 1 Answer

You have to show two things:

1. Every word in the language of your regular expression contains 101 as a substring.

2. Every word containing 101 as a substring belongs to the language of your regular expression.

You can prove both of these using the definition of the language of a regular expression. It is a bit tiring but otherwise requires little creativity.

• However, it's not possible to show all words that contain that substring because it's infinitely many. I'm trying to find the method for finding. Thanks for your answer. – Nijat Mursali Apr 11 '17 at 6:43
• You can use general properties of how regular expressions describe languages. For example, for any two regular expressions $X$ and $Y$, $L(XY) = L(X)L(Y)$. You can use this in your proof. – reinierpost Apr 11 '17 at 19:47
• @reinierpost This is not a property. It's the definition of the language corresponding to a regular expression. – Yuval Filmus Apr 11 '17 at 23:40