Professional Documents
Culture Documents
2 1
2 1
=
=
bbbaaa
abba
m n
b b b a a a wv
2 1 2 1
=
Concatenation
abbabbbaaa
Courtesy Costas Busch - RPI 18
1 2
a a a w
n
R
=
n
a a a w
2 1
=
ababaaabbb
Reverse
bbbaaababa
Courtesy Costas Busch - RPI 19
String Length
Length:
Examples:
n
a a a w
2 1
=
n w =
1
2
4
=
=
=
a
aa
abba
Courtesy Costas Busch - RPI 20
Length of Concatenation
Example:
v u uv + =
8 5 3
8
5 ,
3 ,
= + = + =
= =
= =
= =
v u uv
aababaab uv
v abaab v
u aab u
Courtesy Costas Busch - RPI 21
Empty String
A string with no letters:
Observations:
c ,
abba abba abba
w w w
= =
= =
=
0
Courtesy Costas Busch - RPI 22
Substring
Substring of string:
a subsequence of consecutive characters
String Substring
bbab
b
abba
ab
abbab
abbab
abbab
abbab
Courtesy Costas Busch - RPI 23
Prefix and Suffix
Prefixes Suffixes
abbab
abbab
abba
abb
ab
a
b
ab
bab
bbab
abbab
uv w=
prefix
suffix
Courtesy Costas Busch - RPI 24
Another Operation
Example:
Definition:
n
n
w ww w =
( ) abbaabba abba =
2
=
0
w
( ) =
0
abba
Courtesy Costas Busch - RPI 25
The * Operation
: the set of all possible strings from
alphabet
* E
E
{ }
{ } , , , , , , , , , *
,
aab aaa bb ba ab aa b a
b a
= E
= E
Courtesy Costas Busch - RPI 26
The + Operation
: the set of all possible strings from
alphabet except
+
E
E
{ }
{ } , , , , , , , , , *
,
aab aaa bb ba ab aa b a
b a
= E
= E
E = E
+
*
{ } , , , , , , , , aab aaa bb ba ab aa b a = E
+
L e L abbe
Courtesy Costas Busch - RPI 30
Operations on Languages
The usual set operations
Complement:
{ } { }
{ } { }
{ } { } { } aaaa a ab bb aaaa ab a
ab ab bb aaaa ab a
aaaa bb ab a ab bb aaaa ab a
, , , ,
} { , , ,
} , , , { , , ,
=
=
=
L L E = *
{ } { } , , , , , , , aaa bb ab aa b ba a =
Courtesy Costas Busch - RPI 31
Reverse
Definition:
Examples:
} : { L w w L
R R
e =
{ } { } abab baa ba baba aab ab
R
, , , , =
} 0 : {
} 0 : {
> =
> =
n a b L
n b a L
n n R
n n
Courtesy Costas Busch - RPI 32
Concatenation
Definition:
Example:
{ }
2 1 2 1
, : L y L x xy L L e e =
{ }{ }
{ } baaa bab abaa abb aaa ab
aa b ba ab a
, , , , ,
, , ,
=
Courtesy Costas Busch - RPI 33
Another Operation
Definition:
Special case:
n
n
L LL L =
{ } { }{ }{ }
{ } bbb bba bab baa abb aba aab aaa
b a b a b a b a
, , , , , , ,
, , , ,
3
= =
{ }
{ } { }
=
=
0
0
, , aaa bba a
L
Courtesy Costas Busch - RPI 34
More Examples
} 0 : { > = n b a L
n n
} 0 , : {
2
> = m n b a b a L
m m n n
2
L aabbaaabbbe
Courtesy Costas Busch - RPI 35
Star-Closure (Kleene *)
Definition:
Example:
2 1 0
* L L L L =
{ }
=
, , , ,
, , , ,
, ,
,
* ,
abbbb abba aabb aaa
bbbb bba abb aa
bb a
bb a
=
+
, , , ,
, , , ,
, ,
,
abbbb abba aabb aaa
bbbb bba abb aa
bb a
bb a