Languages and Automata 2020 #8 Pumping lemma for context free languages, Pushdown automata
1. By the pumping lemma show that the following languages is not context free L={0k10k10k :k ≥0}
Solution: We choose the word x=0p10p10p1∈L. With this, we can pump only two blocks of 0s, so the pumped word will not be in L.
2. Is the language L={aibjck:i < j < k}
a) regular?
b) context free?
c) not context free?
Solution: The language is not context free, so it can not be regular either. We can use the pumping lemma to show that. Let x=apbp+1cp+2 ∈ L. If we pump the as or bs, we can use k > 1, and the pumped version of the word will not be in the language. If we pump the cs, then we use k = 0, so the number of cs won’t be greater than the number of bs, so the word is not in L. So L can not be pumped, so it is not context free.
3. For any two languages L1 andL2 letL=L1⊕L2 denote the language that consists of all words that belong to exactly one of L1 and L2.
Show that there exist L1 and L2 context free, such that a) L is context free
b) Lis not context free Solution:
a) L1 =∅, L2 = Σ∗. In this case L= Σ∗ is a context free language.
b)
4. The transition functionδ of a pushdown automaton is given by the following table state input stack new state stack
q a Z0 q AZ0
q b Z0 q BZ0
q a A q AA
q b A q ε
q a B q ε
q b B q BB
q ε Z0 qF ε
Let the start state be q0 and qF the only accept state. Explain how the automaton works. What is the accepted language?
Solution: The number of as and bs in the word are the same. The automaton counts in the stack the number of ss andbs. If there are more as and it reads an ait adds anA to the stack. If it reads a bthen it removes an A from the stack. And similarly, for b.
5. Describe a pushdown automaton for the language a) L1 ={aibjck:i+j =k}
b) L2 ={aibjck:j+k =i} c) L3 ={aibjck:i+k =j } Solution:
a)
state input stack new state stack
q0 a Z0 q0 AZ0
q0 a A q0 AA
q0 b A q1 AA
q1 b A q1 AA
q1 c A q2 ε
q2 c A q2 ε
q2 ε Z0 qF Z0
b)
state input stack new state stack
q0 a Z0 q0 AZ0
q0 a A q0 AA
q0 b A q1 ε
q1 b A q1 ε
q1 c A q2 ε
q2 c A q2 ε
q2 ε Z0 qF Z0
c)
state input stack new state stack
q0 a Z0 q0 AZ0
q0 a A q0 AA
q0 b A q1 ε
q1 b A q1 ε
q1 b Z0 q1 BZ0
q1 b B q1 BB
q1 c B q2 ε
q2 c B q2 ε
q2 ε Z0 qF Z0
6. Describe a pushdown automaton for the language L={aibjck :i=j or i=k}
Solution:
state input stack new state stack
q0 a Z0 q0 AZ0
q0 a A q0 AA
q0 b A q1 ε
q1 b A q1 ε
q1 c Z0 q2 Z0
q2 c Z0 q2 Z0
q2 ε Z0 qF Z0
q0 b A q1 A
q1 b A q1 A
q1 c A q2 ε
q2 c A q2 ε
7. Describe a pushdown automaton for the language L={0m1n: 1≤m < n <2m}
Solution:
state input stack new state stack
q0 0 Z0 qa AZ0
q0 0 Z0 qa AAZ0
qa 0 A qa AA
qa 0 A qa AAA
qa 1 A qb ε
qb 1 A qb ε
qb 1 Z0 qF Z0