Reverse of a regular language
This presentation is the property of its rightful owner.
Sponsored Links
1 / 75

Reverse of a Regular Language PowerPoint PPT Presentation


  • 178 Views
  • Uploaded on
  • Presentation posted in: General

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. Proof. Since is regular, there is NFA that accepts. Example:.

Download Presentation

Reverse of a Regular Language

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


Reverse of a regular language

Reverse of a Regular Language


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


Proof

Proof

Since is regular,

there is NFA that accepts

Example:


Reverse of a regular language

Invert Transitions


Reverse of a regular language

Make old initial state a final state


Reverse of a regular language

Add a new initial state


Reverse of a regular language

Resulting machine accepts

is regular


Grammars

Grammars


Grammars1

Grammars

  • Grammars express languages

  • Example: the English language


Reverse of a regular language

  • A derivation of “the boy walks”:


Reverse of a regular language

  • A derivation of “a dog runs”:


Reverse of a regular language

  • 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” }


Notation

Notation

Variable

or

Non-terminal

Terminal

Production

rule


Another example

Another Example

  • Grammar:

  • Derivation of sentence :


Reverse of a regular language

  • Grammar:

  • Derivation of sentence :


Reverse of a regular language

  • Other derivations:


Reverse of a regular language

  • Language of the grammar


More notation

More Notation

  • Grammar

Set of variables

Set of terminal symbols

Start variable

Set of Production rules


Example

Example

  • Grammar :


More notation1

More Notation

  • Sentential Form:

  • A sentence that contains

  • variables and terminals

  • Example:

Sentential Forms

sentence


Reverse of a regular language

  • We write:

  • Instead of:


Reverse of a regular language

  • In general we write:

  • If:


Reverse of a regular language

  • By default:


Example1

Example

Grammar

Derivations


Reverse of a regular language

Example

Grammar

Derivations


Another grammar example

Another Grammar Example

  • Grammar :

Derivations:


More derivations

More Derivations


Language of a grammar

Language of a Grammar

  • For a grammar

  • with start variable :

String of terminals


Example2

Example

  • For grammar :

Since:


A convenient notation

A Convenient Notation


Linear grammars

Linear Grammars


Linear grammars1

Linear Grammars

  • Grammars with

  • at most one variable at the right side

  • of a production

  • Examples:


A non linear grammar

A Non-Linear Grammar

Grammar :


Another linear grammar

Another Linear Grammar

  • Grammar :


Right linear grammars

Right-Linear Grammars

  • All productions have form:

  • Example:

or


Left linear grammars

Left-Linear Grammars

  • All productions have form:

  • Example:

or


Regular grammars

Regular Grammars


Regular grammars1

Regular Grammars

  • A regular grammaris any

  • right-linear or left-linear grammar

  • Examples:


Observation

Observation

  • Regular grammars generate regular languages

  • Examples:


Regular grammars generate regular languages

Regular Grammars GenerateRegular Languages


Theorem

Theorem

Languages

Generated by

Regular Grammars

Regular

Languages


Reverse of a regular language

Theorem - Part 1

Languages

Generated by

Regular Grammars

Regular

Languages

Any regular grammar generates

a regular language


Reverse of a regular language

Theorem - Part 2

Languages

Generated by

Regular Grammars

Regular

Languages

Any regular language is generated

by a regular grammar


Proof part 1

Proof – Part 1

Languages

Generated by

Regular Grammars

Regular

Languages

The language generated by

any regular grammar is regular


The case of right linear grammars

The case of Right-Linear Grammars

  • Let be a right-linear grammar

  • We will prove: is regular

  • Proof idea: We will construct NFA

  • with


Reverse of a regular language

  • Grammar is right-linear

Example:


Reverse of a regular language

  • Construct NFA such that

  • every state is a grammar variable:

special

final state


Reverse of a regular language

  • Add edges for each production:


Reverse of a regular language

NFA

Grammar


In general

In General

  • A right-linear grammar

  • has variables:

  • and productions:

or


Reverse of a regular language

  • We construct the NFA such that:

  • each variable corresponds to a node:

special

final state


Reverse of a regular language

  • For each production:

  • we add transitions and intermediate nodes

………


Reverse of a regular language

  • For each production:

  • we add transitions and intermediate nodes

………


Reverse of a regular language

  • Resulting NFA looks like this:

It holds that:


The case of left linear grammars

The case of Left-Linear Grammars

  • Let be a left-linear grammar

  • We will prove: is regular

  • Proof idea:

  • We will construct a right-linear

  • grammar with


Reverse of a regular language

Since is left-linear grammar

the productions look like:


Reverse of a regular language

  • Construct right-linear grammar

In :

In :


Reverse of a regular language

Construct right-linear grammar

In :

In :


Reverse of a regular language

  • It is easy to see that:

  • Since is right-linear, we have:

Regular

Language

Regular

Language

Regular

Language


Proof part 2

Proof - Part 2

Languages

Generated by

Regular Grammars

Regular

Languages

Any regular language is generated

by some regular grammar


Reverse of a regular language

Any regular language is generated

by some regular grammar

Proof idea:

Let be the NFA with .

Construct from a regular grammar

such that


Reverse of a regular language

  • Since is regular

  • there is an NFA such that

Example:


Reverse of a regular language

  • Convert to a right-linear grammar


In general1

In General

For any transition:

Add production:

variable

terminal

variable


Reverse of a regular language

For any final state:

Add production:


Reverse of a regular language

  • Since is right-linear grammar

  • is also a regular grammar

  • with


  • Login