Loading in 5 sec....

Reverse of a Regular LanguagePowerPoint Presentation

Reverse of a Regular Language

- 209 Views
- Uploaded on
- Presentation posted in: General

Reverse of a Regular Language

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

Reverse of a Regular Language

Proof idea:

Construct NFA that accepts :

invert the transitions of the NFA

that accepts

Theorem:

The reverse of a regular language

is a regular language

Since is regular,

there is NFA that accepts

Example:

Invert Transitions

Make old initial state a final state

Add a new initial state

Resulting machine accepts

is regular

Grammars

- Grammars express languages
- Example: the English language

- A derivation of “the boy walks”:

- A derivation of “a dog runs”:

- Language of the grammar:

L = { “a boy runs”,

“a boy walks”,

“the boy runs”,

“the boy walks”,

“a dog runs”,

“a dog walks”,

“the dog runs”,

“the dog walks” }

Variable

or

Non-terminal

Terminal

Production

rule

- Grammar:
- Derivation of sentence :

- Grammar:
- Derivation of sentence :

- Other derivations:

- Language of the grammar

- Grammar

Set of variables

Set of terminal symbols

Start variable

Set of Production rules

- Grammar :

- Sentential Form:
- A sentence that contains
- variables and terminals
- Example:

Sentential Forms

sentence

- We write:
- Instead of:

- In general we write:
- If:

- By default:

Grammar

Derivations

Example

Grammar

Derivations

- Grammar :

Derivations:

- For a grammar
- with start variable :

String of terminals

- For grammar :

Since:

Linear Grammars

- Grammars with
- at most one variable at the right side
- of a production
- Examples:

Grammar :

- Grammar :

- All productions have form:
- Example:

or

- All productions have form:
- Example:

or

Regular Grammars

- A regular grammaris any
- right-linear or left-linear grammar
- Examples:

- Regular grammars generate regular languages
- Examples:

Regular Grammars GenerateRegular Languages

Languages

Generated by

Regular Grammars

Regular

Languages

Theorem - Part 1

Languages

Generated by

Regular Grammars

Regular

Languages

Any regular grammar generates

a regular language

Theorem - Part 2

Languages

Generated by

Regular Grammars

Regular

Languages

Any regular language is generated

by a regular grammar

Languages

Generated by

Regular Grammars

Regular

Languages

The language generated by

any regular grammar is regular

- Let be a right-linear grammar
- We will prove: is regular
- Proof idea: We will construct NFA
- with

- Grammar is right-linear

Example:

- Construct NFA such that
- every state is a grammar variable:

special

final state

- Add edges for each production:

NFA

Grammar

- A right-linear grammar
- has variables:
- and productions:

or

- We construct the NFA such that:
- each variable corresponds to a node:

special

final state

- For each production:
- we add transitions and intermediate nodes

………

- For each production:
- we add transitions and intermediate nodes

………

- Resulting NFA looks like this:

It holds that:

- Let be a left-linear grammar
- We will prove: is regular
- Proof idea:
- We will construct a right-linear
- grammar with

Since is left-linear grammar

the productions look like:

- Construct right-linear grammar

In :

In :

Construct right-linear grammar

In :

In :

- It is easy to see that:
- Since is right-linear, we have:

Regular

Language

Regular

Language

Regular

Language

Languages

Generated by

Regular Grammars

Regular

Languages

Any regular language is generated

by some regular grammar

Any regular language is generated

by some regular grammar

Proof idea:

Let be the NFA with .

Construct from a regular grammar

such that

- Since is regular
- there is an NFA such that

Example:

- Convert to a right-linear grammar

For any transition:

Add production:

variable

terminal

variable

For any final state:

Add production:

- Since is right-linear grammar
- is also a regular grammar
- with