Download presentation

Presentation is loading. Please wait.

Published bySamara Trefry Modified over 2 years ago

1
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2
THE PUMPING LEMMA Let L be a regular language with |L| = Then there exists a length P such that 1. |y| > 0 2. |xy| ≤ P 3. xy i z L for any i ≥ 0 ∀ w L, if |w| ≥ P then there exist xyz = w where:

3
PUMPING DOWN C = { 0 i 1 j | i > j ≥ 0} Assume … pumping length P Find a w ∈ C longer than P Show that … w cannot be pumped: If w = xyz with |xy| ≤ P then y = 0 J for some J ≥ 1. Then xy 0 z = xz = 0 P+1-J 1 P C 0 P+1 1 P 00…0011…11 P+1 P w= y xyyz = 00…00011…11 > P+1 P xz = 0…0011…11 ≤ P P

4
CHOOSING WISELY Let BALANCED = { w | w has an equal # of 1s and 0s } Assume … there is a P Find a w ∈ BALANCED longer than P (01) P Show that w cannot be pumped: If w = xyz with |xy| ≤ P then y = 0 J for some J>0. Then xyyz = 0 P+J 1 P BALANCED 0P1P0P1P

5
REUSING A PROOF Pumping a language can be lots of work… Let’s try to reuse that work! {0 n 1 n : n ≥ 0} = BALANCED ∩ 0*1* If BALANCED is regular then so is {0 n 1 n : n ≥ 0}

6
USING CLOSURE A C B ∩ = (Not regular) Prove: A is not regular or any of {¬, ∪, ∩, ･, R, *} If A is regular, then A ∩ C (= B) is regular. (regular) But B is not regular so neither is A.

7
Prove A = {0 i 1 j : i j} is not regular using B = {0 n 1 n : n ≥ 0} B ∪ { strings that mix 0s and 1s } B = ¬A ∩ 0*1* ¬A =

8
PUMPING NON-REGULAR LANGUAGES Let F = {a i b j c k | i, j, k ≥ 0 and i=1 ⇒ j=k} F has pumping length 2! F ∩ ab*c* = {ab n c n | n ≥ 0} i = 0 i = 1 i = 2 A non-regular language may still satisfy the pumping lemma.

9
4011 SO FAR… MODEL OF A PROGRAM: DFA MODEL OF A PROBLEM: LANGUAGE EQUIVALENT MODELS: NFA, REGEXP PROBLEMS THAT A DFA CAN’T SOLVE ARE WE DONE?

10
Σ = {0, 1}, L = { 0 n 1 n | n ≥ 0 } Σ = {a, b, c, …, z}, L = { w | w = w R } Σ = { (, ) }, L = { balanced strings of parens } NONE OF THESE ARE REGULAR We can write a SCHEME or JAVA program for any of them!

11
PUSHDOWN AUTOMATA FINITE STATE CONTROL STACK (Last in, first out) INPUT

12
ε,ε → $ 0,ε → 0 1,0 → ε ε,$ → ε stringpoppush 0011 STACK$ 0011011 $0 11 $ 0 1

13
ε,ε → $ 0,ε → 0 1,0 → ε ε,$ → ε stringpoppush 001 STACK$$0$ 0 1 01001 PDA to recognize L = { 0 n 1 n | n ≥ 0 }

14
Definition: A (non-deterministic) PDA is a tuple P = (Q, Σ, Γ, , q 0, F), where: Q is a finite set of states Γ is the stack alphabet q 0 Q is the start state F Q is the set of accept states Σ is the input alphabet : Q Σ ε Γ ε → (Q Γ ε ) (Q) is the set of subsets of Q and Σ ε = Σ {ε}

15
ε,ε → $ 0,ε → 0 1,0 → ε ε,$ → ε q0q0 q1q1 q2q2 q3q3 Q = {q 0, q 1, q 2, q 3 }Γ =Σ = : Q Σ ε Γ ε → (Q Γ ε ) {0,1}{$,0,1} (q 1,1,0) = { (q 2,ε) } (q 2,1,1) =

16
EVEN-LENGTH PALINDROMES Σ = {a, b, c, …, z} ε,ε → $ ε,ε → εε,ε → ε , → ε, → ε ε,$ → ε q0q0 q1q1 q2q2 q3q3 ,ε → ,ε →

17
Build a PDA to recognize L = { a i b j c k | i, j, k ≥ 0 and (i = j or i = k) } ε,ε → $ b,a → ε ε,$ → ε q0q0 q5q5 q1q1 q3q3 a,ε → a q2q2 q4q4 ε,ε → ε q6q6 ε,$ → ε b,ε → ε c,a → ε c,ε → ε

18
Build a PDA to recognize… L = { x0y | |x| = |y| }

19
A → 0A1 A → B B → # CONTEXT-FREE GRAMMARS A variables terminals production rules start variable 0A1 00A11 00B11 00#11

20
→ → LIKE → UMM → YOU KNOW → GAG ME WITH A SPOON → ε → AS IF → WHATEVER VALLEY GIRL GRAMMAR → LOSER

21
→ | → LIKE | UMM → YOU KNOW | ε → GAG ME WITH A SPOON | AS IF | WHATEVER | LOSER VALLEY GIRL GRAMMAR

22
CONTEXT-FREE GRAMMARS A context-free grammar (CFG) is a tuple G = (V, Σ, R, S), where: V is a finite set of variables R is set of production rules of the form A → W, where A V and W (V Σ)* S V is the start variable Σ is a finite set of terminals (disjoint from V) G = { {S}, {0,1}, R, S }R = { S → 0S1, S → ε } L(G) = { 0 n 1 n | n ≥ 0 }

23
A → 0A1 A → B B → # CONTEXT-FREE GRAMMARS A variables terminals production rules start variable 0A1 00A11 00B11 00#11 uVw yields uvw if (V → v) ∈ R. A derives 00#11 in 4 steps.

24
WRITE A CFG FOR EVEN-LENGTH PALINDROMES S → S for all Σ S → ε

25
WRITE A CFG FOR THE EMPTY SET G = { {S}, Σ, , S }

26
GIVE A CFG FOR… L 3 = { strings of balanced parens } L 4 = { a i b j c k | i, j, k ≥ 0 and (i = j or j = k) }

27
VERY INTERESTING CFGs… http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html http://unununium.org/darcs/stackless-python/Grammar/Grammar

Similar presentations

OK

CSCI 2670 Introduction to Theory of Computing September 15, 2005.

CSCI 2670 Introduction to Theory of Computing September 15, 2005.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on eid festival Tough times never last but tough people do ppt online Ppt on leadership theories Ppt on different occupations in engineering Ppt on fdi in retail sector 2012 Ppt on charge-coupled device cameras Ppt on off the job training methods Ppt on trans-siberian railway Download ppt on corruption Ppt on carburetors