1 a non context-free language (we will prove it at the next class)
Post on 22-Dec-2015
224 views
TRANSCRIPT
14
We will show:
there is a context-free language
which is not deterministic context-free
(accepted by a NPDA)
(not accepted by a DPDA)
L
16
}{}{ 2nnnn babaL
The language is context-freeL
Context-free grammar for : L
21 | SSS
|11 baSS
|22 bbaSS
there is an NPDA that accepts L
17
}{}{ 2nnnn babaL
is not deterministic context-free
Theorem:
The language
(there is no DPDA that accepts ) L
18
Proof: Assume for contradiction that
}{}{ 2nnnn babaL
is deterministic context free
Therefore:
there is a DPDA that accepts M L
21
The language is not context-free
}{ nnn cbaL
}){}{( 2nnnn babaL
(we will prove later today that the union oftwo context-free languages is context-free)
Fact 2:
25
Since is accepted by a NPDA }{ nnn cbaL
it is context-free
Contradiction!
(since is not context-free)}{ nnn cbaL
26
Therefore:
}{}{ 2nnnn babaL
There is no DPDA that accepts
End of Proof
Not deterministic context free
28
Context-free languages are closed under: Union
1L is context free
2L is context free
21 LL
is context-free
Union
30
In general:
The grammar of the union has new start variableand additional production 21 | SSS
For context-free languageswith context-free grammarsand start variables
21, LL
21, GG
21, SS
21 LL S
31
Context-free languages are closed under: Concatenation
1L is context free
2L is context free
21LL
is context-free
Concatenation
32
Example
|11 baSS
|| 222 bbSaaSS
Concatenation
}{1nnbaL
}{2RwwL
21SSS }}{{ Rnn wwbaL
Language Grammar
33
In general:
The grammar of the concatenation has new start variableand additional production 21SSS
For context-free languageswith context-free grammarsand start variables
21, LL
21, GG
21, SS
21LLS
34
Context-free languages are closed under: Star-operation
L is context free*L is context-free
Star Operation
36
In general:
The grammar of the star operation has new start variableand additional production
For context-free languagewith context-free grammarand start variable
LGS
*L1S
|11 SSS
38
Context-free languagesare not closed under: intersection
1L is context free
2L is context free
21 LL
not necessarilycontext-free
Intersection
39
Example
}{1mnn cbaL
|
|
cCC
aAbA
ACS
Context-free:
}{2mmn cbaL
|
|
bBcB
aAA
ABS
Context-free:
}{21nnn cbaLL NOT context-free
Intersection
40
Context-free languagesare not closed under: complement
L is context free L not necessarilycontext-free
Complement
41
}{2121nnn cbaLLLL
NOT context-free
Example
}{1mnn cbaL
|
|
cCC
aAbA
ACS
Context-free:
}{2mmn cbaL
|
|
bBcB
aAA
ABS
Context-free:
Complement
43
The intersection of a context-free language and a regular languageis a context-free language
1L context free
2L regular
21 LL
context-free
44
1Lfor for 2LNPDA
1M
DFA
2M
Construct a new NPDA machinethat accepts
Machine Machine
M21 LL
context-free regular
M simulates in parallel and 1M 2M
48
M simulates in parallel and 1M 2M
M accepts string w if and only if
accepts string and w1M
accepts string w2M
)()()( 21 MLMLML