INHERENT LIMITATIONS OF COMPUTER PROGRAMS

1 / 28

# INHERENT LIMITATIONS OF COMPUTER PROGRAMS - PowerPoint PPT Presentation

CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGRAMS. q 1. 1. 0. 0,1. 1. M. q 0. q 2. 0. 0. 1. q 3. M = (Q, Σ , , q 0 , F) where. Q = {q 0 , q 1 , q 2 , q 3 }. Σ = {0,1}.  : Q  Σ → Q transition function *. q 0  Q is start state.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'INHERENT LIMITATIONS OF COMPUTER PROGRAMS' - pascal

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

INHERENT LIMITATIONS OF COMPUTER PROGRAMS

q1

1

0

0,1

1

M

q0

q2

0

0

1

q3

M = (Q, Σ, , q0, F) where

Q = {q0, q1, q2, q3}

Σ = {0,1}

 : Q Σ→ Q transition function*

q0 Q is start state

F = {q1, q2} Q accept states

*

THE REGULAR OPERATIONS

Negation: A = { w | w  A }

Union: A  B = { w | w  A or w  B }

Intersection: A  B = { w | w  A and w  B }

Reverse: AR = { w1 …wk | wk …w1 A }

Concatenation: A  B = { vw | v  A and w  B }

Star: A* = { w1 …wk | k ≥ 0 and each wi A }

REGULAR EXPRESSIONS
• is a regular expression representing {}

ε is a regular expression representing {ε}

 is a regular expression representing 

If R1 and R2 are regular expressions representing L1 and L2 then:

(R1R2) represents L1L2

(R1  R2) represents L1 L2

(R1)* represents L1*

REGULAR EXPRESSIONS

(+ ∪- ∪ε) {0…9}* (. ∪ε) {0…9}+

* NICK STINKS *

CSCI {1...4}{0...9}{0...9}{0…9}

* NICK RULES *

PRECEDENCE

* 

EXAMPLE

R1R2*  R3 =

(R1 (R2*)) ∪R3

{ w | w has exactly a single 1 }

0*10*

{ w ||w|≥ 3 and its 3rd symbol is 0 }

ΣΣ0Σ*

{ w | every odd position of w is a 1 }

(1Σ)*(1∪ε)

EQUIVALENCE

L can be represented by a regexp

L is a regular language

EQUIVALENCE

Given regular expression R, we show there exists NFA N such that R represents L(N)

L can be represented by a regexp

L is a regular language

Induction on the length of R:

Given regular expression R, we show there exists NFA N such that R represents L(N)

Induction on the length of R:

L can be represented by a regexp

L is a regular language

Base Cases (R has length 1):

R = 

R = ε

R = 

Inductive Step:

Assume R has length k > 1 and that any regular expression of length < k represents a language that can be recognized by an NFA

Three possibilities for R:

R = R1 R2

R = R1R2

R = (R1)*

L can be represented by a regexp

L is a regular language

CONVERT TO NFAs

a*(b∪ε)a*

(1)*∪1(1)*

(lol∪zomg)*

0

0

01*0

1

Proof idea: Transform an NFA for L into a regular expression by removing states and re-labeling the arrows with regular expressions

L can be represented by a regexp

L is a regular language

a∪b

a

q2

GENERALIZED NFAs

a*b

qs

qa

G accepts w if it finds q0q1…qk, w1…wk:

wi∈R(qi,qi+1)

w = w1w2…wk

q0=qs, qk=qa

R(qs,q2) = a*b

R(qa,q) = Ø

R(q,qs) = Ø

ε

ε

ε

ε

ε

NFA TO GNFA

NFA

Add unique and distinct start and accept states

ε

ε

ε

ε

ε

GNFA TO REGEXP

NFA

While machine has more than 2 states:

Pick an internal state, rip it out and re-label the arrows with regular expressions to account for the missing state

a

a,b

(a*b)(ab)*

ε

b

ε

a*b

q1

q2

q3

q0

R(q0,q3) = (a*b)(ab)*

b

bb

a

q1

q2

a

ε

b

ε

b

a

ε

q3

b

bb

a

q1

q2

a  ba

a

ε

b

ε

b

a

ε

b

= R(q1,q1)

bb  (a  ba)b*a

bb

a

q1

q2

a  ba

ε

ε

b  (a  ba)b*

b

Convert the NFA to a regular expression

a, b

(a  b)b*b(bb*b)*

b

q1

q2

(a  b)b*b

ε

b

(a  b)b*b(bb*b)*a

bb*b

a

b

ε

q3

ε

((a  b)b*b(bb*b)*a)* 

((a  b)b*b(bb*b)*a)*(a  b)b*b(bb*b)*

Formally:

Add qstart and qaccept to create G

Run CONVERT(G):

If #states = 2

return the expression on the arrow going from qstart to qaccept

If #states > 2

Formally:

Add qstart and qaccept to create G

Run CONVERT(G):

If #states > 2

select qripQ different from qstart and qaccept

define Q = Q – {qrip}

define Ras:

R(qi,qj) = R(qi,qrip)R(qrip,qrip)*R(qrip,qj)  R(qi,qj)

return CONVERT(G)

NFA

DFA

DEF

Regular

Language

Regular

Expression