

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


page 1 of 2 String Notations For a set C of characters, the notation C^ denotes the set of all finite strings over C. Each xŒC^ has a length, len(x)≥0, the number of characters in string x. The null string which has length 0 is included in C^ and is written as e. For strings u,vŒC^ , their concatenation is uvŒC^ (u followed by v) and len(uv) = len(u) + len(v). Also for wŒC^ and n ≥ 0 an integer, wn^ = ww ... w (n copies) is the n- fold concatenation of w with itself, and w^0 = e. Note that wnwm^ = wn+m^ for all m,n ≥ 0. A language is just a subset of C^. Since a language L is a set, we may speak of its cardinality (number of elements), card(L). For sets of strings S,TÕ C^ we perform the usual set-theoretic operations of union, intersection and complementation. We also perform set concatenation S • T to get a new set S • T = { st | sŒS and tŒT}. We can observe that card(S • T) ≤ card(S) * card(T). We also use the notation Sn^ to denote the set of strings S • S • ... • S (n copies), where S^0 = {e}. And set iteration or star is defined as an arbitrary number of iterations, S^ = S^0 » S^1 » ... » Sn^ » ... The laws of exponents are valid for the power notation for set concatenation as well as string concatenation. Regular Expressions The set operations », •, and ^ are called the regular expression operations. A regular expression is a prototypical description of a language. A regular expression over a character set C is a formula (or pattern) involving characters from C plus several auxiliary symbols, constructed according to the following rules: (1) each lŒC is a regular expression, and auxiliary symbols e and ∅ are regular expressions; (2) using additional auxiliary symbols | (or), • (concatenation), * (star), and parenthesis, if A and B are regular expressions, then so are (a) (A | B), (b) (A • B), and (c) (A^ ) ; (3) only formulas constructed by repeated application of rules (1) and (2) are regular expressions. The formal rules for writing regular expressions as given above require a fully parenthesized form. To provide a more practical format, the regular expression operations are given precedence so that parenthesis can often be omitted: * is highest, • is intermediate, and | is lowest; also, in place of A • B we normally write AB. Each regular expression A denotes a language L(A)Õ C^ , referred to as a regular language, as defined by: L(l) = {l} for lŒC, L(e) ={e} , L(∅) = ∅, if A = B | C, then L(A) = L(B) » L(C), if A = B•C, then L(A) = L(B) • L(C), if A = B^ , then L(A) = (L(B))^.
page 2 of 2
For all these examples we take the character set C = {0,1}. Note that a regular expression written in precedence-oriented shorthand such as (00)* 1* in the fully parenthesized form of the formal definition would be written as (((0•0))•(1)). We use precedence conventions in these examples:
the same first and last character