A Theoretical Analysis of Provable Compositional Generalization in Neural Networks: A Necessary and Sufficient Condition
Yuanpeng Li
cs.LG
May 5, 2025 · v2
cs.AI
TL;DR
The main necessary-and-sufficient theorem for provable compositional generalization is fully proved and machine-verified in Lean 4.
Abstract
Compositional generalization$\unicode{x2013}$the ability to systematically process novel combinations of known components$\unicode{x2013}$is a hallmark of human intelligence; however, its theoretical foundation in neural networks is not yet well understood. This paper establishes a necessary and sufficient condition for provable compositional generalization, precisely characterizing its boundary. Conceptually, the condition consists of two principles: (i) structural alignment, where a model's computational graph aligns with a task's true compositional hierarchy, and (ii) unambiguous minimized representations, where each component encodes adequate but not redundant information on the training data. The result is fully proved and machine-verified in Lean 4 and holds even in few-shot and one-shot regimes. The necessity direction establishes that provable compositional generalization cannot circumvent these requirements, while the sufficiency direction yields a unified inductive bias that jointly governs architectural design, training data properties, and regularization strategies. Building on this condition, we develop an example algorithmic approach, illustrate it through a controlled minimal example, and further demonstrate the condition on the SCAN jump task. All conclusions are derived mathematically without reliance on empirical validation. Our work provides a theoretical characterization of provable compositional generalization.
Problem
The theoretical foundation of compositional generalization in neural networks, meaning systematic handling of novel combinations of known components, is not well understood. The goal is to characterize exactly when a model provably generalizes compositionally.
Approach
Formal definitions are given for components, computational graphs, reference graph sets, structural alignment and representations. The main theorem states that provable compositional generalization holds if and only if the model has Aligned Structure–Unambiguous Minimized Representation (AS-UMR). Necessity is proved under a few assumptions and sufficiency without them, and both are formally verified in Lean 4. An example algorithm uses entropy-minimization regularization (Gaussian noise injection plus a power constraint) to obtain minimized representations.
Results
The condition holds even in few-shot and one-shot regimes and yields a unified inductive bias covering architecture, training data and regularization. It is illustrated on a minimal XOR task and the SCAN jump task. On the XOR example, the full model generalizes perfectly, while the baseline and every ablation reach 0.0 test accuracy.
| Model | Train | Test |
|---|
| Baseline | 1.0 ± 0.0 | 0.0 ± 0.0 |
| Full model | 1.0 ± 0.0 | 1.0 ± 0.0 |
| No structural alignment | 1.0 ± 0.0 | 0.0 ± 0.0 |
| Broken unambiguity | 1.0 ± 0.0 | 0.0 ± 0.0 |
| No entropy minimization | 1.0 ± 0.0 | 0.0 ± 0.0 |
Minimal XOR example: train/test accuracy