Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lfa:lab10-cfl-closures [2020/12/07 18:14]
lfa
lfa:lab10-cfl-closures [2020/12/08 09:12] (current)
lfa
Line 11: Line 11:
 //1.1// Write a PDA which accepts L(G) //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.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 $? +//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 === === Closure Properties of Context-Free Languages ===
  
-== **2.** Which of the following languages are Context-Free?​ Argue for your answer. ​==+**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.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.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.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.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.5.// $ L = \{w \in \{a, b\}^*\ |\ w=a^nb^n \ and\ |w|\ \%\ 3\ =\ 0 \} $ \\
  
-**2.6.** $ L = \{w \in \{a, b\}^*\ |\ w=a^nb^n ​\ and\ |w|\ \%3=\} $ \\+//2.6.// $ L = \{w \in \{a, b\}^*\ |\ \#_{a}(w)=\#​_{b}(w) ​\ and\ nobshouldbefollowedby\ two\ a \} $ \\
  
-**2.7.** Give an example of two context-free languages whose intersection is context-free.+//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.** Show that the following are closed under CF languages:
  
-**2.1.** +//3.1// Reversal ​\\
- +
-$ S \leftarrow aA | A $ \\ +
-$ A \leftarrow aA | B $ \\ +
-$ B \leftarrow bB | \epsilon $ +
- +
-**2.2.** +
- +
-$ S \leftarrow AS | \epsilon $ \\ +
-$ A \leftarrow 0A1 | 01 | B $\\ +
-$ B \leftarrow B1 | \epsilon $ +
- +
-**2.3.** +
- +
-$ S \leftarrow ASB | BSA | \epsilon $\\ +
-$ A \leftarrow aA | \epsilon $\\ +
-$ B \leftarrow bB | \epsilon $ +
- +
-**3.** Write an ambiguous grammar for $ L(a^*) $. +
- +
-=== Regular Grammars === +
- +
-**4.** Is the language described by the following grammar regular? If so, write a regular expression for it. +
- +
-$ S \leftarrow aA $\\ +
-$ A \leftarrow aA | B $\\ +
-$ B \leftarrow Bb | \epsilon $ +
- +
-**5.** Write a regular expression for the language described by: +
- +
-$ S \leftarrow aX $\\ +
-$ X \leftarrow bY | S $\\ +
-$ Y \leftarrow aX | bS | \epsilon $ +
- +
-**6.** Write a regular grammar for $ L((0 \cup 1^*)^*01^*) $. +
- +
-=== Chomsky Normal Form ===  +
- +
-**7.** Remove "​$ ​\epsilon ​\text{-rules} $" from the following grammar: +
- +
-$ A \leftarrow \epsilon | B $\\ +
-$ B \leftarrow b $\\ +
-$ B \leftarrow ABC | BAC $\\ +
-$ C \leftarrow AC | c$ +
- +
-**8.** Remove the "unit rules" from the previous grammar, after "$ \epsilon \text{-rules} $" have been removed. +
- +
-**9.** Apply the CNF conversion rules to the solution for **1.1.** Does the accepted language stay the same? +
  
 +//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.