1.02k likes | 1.14k Views
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
E N D
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010
ContentMidterm againContext-Free LanguagesPush-Down Automata, PDANPDA: Non-Deterministic PDAFormal Definitions for NPDAs NPDAs Accept Context-Free LanguagesConverting NPDA to Context-Free Grammar
Midterm • 5 out of 13 passed… • Many failed on basic definitions • Is something wrong with the course format? • Scheduled exercises • Don’t hesitate to ask for help! • Do labs, exercises etc. • Review lecture material before lectures • Strongly recommended to get a book if you don’t have one • It doesn’t get easier…
Concerning examination in the course: Exercises are voluntary Labs are voluntary Midterms are voluntary Lectures are voluntary… All of them are recommended! JFLAP demo http://www.cs.duke.edu/csed/jflap/movies
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:
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
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
Formal Definition Language of NPDAM Initial state Final state