# Inducing a context free grammar [closed]

I have a file containing a subset of possible strings from a context free language. I am looking for a mechanism to induce the grammar from this information. Is that possible?

• One grammar just lists each string as a production for the start symbol. There are clearly an infinite number of grammars that generate the given strings, so without any other criteria on the grammar, this problem just has no possible answer. Jul 23, 2015 at 2:34
• This question falls a bit short (cf vonbrand) but it's also way too broad; learning grammars in an entire research subfield!
– Raphael
Jul 24, 2015 at 6:15
• It wasn't obvious to me that having only positive examples is not enough to induce a grammar. The answer by @D.W. made that clear. While I understand that grammar induction itself is a sizable field of research, wouldn't this question and the accepted answer below help someone else like me overcome the same misconception? Jul 25, 2015 at 15:44

If you have only positive examples (strings that are in the language), in principle, no, you cannot infer the grammar. For all you can tell, the language might be $\Sigma^*$: no matter how many example strings you have, you'll never be able to rule that out as the language.