RecurrReason / BLOCK_WORLD.md
gmannem's picture
Update BLOCK_WORLD.md
d714593 verified
|
Raw
History Blame Contribute Delete
7.69 kB
# Block World
**Rearrange blocks in stacks from initial to goal configuration**
---
## Overview
Block World is a classical planning puzzle that tests sequential reasoning and dependency analysis. The puzzle involves uniquely labeled blocks (A, B, C, etc.) arranged in K stacks, where the objective is to rearrange blocks from an initial configuration to a specified goal configuration.
### Difficulty Rating: ⭐⭐ (Moderate)
---
## 📊 Statistics
| Metric | Value |
|--------|-------|
| **Total Puzzles** | 849 |
| **Total Moves** | 5,827 |
| **Training Puzzles (N=1-7)** | 549 |
| **Test Puzzles (N=8-10)** | 300 |
| **Difficulty Parameter** | N (number of blocks) |
| **Number of Stacks** | K = 3 |
| **Solution Length** | L(N) = O(N) (linear) |
| **Transition Locality** | O(1) - only check top of stacks |
---
## 🎯 Puzzle Rules
### Objective
Move blocks from the **initial configuration** to the **goal configuration** following movement constraints.
### Constraints
1. **Top Block Movement**: Only the topmost block from any stack can be moved
2. **Valid Placement**: A block can only be placed:
- On an empty stack position, OR
- On top of another block
### Why Block World is Interesting
Block World is the **most learnable** puzzle in the RecurrReason benchmark for three key reasons:
1. **O(1) Transition Locality**: Verifying whether a move is legal requires checking only the top of two stacks (source and destination), independent of total problem size
2. **Linear Solution Length**: L(N) = O(N), meaning solution length grows linearly with difficulty
3. **Dense Training Signal**: All 549 training puzzles share the same movement grammar, providing consistent learning opportunities
---
## 📋 State Representation
States are represented as **lists of K lists**, where each inner list represents one stack containing blocks ordered from **bottom to top**.
### Format
```python
[['B'], [], ['A', 'C']]
```
This represents:
- **Stack 0**: Block B (bottom)
- **Stack 1**: Empty
- **Stack 2**: Block A (bottom), Block C (top)
### Move Representation
```python
['C', 2, 0]
```
This represents: **Move block C from stack 2 to stack 0**
Format: `[block_name, source_stack_index, destination_stack_index]`
---
## 🖼️ Example Puzzle
![Block World Example](https://github.com/gowravmannem/Recurrent-Reasoning-on-Puzzles/blob/main/assets/block_world.png?raw=true)
### Example Trajectory
**Initial State**: `[['B'], [], ['A', 'C']]`
**Goal State**: `[['B'], ['A'], ['C']]`
**Optimal Solution Length**: 3 moves
**Step-by-step solution:**
| Step | Current State | Next State | Move | Description |
|------|--------------|-----------|------|-------------|
| 0 | `[['B'], [], ['A', 'C']]` | `[['B', 'C'], [], ['A']]` | `['C', 2, 0]` | Move C from stack 2 to stack 0 |
| 1 | `[['B', 'C'], [], ['A']]` | `[['B', 'C'], ['A'], []]` | `['A', 2, 1]` | Move A from stack 2 to stack 1 |
| 2 | `[['B', 'C'], ['A'], []]` | `[['B'], ['A'], ['C']]` | `['C', 0, 2]` | Move C from stack 0 to stack 2 |
| 3 | `[['B'], ['A'], ['C']]` | `[['B'], ['A'], ['C']]` | `['_', '_', '_']` | Goal reached! |
**Note**: The final row with `['_', '_', '_']` indicates puzzle completion (sentinel move).
---
## 📁 CSV Column Descriptions
### Columns
| Column | Type | Description |
|--------|------|-------------|
| `N` | int | Number of blocks in the puzzle (difficulty parameter) |
| `K` | int | Number of stacks (always 3 in this dataset) |
| `start_state` | string | Initial configuration of all stacks |
| `goal_state` | string | Target configuration to achieve |
| `current_state` | string | State before this move |
| `next_state` | string | State after applying this move |
| `move` | string | Action taken: `[block, source_stack, dest_stack]` |
| `num_moves` | int | Total number of moves in the optimal solution |
### Data Format
Each row represents one **move** in a solution trajectory. A complete puzzle solution consists of multiple rows (one per move) plus a final row indicating completion.
**Example CSV rows:**
```csv
N,K,start_state,goal_state,current_state,next_state,move,num_moves
3,3,"[['B'],[],['A','C']]","[['B'],['A'],['C']]","[['B'],[],['A','C']]","[['B','C'],[],['A']]","['C',2,0]",3
3,3,"[['B'],[],['A','C']]","[['B'],['A'],['C']]","[['B','C'],[],['A']]","[['B','C'],['A'],[]]","['A',2,1]",3
3,3,"[['B'],[],['A','C']]","[['B'],['A'],['C']]","[['B','C'],['A'],[]]","[['B'],['A'],['C']]","['C',0,2]",3
3,3,"[['B'],[],['A','C']]","[['B'],['A'],['C']]","[['B'],['A'],['C']]","[['B'],['A'],['C']]","['_','_','_']",3
```
---
## 💡 Usage Tips
### For Model Training
1. **Start with Block World**: It's the most learnable puzzle—ideal for validating your training pipeline
2. **Use full trajectories**: Train on complete state→action→next_state sequences
3. **Implement early stopping**: Monitor validation accuracy, stop when plateaus
4. **Try curriculum learning**: Train progressively from N=1 → N=7
### For Evaluation
```python
from datasets import load_dataset
# Load Block World
dataset = load_dataset("gmannem/RecurrReason", "block_world")
# Evaluation metrics to track:
# 1. Success Rate: % of puzzles solved correctly
# 2. Move Validity: % of generated moves that are legal
# 3. Optimality Gap: (|solution| - |optimal|) / |optimal|
# 4. Termination: Reaches goal within 2×optimal steps?
def evaluate_trajectory(model, example):
"""
Autoregressive rollout evaluation.
Start from initial state, generate next states until:
- Goal reached (success!)
- Invalid move generated (constraint violation)
- Loop detected (repeated state)
- Horizon exceeded (2× optimal length)
"""
current = example['start_state']
goal = example['goal_state']
visited = set()
steps = 0
max_steps = 2 * example['num_moves']
while steps < max_steps:
# Generate next state
next_state = model.predict(current, goal)
# Check termination conditions
if next_state == goal:
return "SUCCESS", steps
if next_state in visited:
return "LOOP", steps
if not is_valid_state(next_state):
return "INVALID", steps
visited.add(next_state)
current = next_state
steps += 1
return "TIMEOUT", steps
```
---
## 🔬 Research Directions
Based on our findings, promising research directions include:
1. **Architecture Search**: Why does bidirectional attention help so much? Can we design minimal architectural changes for goal-conditioning?
2. **Length Generalization**: Block World shows gradual OOD degradation—can we improve N=8-10 performance further?
3. **Transfer Learning**: Does Block World skill transfer to other local-structure planning tasks?
4. **Hybrid Approaches**: Combining neural models with explicit state-space search
---
## 📚 References
**Main Paper:**
```bibtex
@inproceedings{mannem2026recurrent,
title={Recurrent Reasoning on Symbolic Puzzles with Sequence Models},
author={Gowrav Mannem and Chowdhury Marzia Mahjabin and Jason Chen and Shivank Garg and Kevin Zhu},
booktitle={ICLR 2026 Workshop on Logical Reasoning of Large Language Models},
year={2026}
}
```
**Original Puzzle Introduction:**
```bibtex
@article{shojaee2025illusion,
title={The illusion of thinking: Understanding the strengths and limitations of reasoning models via the lens of problem complexity},
author={Shojaee, Parshin and Mirzadeh, Iman and Alizadeh, Keivan and Horton, Maxwell and Bengio, Samy and Farajtabar, Mehrdad},
journal={arXiv preprint arXiv:2506.06941},
year={2025}
}
```
---
[← Back to Main README](README.md)