gmannem commited on
Commit
6bd84ef
Β·
verified Β·
1 Parent(s): 5d998aa

Create RIVER CROSSING.md

Browse files
Files changed (1) hide show
  1. RIVER CROSSING.md +309 -0
RIVER CROSSING.md ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # River Crossing
2
+
3
+ **Transport N actor-agent pairs across a river with global safety constraints**
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ River Crossing is a constraint satisfaction planning puzzle that tests multi-agent coordination and safety constraint management. This puzzle is a generalization of classic problems such as the Missionaries and Cannibals problem and the Bridge and Torch problem, which have been widely studied in planning literature.
10
+
11
+ ### Difficulty Rating: ⭐⭐⭐⭐ (Very Hard - Global Constraints)
12
+
13
+ ---
14
+
15
+ ## πŸ“Š Statistics
16
+
17
+ | Metric | Value |
18
+ |--------|-------|
19
+ | **Total Puzzles** | 4,208 |
20
+ | **Total Moves** | 25,396 |
21
+ | **Training Puzzles (N=1-7)** | 630 |
22
+ | **Test Puzzles (N=8-10)** | 3,578 |
23
+ | **Difficulty Parameter** | N (actor-agent pairs) |
24
+ | **Boat Capacities** | k ∈ {2, 3, 4} |
25
+ | **Solution Length** | L(N,k) β‰₯ Ξ©(N/k) (variable) |
26
+ | **Transition Locality** | **O(N) global** - must verify all entities |
27
+
28
+ ---
29
+
30
+ ## 🎯 Puzzle Rules
31
+
32
+ ### Objective
33
+ Transport all 2N individuals (N actors and N agents) from one river bank to the opposite bank using a boat with capacity k.
34
+
35
+ ### Entities
36
+ - **Actors**: a₁, aβ‚‚, ..., aβ‚™
37
+ - **Agents**: A₁, Aβ‚‚, ..., Aβ‚™
38
+ - Each actor aα΅’ is "protected by" their corresponding agent Aα΅’
39
+
40
+ ### Initial State
41
+ All 2N individuals start on one bank (typically left bank).
42
+
43
+ ### Goal State
44
+ All 2N individuals reach the opposite bank.
45
+
46
+ ### Constraints
47
+
48
+ 1. **Boat Capacity Constraint**: The boat can carry at most k individuals at a time
49
+
50
+ 2. **Non-Empty Boat Constraint**: The boat cannot travel emptyβ€”must have at least one person aboard
51
+
52
+ 3. **Safety Constraint** (CRITICAL): An actor aα΅’ cannot be in the presence of another agent Aβ±Ό (where j β‰  i) unless their own agent Aα΅’ is also present
53
+ - This applies **on both banks** AND **inside the boat**
54
+ - Violation at any point renders the solution invalid
55
+
56
+ ### Why River Crossing is Extremely Hard
57
+
58
+ River Crossing is the **second-hardest** puzzle (after Tower of Hanoi):
59
+
60
+ 1. **Global O(N) Constraint Verification**: Every move requires checking safety for all 2N entities
61
+ - Cannot be verified with local checks
62
+ - Must scan entire state (both banks + boat)
63
+
64
+ 2. **Combinatorial Action Space**: On the boat-side bank with m entities:
65
+ ```
66
+ Number of candidate loadings = Ξ£(k, j=1) C(m, j)
67
+ ```
68
+ For k=2 and m=2N: this is O(NΒ²) possible boat configurations
69
+
70
+ 3. **Complex Planning Dependencies**:
71
+ - Who goes in the boat affects who can safely remain
72
+ - Return trips are necessary but non-obvious
73
+ - Requires multi-step lookahead
74
+
75
+ 4. **No Model Achieves >0%**: All tested models (T5, GPT-2, all conditions) achieve **0.00% everywhere**
76
+
77
+ ---
78
+
79
+ ## πŸ“‹ State Representation
80
+
81
+ States are represented as **tuples of two sorted lists**: (left_bank, right_bank)
82
+
83
+ Each list contains the entities currently on that bank.
84
+
85
+ ### Format
86
+ ```python
87
+ (['a1', 'A1'], ['a2', 'A2', 'a3', 'A3'])
88
+ ```
89
+
90
+ This represents:
91
+ - **Left Bank**: Actor a1 and Agent A1
92
+ - **Right Bank**: Actor a2, Agent A2, Actor a3, Agent A3
93
+
94
+ ### Move Representation
95
+ ```python
96
+ ['a1', 'A1']
97
+ ```
98
+
99
+ This represents: **Load actors a1 and Agent A1 onto the boat** (they will travel together)
100
+
101
+ Format: `[entity1, entity2, ...]` (list of entities traveling in this boat trip)
102
+
103
+ An empty move `[]` represents the boat returning empty (when allowed by non-empty constraint).
104
+
105
+ ---
106
+
107
+ ## πŸ–ΌοΈ Example Puzzle
108
+
109
+ ![River Crossing Example](https://github.com/gowravmannem/Recurrent-Reasoning-on-Puzzles/blob/main/assets/river_crossing.png?raw=true)
110
+
111
+ ### Example Trajectory (N=1, k=2)
112
+
113
+ **Initial State**: `(['A1', 'a1'], [])`
114
+ **Goal State**: `([], ['A1', 'a1'])`
115
+ **Boat Capacity**: k = 2
116
+ **Goal Direction**: Right
117
+ **Optimal Solution Length**: 1 move
118
+
119
+ **Step-by-step solution:**
120
+
121
+ | Step | Boat Side | Current State | Next State | Move | Description |
122
+ |------|-----------|--------------|-----------|------|-------------|
123
+ | 0 | L | `(['A1','a1'],[])` | `([],['A1','a1'])` | `['A1','a1']` | Both cross together |
124
+ | 1 | R | `([],['A1','a1'])` | `([],['A1','a1'])` | `[]` | Goal reached! |
125
+
126
+ ### More Complex Example (N=2, k=2)
127
+
128
+ **Initial State**: `(['A1','a1','A2','a2'], [])`
129
+ **Goal State**: `([], ['A1','a1','A2','a2'])`
130
+
131
+ This requires **5 moves** (optimal):
132
+ 1. Send a1 and A1 across β†’ `(['A2','a2'], ['A1','a1'])`
133
+ 2. A1 returns alone β†’ `(['A1','A2','a2'], ['a1'])`
134
+ 3. Send A1 and A2 across β†’ `(['a2'], ['A1','A2','a1'])`
135
+ 4. A2 returns alone β†’ `(['A2','a2'], ['A1','a1'])`
136
+ 5. Send A2 and a2 across β†’ `([], ['A1','A2','a1','a2'])` βœ“
137
+
138
+ **Safety verification at each step**:
139
+ - After step 1: a2 is with A2 on left βœ“, a1 is with A1 on right βœ“
140
+ - After step 2: a2 is with A2 on left βœ“, a1 alone on right βœ“
141
+ - Etc.
142
+
143
+ ---
144
+
145
+ ## πŸ“ CSV Column Descriptions
146
+
147
+ ### Columns
148
+
149
+ | Column | Type | Description |
150
+ |--------|------|-------------|
151
+ | `N` | int | Number of actor-agent pairs (difficulty parameter) |
152
+ | `boat_capacity` | int | Maximum individuals boat can hold (k ∈ {2,3,4}) |
153
+ | `start_state` | string | Initial configuration (tuple of two lists) |
154
+ | `goal_state` | string | Target configuration to achieve |
155
+ | `goal_direction` | string | Target bank ('Left' or 'Right') |
156
+ | `boat_side` | string | Current boat location before move ('L' or 'R') |
157
+ | `current_state` | string | Banks state before this move |
158
+ | `next_state` | string | Banks state after applying this move |
159
+ | `move` | string | Entities traveling in boat: `[entity1, entity2, ...]` |
160
+ | `total_moves` | int | Total moves in the complete optimal solution |
161
+
162
+ ### Data Format
163
+
164
+ Each row represents one **boat crossing** (move).
165
+
166
+ **Example CSV rows:**
167
+ ```csv
168
+ N,boat_capacity,start_state,goal_state,goal_direction,boat_side,current_state,next_state,move,total_moves
169
+ 1,2,"(['A1','a1'],[])","([],['A1','a1'])",Right,L,"(['A1','a1'],[])","([],['A1','a1'])","['A1','a1']",1
170
+ 1,2,"(['A1','a1'],[])","([],['A1','a1'])",Right,R,"([],['A1','a1'])","([],['A1','a1'])","[]",1
171
+ ```
172
+
173
+ ---
174
+
175
+
176
+ ## πŸ’‘ Usage Tips
177
+
178
+ ### For Model Training
179
+
180
+ ⚠️ **EXTREME WARNING**: River Crossing is **unsolved** by all current sequence models.
181
+
182
+ Potential approaches (all experimental):
183
+
184
+ 1. **Explicit Constraint Checker**:
185
+ - Augment model with symbolic safety verifier
186
+ - Only allow moves that pass safety check
187
+ - Hybrid neuro-symbolic approach
188
+
189
+ 2. **Constrained Beam Search**:
190
+ - Generate top-k boat loadings
191
+ - Filter out unsafe options
192
+ - Expand only valid candidates
193
+
194
+ 3. **Graph Neural Networks**:
195
+ - Represent entities and relationships as graph
196
+ - Use GNN to learn safety constraint
197
+ - May capture global structure better than sequences
198
+
199
+ 4. **Curriculum with Safety Signals**:
200
+ - Explicitly annotate which moves violate safety
201
+ - Train classifier to predict "safe" vs "unsafe"
202
+ - Use as auxiliary task
203
+
204
+ 5. **Search-Augmented Generation**:
205
+ - Use model as policy for MCTS or A*
206
+ - Explicit state-space search with neural heuristic
207
+
208
+ ### For Evaluation
209
+
210
+ ```python
211
+ from datasets import load_dataset
212
+
213
+ # Load River Crossing
214
+ dataset = load_dataset("gmannem/RecurrReason", "river_crossing")
215
+
216
+ # WARNING: Expect 0% success rate!
217
+
218
+ def evaluate_river_crossing(model, example):
219
+ """
220
+ Evaluation with strict safety constraint checking.
221
+
222
+ A SINGLE safety violation = immediate failure.
223
+ """
224
+ current_state = example['start_state']
225
+ goal_state = example['goal_state']
226
+ boat_side = example['boat_side']
227
+ boat_capacity = example['boat_capacity']
228
+ steps = 0
229
+ max_steps = 2 * example['total_moves']
230
+
231
+ while steps < max_steps:
232
+ # Model predicts boat loading
233
+ boat_loading = model.predict(current_state, goal_state, boat_side)
234
+
235
+ # CRITICAL: Verify safety at EVERY step
236
+ next_state, next_boat_side = apply_move(
237
+ current_state, boat_loading, boat_side
238
+ )
239
+
240
+ # Check safety constraint
241
+ if violates_safety(next_state):
242
+ return "SAFETY_VIOLATION", steps
243
+
244
+ # Check capacity constraint
245
+ if len(boat_loading) > boat_capacity or len(boat_loading) == 0:
246
+ return "INVALID_CAPACITY", steps
247
+
248
+ if next_state == goal_state:
249
+ return "SUCCESS", steps
250
+
251
+ current_state = next_state
252
+ boat_side = next_boat_side
253
+ steps += 1
254
+
255
+ return "TIMEOUT", steps
256
+
257
+ def violates_safety(state):
258
+ """
259
+ Check global safety constraint.
260
+
261
+ For each actor a_i on a bank, verify:
262
+ - No agent A_j (j != i) is present, OR
263
+ - Agent A_i is also present
264
+ """
265
+ left_bank, right_bank = state
266
+
267
+ for bank in [left_bank, right_bank]:
268
+ actors = [e for e in bank if e.startswith('a')]
269
+ agents = [e for e in bank if e.startswith('A')]
270
+
271
+ for actor in actors:
272
+ actor_id = actor[1:] # Extract numeric ID
273
+ own_agent = f'A{actor_id}'
274
+ other_agents = [a for a in agents if a != own_agent]
275
+
276
+ # If other agents present but own agent missing = VIOLATION
277
+ if other_agents and own_agent not in bank:
278
+ return True
279
+
280
+ return False
281
+ ```
282
+
283
+ ---
284
+
285
+ ## πŸ“š References
286
+
287
+ **Main Paper:**
288
+ ```bibtex
289
+ @inproceedings{mannem2026recurrent,
290
+ title={Recurrent Reasoning on Symbolic Puzzles with Sequence Models},
291
+ author={Gowrav Mannem and Chowdhury Marzia Mahjabin and Jason Chen and Shivank Garg and Kevin Zhu},
292
+ booktitle={ICLR 2026 Workshop on Logical Reasoning of Large Language Models},
293
+ year={2026}
294
+ }
295
+ ```
296
+
297
+ **Classic River Crossing Problems:**
298
+ ```bibtex
299
+ @book{pressman1994puzzles,
300
+ title={Famous puzzles of great mathematicians},
301
+ author={Pressman, Ian and Singmaster, David},
302
+ year={2009},
303
+ publisher={American Mathematical Society}
304
+ }
305
+ ```
306
+
307
+ ---
308
+
309
+ [← Back to Main README](README.md)