Knowledge Refactoring for Inductive Program Synthesis

Sebastijan Dumancic, Tias Guns, Andrew Cropper

Abstract

Inductive Logic Programming (ILP) systems often suffer from a "knowledge explosion" where the accumulation of background knowledge leads to massive search spaces and degraded performance. This paper introduces Knorf, a system designed to automatically refactor an agent's knowledge base into a compact, non-redundant form. By treating knowledge restructuring as a constraint optimization problem, Knorf enables ILP systems to learn up to four times more accurately and twice as fast.

Introduction: The Knowledge Explosion Problem

In machine learning, background knowledge (BK) is a double-edged sword. While it is essential for solving complex tasks, simply accumulating facts—a process known as learning by accretion—eventually leads to a "knowledge explosion." As the knowledge base grows, the search space for new solutions becomes massive, causing AI agents to slow down or fail to find the right answer—a classic challenge in lifelong learning.

Humans manage this complexity by restructuring their knowledge into higher-level abstractions. Instead of memorizing every individual brick placement, we develop concepts like "pillars" or "arches" to simplify how we think about building. Most AI agents lack this ability to reorganize their internal logic. The authors tackle this by defining the knowledge refactoring problem: how to transform a complex, redundant logic program into a compact, efficient one without changing its functional behavior.

Methods: The Knorf System

Knorf treats knowledge restructuring as a Constraint Optimization Problem (COP). The system follows a four-step pipeline to clean up the AI's "brain":

  1. Unfolding: Knorf starts by "unfolding" the existing knowledge base into its most primitive components (e.g., breaking down a "house" into individual brick placements).
  2. Predicate Invention: It searches for recurring patterns within these primitives and "invents" new helper functions (predicates) that represent these patterns.
  3. Folding: It rewrites the original program using these new, higher-level abstractions.
  4. Optimization: Because there are many ways to rewrite a program, Knorf uses a CP-SAT solver to find the "optimal" version—the one that minimizes the total number of literals (size) and reduces overlap between rules (redundancy).
Knorf transforms complex 'unfolded' clauses into simplified 'folded' versions using invented predicates.

Crucially, Knorf ensures syntactic equivalence, meaning the refactored knowledge is guaranteed to produce the exact same results as the original, just more elegantly. Even with a 90-minute timeout, the solver usually finds a "good enough" solution (within 10% of the optimum) in less than a minute.

Evaluation and Key Results

The researchers evaluated Knorf on two distinct domains: synthetic Lego Structures, where the agent learns to build complex 3D models, and String Transformations, a set of 130 real-world tasks (similar to Excel's FlashFill) where the agent manipulates text.

Examples of structural patterns in the Lego domain, where refactoring simplifies the representation of complex builds.
  • Massive Accuracy Gains: In string transformation tasks, Metagol (a state-of-the-art ILP system) achieved four times higher predictive accuracy when using Knorf-refactored knowledge compared to the raw version.
  • Significant Speedups: Refactoring reduced learning times by roughly 20% to 50% across different tasks.
  • Scalability: Knorf proved particularly effective as the knowledge base grew. While standard systems choked on 1,000+ background tasks, the refactored system maintained steady performance.

Discussion: The Power of Abstraction

The study highlights that restructuring is often more important than forgetting. Previous approaches often tried to improve performance by deleting "irrelevant" knowledge. Knorf shows that how knowledge is organized is the real bottleneck. By inventing new predicates, Knorf effectively reduces the "depth" of the search tree for the learner.

Furthermore, the paper reinforces the idea of compression as learning bias. A smaller, cleaner knowledge base restricts the hypothesis space, making it much more likely that the learner will stumble upon the correct solution quickly. Future work may explore when to trigger this heavy optimization process in real-time scenarios and how to optimize for human-centric qualities like readability or modularity, making AI logic easier for humans to audit.

Summary updated

BibTeX
@inproceedings{dumancic2021knowledge,
  author = {Sebastijan Dumancic and Tias Guns and Andrew Cropper},
  title = {{Knowledge Refactoring for Inductive Program Synthesis}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i8.16893},
}
Figure