PDAs Accept Context-Free Languages

Slides:



Advertisements
Similar presentations
EcoTherm Plus WGB-K 20 E 4,5 – 20 kW.
Advertisements

Números.
Trend for Precision Soil Testing % Zone or Grid Samples Tested compared to Total Samples.
Trend for Precision Soil Testing % Zone or Grid Samples Tested compared to Total Samples.
AGVISE Laboratories %Zone or Grid Samples – Northwood laboratory
Trend for Precision Soil Testing % Zone or Grid Samples Tested compared to Total Samples.
Simplifications of Context-Free Grammars
Variations of the Turing Machine
ALAK ROY. Assistant Professor Dept. of CSE NIT Agartala
Reflection nurulquran.com.
EuroCondens SGB E.
Worksheets.
Slide 1Fig 26-CO, p.795. Slide 2Fig 26-1, p.796 Slide 3Fig 26-2, p.797.
Slide 1Fig 25-CO, p.762. Slide 2Fig 25-1, p.765 Slide 3Fig 25-2, p.765.
Sequential Logic Design
Addition and Subtraction Equations
By John E. Hopcroft, Rajeev Motwani and Jeffrey D. Ullman
David Burdett May 11, 2004 Package Binding for WS CDL.
1 When you see… Find the zeros You think…. 2 To find the zeros...
Create an Application Title 1Y - Youth Chapter 5.
Add Governors Discretionary (1G) Grants Chapter 6.
CALENDAR.
CHAPTER 18 The Ankle and Lower Leg
Introduction to Turing Machines
The 5S numbers game..
突破信息检索壁垒 -SciFinder Scholar 介绍
A Fractional Order (Proportional and Derivative) Motion Controller Design for A Class of Second-order Systems Center for Self-Organizing Intelligent.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Break Time Remaining 10:00.
The basics for simulations
Turing Machines.
PP Test Review Sections 6-1 to 6-6
TCCI Barometer March “Establishing a reliable tool for monitoring the financial, business and social activity in the Prefecture of Thessaloniki”
Dynamic Access Control the file server, reimagined Presented by Mark on twitter 1 contents copyright 2013 Mark Minasi.
TCCI Barometer March “Establishing a reliable tool for monitoring the financial, business and social activity in the Prefecture of Thessaloniki”
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
Progressive Aerobic Cardiovascular Endurance Run
Biology 2 Plant Kingdom Identification Test Review.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
TCCI Barometer September “Establishing a reliable tool for monitoring the financial, business and social activity in the Prefecture of Thessaloniki”
When you see… Find the zeros You think….
2011 WINNISQUAM COMMUNITY SURVEY YOUTH RISK BEHAVIOR GRADES 9-12 STUDENTS=1021.
Before Between After.
2011 FRANKLIN COMMUNITY SURVEY YOUTH RISK BEHAVIOR GRADES 9-12 STUDENTS=332.
Subtraction: Adding UP
Numeracy Resources for KS2
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Static Equilibrium; Elasticity and Fracture
Converting a Fraction to %
Resistência dos Materiais, 5ª ed.
Clock will move after 1 minute
Lial/Hungerford/Holcomb/Mullins: Mathematics with Applications 11e Finite Mathematics with Applications 11e Copyright ©2015 Pearson Education, Inc. All.
UNDERSTANDING THE ISSUES. 22 HILLSBOROUGH IS A REALLY BIG COUNTY.
1 Dr. Scott Schaefer Least Squares Curves, Rational Representations, Splines and Continuity.
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
1 Non Deterministic Automata. 2 Alphabet = Nondeterministic Finite Accepter (NFA)
Introduction Embedded Universal Tools and Online Features 2.
úkol = A 77 B 72 C 67 D = A 77 B 72 C 67 D 79.
Schutzvermerk nach DIN 34 beachten 05/04/15 Seite 1 Training EPAM and CANopen Basic Solution: Password * * Level 1 Level 2 * Level 3 Password2 IP-Adr.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
1 A Non Context-Free Language (We will prove it at the next class)
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
NPDAs Accept Context-Free Languages
PDAs Accept Context-Free Languages
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Presentation transcript:

PDAs Accept Context-Free Languages

Theorem: Context-Free Languages (Grammars) Languages Accepted by PDAs

Proof - Step 1: Context-Free Languages (Grammars) Languages Accepted by PDAs Convert any context-free grammar to a PDA with:

Proof - Step 2: Context-Free Languages (Grammars) Languages Accepted by PDAs Convert any PDA to a context-free grammar with:

Converting Context-Free Grammars to PDAs Proof - step 1 Converting Context-Free Grammars to PDAs

Context-Free Languages (Grammars) Languages Accepted by PDAs Convert any context-free grammar to a PDA with:

We will convert grammar to a PDA such that: simulates leftmost derivations of

Convert grammar to PDA Production in Terminal in

PDA computation Grammar leftmost derivation Simulates grammar variable

Example Grammar PDA

Grammar derivation PDA computation

Derivation: Input Time 0 Stack

Derivation: Input Time 0 Stack

Derivation: Input Time 1 Stack

Derivation: Input Time 2 Stack

Derivation: Input Time 3 Stack

Derivation: Input Time 4 Stack

Derivation: Input Time 5 Stack

Derivation: Input Time 6 Stack

Derivation: Input Time 7 Stack

Derivation: Input Time 8 Stack

Derivation: Input Time 9 Stack accept

In general, it can be shown that: Grammar generates string If and Only if PDA accepts Therefore

Therefore: For any context-free language there is a PDA that accepts Context-Free Languages (Grammars) Languages Accepted by PDAs

Converting PDAs to Context-Free Grammars Proof - step 2 Converting PDAs to Context-Free Grammars

Context-Free Languages (Grammars) Languages Accepted by PDAs Convert any PDA to a context-free grammar with:

We can convert PDA to a context-free grammar such that: simulates computations of with leftmost derivations

Modify the PDA so that at end it empties stack and has a unique accept state Empty stack PDA l ® , l ® , l ® , New accept state Old accept states

Deterministic PDAs - DPDAs

Deterministic PDA: DPDA Allowed transitions: (deterministic choices)

Allowed transitions: (deterministic choices)

Not allowed: (non deterministic choices)

DPDA example

Definition: A language is deterministic context-free if there exists some DPDA that accepts it Example: The language is deterministic context-free

Example of Non-DPDA (PDA)

Not allowed in DPDAs

PDAs Have More Power than DPDAs

It holds that: Deterministic Context-Free Languages (DPDA) Context-Free Languages PDAs Since every DPDA is also a PDA

We will actually show: Deterministic Context-Free Languages (DPDA) Context-Free Languages (PDA) We will show that there exists a context-free language which is not accepted by any DPDA

The language is: We will show: is context-free is not deterministic context-free

Language is context-free Context-free grammar for :

Theorem: The language is not deterministic context-free (there is no DPDA that accepts )

Proof: Assume for contradiction that is deterministic context free Therefore: there is a DPDA that accepts

DPDA with accepts accepts

DPDA with Such a path exists due to determinism

Context-free languages Fact 1: The language is not context-free Regular languages Context-free languages (we will prove this at a later class using pumping lemma for context-free languages)

Fact 2: The language is not context-free (we can prove this using pumping lemma for context-free languages)

We will construct a PDA that accepts: which is a contradiction!

DPDA Replace with Modify DPDA

A PDA that accepts Connect the final states of with the final states of

Since is accepted by a PDA it is context-free Contradiction! (since is not context-free)

Therefore: Is not deterministic context free There is no DPDA that accepts it End of Proof

Positive Properties of Context-Free languages

Union Context-free languages are closed under: Union is context free

Example Language Grammar Union

In general: For context-free languages with context-free grammars and start variables The grammar of the union has new start variable and additional production

Concatenation Context-free languages are closed under: Concatenation is context free is context free is context-free

Example Language Grammar Concatenation

In general: For context-free languages with context-free grammars and start variables The grammar of the concatenation has new start variable and additional production

Star Operation Context-free languages are closed under: Star-operation is context free is context-free

Example Language Grammar Star Operation

In general: For context-free language with context-free grammar and start variable The grammar of the star operation has new start variable and additional production

Negative Properties of Context-Free Languages

Intersection Context-free languages are not closed under: intersection is context free is context free not necessarily context-free

Example Context-free: Context-free: Intersection NOT context-free

Complement Context-free languages are not closed under: complement is context free not necessarily context-free

Example Context-free: Context-free: Complement NOT context-free

Intersection of Context-free languages and Regular Languages

The intersection of a context-free language and a regular language is a context-free language context free regular context-free

Machine Machine DFA for NPDA for regular context-free Construct a new NPDA machine that accepts simulates in parallel and

NPDA DFA transition transition NPDA transition

NPDA DFA transition NPDA transition

NPDA DFA initial state initial state NPDA Initial state

NPDA DFA final state final states NPDA final states

Example: context-free NPDA

regular DFA

context-free Automaton for: NPDA

In General: simulates in parallel and accepts string if and only if accepts string and accepts string

Therefore: is NPDA is context-free is context-free

Applications of Regular Closure

The intersection of a context-free language and a regular language is a context-free language Regular Closure context free regular context-free

An Application of Regular Closure Prove that: is context-free

We know: is context-free

We also know: is regular is regular

context-free regular (regular closure) context-free is context-free

Another Application of Regular Closure Prove that: is not context-free

Impossible!!! If is context-free Then context-free regular (regular closure) Then context-free regular context-free Impossible!!! Therefore, is not context free

Decidable Properties of Context-Free Languages

Membership Question: for context-free grammar find if string Membership Algorithms: Parsers Exhaustive search parser CYK parsing algorithm

Empty Language Question: for context-free grammar find if Algorithm: Remove useless variables Check if start variable is useless

Infinite Language Question: for context-free grammar find if is infinite Algorithm: 1. Remove useless variables 2. Remove unit and productions 3. Create dependency graph for variables 4. If there is a loop in the dependency graph then the language is infinite

Example: Infinite language Dependency graph