INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



Advertisements
Similar presentations
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Advertisements

CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CSCI 2670 Introduction to Theory of Computing September 15, 2004.
CS21 Decidability and Tractability
CFG => PDA Sipser 2 (pages ).
CFG => PDA Sipser 2 (pages ). CS 311 Fall Formally… A pushdown automaton is a sextuple M = (Q, Σ, Γ, δ, q 0, F), where – Q is a finite set.
CS5371 Theory of Computation
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Finite State Machines Data Structures and Algorithms for Information Processing 1.
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
Tutorial CSC3130 : Formal Languages and Automata Theory Haifeng Wan ( )
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
CSCI 2670 Introduction to Theory of Computing September 15, 2005.
Context-free Languages
Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
CSCI 2670 Introduction to Theory of Computing September 23, 2004.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
Lecture 6: Context-Free Languages
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which.
CSCI 2670 Introduction to Theory of Computing September 22, 2004.
CSE 105 theory of computation
Context free grammar.
Intro to Theory of Computation
Intro to Theory of Computation
Context-free Languages
Context-Free Grammars
Context-Free Languages
فصل دوم Context-Free Languages
Chapter 2 Context-Free Language - 01
Pushdown automata The Chinese University of Hong Kong Fall 2011
Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

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:

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

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

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}

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.

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 =

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.

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?

Σ = {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!

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

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

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

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 Σ ε = Σ  {ε}

ε,ε → $ 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) = 

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

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,ε → ε

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

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

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

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

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 }

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.

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

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

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

VERY INTERESTING CFGs…