Deterministic PDAs - DPDAs

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

Fall 2003Costas Busch - RPI1 Properties of Context-Free languages.
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
CS21 Decidability and Tractability
Prof. Busch - LSU1 Properties of Context-Free languages.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Courtesy Costas Busch - RPI1 Positive Properties of Context-Free languages.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
1 Converting NPDAs to Context-Free Grammars. 2 For any NPDA we will construct a context-free grammar with.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Costas Busch - RPI1 Positive Properties of Context-Free languages.
Fall 2003Costas Busch - RPI1 Decidable Problems of Regular Languages.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
Fall 2006Costas Busch - RPI1 Properties of Regular Languages.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Prof. Busch - RPI1 Decidable Problems of Regular Languages.
1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
1 A Non Context-Free Language (We will prove it at the next class)
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
1 Let L= { w= u v : u  {a, b}*, v  {c, d}* and |u|= |v|} 1.Design a context-free grammar that generates L. 2.Use your grammar and the construction from.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
CS 203: Introduction to Formal Languages and Automata
Costas Busch - LSU1 Properties of Context-Free languages.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.
Formal Languages, Automata and Models of Computation
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
Properties of Context-Free Languages
PDAs Accept Context-Free Languages
Properties of Regular Languages
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
PROPERTIES OF REGULAR LANGUAGES
Linear Bounded Automata LBAs
7. Properties of Context-Free Languages
NPDAs Accept Context-Free Languages
PDAs Accept Context-Free Languages
Chapter 7 PUSHDOWN AUTOMATA.
NPDAs Accept Context-Free Languages
Single Final State for NFA
DPDA Deterministic PDA
CSE322 PROPERTIES OF REGULAR LANGUAGES
Properties of Regular Languages
4. Properties of Regular Languages
Closure Properties of Context-Free languages
Elementary Questions about Regular Languages
Non-regular languages
Decidable Problems of Regular Languages
The Pumping Lemma for CFL’s
Properties of Context-Free languages
DPDA Deterministic PDA
… NPDAs continued.
Chapter 1 Regular Language
Applications of Regular Closure
NFAs accept the Regular Languages
Normal Forms for Context-free Grammars
Presentation transcript:

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 The language is not context-free Fact 1: 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 Modify Replace with 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 not necessarily context-free

Example 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: 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 transition NPDA

NPDA DFA transition transition NPDA

NPDA DFA initial state initial state Initial state NPDA

NPDA DFA final state final states final states NPDA

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