0% found this document useful (0 votes)
17 views37 pages

Lecture 1

Uploaded by

kumarashish91100
Copyright
© © All Rights Reserved
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)
17 views37 pages

Lecture 1

Uploaded by

kumarashish91100
Copyright
© © All Rights Reserved
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/ 37

CSE322

Formal Languages and


Automation Theory

Unit 1 : Basic
Descriptions
Computation

CPU memory

2
temporary memory

input memory
CPU
output memory

Program memory

3
3
Example: f ( x ) x
temporary memory

input memory
CPU
output memory
Program memory
compute xx
2
compute x x
4
3
f ( x) x
temporary memory
input memory
x 2
CPU
output memory
Program memory
compute xx
2
compute x x
5
3
temporary memoryf ( x) x
z 2 * 2 4
f ( x) z * 2 8
input memory
x 2
CPU
output memory
Program memory
compute xx
2
compute x x
6
3
temporary memoryf ( x) x
z 2 * 2 4
f ( x) z * 2 8
input memory
x 2
CPU
f ( x) 8
Program memory output memory
compute xx
2
compute x x
7
Automaton
temporary memory

Automaton
input memory
CPU
output memory

Program memory

8
Different Kinds of Automata
Automata are distinguished by the temporary memo

• Finite Automata: no temporary memory

• Pushdown Automata: stack

• Turing Machines: random access memory

9
Finite Automaton

temporary memory

input memory
Finite
Automaton
output memory

Example: Vending Machines


(small computing power)
10
Pushdown Automaton
Stack Push, Pop

input memory
Pushdown
Automaton
output memory

Example: Compilers for Programming Languages


(medium computing power)
11
Turing Machine

Random Access
Memory

input memory
Turing
Machine
output memory

Examples: Any Algorithm


(highest computing power)
12
Power of Automata

Finite Pushdown Turing


Automata Automata Machine

Less power More power


Solve more
computational problems
13
Languages

14
• A language is a set of strings

• String: A sequence of letters

– Examples: “cat”, “dog”,


“house”, …

– Defined over an alphabet:


 a, b, c, , z

15
Alphabets and Strings
 a, b
• We will use small alphabets:

• Strings
a
ab u ab
abba v bbbaaa
baba w abba
aaabbbaabab
16
String Operations

w a1a2  an abba
v b1b2 bm bbbaaa

Concatenation

wv a1a2  anb1b2 bm abbabbbaaa

17
w a1a2  an ababaaabbb

Reverse

R
w an  a2 a1 bbbaaababa

18
String Length
w a1a2  an
• Length:w n

• Examples: abba 4
aa 2
a 1
19
Length of Concatenation

uv  u  v

• Example:u aab, u 3
v abaab, v 5

uv  aababaab 8
uv  u  v 3  5 8
20
Empty String

• A string with no letters:

• Observations: 0

w w w

abba abba abba


21
Substring
• Substring of string:
– a subsequence of consecutive
characters

• String Substring
abbab ab
abbab abba
abbab b
abbab bbab
22
Prefix and Suffix
abbab
• Prefixes Suffixes
 abbab w uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab 
23
Another Operation
n
w ww
 
w
n
2
• Example:abba  abbaabba

0
• Definition:w 

0
abba  
24
The * Operation
• * : the set of all possible strings from
• 
alphabet

 a, b
*  , a, b, aa, ab, ba, bb, aaa, aab,

25
The + Operation
 : the set of all possible strings from

alphabet except

 a, b
*  , a, b, aa, ab, ba, bb, aaa, aab,


  *  

 a, b, aa, ab, ba, bb, aaa, aab,
26
Languages
• A language is any subsetof
*

• Example: a, b
*  , a, b, aa, ab, ba, bb, aaa,


• Languages:

a, aa, aab


{ , abba, baba, aa, ab, aaaaaa}
27
Note that:

Sets  { } {}

Set size { }   0

Set size {} 1


String length  0
28
Another Example

n n
L
• An infinite language {a b : n 0}


ab
L abb  L
aabb
aaaaabbbbb
29
Operations on Languages
• The usual set operations

a, ab, aaaa bb, ab {a, ab, bb, aaaa}


a, ab, aaaa bb, ab {ab}
a, ab, aaaa  bb, ab a, aaaa
• Complement:L  *  L

a, ba  , b, aa, ab, bb, aaa,


30
Reverse

R R
• Definition: L {w : w  L}
R
ab, aab, baba
• Examples: ba, baa, abab

n n
L {a b : n 0}

R n n
L {b a : n 0}
31
Concatenation

• Definition: L1L2  xy : x  L1, y  L2 

a, ab, bab, aa


• Example:

ab, aaa, abb, abaa, bab, baaa

32
Another Operation
• Definition: Ln LL L
n
3
a, b a, ba, ba, b 
aaa, aab, aba, abb, baa, bab, bba, bbb
0
• Special case:L 

a, bba, aaa0 


33
More Examples

n n
L {a b : n 0}

2 n n m m
L {a b a b : n, m 0}

2
aabbaaabbb  L

34
Star-Closure (Kleene *)

0 1 2
• Definition:L* L L L 

• Example:
 , 
a, bb, 
 
a, bb*  
 aa , abb, bba , bbbb, 
• aaa, aabb, abba, abbbb,
35
Positive Closure

• Definition:L 1 2
L  L 
L *   

a, bb, 
  
a, bb aa, abb, bba, bbbb, 
aaa, aabb, abba, abbbb,
 
36
End of Topic

Any Query

37

You might also like