• Nem Talált Eredményt

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 = {0

N/A
N/A
Protected

Academic year: 2022

Ossza meg "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 = {0"

Copied!
3
0
0

Teljes szövegt

(1)

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.

(2)

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:

(3)

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

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

Further- more, Uralic languages share a lot of geo-political aspects: the national languages of the group—Finnish, Estonian and Hungarian—are small languages and only moder-

We thank the School of Computer Science (Charles University, Faculty of Mathematics and Physics) and Center of Excellence - Institute for Theoretical Computer Science

Muller context-free languages (MCFLs) are languages of countable words, that is, labeled countable linear orders, generated by Muller context-free grammars.. Equivalently, they are

We also present some explicit constructions in the proofs, which lead to a normal form of context-free grammars generating palindromic languages.. As the proofs progress, we will

It is straightforward that the non-looping version for this result also holds, i.e., non-looping tree-walking automata in universal acceptance mode recognize exactly the tree

It is shown that the following five classes of weighted languages are the same: (i) the class of weighted languages generated by plain weighted context-free grammars, (ii) the class

For each non-terminal, create new rules A → α, where α is the right hand side of the rules, where the right hand side is a non-terminal that can be reached from A in the

Write a regular expression for the following language over the alphabet {0,1}: The set of all strings with at most one pair of consecutive 0’s and at most one pair of consecutive