2. Courtesy: Costas Busch - LSU 2
Language: a set of strings
String: a sequence of symbols
from some alphabet
Example:
Strings: cat, dog, house
Language: {cat, dog, house}
zcba ,,,, Alphabet:
3. Courtesy: Costas Busch - LSU 3
Languages are used to describe
computation problems:
},17,13,11,7,5,3,2{ PRIMES
},6,4,2,0{ EVEN
}9,,2,1,0{ Alphabet:
4. Courtesy: Costas Busch - LSU 4
Computation is translated to set membership
Is number prime?x
}?,17,13,11,7,5,3,2{ PRIMESx
Example computation problem:
Equivalent set membership problem:
5. Courtesy: Costas Busch - LSU 5
Alphabets and Strings
abbaw
bbbaaav
abu
ba,
baaabbbaaba
abba
ab
a
Example Strings
Example Alphabet:
An alphabet is a set of symbols
A string is a sequence of
symbols from the alphabet
String variables
12. Courtesy: Costas Busch - LSU 12
A string with no letters is denoted:
Acts as a neutral element
Observations:
Empty String
or
abbabaababbaabba
www
0
13. Courtesy: Costas Busch - LSU 13
Substring
Substring of string:
a subsequence of consecutive characters
String Substring
bbab
b
abba
ab
abbab
abbab
abbab
abbab
14. Courtesy: Costas Busch - LSU 14
Prefix and Suffix
Prefixes Suffixes
abbab
abbab
abba
abb
ab
a
b
ab
bab
bbab
abbab uvw
prefix
suffix
string
15. Courtesy: Costas Busch - LSU 15
Exponent Operation
Example:
Definition:
n
n
wwww
abbaabbaabba 2
0
w
0
abba
16. Courtesy: Costas Busch - LSU 16
The * Operation
: the set of all possible strings from
alphabet
*
,,,,,,,,,
,
*
aabaaabbbaabaaba
ba
17. Courtesy: Costas Busch - LSU 17
The + Operation
: the set of all possible strings from
alphabet except
,,,,,,,,,
,
*
aabaaabbbaabaaba
ba
*
,,,,,,,, aabaaabbbaabaaba
18. Courtesy: Costas Busch - LSU 18
Languages
A language over alphabet
is any subset of *
,,,,,,,,
,
*
aaabbbaabaaba
ba
},,,,,{
,,
{}
aaaaaaabaababaabba
aabaaa
Languages:
Example:
19. Courtesy: Costas Busch - LSU 19
More Language Examples
An infinite language }0:{ nbaL nn
aaaaabbbbb
aabb
ab
L
Labb
},{ baAlphabet
Lbbabb
20. Courtesy: Costas Busch - LSU 20
prime}isand:{ *
xxxPRIMES
}9,,2,1,0{
},17,13,11,7,5,3,2{ PRIMES
Prime numbers
Alphabet
Language:
Rule: Numbers divisible by 1 and itself
24. Courtesy: Costas Busch - LSU 24
5|},,,,{|
3|,,|
1||
0|{}|
babaabbabbaa
abaaa
Two special languages
Size of a language (number of elements):
or}{ }{
Empty language
Language with
empty string