Top Banner
LECTURE 2 THEORY OF COMPUTATION Yasir Imtiaz Khan
48

Lecture 2 Theory of Computation

Feb 23, 2016

Download

Documents

idola

Lecture 2 Theory of Computation. Yasir Imtiaz Khan. Finite automata. Finite automata. Formal definition. Draw state diagrams. Transition Graph. Abba -Finite Accepter. initial state. final state “accept”. transition. state. Initial Configuration. Input String. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 2 Theory of Computation

LECTURE 2THEORY OF COMPUTATION

Yasir Imtiaz Khan

Page 2: Lecture 2 Theory of Computation

FINITE AUTOMATA

Page 3: Lecture 2 Theory of Computation

FINITE AUTOMATA

Page 4: Lecture 2 Theory of Computation

FORMAL DEFINITION

Page 5: Lecture 2 Theory of Computation

DRAW STATE DIAGRAMS

Page 6: Lecture 2 Theory of Computation

TRANSITION GRAPH

initialstate

final state“accept”

statetransition

Abba -Finite Accepter

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 7: Lecture 2 Theory of Computation

INITIAL CONFIGURATION

1q 2q 3q 4qa b b a

5q

a a bb

ba,

Input String

a b b a

ba,0q

Page 8: Lecture 2 Theory of Computation

READING THE INPUT

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 9: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 10: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 11: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 12: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

Output: “accept”

5q

a a bb

ba,

a b b a

ba,

Input finished

Page 13: Lecture 2 Theory of Computation

REJECTION

1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,0q

Page 14: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 15: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 16: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 17: Lecture 2 Theory of Computation

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,Output:“reject”

a b a

ba,

Input finished

Page 18: Lecture 2 Theory of Computation

ANOTHER REJECTION

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q

Page 19: Lecture 2 Theory of Computation

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q

Output:“reject”

Page 20: Lecture 2 Theory of Computation

MORE EXAMPLES

a

b ba,

ba,

0q 1q 2q

}0:{ nbaML n

accept trap state

Page 21: Lecture 2 Theory of Computation

ML = { all strings with prefix }ab

a b

ba,

0q 1q 2qaccept

ba,3q

ab

Page 22: Lecture 2 Theory of Computation

ML = { all strings without

substring }001

0 00 001

1

0

110

0 1,0

Page 23: Lecture 2 Theory of Computation

NON DETERMINISTIC AUTOMATA

Page 24: Lecture 2 Theory of Computation

FORMAL DEFINITION NFA

Page 25: Lecture 2 Theory of Computation

1q 2q

3q

a

a

a

0q

}{aAlphabet =

Nondeterministic Finite Accepter (NFA)

Page 26: Lecture 2 Theory of Computation

1q 2q

3q

a

a

a

0q

Two choices

}{aAlphabet =

Nondeterministic Finite Accepter (NFA)

Page 27: Lecture 2 Theory of Computation

No transition

1q 2q

3q

a

a

a

0q

Two choicesNo transition

}{aAlphabet =

Nondeterministic Finite Accepter (NFA)

Page 28: Lecture 2 Theory of Computation

a a

0q

1q 2q

3q

a

a

First Choice

a

Page 29: Lecture 2 Theory of Computation

a a

0q

1q 2q

3q

a

a

a

First Choice

Page 30: Lecture 2 Theory of Computation

a a

0q

1q 2q

3q

a

a

First Choice

a

Page 31: Lecture 2 Theory of Computation

a a

0q

1q 2q

3q

a

a

a “accept”

First Choice

All input is consumed

Page 32: Lecture 2 Theory of Computation

a a

0q

1q 2q

3q

a

a

Second Choice

a

Page 33: Lecture 2 Theory of Computation

a a

0q

1q 2qa

a

Second Choice

a

3q

Page 34: Lecture 2 Theory of Computation

a a

0q

1q 2qa

a

a

3q

Second Choice

No transition:the automaton hangs

Page 35: Lecture 2 Theory of Computation

a a

0q

1q 2qa

a

a

3q

Second Choice

“reject”

Input cannot be consumed

Page 36: Lecture 2 Theory of Computation

LAMBDA TRANSITIONS

1q 3qa0q 2q a

Page 37: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

Page 38: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

Page 39: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

(read head does not move)

Page 40: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

Page 41: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

“accept”

String is acceptedaa

all input is consumed

Page 42: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

Rejection Example

a

Page 43: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

a

Page 44: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

(read head doesn’t move)

a

Page 45: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

a

No transition:the automaton hangs

Page 46: Lecture 2 Theory of Computation

a a

1q 3qa0q 2q a

“reject”

String is rejectedaaa

a

Input cannot be consumed

Page 47: Lecture 2 Theory of Computation

Language accepted: }{aaL

1q 3qa0q 2q a

Page 48: Lecture 2 Theory of Computation

Another NFA Example

0q 1q 2qa b

3q