I have a language $L$, which is context-free, and I have $Pref(L)$, which is the language of all the prefixes of the words in $L$.
I need to prove that $pref(L)$ is context free only with closures or grammar.
I can use some help please...thanks in advance
P.S. I'm aware of the fact that there is a question about this language already, but I didn't manage to understand anything of it, and I don't have the permission to comment on the other question. Sorry in advance for duplicating.
I suggest that you take your grammar in Chomsky Normal Form and for every production $A \to BC$ add productions $A_\varepsilon \to BC_\varepsilon$ and $A_\varepsilon \to B_\varepsilon$. Also, for every $A \to a$ add the two rules $A_\varepsilon \to a$ and $A_\varepsilon \to \varepsilon$. Finally change the starting symbol to $S_\varepsilon$ and add $S_\varepsilon \to \varepsilon$. Now any derivation tree will have some $X_\varepsilon$ as the rightmost symbol and it will thus be possible to terminate it at any step.