Transcript
Page 1: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

CSC312Automata Theory

Lecture # 2

Languages

Page 2: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 2

Alphabets: An alphabet is a finite set of symbols, usually letters, digits, and punctuations.

Valid/In-valid alphabets: An alphabet may contain letters consisting of group of symbols for example Σ= {a, ba, bab, d}.

Remarks: While defining an alphabet of letters consisting of more than one symbols, no letter should be started with the letter of the same alphabet i.e. one letter should not be the prefix of another. However, a letter may be ended in a letter of same alphabet.

Valid alphabet :Invalid alphabet :

, ,a ba c

Alphabets and Strings

, ,a ab c

Page 3: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 3

String or word: A finite sequence of letters/alphabets

Examples: “cat”, “dog”, “house”, “read” …

Defined over an alphabet: zcba ,,,,

Alphabets and Strings

Page 4: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 4

Alphabets and Strings

We will use small alphabets:

Strings

abbaw

bbbaaav

abu

ba,

baaabbbaaba

baba

abba

ab

a

Page 5: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 5

String Operations

m

n

bbbv

aaaw

21

21

bbbaaa

abba

mn bbbaaawv 2121

Concatenation

abbabbbaaa

Let we have following strings

Reverse

12aaaw nR abba

aaabbb

Page 6: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 6

String Length

Length:

Examples:

naaaw 21

nw

1

2

4

a

aa

abba

Page 7: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 7

Length of Concatenation

Example:

vuuv

853

8

5,

3,

vuuv

aababaabuv

vabaabv

uaabu

Page 8: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 8

Empty String

A string with no letters: Observations:

Note-1: A language that does not contain any word at all is denoted by or { }. This language doesn’t contain any word not even the NULL string. i.e. { } ≠ {}

or or 0

w w w

abba abba abba

Page 9: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 9

Empty String

Note-2: Suppose a language L doesn’t contain NULL then

L = L + but L ≠ L + {}.

Important : NULL is identity element with respect to concatenation.

Page 10: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 10

SubstringSubstring of string:

a subsequence of consecutive characters

String Substring

bbab

b

abba

ab

abbab

abbab

abbab

abbab

Page 11: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 11

Prefix and Suffix Let the string is Prefixes Suffixes

abbab

abbab

abba

abb

ab

a

b

ab

bab

bbab

abbab uvw

prefix

suffix

Page 12: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 12

Another Operation

- w repeated n time; that is,

Example:

Definition:

n

n wwww

abbaabbaabba 2

0w

0abba

nw

Page 13: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 13

The * Operation

: the set of all possible strings from alphabet , called closure of alphabets also

known as Kleene star operator or Kleene star closure.

i.e. infinitely many words each of finite length.

*

,,,,,,,,,*

,

aabaaabbbaabaaba

ba

Page 14: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

14

The + Operation

: the set of all possible strings from alphabet except , also known as

Kleene plus operator.

Note : are infinite

,,,,,,,,,*

,

aabaaabbbaabaaba

ba

* ,,,,,,,, aabaaabbbaabaaba

* and

Page 15: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 15

LanguagesA language is a set of strings ORA language is any subset of , usually

denoted by L. It may be finite or infinite. Example:

Languages:

If a string w is in L, we say that w is a sentence of L.

*

,,,,,,,,*

,

aaabbbaabaaba

ba

},,,,,{

,,

aaaaaaabaababaabba

aabaaa

Page 16: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 16

Note that:

}{}{

0}{

1}{

0

Sets

Set size

Set size

String length

Page 17: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 17

Another Example

An infinite language }0:{ nbaL nn

aaaaabbbbb

aabb

ab

L Labb

Page 18: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 18

Operations on LanguagesThe usual set operations

Complement:

aaaaaabbbaaaaaba

ababbbaaaaaba

aaaabbabaabbbaaaaaba

,,,,

}{,,,

},,,{,,,

LL *

,,,,,,, aaabbabaabbaa

Page 19: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 19

ReverseDefinition:

Examples:

ConcatenationDefinition:

Examples:

}:{ LwwL RR ababbaabababaaabab R ,,,,

{ : 0}

{ : 0}

n n

R n n

L a b n

L b a n

2121 ,: LyLxxyLL

, , ,

, , , , ,

a ab ba b aa

ab aaa abb abaa bab baaa

Page 20: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 20

Another OperationDefinition:

L concatenated with itself n times.

Special case:

n

n LLLL

bbbbbababbaaabbabaaabaaa

babababa

,,,,,,,

,,,, 3

0

0, ,

L

a bba aaa

Page 21: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 21

More Examples

}0:{ nbaL nn

}0,:{2 mnbabaL mmnn

2Laabbaaabbb

Page 22: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 22

Star-Closure (Kleene *)

Definition:

Example:

210* LLLL

,,,,

,,,,

,,

,

*,

abbbbabbaaabbaaa

bbbbbbaabbaa

bbabba

Page 23: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 23

Positive Closure

Definition:

Note: L+ includes if and only if L includes

*

21

L

LLL

,,,,

,,,,

,,

,

abbbbabbaaabbaaa

bbbbbbaabbaa

bba

bba

Page 24: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Courtesy Costas Busch - RPI 24

Lexicographical OrderAssume that the symbols in are themselves ordered. Definition: A set of strings is in lexicographical order if -The strings are grouped first according to their length. -Then, within each group, the strings are ordered “alphabetically” according to the ordering of the symbols.

Page 25: CSC312 Automata Theory Lecture # 2 Languages. Courtesy Costas Busch - RPI2 Alphabets: An alphabet is a finite set of symbols, usually letters, digits,

Ex: Let the alphabet beThe set of all strings in Lexicographical order is, a, b, aa, ab, ba, bb, aaa, …., bbb, aaaa, …, bbbb, ….

Courtesy Costas Busch - RPI 25

Lexicographical Order

{ , }a b


Top Related