Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lfa:lab10-cfl-closures [2020/12/07 08:20]
lfa created
lfa:lab10-cfl-closures [2020/12/08 09:12] (current)
lfa
Line 1: Line 1:
-.+====== Context Free Languages ====== 
 + 
 +=== Context-Free Grammar to Pushdown Automata === 
 + 
 +** 1.** Consider the following CFG: 
 + 
 +$ S \leftarrow X\ |\ Y $ \\ 
 +$ X \leftarrow YXY\ |\ 0X\ |\ 0 $ \\ 
 +$ Y \leftarrow YY\ |\ 1\ |\ \epsilon $ 
 + 
 +//1.1// Write a PDA which accepts L(G) 
 + 
 +//1.2// Write a sequence of derivations which yeilds $ S\ \Rightarrow\ 110X1Y $ . What is it's corresponding sequence of transitions in the PDA? 
 + 
 +//1.3// In our PDA, $ (p, 111100, XZ0) \mapsto^* ​ (p, e, Z0) $. Write-down the steps. How is $ \alpha $ split into $ \alpha_1 ... \alpha_n $? \\ \\ 
 + 
 + 
 +=== Closure Properties of Context-Free Languages === 
 + 
 +**2.** Which of the following languages are Context-Free?​ Argue for your answer. 
 +  
 +//2.1.// $ L = \{a^{n}b^{2n}c^{2m}d^{m}\ |\ n, m \geq 0 \} $ \\ 
 + 
 +//2.2.// $ L = \{w \in \{a, b\}^*\ |\ each\ sequence\ of\ consecutive\ As\ is\ followed\ by\ the\ same\ number\ of\ Bs\} $ \\ 
 + 
 +//2.3.// $ L = \{a^{n}b^{2n}c^{m}\ |\ n, m \geq 0 \} \cap \{a^{n}b^{m}c^{2m}\ |\ n, m \geq 0 \} $ \\ 
 + 
 +//2.4.// $ L = \{w \in \{a, b\}^*\ |\ a\ and\ b\ can\ be\ matched\ in\ sequences,\ in\ any\ order \} $. Example : $ aabbbbaaaabb \in L $ \\ 
 + 
 +//2.5.// $ L = \{w \in \{a, b\}^*\ |\ w=a^nb^n \ and\ |w|\ \%\ 3\ =\ 0 \} $ \\ 
 + 
 +//2.6.// $ L = \{w \in \{a, b\}^*\ |\ \#​_{a}(w)=\#​_{b}(w) \ and\ no\ b\ should\ be\ followed\ by\ two\ a \} $ \\ 
 + 
 +//2.7.// Give an example of two context-free languages whose intersection is context-free. 
 + 
 + 
 +**3.** Show that the following are closed under CF languages:​ 
 + 
 +//3.1// Reversal \\ 
 + 
 +//3.2// $ init(L) = \{w\ \in\ \Sigma^*\ |\ \exists x\ such\ that\ wx\ \in\ L\}. $ //Hint//: Write a CNF grammar for init L, starting from a grammar for L.