Presentation is loading. Please wait.

Presentation is loading. Please wait.

INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.

Similar presentations


Presentation on theme: "INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011."— Presentation transcript:

1 INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011

2 Q = {q 0, q 1, q 2, q 3 } Σ = {0,1}  : Q  Σ → Q transition function * q 0  Q is start state F = {q 1, q 2 }  Q accept states M = (Q, Σ, , q 0, F) where  01 q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q2q2 q3q3 q2q2 q3q3 q0q0 q2q2 * q2q2 0 0,1 0 0 1 1 1 q0q0 q1q1 q3q3 M

3 A language is regular if it is recognized by a deterministic finite automaton L = { w | w contains 001} is regular L = { w | w has an even number of 1s} is regular The Language of M, L(M), is the set of strings that M accepts

4 Many interesting programs accept regular languages NETWORK PROTOCOLS COMPILERS SUBSTRING GENETIC TESTING BACKWARDS ARITHMETIC

5 THE REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }

6 THEOREM: The Regular Languages are closed under the regular operations. If A and B are regular, applying any regular operation yields a regular language.

7 THE REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A }

8 UNION THEOREM Given two languages, L 1 and L 2, define the union of L 1 and L 2 as L 1  L 2 = { w | w  L 1 or w  L 2 } Theorem: The union of two regular languages is also a regular language

9 Proof: Let M 1 = (Q 1, Σ,  1, q 0, F 1 ) be finite automaton for L 1 and M 2 = (Q 2, Σ,  2, q 0, F 2 ) be finite automaton for L 2 We want to construct a finite automaton M = (Q, Σ, , q 0, F) that recognizes L = L 1  L 2 1 2

10 Theorem: The union of two regular languages is also a regular language q0q0 q1q1 0 0 1 1 p0p0 p1p1 1 1 0 0 M1M1 M2M2 M = ?

11 Idea: Run both M 1 and M 2 at the same time! Q = pairs of states, one from M 1 and one from M 2 = { (q 1, q 2 ) | q 1  Q 1 and q 2  Q 2 } = Q 1  Q 2 q 0 = (q 0, q 0 ) 1 2 F = { (q 1, q 2 ) | q 1  F 1 or q 2  F 2 }  ( (q 1,q 2 ),  ) = (  1 (q 1,  ),  2 (q 2,  ))

12 Theorem: The union of two regular languages is also a regular language q0q0 q1q1 0 0 1 1 p0p0 p1p1 1 1 0 0

13 q 0,p 0 q 1,p 0 1 1 q 0,p 1 q 1,p 1 1 1 0 0 0 0 Intersection: F = {(q 1,q 2 ) | q 1 ∈ F 1 and q 2 ∈ F 2. }

14 THE REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A }

15 REVERSE CLOSURE Regular languages are closed under reverse Assume L is a regular language and M recognizes L We build M R that accepts L R If M accepts w then w describes a directed path in M from start to an accept state Define M R as M with the arrows reversed

16 M R IS NOT ALWAYS A DFA! It may have many start states Some states may have too many outgoing edges, or none

17 1 0 1 0 1 0,1 0

18 NON -DETERMINISM 1 0 1 0 1 0,1 0 What happens with 100? We will say that the machine accepts if there is a way to make it reach an accept state

19 Deterministic Computation Non-Deterministic Computation accept or rejectaccept reject

20 0,1 0,ε0 0,1

21 1 ε0 1 0

22 1 0 0 L(M)={1,00}

23 Q is the set of states Σ is the alphabet  : Q  Σ ε → P(Q) is the transition function Q 0  Q is the set of start states F  Q is the set of accept states A non-deterministic finite automaton is a 5-tuple N = (Q, Σ, , Q 0, F) P(Q) is the set of subsets of Q and Σ ε = Σ  {ε}

24 1 0 0  (q 3,1) = q1q1 q2q2 q3q3 q4q4 N = (Q, Σ, , Q 0, F) Q = {q 1, q 2, q 3, q 4 } Σ = {0,1} Q 0 = {q 1, q 2 } F = {q 4 }  Q  (q 2,1) = {q 4 } 

25  (q 1,ε)= N = (Q, Σ, , Q 0, F) Q = {q 1, q 2, q 3 } Σ = {0,1} Q 0 = {q 1 } F = {q 3 }  Q  (q 1,0) = {q 1, q 2 } {q 2 } 0,1 0,ε0 0,1 q1q1 q2q2 q3q3  (q 2,1) = 

26 MULTIPLE START STATES We allow multiple start states for NFAs, and Sipser allows only one Can easily convert NFA with many start states into one with a single start state: ε ε ε

27 UNION THEOREM FOR NFAs 0 0 1 1 0

28 NFAs ARE SIMPLER THAN DFAs An NFA that recognizes the language {1}: 1 10,1 0 A DFA that recognizes the language {1}:

29 Theorem: Every NFA has an equivalent DFA Corollary: A language is regular iff it is recognized by an NFA Corollary: L is regular iff L R is regular

30 THE REGULAR OPERATIONS Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Negation:  A = { w | w  A } Reverse: A R = { w 1 …w k | w k …w 1  A } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w 1 …w k | k ≥ 0 and each w i  A }


Download ppt "INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011."

Similar presentations


Ads by Google