500 likes | 652 Vues
A Non Context-Free Language. (We will prove it at the next class). Non Context-free languages. Context-free languages. Regular languages. Deterministic PDAs DPDAs. DPDAs. Allowed:. Not allowed:. Allowed:. Something must be matched from the stack. Not allowed:. DPDA example.
E N D
A Non Context-Free Language (We will prove it at the next class)
Non Context-free languages Context-free languages Regular languages
DPDAs • Allowed:
Allowed: Something must be matched from the stack
The language is deterministic context-free
Definition: A language is deterministic context-free if some DPDA accepts it
We will show: there is a context-free language (accepted by a NPDA) which is notdeterministic context-free (not accepted by a DPDA)
Context-free grammar for : there is an NPDA that accepts The language is context-free
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
Fact 1: The language is not context-free (we will prove it at the next class)
Fact 2: The language is not context-free (we will prove later today that the union of two context-free languages is context-free)
We will construct a NPDA that accepts: Contradiction!
We modify Replace with Modified
The NPDA that accepts Modified Original
Since is accepted by a NPDA it is context-free Contradiction! (since is not context-free)
Therefore: There is no DPDA that accepts Not deterministic context free End of Proof
Union Context-free languages are closed under: Union is context free is context free 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
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
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 initial state initial state NPDA Initial state
NPDA DFA final state final states NPDA final states
simulates in parallel and accepts string if and only if accepts string and accepts string
Therefore: is context-free (since is NPDA) is context-free