INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
CS 3240: Languages and Computation Properties of Context-Free Languages.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CS21 Decidability and Tractability
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Introduction to Computability Theory
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
CS5371 Theory of Computation
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.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGRAMS 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.
1 Computer Language Theory Chapter 2: Context-Free Languages.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
CSCI 2670 Introduction to Theory of Computing September 15, 2005.
Context-free Languages
Context-free Languages Chapter 2. Ambiguity.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
Context-Free and Noncontext-Free Languages Chapter 13 1.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
Test # 2 Friday, November 2 nd Covers all of Chapter 2 Test # 2 will be 20% of final score (same as Test #1) Final Exam will be 40% of the final score.
Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
Non-Context-Free Languages Section 2.3 CSC 4170 Theory of Computation.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
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.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
C SC 473 Automata, Grammars & Languages Automata, Grammars and Languages Discourse 04 Context-Free Grammars and Pushdown Automata.
January 20, 2016CS21 Lecture 71 CS21 Decidability and Tractability Lecture 7 January 20, 2016.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Lecture 6: Context-Free Languages
 2004 SDU Lecture8 NON-Context-free languages.  2004 SDU 2 Are all languages context free? Ans: No. # of PDAs on  < # of languages on  Pumping lemma:
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Context-Free and Noncontext-Free Languages Chapter 13.
CSCI 2670 Introduction to Theory of Computing September 22, 2004.
Closed book, closed notes
Standard Representations of Regular Languages
Context-free Languages
Context-Free Grammars
Context-Free Languages
Chapter 2 Context-Free Language - 01
Intro to Theory of Computation
Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011

QUIZ 2 The regular pumping lemma says that… if w  L and |w| ≥ P, then Ǝ x,y,z so w = xyz and: (1) |xy| ≤ P (2) |y| > 0 (3) For every i ≥ 0, xy i z  L. Give a CFG for the language {a n b 2n : n ≥ 0 }: S → aSbb | ε A PDA transition function takes as input a state, an input symbol, and: a stack symbol If P is a PDA then L(P) is the set: { w | P accepts w } Let G = (V,Σ,R,S) be a CFG then R is the set of: Production rules

What are practical uses for PDAs? Why are pumping lemmas annoying? Buddhist temple, CFG, levitating during meditation? What will be on the upcoming midterm? WTF Implementation of PL? Context-Free Pumping Lemma? Why do I care about CNF? Where are we going with this? What does it mean for something to be context free? How does a CFG relate to a computer? What is your favorite topic in this class? Is there a rule for the CF pumping lemma like |xy|≤P? Is there a multi-stack PDA? How many more types of languages are there? PDA/CFG conversions? CNF Unit rule redundancy? Do we need to prove every case for the pumping lemma? Is this class graded on a curve?

I will be in my office: Today 4-5:30pm and Thurs. 9:00am-11:00am HW4 SOLUTIONS POSTED TOMORROW AT NOON.

An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x a string, |x| isthe length of x The unique string of length 0 will be denoted by ε and will be called the empty or null string NOTATION A language over Σ is a set of strings over Σ

Q = {q 0, q 1, q 2, q 3 } are states Σ = {0,1} is the alphabet  : 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, q0q0 q1q1 q3q3 M NFAs have “choices” --  : Q  Σ  P (Q), and accept on input w if there is a path from q 0 to a q a ∈ F.

DFA NFA Regular Language Regular Expression DEF

SOME LANGUAGES ARE NOT REGULAR! B = {0 n 1 n | n ≥ 0} is NOT regular! Suppose B is regular and let P be the pumping length. The string 0 P 1 P  B and has length at least P. So by the pumping lemma, there should be xyz = 0 P 1 P so that |xy| ≤ P, |y| > 0, and xyyz  B. But y must be only 0s (otherwise |xy| > P), so xyyz has at least P+1 “0”s (because |y| > 0) but only P “1”s. So xyyz  B, contradicting the pumping lemma. Therefore B is not regular.

ε,ε → $ 0,ε → 0 1,0 → ε ε,$ → ε stringpoppush A PDA accepts the string x if there is a path on input x and empty stack from q 0 to some q a 2 F. Following transition “a,b  c” reads “a” from the input, pops “b” off the stack, and pushes “c” onto it.

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

PARSE TREES A  0A1  00A11  00B11  00#11 A B 01# A A 01 Each node corresponds to a rule in the derivation. A string is derived ambiguously if it has ≥ 2 parse trees. A grammar is ambiguous if it derives a string ambiguously.

THE CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A → BC A → a S → ε B and C are not start variable a is a terminal S is the start variable Any variable A that is not the start variable can only generate strings of length > 0 Theorem: If G is in CNF, w  L(G) and |w| > 0, then any derivation of w in G has length ≤ 2|w| - 1

THE CONTEXT-FREE PUMPING LEMMA Let L be a context-free language Then there exists P such that For every w  L with |w| ≥ P 1. |vy| > 0 there exist uvxyz=w, where: 3. uv i xy i z  L for any i ≥ 0 2. |vxy| ≤ P { ww | w ∈ Σ* } is not regular!

USING THE PUMPING LEMMA Prove L = {w#w R | w ∈ {0,1}* and #1s = #0s} is not context-free Assume L is context-free. Then there is a pumping length P. No matter what P is, the string s = 0 P 1 P #1 P 0 P has |s| ≥ P and s ∈ L. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| ≤ P, 3) ∀ i, uv i xy i z ∈ L. s = 00…0011…11#11…1100…00 P P P P

USING THE PUMPING LEMMA Prove L = {w#w R | w ∈ {0,1}* and #1s = #0s} is not context-free Assume L is context-free. Then there is a pumping length P. No matter what P is, the string s = 0 P 1 P #1 P 0 P has |s| ¸ P and s 2 L. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| ≤ P, 3) ∀ i, uv i xy i z ∈ L. s = 00…0011…11#11…1100…00 P P P P vxy cannot be only in either half, since pumping would make one side of # longer than the other. # cannot be in v or y since pumping would add too many #s. So it must be in x. vxy since # is in x and |vxy| · P, neither v nor y can have 0s, and at least one must have a 1. Then uv 2 xy 2 z has more 1s than 0s and is not in L.

CONTEXT-FREE LANGUAGES REGULAR LANGUAGES NON-REGULAR NON-CFL FINAL JEOPARDY

A DFA for the language (ab ∪ ba)*

A regular expression for the set of strings accepted by the NFA: 0,1 1

A proof that the language { w  Σ*| w ≠ w R } is not regular.

The language accepted by the following PDA: ε,ε → $ 0,ε → 0 1,0 → ε ε,0 → ε

A CFG for the language { w # b n | |w| = n }.

Regular operations that the Context-Free Languages are closed under. DAILY DOUBLE

A class of strings in the language L = { 1 n #1 n | n ≥ 0} that contradicts the regular pumping lemma for each pumping length p.

A class of strings in the language {a n #a n #a n | n ≥ 0 } that contradicts the context-free pumping lemma for each pumping length p.

A proof that the language { a n #b m | m = n 2, n ≥ 0 } is not context-free.

TRUE