INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Advertisements

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CFGs and PDAs Sipser 2 (pages ). Long long ago…
CSCI 2670 Introduction to Theory of Computing September 15, 2004.
CS21 Decidability and Tractability
CFGs and PDAs Sipser 2 (pages ). Last time…
CFG => PDA Sipser 2 (pages ).
1 Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli.
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.
Decidable languages Sipser 4.1 (pages ). CS 311 Mount Holyoke College 2 Hierarchy of languages All languages Turing-recognizable Turing-decidable.
CS5371 Theory of Computation
Applied Computer Science II Chapter 2 : Context-free languages Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
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
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
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 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
MATLAB objects using nested functions MathWorks Compiler Course – Day 2.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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 PROGAMS 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.
Context-free Grammars Example : S   Shortened notation : S  aSaS   | aSa | bSb S  bSb Which strings can be generated from S ? [Section 6.1]
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
Pushdown Automata (PDAs)
Context Free Grammars CIS 361. Introduction Finite Automata accept all regular languages and only regular languages Many simple languages are non regular:
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.
CS 461 – Sept. 19 Last word on finite automata… –Scanning tokens in a compiler –How do we implement a “state” ? Chapter 2 introduces the 2 nd model of.
Midterm 1 Breakdown >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7.
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 Hopcroft, Motawi, Ullman, Chap 5. Grammars Describes underlying rules (syntax) of programming languages Compilers (parsers) are based on such.
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.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
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 2670 Introduction to Theory of Computing September 23, 2004.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
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.
Theory of Languages and Automata By: Mojtaba Khezrian.
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.
Context free grammar.
Nondeterministic Finite Automata
Intro to Theory of Computation
Intro to Theory of Computation
Context-free Languages
Context-Free Grammars
Context-Free Languages
Midterm #2 — Review problems
Chapter 2 Context-Free Language - 01
Pushdown automata The Chinese University of Hong Kong Fall 2011
Context-Free Grammars
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 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  Σ ε  Γ ε → P(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 1 = { x0y | |x| = |y| } L 2 = { w | w  0 n 1 n for any n} ε,ε → $ 0,ε → 0 1, ε → ε σ, ε → ε ε,$ → ε q0q0 q1q1 q4q4 q6q6 0,ε → 0 1,0 → ε q2q2 q3q3 σ, ε → ε q5q5 ε, 0 → ε 0,ε → ε

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…

COMPILER MODULES LEXER PARSER SEMANTIC ANALYZER TRANSLATOR/INTERPRETER

PARSE TREES A  0A1  00A11  00B11  00#11 A B 01# A A 01

A Language is generated by a CFG  It is recognized by a PDA