1.09k likes | 1.21k Views
CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
E N D
CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010
ContentContext-Free LanguagesPush-Down Automata, PDANPDA: Non-Deterministic PDAFormal Definitions for NPDAs NPDAs Accept Context-Free LanguagesConverting NPDA to Context-Free Grammar
Non-regular languages Context-Free Languages Regular Languages
stack automaton Context-Free Languages Context-Free Grammars Pushdown Automata (CF grammars are defined as generalized Regular Grammars)
is string of variables and terminals Definition: Context-Free Grammars Grammar Variables Terminal symbols Start variables Productions of the form:
is string of terminals Definition: Regular Grammars Grammar Variables Terminal symbols Start variables Right or Left Linear Grammars. Productions of the form: or
Pushdown Automaton - PDA Input String Stack States
The Stack A PDA can write symbols on stack and read them later on. POP reading symbol PUSH writing symbol All access to the stack only on the top! (Stack top is written leftmost in the string, e.g. yxz) A stack is valuable as it can hold an unlimitedamount of (certain kind of) information. The stack allows pushdown automata to recognize some non-regular languages.
The States Pop old- reading stack symbol Push new - writing stacksymbol Input symbol
input stack top Replace (An alternative is to start and finish with empty stack or a stack bottom symbol such as $)
stack top Push input
stack top Pop input
input stack top No Change
Example 3.7 Salling: A PDA for simple nested parenthesis strings Time 0 Input Stack
Example 3.7 Time 1 Input Stack
Example 3.7 Time 2 Input Stack
Stack Example 3.7 Time 3 Input
Stack Example 3.7 Time 4 Input
Stack Example 3.7 Time 5 Input
Example 3.7 Time 6 Input Stack
Example 3.7 Time 7 Input Stack
A string is accepted if: • All the input is consumed • The last state is a final state • Stack is in the initial condition • (either: empty (when we started with empty stack), • or: bottom symbol reached, or similar)
Example NPDA is the language accepted by the NPDA:
Example NPDA NPDAM (Even-length palindromes)
Pushing Strings Pop symbol Input symbol Push string
Example input pushed string stack top Push
Another NPDA example NPDAM
Execution Example Time 0 Input Stack Current state
Time 1 Input Stack
Time 2 Input Stack
Time 3 Input Stack
Time 4 Input Stack
Time 5 Input Stack
Time 6 Input Stack
Time 7 Input Stack accept
Transition function new state current state current stack top new stack top current input symbol An unspecified transition function is to the null set and represents a dead configuration for the NPDA.
Final states States Input alphabet Stack start symbol Transition function Stack alphabet Formal Definition Non-Deterministic Pushdown Automaton NPDA
Instantaneous Description Current stack contents Current state Remaining input
Example Instantaneous Description Input Time 4: Stack
Example Instantaneous Description Input Time 5: Stack
We write Time 4 Time 5