0% found this document useful (0 votes)
68 views32 pages

Languages: Prof. Busch - LSU 1

This document discusses foundational concepts in formal language theory including: - Languages are sets of strings over an alphabet - Strings are sequences of symbols from an alphabet - Languages can describe computation problems and be represented as set membership questions - Common operations on strings include concatenation, reversal, determining length - Special strings include the empty string and substrings - Languages undergo operations like union, intersection, and Kleene closure

Uploaded by

sat258
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views32 pages

Languages: Prof. Busch - LSU 1

This document discusses foundational concepts in formal language theory including: - Languages are sets of strings over an alphabet - Strings are sequences of symbols from an alphabet - Languages can describe computation problems and be represented as set membership questions - Common operations on strings include concatenation, reversal, determining length - Special strings include the empty string and substrings - Languages undergo operations like union, intersection, and Kleene closure

Uploaded by

sat258
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 32

Prof.

Busch - LSU 1
Languages
Prof. 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}
{ } z c b a , , , , = E Alphabet:
Prof. 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 { = E
Alphabet:
Prof. Busch - LSU 4
Computation is translated to set membership
Is number prime?
x
}? , 17 , 13 , 11 , 7 , 5 , 3 , 2 { = ePRIMES x
Example computation problem:
Equivalent set membership problem:
Prof. Busch - LSU 5
Alphabets and Strings






abba w
bbbaaa v
ab u
=
=
=
{ } b a, = E
b aaabbbaaba
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
Prof. Busch - LSU 6
} 9 , , 2 , 1 , 0 { = E Decimal numbers alphabet
102345
567463386
} 1 , 0 { = E Binary numbers alphabet
100010001 101101111
Prof. Busch - LSU 7
} 1 { = E Unary numbers alphabet
1
Unary number:
Decimal number:
1
11
2
111
3
1111
4
11111
5
Prof. Busch - LSU 8
String Operations
m
n
b b b v
a a a w

2 1
2 1
=
=
bbbaaa
abba
m n
b b b a a a wv
2 1 2 1
=
Concatenation
abbabbbaaa
Prof. Busch - LSU 9
1 2
a a a w
n
R
=
n
a a a w
2 1
=
ababaaabbb
Reverse
bbbaaababa
Prof. Busch - LSU 10
String Length


Length:


Examples:

n
a a a w
2 1
=
n w =
1
2
4
=
=
=
a
aa
abba
Prof. Busch - LSU 11
Length of Concatenation



Example:
v u uv + =
8 5 3
8
5 ,
3 ,
= + = + =
= =
= =
= =
v u uv
aababaab uv
v abaab v
u aab u
Prof. Busch - LSU 12
A string with no letters is denoted:

Acts as a neutral element
Observations:


Empty String
c or
abba ba ab abba abba
w w w
= = =
= =
=


0
Prof. Busch - LSU 13
Substring
Substring of string:
a subsequence of consecutive characters

String Substring
bbab
b
abba
ab
abbab
abbab
abbab
abbab
Prof. Busch - LSU 14
Prefix and Suffix

Prefixes Suffixes


abbab
abbab
abba
abb
ab
a

b
ab
bab
bbab
abbab
uv w=
prefix
suffix
string
Prof. Busch - LSU 15
Exponent Operation



Example:


Definition:

n
n
w ww w =
( ) abbaabba abba =
2
=
0
w
( ) =
0
abba
Prof. Busch - LSU 16
The * Operation
: the set of all possible strings from
alphabet






* E
E
{ }
{ } , , , , , , , , , *
,
aab aaa bb ba ab aa b a
b a
= E
= E
Prof. Busch - LSU 17
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
+

Prof. Busch - LSU 18


Languages
A language over alphabet
is any subset of
Example:





* E
{ }
{ } , , , , , , , , *
,
aaa bb ba ab aa b a
b a
= E
= E
{ }
{ }
} , , , , , {
, ,
aaaaaa ab aa baba abba
aab aa a

Language:
Language:
Language:
E
Prof. Busch - LSU 19
More Language Examples


An infinite language
} 0 : { > = n b a L
n n
aaaaabbbbb
aabb
ab

L e
L abb e
} , { b a = E
Alphabet
L bbabb e
Prof. Busch - LSU 20
prime} is and : {
*
x x x PRIMES E e =
} 9 , , 2 , 1 , 0 { = E
} , 17 , 13 , 11 , 7 , 5 , 3 , 2 { = PRIMES
Prime numbers
Alphabet
Language:
Prof. Busch - LSU 21
even} is and : {
*
x x x EVEN E e =
} 9 , , 2 , 1 , 0 { = E
Even and odd numbers
Alphabet
odd} is and : {
*
x x x ODD E e =
} , 6 , 4 , 2 , 0 { = EVEN
} , 7 , 5 , 3 , 1 { = ODD
Languages:
Prof. Busch - LSU 22
Addition (of unary numbers)
} , , 1 { = + = E
} n
, 1 z , 1 y , 1 x : {
m n
k m
z y x ADDITION
k
= +
= = = = + =
ADDITION e = + 11111 111 11
ADDITION e = + 111 111 111
Alphabet:
Language:
Prof. Busch - LSU 23
Squares (of unary numbers)
} # , 1 { = E
} , 1 y , 1 x : # {
2 m n
n m y x SQUARES = = = =
SQUARES e 1111 # 11
SQUARES e 1111 # 111
Alphabet:
Language:
Prof. Busch - LSU 24
{ }
{ }
5 | } , , , , { |
3 | , , |
1 | |
0 | {} |
=
=
=
=
baba abba bb aa
ab aa a

Two special languages


Size of a language (number of elements):
} {
} {
Empty language
Language with
empty string
Prof. Busch - LSU 25
Note that:
} { } { = = C
0 } { = C =
1 } { =
0 =
Sets
Set size
Set size
String length
Prof. Busch - LSU 26
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 =
Prof. Busch - LSU 27
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
Prof. Busch - LSU 28
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
, , , , ,
, , ,
=
Prof. Busch - LSU 29
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
Prof. Busch - LSU 30

} 0 : { > = n b a L
n n
} 0 , : {
2
> = m n b a b a L
m m n n
2
L aabbaaabbbe
Example
Prof. Busch - LSU 31
Star-Closure (Kleene *)
All strings that can be constructed from

Definition:

Example:





2 1 0
* L L L L =
{ }

=
, , , ,
, , , ,
, ,
,
* ,
abbbb abba aabb aaa
bbbb bba abb aa
bb a
bb a

L
Prof. Busch - LSU 32
Positive Closure

Definition:
2 1
L L L =
+
{ }

=
+
, , , ,
, , , ,
, ,
,
abbbb abba aabb aaa
bbbb bba abb aa
bb a
bb a

You might also like