Discussion. Questions about regular expression matching [017F]

Here are some questions for discussion.

  1. Is there an algorithm which, given a string u and a regular expression r, computes whether or not u matches r?
  2. In formulating the definition of regular expressions, have we missed out on some practically useful notions of pattern?
  3. Is there an algorithm that will compute whether two regular expressions generate the same language?
  4. Is every formal language of generated by a regular expression?

We will come back to these questions in subsequent lectures. In the meantime, we can say:

  1. Is there an algorithm which, given a string u and a regular expression r, computes whether or not u matches r? Yes. One very simple way is to simply use the rules of Definition [017D] as a search algorithm, but this is not very efficient; better ways to decide regular expression matching can be achieved using finite automata, which we will study in the next lecture.
  2. In formulating the definition of regular expressions, have we missed out on some practically useful notions of pattern? Yes! For example, it can be useful to specify a range of symbols (including all symbols!) over an alphabet like most practical regular expression libraries allow. A more sophisticated example is complementation, where a string matches \mathord {\sim }(r) if and only if it does not match r. We will ultimately see that the complement of any regular expression already exists—but it can be useful to include it as a built-in feature.
  3. Is there an algorithm that will compute whether two regular expressions generate the same language? Yes, but we will need the theory of finite automata to see that this is the case.
  4. Is every formal language of generated by a regular expression? No: we will ultimately learn a technique, called the pumping lemma to find counter-examples.