---
title: 'DreamCoder-ARC: Neurosymbolic ARC Solver'
url: https://www.emergentmind.com/topics/dreamcoder-arc
type: topic
---

# DreamCoder-ARC: Neurosymbolic ARC Solver

DreamCoder-ARC is a neurosymbolic, program synthesis-based system designed to address the Abstraction and Reasoning Corpus (ARC), a benchmark suite of visual reasoning tasks intended to probe broad generalization in artificial intelligence. By integrating programmatic abstraction (via library learning), neural-guided search, and domain-specific language (DSL) induction, DreamCoder-ARC offers a structured approach to solving ARC tasks. Its pipeline is further augmented with large language model (LLM) prompting and ensemble methods, resulting in state-of-the-art performance on a subset of ARC tasks and establishing a reproducible platform for future research [2110.11536][2402.03507].

## 1. System Overview and Wake-Sleep Architecture

At its core, DreamCoder-ARC implements a wake-sleep architecture adapted for ARC’s program synthesis formulation. The system consists of three primary phases:

- **Wake (Program Enumeration):** Programs in a typed, grid-centric DSL (PeARL) are enumerated to fit the input/output pairs defining an ARC task. Candidate solutions $p$ are sampled in order of increasing $-\log P_\text{library}(p)$, leveraging a joint probabilistic model:

  \[
  P(p, T) = P_\text{library}(p) \cdot \prod_{(x,y)\in T} \mathbb{1}[p(x) = y]
  \]
  where $P_\text{library}(p) \propto \exp(-|p|)$ is an MDL prior over the current DSL grammar.

- **Sleep-Compression (Abstraction Induction):** Solution programs (the “frontiers”) from wake are analyzed to identify common subexpressions. These are promoted to new, higher-order primitives, thereby expanding the DSL and biasing future searches toward compressed, reusable abstractions.

- **Dreaming Sleep (Neural Recognition Model Training):** A neural model $R_\theta$ guides future synthesis by learning a contextual grammar $G_\theta(p|T)$, which predicts the likelihood of rewrite rules or primitives appearing in solution programs conditioned on the task. Training is performed on “dreamed” (synthetically generated) tasks using an entropy-based objective,
  \[
  L(\theta) = \mathbb{E}_{(p^*, T)}[ -\log G_\theta(p^*|T) ] + \lambda\,\text{CE}(\text{used\_prims}(p^*), \sigma(Q(T)))
  \]
  which combines program likelihood and a binary classification loss over primitive usage for $Q$, the 3D recognition tensor output.

Each phase alternates in an iterative loop:
```python
Initialize DSL_library ← PeARL base primitives
Initialize recognition model θ (random)
for iteration = 1…N:
  # Waking: solve all ARC tasks via guided enumeration
  for each ARC task T:
    frontier[T] ← Enumerate programs p ∼ G_θ(p|T) sorted by –log P_library(p)
      stopping when p(T.inputs)=T.outputs or timeout
  # Abstraction sleep: induce new primitives
  new_primitives ← FindCommonSubexpr(frontier)
  DSL_library ← DSL_library ∪ new_primitives
  Update P_library from DSL_library
  # Dreaming sleep: recognition model update
  dreamed_batch ← HelmholtzSample(DSL_library)
  Optimize θ on L(θ) over dreamed_batch for M steps
end for
```
[2402.03507]

## 2. Domain-Specific Language: PeARL

DreamCoder-ARC’s effectiveness is predicated on the expressiveness and structure of its DSL, PeARL (Perceptual Abstraction & Reasoning Language). PeARL captures functional, type-safe manipulations over grid representations prevalent in ARC.

- **Types:** 
  - `grid` (rectangular subimages with spatial metadata)
  - `colour` (int-valued, with $0$ as background)
  - `pos`, `size` (coordinate/shape tuples)
  - `count` (integer for arithmetic)
  - `list[T]` (homogeneous, e.g., `list[grid]`)

- **Primitives:** 
  - *Rigid Transforms:* rotate90, rot180, flipX, swapXY
  - *Cropping & Embedding:* leftHalf, rightHalf, mirrorY, ic_embed
  - *Color Manipulation:* topCol, filterCol, eraseCol, invert
  - *Morphology:* fillHoles, makeBorder
  - *Splits & Reductions:* split4, split8, pickMaxSize, pickUnique
  - *Higher-Order:* mapSplit8, mkList

**Program Example:**
```python
@dsl.primitive
def topCol(g: Grid) -> Colour: ...
@dsl.primitive
def filterCol(c: Colour, g: Grid) -> Grid: ...
```
Type signatures: `topCol: grid → colour`, `filterCol: colour → grid → grid`, yielding composite programs such as:
$$\lambda \$0. \operatorname{filterCol}(\operatorname{topCol} \$0, \$0)$$
which selects the most common color in the input grid.

PeARL is explicitly constructed with typing rules such that only well-typed functional compositions are permitted, significantly constraining and structuring the combinatorial search space [2402.03507][2110.11536].

## 3. Neural-Guided and Bidirectional Search Algorithms

DreamCoder-ARC employs a neural-guided, bidirectional search methodology modeled after human approaches. The agent constructs a graph $G = (V, E)$ where:

- **Nodes $V$:** Grid values are either *grounded* (produced by a known subprogram) or *ungrounded* (output to be synthesized).
- **Edges $E$:** Operator applications in one of three modes:
    - *Forward:* Ordinary functional application from inputs to outputs.
    - *Inverse:* Deductive reasoning to infer potential inputs for a desired output using known function inverse semantics.
    - *Conditional-Inverse:* If some arguments are known, deduce the remainder.

Neural guidance leverages a deep set aggregation of CNN-embedded grid states, with a learned policy $\pi_\theta(f, m, v_1, ..., v_k | G_t)$ over operators, modes, and node arguments. Training combines supervised traces and policy-gradient reinforcement on synthetic (dreamed) expansions, utilizing a reward structure:
- $+1$ if the target node is grounded (solution found)
- $-1$ penalty for invalid actions to prune dead-ends

Mathematically, the policy is:
\[
\pi_\theta(a_t | s_t) = \text{softmax}_a\, Q_\theta(s_t, a)
\]
with cross-entropy and RL updates optimizing program synthesis paths [2110.11536].

## 4. Empirical Evaluation and Results

DreamCoder-ARC is evaluated across multiple domains:

- **ARC Symmetry Tasks:** On a curated set of 18 symmetry/mirroring ARC problems, the bidirectional agent in a restricted DSL solved 14/18, matching forward-only search.
- **24-Game Arithmetic Puzzles:** With four numbers and basic arithmetic operations, bidirectional search significantly outperformed forward-only (e.g., for depth-4, 85.3% vs 67.0% puzzles solved).
- **Double-and-Add Tasks:** Bidirectional agent achieved 100% test accuracy after one epoch of supervised training; forward-only failed to generalize at all even after 50 epochs.

Ablation experiments established that:
- Library learning (abstraction induction) alone increased ARC symmetry problems solved from 16 to 22 after four compression cycles.
- Bidirectional neural guidance consistently dominated forward-only baselines in arithmetic settings.

A table from [2402.03507] summarizes LLM and DreamCoder ARC coverage:

| Model         | ARC-Easy (Aug) | ARC-Hard (Aug) |
|---------------|:--------------:|:--------------:|
| DreamCoder    |      70        |      18        |
| GPT-4         |      85        |      32        |

Overlap is partial: only 37% of “easy” tasks solved by GPT-4 were also solved by DreamCoder, illustrating differing strengths.

## 5. LLM Prompting and Ensemble Strategies

ARC task serialization techniques allow modern LLMs (GPT-3, GPT-4, LLaMA) to be prompted in both completion and chat modalities. Grid inputs are tokenized row-wise; multiple orientation augmentations (original, transposed, rotated) counteract LLM biases. Deterministic, greedy decoding ensures reproducibility, with up to three guesses permitted per test grid.

LLM solutions cover distinct subsets of ARC tasks. Ensemble analysis employs weighted-voting, with DreamCoder, GPT-4, and IceCuber each contributing multiple solutions weighted by empirical solver confidence. Combined, this ensemble achieves:

| System Combination         | ARC-Easy | ARC-Hard |
|---------------------------|----------|----------|
| IceCuber + DreamCoder + GPT-4 |  228/400 (57.0%)  | 161/400 (40.3%) |

This combination substantially outperforms any single constituent system [2402.03507].

## 6. Limitations and Future Directions

While DreamCoder-ARC demonstrates nontrivial progress, scaling to the full 400-task ARC evaluation remains beyond reach for current instantiations. Key constraints are:

- **DSL Expressiveness:** Many ARC problems require object detection, novel visual primitives, or sophisticated counting that are absent from the hand-engineered DSL.
- **Search Complexity:** Even bidirectional heuristics can permit exponential search graph growth due to branching in inverse expansions.
- **Abstraction/Inverse Gap:** Newly induced abstractions lack automatic inverse semantics, impeding immediate integration into bidirectional reasoning.
- **Learning Efficiency:** Recognition model training, while accelerating search, remains data-intensive relative to the sample efficiency observed in human ARC solvers.

Planned future improvements include:
- Automated synthesis of inverses for newly induced abstractions
- Type-directed pruning in search to reduce invalid inverses
- Incorporation of neural–symbolic perceptual pipelines in lieu of hand-crafted encoders
- DSL extensions for richer visual/combinatorial reasoning
- Meta-learning and curriculum approaches for rapid adaptation with minimal I/O pairs [2110.11536][2402.03507].

## 7. Software and Reproducibility: the arckit Library

To advance reproducible research, DreamCoder-ARC is accompanied by the open-source **arckit** Python library. arckit provides:

- Full ARC-Easy and ARC-Hard datasets with metadata
- Pythonic APIs (`TaskSet`, `Task`) for data access
- Utilities for exact-match accuracy computation under Kaggle rules (up to three guesses)
- Prompt templates for diverse LLM platforms
- Vector-graphics visualization for I/O grids and predictions
- An interactive command-line interface (`arctask`)

Installation is available via:
```bash
pip install arckit
```
with detailed documentation and code at https://github.com/mxbi/arckit [2402.03507].

---

DreamCoder-ARC establishes a reproducible, neurosymbolic framework that integrates abstraction-driven program synthesis, neural search guidance, and large language model prompting for the challenging ARC benchmark, significantly advancing the state of systematic machine reasoning.

Source: https://www.emergentmind.com/topics/dreamcoder-arc