Full Transcript

**University of Science and Technology** **Faculty of Computer Science and Information Technology** [Computer Science Department] Subject: Theory of Computation Lecture (10) Instructor: Prof. Noureldien Abdelrahman Date 11-1-2023 PUSHDOWN AUTOMATA In this section we introduce a new type of co...

**University of Science and Technology** **Faculty of Computer Science and Information Technology** [Computer Science Department] Subject: Theory of Computation Lecture (10) Instructor: Prof. Noureldien Abdelrahman Date 11-1-2023 PUSHDOWN AUTOMATA In this section we introduce a new type of computational model called ***pushdown automata***. These automata are like nondeterministic finite automata but have an extra component called a ***stack***. The stack provides additional memory beyond the finite amount available in the control. The stack allows pushdown automata **to recognize some non-regular languages.** Pushdown automata are equivalent in power to context-free grammars. This equivalence is useful because it gives us two options for proving that a language is context free. We can give either a context-free grammar generating it or a pushdown automaton recognizing it. The following figure is a schematic representation of a finite automaton. The **control** represents the **[states and transition function]**, the tape **[contains the input string]**, and the arrow represents the input head, pointing at the **[next input symbol to be read]**. With the addition of a stack component we obtain a schematic representation of a pushdown automaton, as shown in the following figure. A pushdown automaton (PDA) can write symbols on the stack and read them back later. Writing a symbol "pushes down" all the other symbols on the stack. At any time the symbol on the top of the stack can be read and removed. The remaining symbols then move back up. Writing a symbol on the stack is often referred to as ***pushing*** the symbol, and removing a symbol is referred to as ***popping*** it. A stack is valuable because it can hold an unlimited amount of information. Recall that a finite automaton is unable to recognize the language {0n1n\|n \_ 0} because it cannot store very large numbers in its finite memory. A PDA is able to recognize this language because it can use its stack to store the number of 0s it has seen. Thus the unlimited nature of a stack allows the PDA to store numbers of unbounded size. The following informal description shows how the automaton for this language works. \"Read symbols from the input. As **[each 0 is read, push it onto the stack]**. As soon **as 1s are seen, pop a 0 off the stack for each 1 read**. If reading the input is finished exactly when the stack becomes empty of 0s, accept the input. If the stack becomes empty while **[1s remain or if the 1s are finished while the stack still contains 0s or if any 0s appear in the input following 1s, reject the input]**.**\"** We focus on nondeterministic pushdown automata because these automata are equivalent in power to context-free grammars. **Formal Definition of Pushdown Automation** The formal definition of a pushdown automaton is similar to that of a finite automaton, except for the stack. The machine may use different alphabets for its input and its stack, so now we specify both an input alphabet ∑ and a stack alphabet ┌. The domain of the transition function is. Thus the current state, next input symbol read, and top symbol of the stack determine the next move of a pushdown automaton. Either symbol may be €, causing the machine to move without reading a symbol from the input or without reading a symbol from the stack. The function ϭ can indicate this action by returning a member of Q together with a member of┌~€~ , that is, a member of Q × ┌~€~. Putting it all together, our transition function ϭ takes the form We can also use a state diagram to describe a PDA, as in Figures blow. Such diagrams are similar to the state diagrams used to describe finite automata, modified to show how the PDA uses its stack when going from state to state. We write "a,b → c" to signify that when the machine is reading an **a** from the input, it may replace the symbol **b** on the top of the stack with a **c**. Any of a, b, and c may be €. If a is €, the machine may make this transition without reading any symbol from the input. If b is €, the machine may make this transition without reading and popping any symbol from the stack. If c is €, the machine does not write any symbol on the stack when going along this transition. This PDA as shown **[above is able to get the same effect by initially placing a special symbol \$ on the stack]**. Then if it ever sees the \$ again, it knows that the stack effectively is empty. Subsequently, when we refer to testing for an empty stack in an informal description of a PDA, we implement the procedure in the same way. Similarly, PDAs cannot test explicitly for having reached the end of the input string. This PDA is able to achieve that effect bec**ause the accept state takes effect only when the machine is at the end of the input**. Thus from now on, we assume that PDAs can test for the end of the input

Use Quizgecko on...
Browser
Browser