Fall 98, CSE 468: Lecture 5 (Sep 4)


Regular Expressions and Regular Languages

Regular expressions

All the expressions constructed on We will use parentheses to represent the structure of an expression, and we will assume that * has precedence over concatenation, concatenation has precedence over +, and that concatenation and + are associative.

Language represented by a regular expression

The empty string lambda stands for {lambda}, an alphabet symbol a stands for {a}, + stands for union, and concatenation and * stand for the homonymous operations on languages.

Example. The set of strings on {a,b} with odd lenght can be represented by the regular expression (a + b)(aa + ab + ba + bb)*.

Regular Languages

The class of Regular Languages is constituted by the languages represented by regular expressions. These are important in computer science, because they are particularly simple to recognize (as we will see later) and there are interesting parts of a programming language that can be expressed as regular languages. Typically, the tokens of a programming language are a regular language. The component of the system which recognizes them is called "scanner".

Examples

Language recognition

Given the formal specification of a language, one of the main questions which arise is, how to tell whether or not a certain string belongs to the given language. And of course, we want to do it automatically.

This concept is fundamental in computer science: When we write a program, the first thing we want the computer to check is whether the program is syntactically correct. This is nothing else than the problem of recognizing whether our program (a string of symbols) belongs to the language specified by the syntax.

Abstract machine for language recognition

A device for recognizing strings in a given language, in general, will take in input one simbol of the string at the time, and will take a decision (reject/accept/go on) depending on
  1. the current symbol, and
  2. the symbols previously examined.

Finite Automata

In the above description of an abstract machine for language recognition, it will turn out that, if the language is regular, the amount of memory necessary for point 2 is bounded. I.e. it does not depend on the string to be recognized. (But depends, of course, on the language. Note that each machine corresponds to a paticular language.) The bounded memory is the characteristic of a class of machines called Finite Automata.

Example. Automata for recognizing strings on {a,b} with odd lenght. Note that at each step, the only information we need to remember, about the portion of the string already examined, is whether it is odd or even.