Loading in 5 sec....

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen UniversityPowerPoint Presentation

CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University

- 71 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University' - georgia-dodson

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### NPDAsNon-deterministic Push-Down Automata

### NPDAs Accept Context-Free Languages

### Converting Context-Free Grammarsto NPDAs

### Converting NPDAstoContext-Free Grammars

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

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 GrammarsGrammar

Variables

Terminal

symbols

Start

variables

Productions of the form:

Definition: Regular Grammars

Grammar

Variables

Terminal

symbols

Start

variables

Right or Left Linear Grammars. Productions of the form:

or

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.

stack

top

Replace

(An alternative is to start and finish with empty stack or a stack bottom symbol such as $)

- 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)

is the language accepted by the NPDA:

Another NPDA example

NPDAM

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.

states

States

Input

alphabet

Stack

start

symbol

Transition

function

Stack

alphabet

Formal DefinitionNon-Deterministic Pushdown Automaton NPDA

NPDAM

NPDAM

NPDAM

Context-Free

Languages

(Grammars)

Languages

Accepted by

NPDAs

Convert any context-free grammarGto a NPDA Mwith L(G) = L(M)

Context-Free

Languages

(Grammars)

Languages

Accepted by

NPDAs

Convert any NPDA M to a context-free grammarGwith L(M) = L(G)

What is the equivalent NPDA?

NPDA

A leftmost derivation:

The grammar simulates the machine

A derivation in Grammar

variables

terminals

Input processed

Stack contents

in NPDA M

Some Simplifications

- First we modify the NPDA so that
- It has a single final state qf and
- It empties the stack
- when it accepts the input

Original NPDA

Empty Stack

Second we modify the NPDA transitions.

All transitions will have form:

or

which means that each move

increases/decreases stack by a single symbol.

- Those simplifications do not affect generality of our argument.
- It can be shown that for any NPDA there exists an equivalent one having above two properties
- i.e.
- the equivalent NPDA with a single final state which empties its stack when it accepts the input, and which for each move increases/decreases stack by a single symbol.

Example of a NPDA in an appropriate form argument.

The Grammar Construction argument.

In grammarG

Stack symbol

Variables:

states

Terminals:

Input symbols of NPDA

For each transition: argument.

we add production:

Example argument.

Grammar production:

Grammar productions: argument.

Grammar production: argument.

Resulting Grammar argument.

Resulting Grammar, cont. argument.

Resulting Grammar, cont. argument.

Derivation of string argument.

Explanation argument.

By construction of Grammar:

if and only if

in the NPDA going from qito qj

the stack doesn’t change below

and A is removed from stack

Context-Free argument.

Languages

(Grammars)

Languages

Accepted by

NPDAs

We have shown the procedure to convert

any NPDA Mto a context-free

grammar G with L(M) = L(G)

which means

Example argument.(Sudkamp 8.1.2)

Language consisting solely of a’s or an equal number of a´s and b´s.

Download Presentation

Connecting to Server..