Language Operations
Language Operations
Language Operations
Operations
that can be used to construct languages from other languages. Recall: A language is any set of strings
The class of regular languages is closed under the following operations (i.e., performing these operations on regular languages creates other regular languages)
Definition
If L1 and L2 are two languages, we define:
the
concatenation of L1 and L2, denoted by L1L2, as the set of all words given by the concatenation of any word in L1 with any word in L2.
Regular expressions
A useful shorthand for describing regular languages. Compare to arithmetic expressions, such as (x + 3)/2. An arithmetic expression is constructed using arithmetic operators, such as addition and division. A regular expression is constructed using operations on languages, such as concatenation, union, and Kleene star.
The value of an arithmetic expression is a number. The value of a regular expression is a (formal) language.
Examples
1. 2. 3. 4. 5. 6.
a*+ b = {b, , a, aa, aaa, aaaa, aaaaa, } a*ba* = {w * | w has exactly one b} (a + b)*aa (a + b)* = {w * : w contains aa} (a + b)*aa (a + b)* + (a + b)*bb (a + b)* = {w * : w contains aa or bb} (a + )b* = {abn : n 0} {bn : n 0}
As with arithmetic expressions, there is an order of precedence for operators -- unless you change it using parentheses. The order is: star closure first, then concatenation, then union.