Loading in 5 sec....

Introduction to the Theory of ComputationPowerPoint Presentation

Introduction to the Theory of Computation

- 128 Views
- Uploaded on
- Presentation posted in: General

Introduction to the Theory of Computation. John Paxton Montana State University Summer 2003. Humor.

Introduction to the Theory of Computation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Introduction to the Theory of Computation

John Paxton

Montana State University

Summer 2003

- A man walks up to the Marine guard at the White House front gate and asked to see President Clinton. The guard says "Sorry sir but Clinton is no longer president." The man comes back the next day and again approaches the same guard and asks to see President Clinton. Again the guard says "Sir, Clinton is no longer president." The man leaves but comes back the third day and again asked to see President Clinton. The guard says "Sir...you have been here three days in a row asking to see President Clinton...and I have told you each time that Clinton is no longer president...what gives?" The man says "I know... I just like hearing it."

- Pattern Recogniton
- Unix (GREP)
- Perl
- Text Editors

R is a regular expression if R is

- a for some a in the alphabet S
- e
- {}
- (R1 U R2) where R1 and R2 are both regular expressions
- (R1 R2)
- (R1*)

- 0*10*
- S*1S*
- (SS)*
- 01 U 10
- (0 U e)1*
- 0S*0 U 1S*1 U 0 U 1
- 1*{}
- {}*

- {w | w begins with a 1 and ends with a 0}
- {w | w contains at least 3 0s}
- {w | w starts with a 0 and has odd length or starts with a 1 and has even length}
- {w | the length of w is at most 5}
- {w | w contains at least two 0s and at most one 1}
- All strings except the empty string

- A language is regular if and only if some regular expression describes it.
- Part I. If a language is described by a regular expression, then it is regular.
- Part II. If a language is regular, then it is described by a regular expression.

- R = a
- R = e
- R = {}
- R = R1 U R2
- R = R1 R2
- R = R1*

#1

a

- Build an NFA from the regular expression (ab U a)*.
- Build an NFA from the regular expression (0 U 1)*000(0 U 1)*.

- A generalized nondeterministic finite automaton (GNFA):
- The start state has transition arrows going to every other state but no arrows coming in from any other state.
- There is only a single accept state, and it has arrows coming in from every other state but no arrows going to any other state. Furthermore, the accept state is not the same as the start state

- Except for the start state and accept state, one arrow goes from every state to every other state and also from each state to itself.

a U b

a

e

qstart

q1

qaccept

a*

- A generalized nondeterministic finite automaton, (Q, S, d, qstart, qaccept) is a 5-tuple where
- Q is the finite set of states
- S is the input alphabet
- d : (Q – {qaccept}) x (Q – {qstart}) R is the transition function
- qstart is the start state
- qaccept is the accept state

- A GNFA accepts a string w in S* if w = w1w2…wk where each wi is in S* and a sequence of states q0,q1,…qk exists such that
- q0 = qstart
- qk = qaccept
- for each i, wie L(Ri) where Ri = d(qi-1,qi)

- Start with a k state DFA
- Construct a k+2 state GNFA
- Map to a k+1 state GNFA
- …..
- Map to a 2 state GNFA
- Read off the regular expression!

- 2 state DFA

a

a, b

b

1

2

- 4 state GNFA

a

a U b

b

1

2

{}

e

e

{}

{}

- 3 state GNFA

a U b

ea*b

2

e

ea*{} U {}

- 3 state GNFA (simplified)

a U b

a*b

2

e

{}

- 2 state GNFA

Regular Expression: a*b(a U b)*

{} U a*b(a U b)*e

- Convert to a regular expression

a

b

1

3

2

e