TITLE: An analog of the Myhill-Nerode Theorem for context-free languages?
QUESTION [13 upvotes]: The Myhill-Nerode Theorem gives an exact characterization of the regular languages.  Given any language, one can check whether it meets the criteria of the Myhill-Nerode theorem to decide whether or not it is regular.  Note that this is stronger than the pumping lemma for regular languages, which gives a necessary (but not sufficient) condition for a language to be regular.
Is there an analogous result for context-free languages?  That is, is there a theorem that gives a necessary and sufficient condition for a language to be context-free?
Thanks!

REPLY [3 votes]: I posted this as an answer to this question on CS, but I think it is also relevant for this one.
There is a very nice characterization of context-free languages (credited to Wechler) in the paper by Berstel and Boasson, Towards an algebraic theory of context-free languages. Let me introduce a few definitions in order to state this result (Theorem 3.1 in the paper). 
The polynomial closure $Pol(\mathcal{L})$ of a class $\mathcal{L}$ of languages of $A^*$ is the set of all languages that are finite unions of products of the form $L_0a_1L_1 \dotsm a_nL_n$, where $L_0, ..., L_n \in \mathcal{L}$ and $a_1, ..., a_n \in A$.
An algebra is a class $\mathcal{A}$ of languages containing the language $\{1\}$ and such that $\mathcal{A} = Pol(\mathcal{A})$. It is finitely generated if $\mathcal{A} = Pol(\mathcal{F})$ for some finite set $\mathcal{F}$ of languages. It is stable if, for each $L \in \mathcal{A}$ and $u \in A^*$, the language $u^{-1}L = \{v \mid uv \in L\}$ also belongs to $\mathcal{A}$.
Note that it suffices to have $a^{-1}L \in \mathcal{A}$ for all $a \in A$.
Theorem. A language of $A^*$ is context-free if and only if it belongs to a finitely generated stable algebra.
See the article for illuminating examples and many nice consequences.