Abstract
Learning Context-Free Grammars (CFGs) from examples is a foundational challenge in computer science, complicated by the theoretical impossibility of identifying correct grammars from positive examples alone in the limit. This paper proposes a novel framework that treats grammar induction as a classical planning task. By representing grammar rules as recursive planning programs, the authors leverage off-the-shelf planners to discover complex structures from as few as one or two example strings. The approach is shown to be efficient and versatile, handling tasks ranging from simple recursive languages to basic natural language models.
Introduction
The ability to learn the underlying rules of a language—its grammar—is a core problem in AI. Context-Free Grammars are particularly significant due to their ability to represent nested structures, such as balanced parentheses or nested control flow in programming. However, inductive learning of CFGs is notoriously difficult. Traditional methods often require large datasets or a mix of positive and negative examples. This work addresses the challenge of learning from minimal data by framing the search for grammar rules as a strategic planning problem.
Methodology: Grammar as Planning Programs
The authors utilize Generalized Planning to solve the induction problem. Instead of searching for a linear sequence of actions, the goal is to find a planning program—a set of procedures that can solve multiple instances of a problem.
Key aspects of the compilation include:
- PDDL Translation: The grammar-learning task is translated into a Planning Domain Definition Language (PDDL) problem where "actions" correspond to defining lines of a grammar rule.
- Non-Determinism: To handle the non-deterministic nature of CFGs (where a symbol can expand into multiple sequences), the authors introduce a
chooseinstruction. - Recursion: Non-terminal symbols are represented as recursive procedure calls within the planning program.
A candidate grammar is validated only if the planner can successfully use it to parse every input string in the training set. This unified framework allows the same underlying model to perform generation (learning rules), recognition (parsing), and production (generating strings).
Experimental Evaluation
The method was evaluated across six synthetic domains: $A^n B^n$, balanced parentheses (single and multiple types), binary and decimal arithmetic expressions, and a simplified English grammar. Using the Fast Downward planner (LAMA-2011), the system demonstrated remarkable efficiency and data economy.
Key Results
- Efficiency: Simple grammars like $A^n B^n$ were learned in under 0.5 seconds. Even the English grammar was induced in approximately 3.6 seconds.
- Minimal Data: The system correctly identified underlying grammars from just one or two example strings in several domains.
- Scalability: Once learned, the recursive programs could parse strings requiring trees up to 92 levels deep, proving the robustness of the discovered rules.
Discussion and Future Work
While the planning-based approach is highly effective for small-data induction, it is sensitive to the search space bounds (e.g., maximum rule length). If bounds are too loose, the search space expands significantly. Additionally, the current model relies solely on positive examples, which may lead to over-generalization. Future work aims to incorporate negative examples to refine the learned grammars and to extend the framework to handle "lifted" variables for more complex natural language processing.
Conclusion
By treating grammars as recursive computer programs, this research provides a powerful new lens for inductive logic programming and language learning. The use of classical planning allows for the discovery of compact, logical rules from minimal evidence, bridging the gap between symbolic reasoning and linguistic structure discovery.
Summary updated