Lecture 3 Regular Expressions
Lecture 3 Regular Expressions
Otomata Teorisi
Sunu III
Düzenli İfadeler
• L4 = {Λ x xx xxx xxxx …}
• The closure of a smaller set
• Let S = {x}, then L4 = S*
• As shorthand L4 = {x}*
• x*
• Indicates some sequence of x’s (maybe none at all)
• Written in boldface type to distinguish it from an alphabet
character
x* = Λ or x or x2 or x3 or x4 …
x* = xn for some n = 0 1 2 3 4 …
• Think the star as undetermined power
• x* stands for a string of x’s but we do not specify how many
• An arbitrary concatenation of copies of that letter (maybe none at all)
• Can be used to define languages, L4 = language(x*)
The Star Operator
• L4 = language(x*)
• x* is any string of x’s
• L4 is the set of all possible strings of x’s of any length including Λ
• Suppose that we wish to describe L over the Σ = {a b} where L =
{a ab abb abbb abbbb …}
• We could summarize this language by “all words of the form one a
followed by some number of b’s (maybe no b’s at all)”
• We can also write L = language(ab*)
• The language in which the words are the concatenation of an initial a with
some or no b’s
• Not string can contain a blank unless a blank is a character in Σ
The Star Operator
b*a*: all a’s, all b’s, Λ, or some b’s followed by some a’s
Finite Language
• If S = {a bb bab}, T = {a ab}
• ST = {aa aab bba bbab baba babab}
• If P = {a bb bab}, Q = {Λ bbbb}
• PQ = {a bb bab abbbb bbbbbb babbbbb}
• If L is any language
• LΛ = ΛL = L
Languages Associated with REs
• (a + b*)* = (a + b)*
• (a*)* = a*
However
• (aa + ab*)* ≠ (aa + ab)*
• Check the word abbabb
• The language defined by the RE on the right cannot contain any word
with a double b
Example
• (a *b*)*
• Factors of the form a*b*
• Both the signle letters a and b are words of the form a*b*
• This language contains all strings of a’s and b’s
• Therefore, (a *b*)* = (a + b)*
• b*(abb*)*(Λ + a)
• The language of all words without a double a
• The word starts with some b’s
• Then come repeated factors of the abb* (a followed by at least
one b)
• Finish with a final a or leave the last b