Professional Documents
Culture Documents
Languages: Costas Busch - LSU 1
Languages: Costas Busch - LSU 1
Example:
Strings: cat, dog, house
Language: {cat, dog, house}
Alphabet: a, b, c, , z
PRIMES {2,3,5,7,11,13,17, }
EVEN {0,2,4,6, }
x PRIMES {2,3,5,7,11,13,17,}?
102345 567463386
w a1a2 an abba
v b1b2 bm bbbaaa
Concatenation
Reverse
R
w an a2a1 bbbaaababa
Examples: abba 4
aa 2
a 1
Costas Busch - LSU 10
Length of Concatenation
uv u v
Example: u aab, u 3
v abaab, v 5
uv aababaab 8
uv u v 3 5 8
Costas Busch - LSU 11
Empty String
A string with no letters is denoted: or
Acts as a neutral element
Observations: 0
w w w
String Substring
abbab ab
abbab abba
abbab b
abbab bbab
Costas Busch - LSU 13
Prefix and Suffix
string abbab
Prefixes Suffixes
abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab
Costas Busch - LSU 14
Exponent Operation
n
w ww w
n
Definition: w
0
abba 0
Costas Busch - LSU 15
The * Operation
*
: the set of all possible strings from
alphabet
a, b
, a, b, aa, ab, ba, bb, aaa, aab,
*
a, b
, a, b, aa, ab, ba, bb, aaa, aab,
*
*
a, b, aa, ab, ba, bb, aaa, aab,
Costas Busch - LSU 17
Languages
A language over alphabet
is any subset of *
Example: a, b
, a, b, aa, ab, ba, bb, aaa,
*
Languages: {}
a, aa, aab
{ , abba, baba, aa, ab, aaaaaa}
Costas Busch - LSU 18
More Language Examples
Alphabet {a, b}
An infinite language L {a b : n 0}
n n
bbabb L
ab abb L
L
aabb
aaaaabbbbb
Costas Busch - LSU 19
Prime numbers
Numbers divisible by 1 and itself
PRIMES {2,3,5,7,11,13,17,}
EVEN {0,2,4,6, }
ODD {1,3,5,7, }
Costas Busch - LSU 21
Addition (of unary numbers)
Alphabet: {1,, }
Language:
ADDITION {x y z : x 1 , y 1 , z 1 , n m k
n m k , n 1, m 1}
11 111 11111 ADDITION
111 111 111 ADDITION
ADDITION {1 1 11,1 11 111,11 1 111,11 11 1111 , ...}
Costas Busch - LSU 22
Squares (of unary numbers)
Alphabet: {1, # }
Language:
SQUARES {x#y : x 1 ,y 1 , m n }
n m 2
11#1111 SQUARES
111#1111 SQUARES
SQUARES {1#1,11#1111 ,111#111111111 , ...}
Costas Busch - LSU 23
Two special languages
Language with
Empty language empty string
{ } or { }
Size of a language (number of elements):
| {} | 0
| | 1
| a, aa, ab | 3
| { , aa, bb, abba, baba} | 5
Costas Busch - LSU 24
Note that:
Sets { } { }
Set size {} 0
Set size { } 1
String length 0
Costas Busch - LSU 25
Operations on Languages
The usual set operations:
Complement: L L *
R R
Definition: L {w : w L}
n n
L {a b : n 0}
R n n
L {b a : n 0}
Costas Busch - LSU 27
Concatenation
a, b a, b a, b a, b
3
a, bba, aaa 0
2 n n m m
L {a b a b : n, m 0}
2
aabbaaabbb L
Definition: L L L L
* 0 1 2
Example:
, L 0
a, bb, L1
a, bb* 2
aa , abb, bba , bbbb, L
aaa, aabb, abba, abbbb, L3
Definition: L L L L
1 2 3
Note that: L L L
* 0
1
a, bb, L
2
a, bb aa, abb, bba, bbbb, L
aaa, aabb, abba, abbbb, L3
Costas Busch - LSU 32