Complexity and Computability Theory I Lecture #11 Instructor: Rina Zviel-Girshin Lea Epstein.

Slides:



Advertisements
Similar presentations
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
Advertisements

Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Pushdown Automata CPSC 388 Ellen Walker Hiram College.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
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,
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.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4 Updated by Marek Perkowski.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
Grammars, Languages and Finite-state automata Languages are described by grammars We need an algorithm that takes as input grammar sentence And gives a.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
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.
Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Push-down Automata Section 3.3 Fri, Oct 21, 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
Complexity and Computability Theory I Lecture #2 Rina Zviel-Girshin Leah Epstein Winter
Lecture # 22. PDA of language {a n b n : n=0,1,2,3, …}
Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein.
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.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Formal Languages, Automata and Models of Computation
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Push Down Automata Chapter 14. Introduction We have seen different types of languages so far –Regular Languages –Nonregular Languages –Context Free Languages.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
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,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
Lecture # 21.
Formal Languages, Automata and Models of Computation
CSE 105 theory of computation
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
PDA’s - A new format for FAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata.
Pushdown Automata.
Complexity and Computability Theory I
Non Deterministic Automata
Pushdown automata a_introduction.htm.
CS21 Decidability and Tractability
CSE 105 theory of computation
ReCap Chomsky Normal Form, Theorem regarding CNF, examples of converting CFG to be in CNF, Example of an FA corresponding to Regular CFG, Left most and.
… NPDAs continued.
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

Complexity and Computability Theory I Lecture #11 Instructor: Rina Zviel-Girshin Lea Epstein

Rina Overview Models and limitations Examples Nondeterministic PDA Examples Equivalence of PDA’s models

Rina Finite automata A finite automaton has a huge limitation. It can count only by changing states. So the highest number FA can remember is not more than number of it's states. This limitation confined the class of languages that FA can recognize to a rather small category - that of regular languages.

Rina Turing machine Infinite memory can allow us recognition of larger class of languages. If we put no constrains on the use of this memory, i.e. the automaton can read and write in any location in the memory, then we have the most potent automaton - Turing machine.

Rina Power of TM We claim that Turing machine (TM) can perform any computation the most powerful computer can.

Rina The stack model If we add to FA an unlimited memory but limit the use of it we get a machine which is stronger than FA but less powerful than TM. Our limitation - the memory will be a stack. We can read/write only at the top of the stack, obliterating the previous content.

Rina The stack model (cont.) We still have states to remember the previous contents (if we wish to do so). But as the number of states is finite we can remember only finite contents while our stack is infinite.

Rina Pushdown automata Informally a pushdown automata (PDA) is a FA+stack. To remember or to count we write to the stack and read afterwards when we need the information.

Rina Example For example the following language can be recognized by PDA but not FA. L = {a i b i | i>0} The basic idea of recognition: remembering a's by pushing it to the stack comparing the number of b's to the number of a's by popping one a for each b.

Rina Example (cont.) If the stack was emptied before the end of input - we had more b's than a's. If the stack was not emptied at the end of input - we had more a's than b's. The automaton will accept a word if at exactly the end of input the stack is emptied for the first time.

Rina Example (cont.) It gets stuck and rejects the word if the two events - –end of input and –the first time stack becomes empty - are not simultaneous.

Rina Acceptance by PDA There are several models of PDA with different acceptance policies. All are equivalent. –acceptance by an empty stack –acceptance using accepting states –acceptance by an empty stack and accepting states

Rina Acceptance by an empty stack The automaton will accept a word if exactly at the end of input the stack is emptied for the first time. All states are the same, there are no accepting states.

Rina Acceptance using accepting states The automaton will accept a word if at exactly the end of input the automaton is in accepting state. Whether the stack is empty or not at that time has no relevance.

Rina Acceptance by an empty stack and accepting states The automaton will accept a word if three events happen simultaneously: –the end of input –the stack is emptied for the first time –automaton is in accepting state.

Rina Transition function in PDA There are two differences between the transition functions of PDA and FA. In PDA we move using –A state, –A letter of input and –A letter of stack The transition function output is a state and a letter or string to be written into the stack.

Rina Formal definition of PDA A pushdown automaton is a 6-tuple (Q, , , , q0, F) where: Q – a finite set of states  - a finite input alphabet  - a finite stack alphabet  : Q  (  U  )    P(Q   *) q0  Q the start state F – a finite set of accepting states.

Rina The possible stack transformations Consider different possibilities of transition function:  (q, ,X) = (q', Y) where  (q - current state,  - input letter, X - top of the stack) = (q' - next state, Y - string to write into the stack)

Rina Popping the stack Popping the stack:  (q, ,X) = (q',  ) write an empty word to the stack, i.e. deleting the X at the top of the stack and moving the top pointer one cell down.

Rina No change No change:  (q, ,X) = (q', X) write the same letter to the stack, i.e. not changing the X at the top of the stack and not moving the top pointer

Rina Add to the stack Add to the stack:  (q, ,X) = (q', W 1..W n X) write the same letter to the stack and above it write a string, i.e. not changing the X at the top of the stack, but adding any number of letters above in the same one transition and moving the top pointer as needed

Rina Change the stack Change the stack:  (q, ,X) = (q', W 1..W n ) delete the letter X in the stack and instead write a string, i.e. changing the X at the top of the stack into any number of letters above in the same one transition and moving the top pointer as needed

Rina Bottom of the stack symbol The acceptance model we will use will be by emptying the stack. In this model of acceptance the PDA is stuck immediately if the stack is empty. Therefore the PDA can't start with an empty stack.

Rina Bottom of the stack symbol Therefore we will assume that at the commencement of the computation, the stack already includes one symbol - a special "bottom of the stack symbol". There are many possible notations for the symbol, such as $, ┤. We will use the letter Z for the "bottom of the stack symbol".

Rina Example Construct a PDA to recognize: L = {a i b i | i>0} We will use the empty stack model.

Rina Example Construct a PDA to recognize: L = {wcw R |w  {a,b}*} We will use the empty stack model.

Rina Example L = {a i b j | i >0 and j=i+5} Construct a PDA to recognize: We will use the empty stack model.

Rina Deterministic PDA A PDA is called deterministic if”f it holds the following two conditions: for each q  Q, a  {  } and X  –|  (q,a,X)|  1 for each q  Q and X  –if  (q, ,X)  –then for each   (q, ,X)= 

Rina Deterministic PDA Informally A PDA is called non-deterministic if there exist at least two transitions from the current state q and stack top X: –one with  (  -transition) and –another with .

Rina Example of ND PDA Construct a PDA to recognize: L = {ww R |w  {a,b}*} We will use the empty stack model

Rina Example of ND PDA Construct a PDA to recognize: L = {a i b j c i+j | i,j  0} We will use the empty stack model. The basic idea: push a’s and b’s to the stack and than pop the stack top symbol for each c letter.

Rina L = {a i b j c i+j | i,j  0}

Rina Example Construct a PDA to recognize: L = {a i b j | i,j>0} We will use a finite state model.

Rina Equivalent form of acceptance The empty stack PDA equivalent to the final state PDA The basic idea: We will use the empty stack PDA model during the computation and on the last stage we will produce  -transition to the final state.

Rina Algorithm Given PDA=(Q, , , , q0, ∅ ) Convert it to FS PDA=(QU{s,f}, ,  U{Y}, , s, F={f}) 1.Create a new start state s and a new final state f. 2.Create a new bottom of the stack symbol: Y.

Rina Algorithm(cont.) 3.Connect a new start state s to the old start state q0 by an edge labeled ,Y; ZY that means  (s, ,Y)=(q0,ZY) 4.Connect each state of the PDA to the new final state f and label the edges with the expression ,Y; Y.

Rina L={a} Given an empty stack automaton: Construct an equivalent final-state automaton.

Rina L={a} The resulting finite-state automaton:

Rina Equivalent form of acceptance The final-state PDA is equivalent to the empty stack PDA The basic idea: We will use a finite state PDA model during the computation and on the last stage we will produce  -transition to empty the stack state - by popping everything from the stack.

Rina Algorithm Given PDA=(Q, , , , q0, F) Convert it to ESPDA=(QU{s,f}, ,  U{Y}, , s, ∅ ) 1. Create a new start state s and a new “empty state” f. 2. Create a new bottom of the stack symbol: Y.

Rina Algorithm(cont.) 3. Connect a new start state s to the old start state q0 by an edge labeled ,Y; ZY that means  (s, ,Y)=(q0,ZY) 4. Connect each final state of the PDA to the new empty state f and label the edges with the expression ,A;  where A means any symbol of the stack, including Z and Y. 5. Add new edges from f to f labeled as in step 4:  (f, ,A)=(f,  ) for every A in .

Rina L={a} Given a finite-state automaton: Construct an equivalent empty stack automaton.

Rina L={a} The resulting automaton:

Rina Any Questions?