decoupled-search 0.3.1

Decoupled (star-topology) search for factored SAS+ planning: star factorings, cost-optimal and greedy search, dominance pruning and decoupled heuristics
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
# decoupled-search: design

Decoupled (star-topology) search for factored SAS+ planning tasks from
[`sas-plus`](https://crates.io/crates/sas-plus). The crate partitions a
task's variables into one *center* and several *leaves*, searches over center
paths only, and keeps, per leaf, the set of leaf states reachable along the
current center path together with their cheapest cost (the *price*).

## Terminology

| Term | Meaning |
| --- | --- |
| Factoring | A partition of the state variables into a center `C` and leaves `L1..Lk`. `C` may be empty, `k` may be 0. |
| Leaf state | An assignment to the variables of one leaf, stored as a mixed-radix rank. |
| Leaf action of `L` | An operator whose effects all lie in `L` (at least one), and whose preconditions and effect conditions all lie in `C ∪ L`. |
| Global action | Every other operator: it changes the center, or touches two leaves, or reads another leaf. |
| Decoupled state | A center state plus, per leaf, a price for every leaf state (`∞` = unreached). |
| `g` | The cost of the global actions on the path to a decoupled state. |
| Price | The cost of the cheapest leaf-action sequence that reaches a leaf state, interleaved with the current global path. |

## Factoring strategies

The classification above is our own formulation. It makes every variable
partition a valid factoring: an operator that would break the star topology
(for example one that reads leaf `L1` and writes leaf `L2`) becomes a global
action, so it is searched explicitly instead of being priced. The factoring
therefore only affects performance, never soundness or optimality. Gnad,
Poser and Hoffmann (2017) define star factorings by: every action that does
not affect the center affects only one leaf and has preconditions only on
it and the center. Our leaf actions are exactly those actions (their
*leaf-only* actions); we additionally accept actions that affect the center
or several leaves, and actions that read another leaf, as global actions,
so arbitrary partitions are searchable. These are the *generalized
factorings* of Gnad, Torralba and Fišer (ICAPS 2022, Definitions 3 and 4:
any partition, a possibly empty center, and every action that is not
leaf-only is global); their Theorem 1 maps one to a star factoring of the
task with one extra unary center variable that every global action sets,
with the same decoupled state space, so the search stays sound, complete
and optimal. Strategies 1 to 6 below produce *strict-star* factorings
(every causal-graph arc between factors touches the center), which are
star factorings; strategy 7 produces generalized ones.

Strategies:

1. **Fork (sink components)**, `Factoring::fork`. Every sink
   strongly connected component of the causal graph (no arcs leaving it) whose
   leaf state space has at most `2^16` states becomes a leaf; everything else
   is the center. This is the refined fork strategy of Gnad, Poser and
   Hoffmann (footnote 1), which maximises the number of fork leaves.
   Operators on a sink component read only the center and that
   component, so all of them are leaf actions. On a task whose causal graph is
   one component, this yields no leaves and the search degenerates to plain
   uniform-cost search over the center.
2. **Explicit**, `Factoring::new(task, leaves)`. The caller names
   the leaves; the center is the rest. Used by tests to exercise arbitrary
   partitions.
3. **Inverted fork**, `Factoring::inverted_fork`. The fork strategy on the
   reversed causal graph: every small source SCC (no arcs entering it)
   becomes a leaf (the paper's refined inverted fork).
4. **X-shape**, `Factoring::x_shape` (Gnad, Hoffmann and Domshlak, SoCS
   2015). The fork leaves, plus every small source SCC that has no arc
   into a fork leaf (the inverted fork run on the fork center; fork leaves
   have no outgoing arcs, so these are source SCCs of the whole graph).
5. **Incident arcs**, `Factoring::incident_arcs` (the paper's Figure 2).
   Sort the variables by decreasing number of incident causal-graph arcs
   (in plus out), move them into the center one at a time, take the
   weakly connected components of the rest (within `2^16` states) as the
   leaves, and keep the candidate with the most mobile leaves.
6. **Independent set**, `Factoring::max_leaves` (Figure 1). Seed one leaf
   per variable of a maximum independent set of the causal graph, grow the
   leaves by variables adjacent to exactly one leaf (`maximizeFlexibility`),
   drop frozen leaves, grow again, and keep the result with the most mobile
   leaves over all enumerated maximum independent sets. Branch and bound
   enumerates up to 16 sets within a budget of `2^24` neighbour lookups
   (deterministic, instead of the paper's ten-second time-out); a unit
   test checks it against brute force. Growing tracks mobility
   incrementally: without axioms, moving `v` into leaf `L` can only change
   `L`'s mobility, through operators touching `v`.
7. **Generalized**, `Factoring::generalized` (Gnad, Torralba and Fišer,
   ICAPS 2022). The candidate leaves are the paper's potential leaves, the
   effect variable sets of the operators. The paper picks leaves with an
   integer program maximizing the number of mobile leaves (objective L);
   here a greedy pass approximates it: candidates smallest first, then by
   how few other candidates they overlap, then by how many operators share
   the effect set, and a candidate stays only if it is disjoint from the
   leaves so far and it and every earlier leaf stay mobile. Leaves may read
   and write each other (those operators are global) and the center may
   be empty. On the paper's Example 1 (agents that charge each other's
   batteries) it finds one leaf per agent with its battery around an empty
   center, where no star strategy has two mobile leaves. On 96 of 100
   random tasks it has two or more mobile leaves without being a star, and
   decoupled search over those matches Dijkstra. `Factoring::auto` now
   returns it on 171 of 200 unstructured random tasks (where star
   strategies rarely find two mobile leaves) and on 2 of 200 random star
   tasks. On the random tasks where no star strategy finds two mobile
   leaves, it still finds two or more in most cases, and search over them
   matches Dijkstra (issue #3's acceptance).

   *Several centers.* A factoring with centers `C_1, ..., C_k`, each with
   its own leaves, searches like the generalized factoring with center
   `C_1 ∪ ... ∪ C_k`: global actions are exactly the actions that are not
   leaf-only, wherever they act, and a leaf-only action may read any center
   variable, so tying a leaf to one center would only make more actions
   global. Several centers are therefore covered by generalized factorings
   (with the union as center, or no center at all). A *nested* hierarchy,
   where a group of a sub-center and its leaves is itself decoupled inside
   a leaf of an outer star, is not: its pricing would range over the inner
   decoupled states, which no published formulation describes. Symbolic
   leaves cover the practical case of such a group, one large leaf.

   The other
   objectives (mobility, balanced mobility, fact flexibility) and the
   minimum leaf flexibility constraint are not implemented.

`Factoring::check_star` reports the first causal-graph arc between two
leaves (`Error::NotStar`). Every strategy except `Factoring::new` and `Factoring::generalized` passes
it; search does not require it. Derived variables are never leaf
variables: the strategies move them to the center (see
[Conditional effects and axioms](#conditional-effects-and-axioms)).

*Scoring.* `Factoring::score` compiles the factoring with the search's own
operator classification and reports the number of leaves, *mobile* leaves
(leaves with at least one leaf action: the paper's flexibility, the share
of leaf-only actions among the actions affecting the leaf, above 0), leaf
and global actions, the leaf-action share, and the largest and total leaf
size. `Factoring::auto` scores every `Strategy`, keeps those with at least
two mobile leaves (the paper abstains below two, since decoupling pays off
by not enumerating combinations of leaf states across leaves), and picks
the best by the larger leaf-action share (an exact fraction), more mobile
leaves, the smaller largest leaf, and the earlier strategy. Factorings the
search would reject are skipped; if none is left, the result is the
factoring without leaves (explicit search). The paper ranks by one-second
sample searches; `Factoring::auto_by_sample` does that with an expansion
budget instead of a clock (see the table).

*Checked against the paper* (Gnad, Poser and Hoffmann, IJCAI 2017):

| Paper | Paper rule | Our code | Status |
| --- | --- | --- | --- |
| Sec. 3.3, fn. 1 | refined fork / inverted fork: leaves are the sink / source causal-graph SCCs | `fork`, `inverted_fork`, components over `2^16` states join the center | matches (leaf bound: see below) |
| Sec. 3.3 (and Gnad, Hoffmann and Domshlak 2015) | X-shape: fork strategy, then inverted fork on the fork center; inverted-fork leaves with an arc into a fork leaf go back to the center | `x_shape`, on the refined fork and inverted fork | matches, with the refined (maximum-leaves) fork of footnote 1 instead of the 2015 greedy horizontal line |
| Sec. 4 | leaf-size bound `2^32` states | `MAX_LEAF_STATES = 2^16` for explicit leaves, none for symbolic ones | deliberate deviation: explicit leaf states are `u16` ranks |
| Sec. 4.1 | mobile: flexibility (leaf-only actions over all actions affecting the leaf) above 0; frozen otherwise | at least one leaf action (`score`, and a cheap count the strategies use, asserted equal) | matches |
| Fig. 2 | incident arcs: static order on the full causal graph, one candidate per center size 1 to the number of variables, max mobile leaves | same; ties: smaller variable, then smaller center | bug fixed: the order was recomputed per step from neighbours outside the center (distinct neighbours, not arcs), and the first candidate with two leaves (mobile or not) was taken; regression test `incident_arcs_keeps_the_most_mobile_leaves` |
| Fig. 1 | MIS seed, `maximizeFlexibility`, drop frozen, `maximizeFlexibility` | `max_leaves`, as listed above | bug fixed: `max_leaves` was the incident-arcs walk with the most (not mobile) leaves, with no independent set and no growing; regression test `max_leaves_grows_the_independent_set` |
| Fig. 1 | per round an argmax over the round's leaf sets (pseudocode: their size; prose: mobile leaves); return the round with the most mobile leaves | per round the most mobile leaves (the prose; the number of leaves is constant while growing), smallest variable on ties; between rounds the latest on ties | deliberate reading, ties ours |
| Sec. 4.1 | all maximum independent sets found within 10 s | up to 16 within a deterministic work budget | deliberate deviation: `no_std`, reproducible |
| Sec. 4 | abstain below two mobile leaves | `incident_arcs` and `max_leaves` return their best candidate anyway; `auto` abstains (no leaves) | deliberate: the strategy functions return a `Factoring`, not an `Option`; `auto` used to accept a single mobile leaf |
| Sec. 5 | pick a factoring by 1 s sample searches (LM-cut A\* / GBFS with `h^FF`); a sample that solves the task wins; else expansions (optimal) or heuristic improvement `h(I) / min h` (satisficing), higher better | `auto`: static score (leaf-action share, mobile leaves, largest leaf); opt-in `auto_by_sample(task, objective, expansions)`: samples of A\* with `h^max` or GBFS with `h^FF` under an expansion budget; finished samples win (least work first); optimal: expansions per work unit; satisficing: heuristic improvement, then less work | deliberate deviation: an expansion budget instead of a clock (`no_std`), so the expansion rate is measured in deterministic work units (per generated state, one plus its leaf states), and `h^max` instead of LM-cut; the chosen factoring is returned, not the sample's plan |
| — | no axioms | every strategy and `check_star` work on the causal graph with derived variables contracted into their inputs (`factoring/graph.rs`): the inputs of a derived variable are adjacent, so none is split over two leaves (`Error::AxiomAcrossLeaves`), and an operator reading a derived variable reads its inputs, as the search attaches it | extension; regression tests `strategies_keep_axiom_inputs_in_one_factor`, `derived_variables_count_as_their_inputs`, `unread_derived_variables_leave_fork_leaves_alone` |
| Sec. 2 | causal graph arcs `pre ∪ eff -> eff` | `sas_plus::CausalGraph`, plus effect conditions and axioms | matches (the extra arcs only keep conditional effects and axioms inside one factor) |

## Decoupled state and pricing

```text
DecoupledState {
    center: Vec<Value>,      // values of the center variables, in Factoring::center order
    prices: Vec<Prices>,     // per leaf: reached ranks (u16, ascending) and their u64 prices
}
```

Leaf states are ranked in mixed radix over the leaf's variables, so a leaf
with variables of domain sizes `d0, d1, ...` has `d0 * d1 * ...` ranks.
Reading or setting one variable of a rank is a division, a modulus and an
add; nothing allocates per leaf state.

*Leaf closure.* Given a center state and seed prices for a leaf, Dijkstra over
the leaf's ranks with the leaf actions whose center preconditions hold. The
result is the new price vector. Seeds are all finite-priced ranks.

Stored states keep only the reached leaf states: parallel vectors of `u16`
ranks and `u64` prices, ten bytes per reached state. When every reached
state has price 0 (always, with reachability-only leaves) the price vector
is dropped, two bytes per reached state. Leaf closure,
transfers and reconstruction work on a dense vector that successor
generation builds from the stored form and compacts again; that costs
`O(|S_L|)` time per leaf per successor, but no longer `O(|S_L|)` memory per
stored state.

## Successor generation

A global action `a` is applicable in decoupled state `s` iff its center
preconditions hold in `s.center` and, for each leaf where it has a
precondition, at least one reached leaf state satisfies it. The successor:

1. for each leaf `a` reads or writes: keeps the reached ranks satisfying
   `pre_L(a)`, maps each through `eff_L(a)` (conditional effects evaluated
   on that rank and the predecessor center), and keeps the minimum price on
   collisions; leaves `a` does not touch keep their prices;
2. applies `a`'s center effects (conditions read from the predecessor
   center), then re-evaluates the derived center variables;
3. re-runs the leaf closure on every leaf, since the center changed;
4. has `g(s') = g(s) + cost(a)`.

## Goal test and search

A decoupled state is a goal state iff the center goal holds and every leaf has
a reached rank satisfying its goal. Its *solution cost* is `g` plus, per leaf,
the cheapest price among goal ranks.

`search` is uniform-cost search over decoupled states ordered by `g`,
`astar` orders by `g + h`. Because the solution cost exceeds `g` by the
leaf goal prices, the first goal state found is not necessarily optimal.
Both record the best solution at generation time and stop once the popped
key is at least the best solution cost (leaf prices are non-negative and
`h` is a lower bound). `gbfs` orders by `h` alone and returns the first
solution generated.

`Config::anytime_astar` is Gnad and Hoffmann's Anytime Fork-Root A\*
(ICAPS 2015, Figure 4), generalised to star factorings:

| Paper | Paper rule | Our code | Status |
| --- | --- | --- | --- |
| Fig. 4 | A\* ordered by a root heuristic `h^R` (remaining center cost) | key `g + root`, where `root` sees every reached fact at price 0 | matches |
| Def. 6 | leaves-for-free root estimate: `h` on the task with leaf-action costs 0 | `Factoring::with_free_leaf_actions`, for example under `HMax` | matches |
| Fig. 4 | discard generated `N` with `g + h^F >= U` | same, counted in `Statistics::bound_pruned` | matches |
| Fig. 4 | goals checked on expansion; `U` updated; stop at an expanded goal with goal price `MINGprice`, else exhaust the open list | goals recorded on generation; stop once popped key + `MINGprice >= U` | deliberate: subsumes the paper's early termination (its goal has key `g`, so `U <= key + MINGprice`) and is sound by the A\* covering argument |
| Fig. 4 | `MINGprice`: sum over leaves of the optimal cost of the projection onto the leaf | per leaf the cheapest leaf-action cost from the initial to a goal leaf state, global parts free, center ignored, reduced transitions skipped; 0 for leaves whose transitions read the center | generalisation (global actions move leaves at no price), a lower bound on every goal price |
| Thm. 5 | optimal for root-admissible `h^R` and fork-admissible `h^F` | same; checked against Dijkstra with a blind root and `h^max` on the free-leaf task in every optimal configuration | matches |
| Fig. 4 | Fork-Root A\* (FRA\*, not complete) | not implemented | not needed: anytime A\* is complete |

## Dominance pruning

Prices can grow without bound along center cycles: a center loop that forces
a leaf to alternate between two states raises both prices on every round.
Exact duplicate detection then never terminates on unsolvable tasks, so
uniform-cost search, A* and GBFS prune a generated state `n` if a stored
state `t` (open or closed) with the same center *dominates* it: every
completion of `n` maps to a completion of `t` with the same remaining
global actions at no higher total cost. Dominated nodes already in the open
list are not removed, and the store is a list per center state.

`Config::pruning` selects one of the criteria of Torralba, Gnad, Dubbert and
Hoffmann (IJCAI 2016), checked against the paper and its extended
technical report (see the table below) and generalised to this crate's
global actions. Each gives a bound `D_t(x)` for every leaf state `x`
reached in `n`: what `t` must pay to do whatever `n` can do from `x`.

| `Pruning` | Bound and compared states | Paper |
| --- | --- | --- |
| `Basic` | `price_t(x)`, all reached `x` | Def. 1 (Gnad and Hoffmann) |
| `Frontier` | `price_t(x)`, only on the frontier of `n` | Defs. 2, 3 |
| `EffectivePrices` | least `p` with `p = price_t` on anchored states, `p(x) = min(price_t(x), max_{x -a-> y} p(y) - cost(a))` elsewhere | Def. 4 |
| `Simulation` | `min_{x ⪯ y} price_t(y)` for the leaf simulation `⪯` | Defs. 5, 6 |
| `EffectiveSimulation` | effective prices over simulation bounds | Def. 7 |
| `Adaptive` (default) | `EffectivePrices`, then `EffectiveSimulation` once the search has spent the simulation's estimated cost | ours |

*Generalisation.* The paper assumes fork factorings with a single goal leaf
state, where only leaf actions move a leaf. Here global actions may read
and write leaves, and leaf goals are partial. A leaf state is *anchored* if
it satisfies the leaf goal or the leaf preconditions of some global
action's part on the leaf (all states are, if a part has no leaf
precondition). The frontier contains the anchored states; effective prices
stop their recursion there; the simulation must match every global part
with the same action (preconditions and successors). An unanchored state
can only be left by leaf actions, which is what the paper's proofs use, so
they carry over; the dominance module's rustdoc writes them out for this
setting. Leaves whose transitions depend on the center (center-conditioned
effects, derived slots) or that exceed `Config::max_analysis_states`
(default 256) use the basic bound.

*Leaf simulation* (`search/dominance/simulation.rs`) is the coarsest
relation with: goal leaf states are simulated only by goal leaf states;
global parts are matched by the same part; a leaf action `x -a-> x'` is
matched by staying (`x' ⪯ y`) or by a leaf action `b` with `cost(b) <=
cost(a)` and center preconditions contained in `a`'s, `y -b-> y'`, `x' ⪯
y'`. It is computed once per leaf by worklist refinement.

*Folding `g` in.* Leaf prices
exclude `g`. The classic rule, `g(t) <= g(n)` and every bound at most the
price, is used with `fold_g = false`. Comparing `g + price` per leaf state
would be unsound with two or more leaves: `g` is paid once but credited
once per leaf (`t`: `g = 0`, prices 10 and 10; `n`: `g = 10`, prices 0 and
0; per leaf both sum to 10, but completing both leaves costs 20 from `t`
and 10 from `n`). With `fold_g = true` (default) the budget is shared:
with `δ_L = max_x (D_t(x) - price_n(x))`, `t` dominates `n` iff
`g(t) + Σ_L δ_L <= g(n)`. Every completion of `n` through leaf states
`x_L` then has one of `t` cheaper by at least `g(n) - g(t) - Σ_L δ_L >= 0`.
This subsumes the classic rule and preserves optimality.

*Optimality of A\*.* A stored node covers cost `C` via global actions `π`
if `π` leads it to a goal with total cost at most `C`. While `C*` is not
recorded, a covering node with the shortest `π` is open: were it closed,
its successor along `π[0]` was stored (shorter cover), pruned by a node
covering via the same shorter suffix (dominance keeps the remaining global
actions, so no `d*` condition as in the paper is needed), or a dead end of
an admissible heuristic (impossible). So the search does not stop with a
popped key `>= best` before `best = C*`.

*Greedy search* only needs reachability: `t` dominates `n` if every
compared bound is finite, whatever the costs.

*Termination* follows from Dickson's lemma for the basic criterion, which
every other one subsumes: the comparison is a well-quasi-order on
`(g, prices)` per center state, so no infinite sequence of pairwise
non-dominated states exists.

*Adaptive default.* Simulation costs `O(size^2 * actions)` per leaf once
per search, which dominated small searches (gripper: 1.24 ms against
24 µs for `Basic`). `Pruning::Adaptive` follows the ski-rental rule: it
uses effective prices, counts one work unit per leaf state of every
generated decoupled state, and computes the simulations and switches to
`EffectiveSimulation` once the work reaches `Σ size^2 * (1 + leaf actions)`
over the analysed leaves. Mixing sound criteria is sound; cached bounds
are recomputed after the switch. Measured on gripper (fork, uniform-cost,
release, criterion `--quick`): `Basic` 22 µs, `Adaptive` 40–57 µs,
`EffectiveSimulation` 700–750 µs.

*Leaf reduction* (`Config::reduce_leaves`, default off). Section 6 of
the extended technical report calls a leaf transition `x -a-> x'`
superfluous if `x' ⪯ x`, or if another transition `x -b-> y'` has
`x' ⪯ y'`, center preconditions contained in `a`'s and `cost(b) <=
cost(a)`; it then removes unreachable leaf states and leaf actions without
transitions. It gives no removal order and no proof. Read as one
simultaneous step the rule is unsound: two transitions that replace each
other (two copies of one action) would both go. We remove `a` under the
second condition only if `a` does not replace `b` in turn or `b` has the
smaller index, which is what one-at-a-time removal, each step justified by
a transition still present, removes (up to which of two mutually replacing
transitions stays). Leaf closure skips removed transitions, so leaf states
only reachable through them are never reached. `Config::reduced_task`
returns the task without the leaf actions that keep no transition from a
leaf state the reduced leaf can still reach (under any center), for
building heuristics: the report's gain from removed actions (LM-cut in
Logistics98). It is sound only together with `reduce_leaves` in the
search: every reached leaf state is then reduced-reachable, and every
decoupled state has a cheapest completion over kept transitions from such
states, so a heuristic admissible on the reduced task is admissible for
the search. A random cross-check runs A\* with `h^max` of the reduced task
against Dijkstra. Soundness (our proof, on
`Config::reduce_leaves`): "replaces" is a preorder, the index tie-break
makes the removal order a strict partial order, so the first removed step
of any compliant leaf path can be replaced by a kept step or by staying,
and the rest of the path is mirrored by the simulation; repeating
terminates, so the reduced system loses no completion and no cost. On the
Logistics example it removes the five unloads at non-goal locations and
the load at the goal (those states become unreachable) and stores fewer
decoupled states. Reconstruction runs the same reduced closure, so plans
stay consistent.

*Checked against the papers.* Torralba, Gnad, Dubbert and Hoffmann, IJCAI
2016 and its extended technical report (the definitions are identical in
both; the proofs and the leaf reduction are in the report only):

| Paper | Paper rule | Our code | Status |
| --- | --- | --- | --- |
| Def. 1 | `s ⪯_B t` iff same center and `prices(s) >= prices(t)` everywhere | `Pruning::Basic`, all reached states of `n` | matches |
| Def. 2 | frontier: the goal leaf state, plus `x` with a leaf transition `x -a-> y`, `price(x) + cost(a) < price(y)` (transitions ignore the center) | anchored states (goal *or* a global part's leaf precondition) plus the same improvement test over leaf actions under any center | deliberate deviation: global actions may read and write leaves, so a leaf state can also matter by enabling one; the report's proof (last state on the path whose price equals the path cost) then ends in an anchored state |
| Def. 3 | compare prices on the frontier of `s` | `Pruning::Frontier` | matches |
| Def. 4 | `Eprices(t)`: least `p` with `p = price` at the goal, `min(price, max_{x -a-> y} p(y) - cost(a))` elsewhere | `effective_prices`, anchored states keep the base bound; max-heap Dijkstra backwards | deliberate deviation (anchored for goal), as Def. 2 |
| Def. 5 | leaf simulation: goal only simulated by goal; each `x -a-> x'` matched by staying or by `y -b-> y'`, `pre_C(b) ⊆ pre_C(a)`, `cost(b) <= cost(a)`; coarsest one | `simulation::simulators`, coarsest by worklist refinement; partial goals (goal states only simulated by goal states) and every global part matched by itself | deliberate deviation (global parts, partial goals), proof in the module rustdoc |
| Def. 6 | `min_{x ⪯ y} price(t)(y)` | `simulation_bounds` | matches |
| Def. 7 | `ESprices`: as Def. 4 with the simulation minimum off the goal, the plain price at the goal | the simulation minimum on anchored states too | deliberate deviation, sound by Theorem 5's argument (Lemma 1 holds from every leaf state); it can only prune more |
| Sec. 3 | prune `s` if a seen `t` has `s ⪯ t` and `g(s) >= g(t)`; dominance also requires `d*(s) >= d*(t)` for 0-cost actions | `fold_g = false`: `g(t) <= g(n)` and every bound at most the price; `fold_g = true` (default): one budget `g(t) + Σ_L δ_L <= g(n)` | deliberate extension (subsumes the paper's rule); no `d*` condition, because every criterion maps a completion to one with the same remaining global actions, see *Optimality of A\** |
| Sec. 3 | fork factorings, one goal leaf state, center actions do not touch leaves | star factorings with global actions on leaves, partial leaf goals; leaves with center-dependent transitions or more than `max_analysis_states` states use Def. 1 | deliberate generalisation, proofs on `Pruning` |
| Sec. 6 (report) | superfluous transitions, then unreachable leaf states, then actions without transitions | rule 2 with the removal order above; states stay but are never reached; `Config::reduced_task` drops the actions for heuristics | bug in the literal rule avoided; ours strengthened to match one-at-a-time removal (before, equal-cost and equal-precondition replacements were kept whenever the replacing action had the larger index; regression test `one_directional_replacement_removes_the_dominated_transition`) |
| Sec. 8 | DA\* and anytime ADA\* | `astar` (DA\*, stopping once the popped key reaches the best solution cost recorded at generation) and `anytime_astar` (ADA\*, see *Goal test and search*) | matches |

## Partial-order reduction

`Config::stubborn_sets` prunes the successors of an expanded decoupled
state to a *decoupled strong stubborn set* (DSSS) after Gnad, Hoffmann and
Wehrle (JAIR 2019, Section 4). Off by default. The rules below follow the
paper's general-star construction (Definitions 4 to 8) with its own cheap
approximations (Section 7.1); the fork and inverted-fork refinements of its
Section 5 and the "safety belt" that switches pruning off when it does not
pay are not implemented.

### Mapping to this crate

| Paper | Here |
| --- | --- |
| center action `A^C` (expanded explicitly) | every `GlobalAction`, including globals that touch two or more leaves and no center variable |
| leaf action `A^L[F^L] \ A^C` (priced, never expanded) | `LeafAction` of leaf `F^L` |
| leaf path, projection onto `F^L` | the leaf's transition graph with every leaf action and every global part on the leaf, center preconditions ignored; global parts cost 0 (their cost is in `g`) |
| `p` reached in `s^F` | center satisfies `p`'s center part; per leaf some leaf state of finite price satisfies `p`'s part on that leaf |
| `prices[s^F]`, `goalprice` | `DecoupledState::prices`, `Prices::cheapest_goal` |

The stubborn set ranges over all operators, leaf actions included; only
the reached global actions in it are expanded. The proof needs this:
step (f) of Theorem 1 shows that the first shared action `a_k` is a center
action because a leaf action could be moved before the pivot, which a
past-maximal plan rules out. Globals that touch no center variable play
the paper's center role unchanged: they are on the center path, and
past-maximality only moves actions confined to one leaf.

### Construction

The set `A` is the least fixed point of the rules below, seeded by rule 1.

1. *Goal.* In a non-goal state: a decoupled necessary enabling set for the
   goal (Definition 4): if some goal fact on a leaf variable is not reached,
   all achievers of the first such fact; else, if some leaf's goal part is
   reached fact by fact but not by one leaf state, all achievers of every
   goal fact on that leaf; else all achievers of the first center goal fact
   the center violates. "First" is in variable order. In a goal state
   (Definition 8): for every leaf with a goal, a goal-price frontier set
   (Definition 7), approximated as all actions on transitions
   `x -a-> y` with `x` reached, `price(x) + cost(a) < price(y)`, and
   `g*(x) + cost(a) + h*(y) < goalprice`, where `g*` and `h*` are leaf
   distances from the initial leaf state and to the leaf goal on the
   center-ignoring leaf graph. If no leaf has a frontier transition, `A`
   is empty and the state is not expanded: its goal price cannot improve.
2. *Unreached actions.* For every `a` in `A` whose precondition is not
   reached: a decoupled necessary enabling set for `pre(a)`, as in rule 1.
3. *Interference.* For every reached `a` in `A`: every `a'` that
   interferes with `a` (one's effect contradicts the other's precondition,
   or the effects contradict) and whose precondition is consistent with
   `pre(a)`.
4. *Reached leaf preconditions.* For every reached `a` in `A` and every
   leaf `F^L` it has preconditions on: a reached-enabling set for
   `pre(a)[F^L]` (Definition 5), approximated as all actions on the leaf
   graph's transitions out of reached leaf states that violate
   `pre(a)[F^L]` and can reach a leaf state that satisfies it.

The expanded successors are those of the reached global actions in `A`.
Corollaries 1 and 2 of the paper make `A` *safe*: it holds the first
center action of a strongly optimal decoupled plan (up to permutation)
from every solvable state where the empty plan is not optimal. Uniform-cost
search, A\* and anytime A\* use rules 1 to 4 in both forms; GBFS stops at
its first goal state and only meets the non-goal form. With reachability-
only leaves every reached leaf state has price 0, so the goal form is
never needed there either.

### Where the paper's guarantee stops

- *Conditional effects and axioms.* The paper is stated for plain FDR
  tasks; interference and enabling sets are not defined for effect
  conditions or derived variables. A task with either is searched with
  full expansion, `stubborn_sets` notwithstanding.
- *Dominance pruning.* The paper combines DSSS with duplicate detection
  only. Combining it with a dominance criterion is safe if, whenever `t`
  is pruned by a stored `n`, `n` can follow `t`'s remaining center path at
  no higher cost to go: then the witness of `t`'s optimal plan moves to
  `n`, and the induction on (cost to go, 0-cost center actions left) that
  proves A\* complete under DSSS carries over. `Basic`, `Frontier` and
  `EffectivePrices` with `fold_g = false` compare under the same center
  and keep every leaf path of `t` available to `n`, which should give that
  property. This is a sketch of this crate's, not a proof from the paper;
  the cross-checks below test it. `Simulation`, `Adaptive` and
  `fold_g = true` are covered by the cross-checks only.
- *Leaf reduction.* `Config::reduce_leaves` removes leaf transitions; the
  sets are built on the unreduced leaf graph, a superset of what the search
  uses. Covered by the cross-checks only.

### Checks

- Every random-task cross-check (Dijkstra cost, `Plan::validate`) runs
  again with `stubborn_sets`, under every `Pruning` with both `fold_g` and
  under leaf reduction, on tasks that include 0-cost operators,
  conditional effects and axioms (the last two with full expansion).
- The paper's examples as oracles: the NoEmpty transport task, and
  Example 2 (company car), whose optimal cost is 2, not the 100 of the
  initial goal state.
- Theorem 5's first family (`M` trucks, each with its own `N`
  packages): exactly `M + 1` states are stored, as the paper states (7
  against 729 for `M = 6`, `N = 2`).
- On 100 random tasks over every test factoring, stubborn sets prune
  together with dominance in about 100 runs per configuration and store
  fewer states in total: 2698 against 4117 under the default, 3618
  against 6261 under `Basic` without `fold_g`, 2587 against 3941 with leaf
  reduction.
- GBFS with stubborn sets, with priced and with reachability-only leaves,
  finds a valid plan exactly on the solvable random tasks.
- The `search` fuzz target sets `stubborn_sets` from its input.
- `Statistics::stubborn_pruned` counts the applicable global actions the
  sets leave out.

## Symbolic leaves and center

Gnad, Torralba and Hoffmann (SoCS 2017) keep each leaf's pricing
function as binary decision diagrams instead of an explicit price per leaf
state. The decoupled state space does not change: the same center paths,
the same prices, the same plans. Only the representation does, so leaves
far larger than `MAX_LEAF_STATES` become usable when their reachable sets
have small diagrams. Small leaves stay enumerated next to symbolic ones
(mixed leaves, the paper's best configuration). The paper does not expand
sets of decoupled states at once; the symbolic center below is this
crate's formulation. The code is `src/symbolic.rs` with
`src/symbolic/{bdd_leaf,explicit,grouped}.rs`.

### Representation

- *Encoding.* Each leaf variable gets `ceil(log2 |D(v)|)` bits; current
  and next bits are interleaved per leaf, in leaf variable order. All
  symbolic leaves (and a symbolic center) share one oxidd manager, each on
  its own variables.
- *Transition relations.* One relation per leaf action projected onto its
  leaf, grouped by (cost, center precondition), and one per global part on
  the leaf (cost 0 in the leaf; the action's cost is in `g`).
- *Pricing function.* Per leaf, a list of layers `(price, depth, set)`,
  ascending in `(price, depth)`, pairwise disjoint, every leaf state at its
  cheapest price. `depth` counts the 0-cost image steps inside a price, so
  reconstruction can always step back to a strictly smaller key. The
  reached set is the union of the layers.

### Operations

The explicit path's operations, each with its symbolic form:

| Explicit | Symbolic |
| --- | --- |
| closure (`View::close`) | symbolic Dijkstra per leaf from the current layers, over the relations whose center precondition holds; 0-cost relations iterate to a fixpoint within a price, each round a new `depth` |
| transfer across a global action | per layer: intersect with the part's precondition, image through its relation, then subtract all cheaper layers to restore disjointness |
| applicability (reached precondition) | some layer intersects the precondition BDD |
| goal price | least price whose layer intersects the leaf goal BDD |
| `FactPrices` (all heuristics) | per leaf fact, least price whose layer intersects the fact's BDD |
| dominance, `Pruning::Basic` | same center, `g` no higher, and every layer `(p, S)` of the new state has `S` inside the union of the stored state's layers of price at most `p` |
| `min_goal_price` (anytime A\*) | symbolic Dijkstra on all leaf relations, center ignored |
| plan reconstruction | see below |

*Reconstruction (this crate's design; the paper does not describe it).*
Walk the center path backwards, one leaf at a time, with a single leaf
state `x` at key `(p, d)` in node `k`, starting from a cheapest goal leaf
state `pick`ed from the final node. Either some leaf relation of cost `c`
active under node `k`'s center has a predecessor of `x` in node `k`'s
layer at `p - c` (at depth `d - 1` if `c = 0`): step back to it and record
the action; or `x` came in with the transfer, and node `k - 1` has a leaf
state `y` at price `p` whose global part leads to `x`: continue from `y` in
node `k - 1`. The key falls strictly in each step, so the walk ends at the
initial leaf state in the initial node. Leaf actions are then interleaved
with the center path as in the explicit path.

### Mixed leaves

`Config::symbolic_min_states` (default 1024, about where diagrams start to
pay off on the benchmark below) keeps every leaf with fewer states
enumerated: dense prices over the explicit search's compiled leaf, with
its leaf closure, transfers and goal bound (`symbolic/explicit.rs`). Both kinds
answer the same per-leaf questions (closure, transfer, least price in a
set, dominance slack), so the search does not tell them apart. A leaf
above `MAX_LEAF_STATES` that would be enumerated is rejected with
`LeafTooLarge`.

### Symbolic center

`Config::symbolic_center` (this crate's formulation) makes a search node
`(C, P, g)` a BDD `C` of center states that all have pricing `P` and cost
`g`; its members are the decoupled states `(c, P)` for `c` in `C`.

1. *Expansion.* For global action `a`: the members whose center satisfies
   `a`'s center preconditions, carried by `a`'s center relation (image),
   with `P` carried across `a`'s leaf parts. That carried pricing is the
   same for every member, since without conditional effects leaf parts do
   not read the center.
2. *Classes.* The closure after `a` depends on the center only through
   which leaf actions' center preconditions hold. The image is split by
   each distinct such precondition (inside or outside), and each class is
   closed once. Every member of a class gets exactly the pricing an
   explicit successor with that center gets.
3. *Merging.* A new node joins a stored node that is not yet expanded, has
   the same `g` and the same pricing (canonical BDDs compare by value),
   and was created after the new node's parent. Its members are still
   reached at cost `g` with that pricing, and parent links always point to
   older nodes.
4. *Dominance.* A stored node with `g` no higher (ignored by GBFS) and
   pointwise no higher prices removes its center states from the new node,
   which is `Pruning::Basic` applied per member; the node is pruned when
   none remain. Stored nodes are scanned linearly.
5. *Goals and heuristics.* A node holds a solution if a member satisfies
   the center goal; its cost is `g` plus the leaf goal prices, as for
   every member. Heuristics see a center fact as reached at price 0 when
   some member has it. Fact prices are monotone, so this is a lower bound
   on every member's estimate, and admissible heuristics stay admissible.
6. *Reconstruction.* Pick a goal center state of the final node, then walk
   back: the node's sources record `(parent, action, contributed states)`,
   the preimage of the current center state under that action's relation,
   intersected with the parent's members, gives a predecessor. The
   concrete center path then feeds the leaf reconstruction above.

Every member is an ordinary decoupled state reached at its recorded cost,
and every successor of a member is a member of some generated node, so
uniform-cost search and A\* stay optimal and GBFS complete. Anytime A\*
and `fold_g` are rejected.

### Scope

- Feature `symbolic-leaves`. `Config::symbolic_leaves` switches leaves
  with at least `symbolic_min_states` states to diagrams;
  `Config::symbolic_center` works with symbolic or enumerated leaves.
- Supported with symbolic leaves: uniform-cost search, A\*, anytime A\*
  and GBFS, priced and reachability-only leaves, `Pruning::Basic` with and
  without `fold_g` (the per-leaf slack is the largest price difference
  over intersecting layers), and every heuristic, since heuristics read
  only `FactPrices`; the paper's symbolic LM-cut is not needed because
  the seeded LM-cut here already works on per-fact prices.
- Rejected with `Error::SymbolicUnsupported`: the other dominance criteria
  (they analyse explicit leaf states), `reduce_leaves`, `stubborn_sets`,
  conditional effects and axioms; with a symbolic center also anytime A\*
  and `fold_g`.
- `Factoring::new` accepts leaves of any size; the explicit path rejects a
  leaf above `MAX_LEAF_STATES` when it compiles the task.
- A run that fills the node table restarts with four times the nodes, up
  to `2^24`, then fails with `Error::OutOfNodes`.
- With a concrete center, the best-first loop is a copy of the explicit
  one restricted to basic dominance, so that both expand the same states
  in the same order.

### Checks

- Differential (`tests/it/symbolic.rs`): on 60 random tasks with 0-cost
  operators under every test factoring, symbolic and explicit search under
  `Basic` with and without `fold_g` give the same plan cost (priced leaves)
  and the same `expanded`, `generated`, `dominated`, `dead_ends`, `stored`
  and `bound_pruned` counts, for uniform-cost search, A\*, anytime A\* and
  GBFS with both leaf modes; every plan validates.
  The differential runs three times: every leaf symbolic, leaves with
  fewer than 4 states enumerated (mixed), and every leaf enumerated inside
  the symbolic search.
- Size: one leaf of 20 binary variables, which the explicit path rejects
  with `LeafTooLarge`, is solved with a valid plan.
- Symbolic center: on the same 60 random tasks and factorings,
  uniform-cost search and A\* find the Dijkstra cost and GBFS finds a plan
  exactly on solvable tasks, with symbolic and enumerated leaves and both
  leaf modes; every plan validates. On `n = 8` center switches that turn on
  independently (and one leaf), it stores `n + 1` nodes where the explicit
  center stores `2^n`. On the random tasks, A\* keeps the Dijkstra cost
  under every heuristic of the crate (`h^max`, both LM-cut modes,
  merge-and-shrink), and the symbolic center stores a different number of
  nodes than the concrete one in some runs, so merging and member-wise
  dominance are exercised.
- `benches/search.rs` (`bench_symbolic`), uniform-cost search under basic
  dominance, `--quick` on one machine: the gripper fork (tiny leaves) takes
  18 µs explicit and 363 µs symbolic; one leaf of `n` binary variables
  takes 53 µs against 541 µs at `n = 8`, 3.1 ms against 1.1 ms at
  `n = 12`, 35.5 ms against 2.2 ms at `n = 16`, and 6.8 ms symbolic at
  `n = 24`, where explicit leaves are rejected. Symbolic leaves pay off
  once a leaf has a few thousand states. Mixed leaves on the gripper fork
  (all leaves below the threshold, so enumerated inside the symbolic
  search) take 142 µs against 309 µs all symbolic.
- `bench_symbolic_center`: on `n` center switches the symbolic center
  takes 558 µs against 154 µs explicit at `n = 6`, 1.7 ms against 8.0 ms
  at `n = 10`, and 3.4 ms against 117 ms at `n = 14`; on the gripper fork,
  where few center states share a pricing, 302 µs against 29 µs. It pays
  off when many center states share their leaf pricing.

### Dependency

`symbolic-search` wraps oxidd behind its public `backend::Backend` trait.
It needs `std` and Rust 1.91, which sets this crate's MSRV; the `no_std`
build leaves the `symbolic-leaves` feature out.

## Reachability-only leaves

`Leaves::Reachability` closes leaves with every leaf action at cost 0, so
a decoupled state records only which leaf states are reached. States are
smaller and dominance is plain set inclusion (modulo simulation). This
loses costs, so it is refused for cost-optimal search
(`Error::ReachabilityNotOptimal`); GBFS uses it, and the plan's cost is
summed from its operators. Solvability is unchanged: tests compare it with
Dijkstra under every criterion.

## Solution reconstruction

The search keeps parent pointers between decoupled states (global action
plus predecessor). Leaf paths are recomputed only for the solution:

1. per leaf, pick the cheapest goal rank in the final decoupled state;
2. walk the stages backwards: re-run the closure of that stage with parent
   pointers (updated only on strict improvement, so zero-cost operators cannot
   create cycles), and trace from the target rank back to a seed;
3. step across the global action: the predecessor rank must satisfy the
   action's leaf precondition, map to the seed under its leaf effects, and
   carry exactly the seed's price;
4. emit the plan as: stage 0 leaf actions of every leaf, global action 1,
   stage 1 leaf actions, and so on. Leaf actions of different leaves within a
   stage commute, since each reads only the fixed center and its own leaf.

The plan cost equals the reported solution cost (a debug assertion checks
it). `Plan::validate` checks plans with explicit-state sas-plus semantics,
independent of the decoupled machinery, and reports the first problem as a
`PlanError`.

## Heuristic interface

A decoupled state stands for many explicit states, so the heuristic must
be admissible for all of them at once:

```rust
pub trait DecoupledHeuristic {
    /// Lower bound on the remaining cost beyond g (leaf prices plus further
    /// operators); `None` if provably unsolvable.
    fn estimate(&self, facts: &FactPrices<'_>) -> Option<u64>;
}
```

`FactPrices` gives, per fact, the cheapest price of a member state
containing it: 0 for the center facts that hold, the cheapest reached leaf
state for leaf facts, and records the leaf of every variable
(`FactPrices::leaf_of`). The contract: a member state costs at least the sum
over factors (the center counts as one) of the largest price of its facts
in that factor. `FactPrices::new` and `FactPrices::from_state` build them
for heuristic tests.

- `HMax` seeds `h^max` over all operators of the original task with these
  prices. It is admissible: a completion through a member state pays at
  least the largest price of a fact it uses, plus at least `h^max` of that
  state.
- `HFf` extracts a relaxed plan from `h^add` best supporters and adds the
  largest seed price it starts from; it is not admissible and meant for
  GBFS.
- `MasHeuristic` (feature `merge-and-shrink`) evaluates a merge-and-shrink
  abstraction's merge tree bottom-up on fact prices: per tree node and
  abstract state the cheapest price bound, summing children that touch
  disjoint factors and taking the maximum when they share one; the estimate
  is the cheapest bound plus abstract goal distance at the root. The proof
  is in the module rustdoc. `MergeAndShrinkHeuristic` keeps its tree
  private, so the adapter builds the abstraction from the crate's public
  `Factor`, `MergeStrategy` and `ShrinkStrategy` (label reduction is not
  public and is skipped).

Gnad and Hoffmann (2015, Definition 5) fold leaf prices in by a task
`Π^L$` whose leaf variables start unknown and with one new action per
reached leaf state, setting that state at its price (once per leaf). In
the delete relaxation the once-per-leaf flag never blocks, so `h^max` on
`Π^L$` gives each leaf fact the cheapest price of a reached leaf state
containing it, which is exactly our seed: `HMax` (plain seeded `h^max` in
`heuristic/relaxed.rs`) matches their `h^max_{L$}`; the 0-cost seeds for
the default values of derived variables are our extension, since the
paper has no axioms. `HFf` uses the same seeds and
adds the largest seed price its relaxed plan starts from, our own choice
rather than `h^FF` on `Π^L$`; it is not admissible either way. Their root estimate
(Definition 6) is `Factoring::with_free_leaf_actions`.

- `LmCutHeuristic` (feature `lm-cut`) wraps `planning_heuristics::LmCut`
  in two admissible ways (proofs on the type):
  - `LmCutHeuristic::new`, *seeded* (the default): one `LmCut` built on
    the task, evaluated per state with `LmCut::value_seeded`, whose seeds
    add up over the facts a plan uses. Seeding every fact with its fact
    price would pay a multi-variable leaf state's price once per variable
    and overestimate (unit test `a_leaf_state_is_paid_once`). So in each
    factor one representative variable (most expensive goal fact, then
    most expensive fact) keeps its facts' prices and the others are seeded
    at 0: the shares of a leaf state's facts sum to at most its price. The
    estimate is the maximum with `HMax`, which charges a leaf state once.
  - `LmCutHeuristic::with_price_levels`: `Π^L$` at the fact level with one
    purchase operator per factor and price level, rebuilt per estimate
    (a task and an `LmCut` each time). It charges a multi-variable leaf
    state's price once for all its facts, so it can be stronger there.
  - Neither dominates the other. A brute-force unit test checks both
    against the cheapest member state plus `h*`, and against `h^max`.
    Gripper, A\* under the fork factoring, criterion `--quick` on a
    loaded machine: `h^max` 67 µs, seeded LM-cut 78 µs, price levels
    124 µs.
  - A prebuilt exact `Π^L$` (one purchase per leaf state, seeded with the
    leaf-state prices) would need the reached leaf states and their prices
    in `FactPrices` and the factoring at construction; not done.
- Leaf reduction and LM-cut (`Config::reduced_task`): on random tasks
  where reduction removes operators, A\* under leaf reduction with LM-cut
  of the reduced task expands fewer states in total than with LM-cut of
  the full task (seeded LM-cut: 150 against 158 over the test's 60 seeds,
  8 instances better), at the same cost. On the Logistics example there is no gain:
  LM-cut is already perfect (3) and the removed operators give the delete
  relaxation no shortcut; the report's gain is in Logistics98, with
  airplanes and airports, which we have no fixture for.

## Conditional effects and axioms

*Conditional effects.* An effect fires when its conditions hold in the
state the operator is applied in; effects apply in operator order and a
later firing effect on the same variable wins, as in `sas_plus::Task::apply`.
Decoupled search evaluates them per leaf state where it can:

- an effect on leaf `L` may be conditioned on the center and on `L`. It is
  evaluated per rank, on the center the operator is applied in (fixed
  during leaf closure, the predecessor center for a global action);
- an effect on the center may be conditioned only on the center. A
  condition on a leaf would make the successor center depend on the leaf
  state (`Error::CenterEffectReadsLeaf`);
- an effect on leaf `L` conditioned on another leaf would couple the two
  leaves (`Error::EffectConditionAcrossLeaves`).

An operator is a leaf action of `L` if its preconditions, effects and
effect conditions all lie in `C ∪ L` and it sets something in `L` but
nothing in `C`.

*Axioms.* Derived variables are never leaf variables (`Factoring::new`
rejects them with `Error::DerivedInLeaf`, the strategies keep them in the
center). The compiler follows each derived variable's rules transitively to
the state variables they read:

- only center variables: the derived variable is a center slot,
  re-evaluated after every center change;
- the center and one leaf `L`: it is *attached* to `L` as an extra slot
  whose value is evaluated per rank under the current center (a `View`
  evaluates all attached slots once per center). Preconditions, goals and
  effect conditions on it are facts on `L`;
- two leaves: `Error::AxiomAcrossLeaves`.

Evaluation mirrors `sas_plus::Task::evaluate_axioms` on a scratch
assignment, restricted to the derived variables of one factor, which is
closed under dependencies; a unit test compares it with sas-plus on random
states. Leaves with attached derived variables cost `O(|S_L| * rules)` per
closure and transfer for the evaluation.

*Heuristics.* `h^max` and `h^FF` split operators into one relaxed operator
for the unconditional effects and one per conditional effect (preconditions
plus conditions), add every axiom as a 0-cost relaxed operator, and seed the
default value of every derived variable at cost 0: no relaxed operator
produces a default value, and without the seed a goal on it would make
`h^max` declare a solvable state a dead end.

Invalid tasks are rejected via `Task::validate`.

## Testing strategy

- **Cross-check against explicit-state Dijkstra.** On random tasks from
  `sas_plus::random::random_task`, compare solvability and optimal cost
  between a plain Dijkstra over `sas_plus::State` and decoupled search.
  Every check runs uniform-cost search, A* with `h^max` (and the
  merge-and-shrink adapter, exact and size-limited, and LM-cut, with their
  features),
  and anytime A* with each of those as the fork heuristic under a blind
  root and `h^max` of the free-leaf task, in every optimal configuration
  (six criteria with and without `fold_g`, and leaf reduction under
  three). Heuristics on `Config::reduced_task` are cross-checked
  separately: A\* with `h^max` against the optimum, GBFS with `h^FF` in
  both leaf modes against solvability. Random tasks mostly have one causal-graph component, so the
  tests also run every seed under several explicit partitions and assert
  that enough solvable, nonzero-cost cases with at least two leaves were
  seen. Variants zero some operator costs, and add conditional effects and
  derived variables: unmodified, every factoring is either rejected with a
  precise error or matches; with the inexpressible conditions dropped per
  factoring, every factoring must be accepted and match, with a floor on
  runs that attach derived variables to leaves.
- **Admissibility on member states.** A unit test enumerates the member
  states of the first decoupled states of random tasks and checks `h^max`
  and the merge-and-shrink adapter against the cheapest member price plus
  `h*` from `Task::perfect_heuristic`.
- **Dominance non-vacuity.** The Logistics example of Torralba et al.
  shows each stronger criterion avoiding the basic blow-up; aggregated
  random runs show each setting pruning what the weaker one keeps; a unit
  test pins the two-leaf counterexample to per-leaf `g` folding; the leaf
  simulation is hand-checked on a Logistics leaf.
- **Fork shape**, **star tasks** (all strategies and `auto`), **scoring**.
- **Plan validity.** Every returned plan passes `Plan::validate`, which is
  itself checked against `Task::validate_plan`.
- **Greedy search** with `h^FF`, `h^max`, and reachability-only leaves
  under every criterion: solvability as Dijkstra, never below the optimum.
- **Termination on unsolvable tasks** and **fixtures** (gripper, optimal
  costs 7 and 5).
- **Axiom evaluation** against `Task::evaluate_axioms` on random states.
- **Property tests** (`tests/it/props.rs`, proptest): every factoring
  strategy against Dijkstra on fresh random tasks (conditional effects,
  axioms, zero costs; rejection allowed) and on random star tasks (an
  eighth of the cases, they are larger), and `h^max` and both LM-cut
  modes against `h*` from arbitrary explicit states, with `None` only on
  dead ends. `task test:prop` raises the case count.
- **Fuzz targets** (`fuzz/`, cargo-fuzz on nightly): `search` builds an
  arbitrary leaf partition (unknown variables included) on a small random
  task and checks that the factoring and search entry points reject or
  agree with explicit search, uniform-cost, A\* with `h^max` and LM-cut,
  and greedy search alike; `plan` checks `Plan::validate` against
  `Task::validate_plan` on arbitrary operator sequences and costs. CI
  builds them; `task fuzz:smoke` runs them.
- The seeded cross-checks loop seeds deterministically. Tests build with
  `opt-level = 1`.

## Limitations

`Factoring::generalized`
approximates the paper's integer program greedily. Also open: an index for
the dominance store, an index for the symbolic center's dominance scan (it only buckets by `g`), the fork and inverted-fork refinements of
decoupled strong stubborn sets, and a nested hierarchy of factors (a decoupled group inside a
leaf), which generalized factorings do not express (see Factoring strategies, item 7).

## Cross-crate needs

- `sas-plus`: no SCC computation on `CausalGraph`; this crate computes sink
  components itself. A `CausalGraph::strongly_connected_components` would
  serve this crate and `merge-and-shrink`.
- `sas-plus`: `State` does not implement `Ord`, so `no_std` maps keyed by
  states need a `Vec<Value>` key. An `Ord` derive would help.
- `heuristic-search`: the test-only Dijkstra here could be replaced by its
  `dijkstra`, and decoupled search could reuse its open lists if the crate
  exported them (`open_list` is private).
- `search-core`: a shared `Plan { ops, cost }` type (with validation) would
  avoid one more local definition.
- `merge-and-shrink`: an accessor for `MergeAndShrinkHeuristic`'s final
  `Factor` (or its merge tree) would let `MasHeuristic` wrap the crate's own
  `build`, with label reduction, instead of re-running the merge loop from
  the public parts (including a copy of its private `shrink_sizes`).
- `planning-heuristics`: `HMax` and `HFf` here run their own relaxed
  exploration; `h_max_seeded` sums seeds, while `HMax` takes the maximum
  per factor, so they are not interchangeable. `LmCutHeuristic::new` uses
  `LmCut::value_seeded`.

## References

- Daniel Gnad and Jörg Hoffmann. *Beating LM-Cut with h^max (Sometimes):
  Fork-Decoupled State Space Search.* ICAPS 2015, pp. 88–96 (Anytime
  Fork-Root A\*, Figure 4).
- Daniel Gnad and Jörg Hoffmann. *Star-Topology Decoupled State Space
  Search.* Artificial Intelligence 257 (2018), pp. 24–60.
  doi:10.1016/j.artint.2017.12.004.
- Daniel Gnad, Jörg Hoffmann and Carmel Domshlak. *From Fork Decoupling
  to Star-Topology Decoupling.* SoCS 2015.
- Daniel Gnad, Jörg Hoffmann and Martin Wehrle. *Strong Stubborn Set
  Pruning for Star-Topology Decoupled State Space Search.* JAIR 65 (2019),
  pp. 343–392. doi:10.1613/jair.1.11576.
- Daniel Gnad, Álvaro Torralba and Jörg Hoffmann. *Symbolic Leaf
  Representation in Decoupled Search.* SoCS 2017, pp. 124–128. Technical
  report: <https://people.cs.aau.dk/~alto/papers/socs17-tr.pdf>.
- Daniel Gnad, Álvaro Torralba and Daniel Fišer. *Beyond Stars – Generalized
  Topologies for Decoupled Search.* ICAPS 2022, pp. 110–118.
- Daniel Gnad, Valerie Poser and Jörg Hoffmann. *Beyond Forks: Finding and
  Ranking Star Factorings for Decoupled Search.* IJCAI 2017, pp. 4310–4316.
- Álvaro Torralba, Daniel Gnad, Patrick Dubbert and Jörg Hoffmann. *On
  State-Dominance Criteria in Fork-Decoupled Search.* IJCAI 2016,
  pp. 3265–3271. Extended technical report with the proofs and the leaf
  reduction rule:
  <https://fai.cs.uni-saarland.de/hoffmann/papers/ijcai16b-tr.pdf>.