Introduction to the theory of computation
This presentation is the property of its rightful owner.
Sponsored Links
1 / 20

Introduction to the Theory of Computation PowerPoint PPT Presentation


  • 103 Views
  • Uploaded on
  • Presentation posted in: General

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

Download Presentation

Introduction to the Theory of Computation

An Image/Link below is provided (as is) to download presentation

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 - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introduction to the theory of computation

Introduction to the Theory of Computation

John Paxton

Montana State University

Summer 2003


Humor

Humor

  • 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."


1 3 regular expression

1.3 Regular Expression

  • Pattern Recogniton

    • Unix (GREP)

    • Perl

    • Text Editors


Formal definition

Formal Definition

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*)


Exercise describe the language

Exercise: Describe the Language

  • 0*10*

  • S*1S*

  • (SS)*

  • 01 U 10

  • (0 U e)1*

  • 0S*0 U 1S*1 U 0 U 1

  • 1*{}

  • {}*


Exercise give the regular expression

Exercise: Give the Regular Expression

  • {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


Theorem

Theorem

  • 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.


Part 1 show constructions

Part 1: Show constructions

  • R = a

  • R = e

  • R = {}

  • R = R1 U R2

  • R = R1 R2

  • R = R1*

#1

a


Exercises

Exercises

  • Build an NFA from the regular expression (ab U a)*.

  • Build an NFA from the regular expression (0 U 1)*000(0 U 1)*.


Part ii

Part II

  • 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


Introduction to the theory of computation

GNFA

  • 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*


Gnfa definition

GNFA Definition

  • 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


Gnfa acceptance

GNFA Acceptance

  • 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)


Part ii proof process

Part II: Proof Process

  • 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!


Conversion example

Conversion Example

  • 2 state DFA

a

a, b

b

1

2


Conversion example1

Conversion Example

  • 4 state GNFA

a

a U b

b

1

2

{}

e

e

{}

{}


Conversion example2

Conversion Example

  • 3 state GNFA

a U b

ea*b

2

e

ea*{} U {}


Conversion example3

Conversion Example

  • 3 state GNFA (simplified)

a U b

a*b

2

e

{}


Conversion example4

Conversion Example

  • 2 state GNFA

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

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


Exercise

Exercise

  • Convert to a regular expression

a

b

1

3

2

e


  • Login