CS21 Decidability and Tractability

Slides:



Advertisements
Similar presentations
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Advertisements

Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
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.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
January 23, 2015CS21 Lecture 81 CS21 Decidability and Tractability Lecture 8 January 23, 2015.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
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.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Languages and Automata
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Pushdown Automata (PDAs)
Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
CHAPTER 1 Regular Languages
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
CS355 - Theory of Computation Regular Expressions.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
January 20, 2016CS21 Lecture 71 CS21 Decidability and Tractability Lecture 7 January 20, 2016.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Theory of Languages and Automata By: Mojtaba Khezrian.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
CSE 105 theory of computation
PROPERTIES OF REGULAR LANGUAGES
CS21 Decidability and Tractability
Pushdown Automata.
Intro to Theory of Computation
Summary.
Context-Free Grammars
Context-Free Languages
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Decidability and Tractability
CHAPTER 1 Regular Languages
Presentation transcript:

CS21 Decidability and Tractability Lecture 4 January 12, 2015 January 12, 2015 CS21 Lecture 4

Outline Pumping Lemma Pushdown Automata Context-Free Grammars and Languages January 12, 2015 CS21 Lecture 4

Regular expressions and FA Theorem: a language L is recognized by a FA iff L is described by a regular expr. Languages recognized by a FA are called regular languages. Rephrasing what we know so far: regular languages closed under 3 operations NFA recognize exactly the regular languages regular expressions describe exactly the regular languages January 12, 2015 CS21 Lecture 4

Limits on the power of FA Is every language describable by a sufficiently complex regular expression? If someone asks you to design a FA for a language that seems hard, how do you know when to give up? Is this language regular? {w : w has an equal # of “01” and “10” substrings} January 12, 2015 CS21 Lecture 4

Limits on the power of FA Intuition: FA can only remember finite amount of information. They cannot count languages that “entail counting” should be non-regular… Intuition not enough: {w : w has an equal # of “01” and “10” substrings} = 0Σ*0  1Σ*1 but {w: w has an equal # of “0” and “1” substrings} is not regular! January 12, 2015 CS21 Lecture 4

Limits on the power of FA How do you prove that there is no Finite Automaton recognizing a given language? January 12, 2015 CS21 Lecture 4

Non-regular languages Pumping Lemma: Let L be a regular language. There exists an integer p (“pumping length”) for which every w  L with |w|  p can be written as w = xyz such that for every i  0, xyiz  L , and |y| > 0, and |xy|  p. January 12, 2015 CS21 Lecture 4

Non-regular languages Using the Pumping Lemma to prove L is not regular: assume L is regular then there exists a pumping length p select a string w  L of length at least p argue that for every way of writing w = xyz that satisfies (2) and (3) of the Lemma, pumping on y yields a string not in L. contradiction. January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples Theorem: L = {0n1n : n  0} is not regular. Proof: let p be the pumping length for L choose w = 0p1p w = 000000000…0111111111…1 w = xyz, with |y| > 0 and |xy|  p. p p January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples 3 possibilities: w = 000000000…0111111111…1 in each case, pumping on y gives a string not in language L. x y z x y z x y z January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples Theorem: L = {w: w has an equal # of 0s and 1s} is not regular. Proof: let p be the pumping length for L choose w = 0p1p w = 000000000…0111111111…1 w = xyz, with |y| > 0 and |xy|  p. p p January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples 3 possibilities: w = 000000000…0111111111…1 first 2 cases, pumping on y gives a string not in language L; 3rd case a problem! x y z x y z x y z January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples recall condition 3: |xy|  p since w = 0p1p we know more about how it can be divided, and this case cannot arise: w = 000000000…0111111111…1 so we do get a contradiction. conclude that L is not regular. x y z January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples Theorem: L = {0i1j: i > j} is not regular. Proof: let p be the pumping length for L choose w = 0p+11p w = 000000000…01111111…1 w = xyz, with |y| > 0 and |xy|  p. p+1 p January 12, 2015 CS21 Lecture 4

Pumping Lemma Examples 1 possibility: w = 000000000…0111111111…1 pumping on y gives strings in the language (?) this seems like a problem… Lemma states that for every i  0, xyiz  L xy0z not in L. So L not regular. x y z January 12, 2015 CS21 Lecture 4

Proof of the Pumping Lemma Let M be a FA that recognizes L. Set p = number of states of M. Consider w  L with |w|  p. On input w, M must go through at least p+1 states. There must be a repeated state (among first p+1). y x z M January 12, 2015 CS21 Lecture 4

FA Summary A “problem” is a language A “computation” receives an input and either accepts, rejects, or loops forever. A “computation” recognizes a language (it may also decide the language). Finite Automata perform simple computations that read the input from left to right and employ a finite memory. January 12, 2015 CS21 Lecture 4

FA Summary The languages recognized by FA are the regular languages. The regular languages are closed under union, concatenation, and star. Nondeterministic Finite Automata may have several choices at each step. NFAs recognize exactly the same languages that FAs do. January 12, 2015 CS21 Lecture 4

FA Summary Regular expressions are languages built up from the operations union, concatenation, and star. Regular expressions describe exactly the same languages that FAs (and NFAs) recognize. Some languages are not regular. This can be proved using the Pumping Lemma. January 12, 2015 CS21 Lecture 4

Machine view of FA q0 input tape finite control 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 q0 finite control January 12, 2015 CS21 Lecture 4

Machine view of FA q3 input tape finite control 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 q3 finite control January 12, 2015 CS21 Lecture 4

Machine view of FA q1 input tape finite control 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 q1 finite control January 12, 2015 CS21 Lecture 4

Machine view of FA q2 input tape finite control etc… 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 q2 finite control etc… January 12, 2015 CS21 Lecture 4

A more powerful machine limitation of FA related to fact that they can only “remember” a bounded amount of information What is the simplest alteration that adds unbounded “memory” to our machine? Should be able to recognize, e.g., {0n1n: n ≥ 0} January 12, 2015 CS21 Lecture 4

Pushdown Automata q0 input tape finite control New capabilities: 1 1 1 1 1 1 1 1 q0 New capabilities: can push symbol onto stack can pop symbol off of stack (infinite) stack 1 1 : January 12, 2015 CS21 Lecture 4

Pushdown Automata q0 input tape finite control (infinite) stack : 1 1 1 1 1 1 1 1 1 1 q0 $ (infinite) stack : January 12, 2015 CS21 Lecture 4

Pushdown Automata q1 input tape finite control (infinite) stack : 1 1 1 1 1 1 1 1 1 1 q1 (infinite) stack $ : January 12, 2015 CS21 Lecture 4

Pushdown Automata q1 input tape finite control (infinite) stack : 1 1 1 1 1 1 1 1 1 1 q1 (infinite) stack $ : January 12, 2015 CS21 Lecture 4

Pushdown Automata q2 input tape finite control (infinite) stack : 1 1 1 1 1 1 1 1 1 1 q2 (infinite) stack $ : January 12, 2015 CS21 Lecture 4

Pushdown Automata q2 input tape finite control (infinite) stack : 1 1 1 1 1 1 1 1 q2 Note: often start by pushing $ marker onto stack so that we can detect “empty stack” $ (infinite) stack : January 12, 2015 CS21 Lecture 4

Pushdown Automata (PDA) We will define nondeterministic pushdown automata immediately potentially several choices of “next step” Deterministic PDA defined later weaker than NPDA Two ways to describe NPDA diagram formal definition January 12, 2015 CS21 Lecture 4

NPDA diagram tape alphabet Σ stack alphabet  transition label: (tape symbol read, stack symbol popped → stack symbol pushed) 0, ε → 0 ε, ε → $ start state 1, 0 → ε states accept states ε, $ → ε 1, 0 → ε transitions January 12, 2015 CS21 Lecture 4

NPDA operation Taking a transition labeled: a, b → c a  (Σ  {ε}) read a from tape, or don’t read from tape if a = ε pop b from stack, or don’t pop from stack if b = ε push c onto stack, or don’t push onto stack if c = ε January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 1 Stack contents: $ accepted Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 1 Stack contents: $ accepted January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 Stack contents: $ Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 Stack contents: $ January 12, 2015 CS21 Lecture 4

Example NPDA tape: 1 Stack contents: $ not accepted Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε tape: 1 Stack contents: $ not accepted January 12, 2015 CS21 Lecture 4

Example NPDA What language does this NPDA accept? Σ = {0, 1}  = {0, 1, $} 0, ε → 0 ε, ε → $ 1, 0 → ε ε, $ → ε 1, 0 → ε What language does this NPDA accept? January 12, 2015 CS21 Lecture 4

Formal definition of NPDA A NPDA is a 6-tuple (Q, Σ, , δ, q0, F) where: Q is a finite set called the states Σ is a finite set called the tape alphabet  is a finite set called the stack alphabet δ:Q x (Σ  {ε}) x (  {ε}) → (Q x (  {ε})) is a function called the transition function q0 is an element of Q called the start state F is a subset of Q called the accept states January 12, 2015 CS21 Lecture 4

Formal definition of NPDA NPDA M = (Q, Σ, , δ, q0, F) accepts string w  Σ* if w can be written as w1w2w3…wm  (Σ  {ε})*, and there exist states r0, r1, r2, …, rm, and there exist strings s0, s1, …, sm in ({ε})* r0 = q0 and s0 = ε (ri+1, b)  δ(ri, wi+1, a), where si = at, si+1 = bt for some t  * rm  F January 12, 2015 CS21 Lecture 4