1.07k likes | 1.28k Views
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2012. Content Context-Free Languages Push-Down Automata, PDA NPDA: Non-Deterministic PDA Formal Definitions for NPDAs NPDAs Accept Context-Free Languages Converting NPDA to Context-Free Grammar.
E N D
CDT314FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2012
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
Context-Free Languages Based on C Busch, RPI, Models of Computation
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:
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 is 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 information (but it is not random access!). 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 either start and finish with empty stack or with a stack bottom symbol such as $)
stack top Push input
stack top Pop input
input stack top No Change
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, depending on convention)
Example NPDA is the language accepted by the NPDA:
Example NPDA NPDAM (Even-length palindromes) Example :aabaaabbblbbbaaabaa
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
A computation example For convenience we write
Formal Definition Language of NPDAM Initial state Final state
Example NPDAM