If I have a CFL, can I define a regular substitution to make it a RL?
For example, if I have the language $\{a^nb^n \mid n\ge0\}:$
Define $h(a)=a$ , $h(b)=b$, then $h(L)={a^*}$ , am I right?
Thanks!
If I have a CFL, can I define a regular substitution to make it a RL?
For example, if I have the language $\{a^nb^n \mid n\ge0\}:$
Define $h(a)=a$ , $h(b)=b$, then $h(L)={a^*}$ , am I right?
Thanks!
No,by your defined substitution CFLs remains CFLs.
For example, $\{a^nb^n \mid n\ge0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL. But when every symbol converges to single image then your language forcefully becomes regular (as @rici answer) which is really very bad way of thinking because by the definition homomorphism of CFLs is CFLs.
N. B.- One thing remember substitution for DCFLs are not closed in general (for example) but substitution for CFLs(NCFLs) are closed always.
Yes, you can.
For instance: with language $L = \{a^nb^n \mid n\ge0\}$ and mapping $h(\epsilon)=\epsilon, h(a)=a, h(b)=a$ (which I think is what you meant to write), $h(L) = (aa)^*$.
What is more: every context-free language on a single-symbol alphabet is regular, so a mapping that maps every symbol to the same symbol always produces a regular language.
However, as user19121278 points out, not every mapping will.
For instance: the identity mapping ($h(\epsilon)=\epsilon, h(a)=a, h(b)=b$ for alphabet $\{a,b\}$) maps every language to itself, so it will never map a non-regular language onto a regular one.