AI Wiki中文/EN

Planning graphs: compatible pairs do not make a complete plan

规划图

Build a STRIPS planning graph with persistence and mutex, test level-off correctly, and expose a joint resource constraint.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Three tasks, two tokens, and a graph that stays optimistic

Suppose a workshop must complete tasks A, B and C. Each task consumes one unused calibration token. There are two tokens, either token works for any task, and no action replaces a token. This is a hypothetical planning problem, with tokens representing an explicitly modelled resource.

Each task is possible. Any pair of tasks can be completed together by using different tokens. All three cannot be completed: finishing three distinct tasks would consume at least three tokens. A representation that remembers only individual possibilities and pairwise compatibility can miss that shortage.

A planning graph makes precisely this tradeoff. It alternates layers of possibly true facts and possibly usable actions, then marks certain pairs as mutually exclusive, or mutex. It can expose impossible combinations before searching through complete plans. A whole fact layer is not one reachable state, and a whole action layer is not a schedule to execute.

Blum and Furst’s Graphplan uses this structure to constrain a separate plan-extraction search. Their 1997 paper explains both phases; the program below implements the graph construction and necessary-condition checks. It deliberately returns not-ruled-out for the three-task example. Original paper, §§2–3.

Keep possibilities, then remove incompatible pairs

Our model has finitely many named atoms and already grounded actions: objects have already been substituted into any action templates. A concrete state ss is the set of atoms currently true; other atoms are false. An action aa has positive preconditions Pre(a)Pre(a), add effects Add(a)Add(a) and delete effects Del(a)Del(a), with disjoint add and delete sets. Its sequential transition is:

Pre(a)⊆s⟹γ(s,a)=(s∖Del(a))∪Add(a).Pre(a)\subseteq s\quad\Longrightarrow\quad\gamma(s,a)=(s\setminus Del(a))\cup Add(a).

Actions can share a parallel step when their preconditions hold in the preceding state and neither action deletes another’s precondition or add effect. Under these conditions, executing them in any sequential order gives the same result. This is a discrete independence convention, not a model of overlapping durations. Shared equipment must be represented by facts and effects; the algorithm does not infer a resource constraint from an action’s name. Parallel-plan convention, §2.

Let PiP_i be a fact layer and MiM_i its unordered mutex pairs. Initially P0=IP_0=I and M0M_0 is empty: all initial facts really coexist. At level ii, include each action whose preconditions appear in PiP_i and contain no mutex pair. Also add a persistence action for every p∈Pip\in P_i: it requires pp, adds pp and deletes nothing. These no-ops carry a fact to the next layer when no selected action destroys it.

Two distinct action nodes a,ba,b are mutex if their effects interfere, or if their preconditions have competing needs:

{a,b}∈MiA⟺Del(a)∩(Pre(b)∪Add(b))≠∅∨ Del(b)∩(Pre(a)∪Add(a))≠∅∨ ∃p∈Pre(a),q∈Pre(b):{p,q}∈Mi.\begin{aligned}\{a,b\}\in M_i^A\quad\Longleftrightarrow\quad&Del(a)\cap(Pre(b)\cup Add(b))\ne\varnothing\\&\lor\ Del(b)\cap(Pre(a)\cup Add(a))\ne\varnothing\\&\lor\ \exists p\in Pre(a),q\in Pre(b):\{p,q\}\in M_i.\end{aligned}

The first two lines include inconsistent effects and deleting another action’s prerequisite. The third propagates a conflict from the preceding fact layer. A delete effect never simply erases a fact from the next layer: different actions may preserve or reestablish that fact along different possibilities.

Write Suppi(p)Supp_i(p) for the actions at this level that add pp, including persistence actions. The next facts are the union of add effects. Two distinct next-layer facts are mutex only when every choice of one supporter for each fact is mutex:

Pi+1=⋃a∈AiAdd(a),Suppi(p)={a∈Ai:p∈Add(a)},{p,q}∈Mi+1⟺∀a∈Suppi(p),b∈Suppi(q):{a,b}∈MiA(p≠q).\begin{aligned}P_{i+1}&=\bigcup_{a\in A_i}Add(a),\\Supp_i(p)&=\{a\in A_i:p\in Add(a)\},\\\{p,q\}\in M_{i+1}&\Longleftrightarrow\forall a\in Supp_i(p),b\in Supp_i(q):\{a,b\}\in M_i^A\qquad(p\ne q).\end{aligned}

A single action that produces both facts supplies a compatible witness: an action is not mutex with itself. “Some supporters conflict” is insufficient to mark the facts mutex. The university slides illustrate the distinction between competing needs and inconsistent support. CMU 15-381, slides 10–11.

Why are these tests sound? Induct on the number of steps. Initial facts all occur together. For a real next step, each chosen action’s preconditions occurred together before, so no sound previous mutex blocks it. Compatible chosen actions do not interfere. A fact that survives can be supported by its no-op, which does not conflict with the chosen actions that preserve it. Consequently, every true next-state fact appears in the graph, and every pair that actually co-occurs has compatible supporters. For positive goals GG, a real plan therefore implies:

a plan achieves G within i steps⟹G⊆Pi ∧ ∀p,q∈G (p≠q⇒{p,q}∉Mi).\text{a plan achieves }G\text{ within }i\text{ steps}\quad\Longrightarrow\quad G\subseteq P_i\ \land\ \forall p,q\in G\ (p\ne q\Rightarrow\{p,q\}\notin M_i).

Waiting with persistence actions accounts for plans shorter than ii. The converse is false: the two-token example provides compatible witnesses for each pair, but no single choice supports all three tasks. Even admitting an action with three pairwise compatible prerequisites does not prove that all three can occur together.

Graph construction eventually levels off. Facts persist, and a present nonmutex pair stays nonmutex through its two persistence actions. Thus facts and present nonmutex pairs can only accumulate. For QQ distinct atoms in the model, there are at most QQ facts and (Q2)\binom Q2 such pairs. Every unequal transition adds at least one item to these two collections. The first equal transition certifies stability:

Pi+1=Pi ∧ Mi+1=Mi⟹all later fact layers and mutex sets are identical,h≤1+Q+(Q2).P_{i+1}=P_i\ \land\ M_{i+1}=M_i\quad\Longrightarrow\quad\text{all later fact layers and mutex sets are identical},\qquad h\leq 1+Q+\binom Q2.

Here hh counts constructed action layers when running until level-off; the bound includes the final equality check and also covers an empty model. Comparing facts alone is wrong. Once both sets agree, the same deterministic construction produces the same next layer. At that fixed graph, an absent goal or a mutex goal pair proves unreachability. Goals that pass the test remain unresolved. Full Graphplan uses backward extraction and memoized failed goal sets for a stronger termination argument; graph stability alone is not that argument. Original paper, §5.1–5.3.

Build the graph without inventing a plan

The following complete program uses only the Python standard library. An action row is (name, pre, add, delete). Containers supplied by the caller must be lists or tuples; names are nonempty strings. Repeated atoms are normalized, repeated action names are rejected, and input objects remain unchanged. Negative preconditions are outside this interface: an atom named not_ready is just an ordinary atom.

Real actions and persistence actions have different tagged IDs, so an action named p cannot collide with the persistence action for atom p. max_levels limits newly constructed action layers. Zero returns just the initial layer; None continues until both facts and mutex stabilize. If equality is detected on the final allowed expansion, the stop reason is level-off.

goal_test accepts an unmodified graph returned by this program. empty-plan is justified by the initial state. not-ruled-out means the necessary conditions passed at first_layer; it is not a witness. unreachable requires a fixed graph that still fails those conditions. ruled-out-through-horizon says only that no plan fits within the layers constructed so far. A returned first_layer is a lower bound on parallel plan length when a plan exists.

from itertools import combinations


def names(items):
    if type(items) not in (list, tuple):
        raise ValueError('Expected a list or tuple of atom names')
    if any(type(x) is not str or not x for x in items):
        raise ValueError('Atom names must be nonempty strings')
    return frozenset(items)


def pair(x, y):
    return frozenset((x, y))


def planning_graph(initial, rows, max_levels=None):
    facts = names(initial)
    if type(rows) not in (list, tuple):
        raise ValueError('Actions must be a list or tuple')
    if max_levels is not None and (type(max_levels) is not int or max_levels < 0):
        raise ValueError('max_levels must be a nonnegative integer or None')
    actions = {}
    for row in rows:
        if type(row) not in (list, tuple) or len(row) != 4:
            raise ValueError('An action is (name, pre, add, delete)')
        name, pre, add, delete = row
        if type(name) is not str or not name or ('act', name) in actions:
            raise ValueError('Action names must be nonempty and unique')
        pre, add, delete = names(pre), names(add), names(delete)
        if add & delete:
            raise ValueError('Add and delete effects must be disjoint')
        actions[('act', name)] = (pre, add, delete)
    ps, pms, layers, ams = [facts], [frozenset()], [], []
    stop = 'horizon'
    while max_levels is None or len(layers) < max_levels:
        pm = pms[-1]
        layer = {
            key: value for key, value in actions.items()
            if value[0] <= facts
            and all(pair(p, q) not in pm for p, q in combinations(value[0], 2))
        }
        for p in sorted(facts):
            layer[('keep', p)] = (frozenset((p,)), frozenset((p,)), frozenset())
        am = set()
        for a, b in combinations(layer, 2):
            ap, aa, ad = layer[a]
            bp, ba, bd = layer[b]
            if (ad & (bp | ba) or bd & (ap | aa)
                    or any(pair(p, q) in pm for p in ap for q in bp)):
                am.add(pair(a, b))
        support = {}
        for a, (_, add, _) in layer.items():
            for p in add:
                support.setdefault(p, []).append(a)
        next_facts = frozenset(support)
        next_pm = frozenset(
            pair(p, q) for p, q in combinations(sorted(next_facts), 2)
            if all(pair(a, b) in am for a in support[p] for b in support[q])
        )
        layers.append(layer)
        ams.append(frozenset(am))
        ps.append(next_facts)
        pms.append(next_pm)
        if next_facts == facts and next_pm == pm:
            stop = 'level-off'
            break
        facts = next_facts
    return {'stop': stop, 'facts': tuple(ps), 'fact_mutex': tuple(pms),
            'actions': tuple(layers), 'action_mutex': tuple(ams)}


def goal_test(graph, goals):
    # graph is an unmodified result of planning_graph, not an arbitrary schema.
    goals = names(goals)
    for depth, (facts, pm) in enumerate(zip(graph['facts'], graph['fact_mutex'])):
        if goals <= facts and all(pair(p, q) not in pm for p, q in combinations(goals, 2)):
            return {'status': 'empty-plan' if depth == 0 else 'not-ruled-out',
                    'first_layer': depth}
    return {'status': 'unreachable' if graph['stop'] == 'level-off'
            else 'ruled-out-through-horizon', 'first_layer': None}


def resource_example():
    return [('do_' + task + '_' + token, [token], [task], [token])
            for task in ('A', 'B', 'C') for token in ('token1', 'token2')]


def envelope_example():
    return [('open_check', ['closed'], ['checked'], ['closed']),
            ('close', [], ['closed'], []),
            ('file', ['closed', 'checked'], ['filed'], [])]


if __name__ == '__main__':
    graph = planning_graph(['token1', 'token2'], resource_example())
    print('Resources:', graph['stop'],
          [(len(p), len(m)) for p, m in zip(graph['facts'], graph['fact_mutex'])])
    print('Three tasks:', goal_test(graph, ['A', 'B', 'C']))
    graph = planning_graph(['closed'], envelope_example())
    print('Envelope:', graph['stop'],
          [(sorted(p), len(m)) for p, m in zip(graph['facts'], graph['fact_mutex'])])
    print('Filing:', goal_test(graph, ['filed']))

Running the file prints:

Resources: level-off [(2, 0), (5, 0), (5, 0)]
Three tasks: {'status': 'not-ruled-out', 'first_layer': 1}
Envelope: level-off [(['closed'], 0), (['checked', 'closed'], 1), (['checked', 'closed'], 0), (['checked', 'closed', 'filed'], 0), (['checked', 'closed', 'filed'], 0)]
Filing: {'status': 'not-ruled-out', 'first_layer': 3}

Each resource-layer pair reports the number of facts and mutex pairs. The second example models opening an envelope to check its contents, closing it, then filing it. open_check removes closed; close can establish it again. At layer 1, checked and closed are mutex. At layer 2, the facts are unchanged but the mutex disappears: keep the check result while closing the envelope. Only then can file enter the next action layer.

Fact layerFactsMutex pairsIs file admitted from this layer?
0closed0No
1checked, closed1No
2checked, closed0Yes
3checked, closed, filed0Yes
4checked, closed, filed0Stable graph; no further expansion needed

The graph does not return the envelope plan. We can separately verify the three-step sequence open_check, close, file against the transition rule. In contrast, exhaustive concrete-state exploration of the token model yields 13 reachable states and no state with all three tasks. In every reachable state, completed distinct tasks plus remaining tokens is at most two. Spending another token on an already completed task can reduce this quantity, but cannot increase it.

Eight test groups extract the authored code, compare 2,668 small two-atom models against enumerated concrete parallel transitions, and check soundness on 60 seeded four-atom models. Targeted checks cover deleted facts versus persistence, one action supporting two facts, competing needs, graph stability, horizon meanings, input errors and unchanged inputs. This is an automated technical check of a teaching implementation, not a claim of human review.

For the code’s cost, let AA be the number of grounded real actions, QQ the number of distinct model atoms, B=A+QB=A+Q, LL the raw input length including one constant unit, and hh the number of constructed action layers. Treat names as unit-cost keys and hash-table operations as expected constant time. Preconditions are checked in pairs, action pairs compare preconditions, and fact pairs examine supporter pairs. A deliberately loose bound for the retained whole graph is:

T=O(L+h(B+1)2(Q+1)2),S=O(L+(h+1)(BQ+B2+Q2+1)).T=O\bigl(L+h(B+1)^2(Q+1)^2\bigr),\qquad S=O\bigl(L+(h+1)(BQ+B^2+Q^2+1)\bigr).

The bounds include no-op storage, sorting and the empty-model constants; they are not bounds for arbitrary lifted action descriptions or a plan extractor. The separate goal check with gg supplied goal entries costs at most O(g+(h+1)(g+1)2)O(g+(h+1)(g+1)^2) time and O(g+1)O(g+1) extra space. The layer horizon is not an overall time or memory budget.

A compact graph cannot remember every joint restriction

The token example is not a bug to fix by marking every pair of tasks mutex. Each pair has a real plan, so doing that would reject valid two-task goals. The missing information concerns triples. An extractor can search for one compatible choice of supporters for all goals, then recursively support all their prerequisites; it cannot choose a different support assignment independently for each pair. Extraction, CMU slides 21–22.

Our program ends graph construction at level-off even when goals remain unresolved. It does not implement extraction, failed-subgoal memoization or a complete planner. In full Graphplan, extraction may have to continue at later horizons after the graph’s sets have stabilized. The original paper’s failure test also reasons about the evolution of memoized failed goal sets.

Removing all delete effects produces a different, more optimistic model. In the token example it allows tokens to be reused indefinitely. In the envelope example it incorrectly keeps closed while opening the envelope. Such a relaxed graph can be useful for a heuristic, but it is not the full mutex graph defined here.

The action language also omits negative preconditions, conditional effects, numeric resources, uncertainty and time durations. Explicit grounding can be large before construction begins. If plan extraction is added, the compact graph does not make the combinatorial search disappear. A parallel horizon measures layers of independent actions; it does not by itself minimize total actions, monetary cost or elapsed physical time.

Predict the layer before running the code

  1. In the token model, is it sound to report unreachable for goals A and B because A, B and C cannot all be achieved?

Answer: No. Use do_A_token1 and do_B_token2 in one parallel step. The obstruction concerns the three-goal set, not either of its pairs. The graph correctly gives no mutex among A, B and C, while leaving their joint achievement unresolved.

  1. Stop envelope construction after two action layers. Is filed unreachable? What goes wrong if level-off compares only facts?

Answer: It is ruled-out-through-horizon, not proved unreachable. Layers 1 and 2 have the same facts but different mutex sets. At layer 2, closed and checked can coexist, admitting file; filed first appears at layer 3. Comparing only facts would stop one expansion too early and produce a false impossibility claim.

  1. A single action has precondition p, adds both q and r, and deletes p. Starting with p, which pairs among p, q, r are mutex at layer 1?

Answer: The pairs p,q and p,r are mutex: the action conflicts with the persistence action for p. The pair q,r is not mutex because the same action supports both. A fact mutex test that rejects a supporter used twice would be wrong.

  1. Add a third token to the resource example. What changes, and what does a first_layer of 1 prove?

Answer: Include an action for each task using the third token, and place that token in the initial state. The three actions using different tokens form a valid one-step parallel plan. A graph result of 1 alone still proves only a lower bound and pairwise admissibility; the explicitly checked three-action set supplies the missing witness. In the original two-token model the same graph result had no witness.

Read construction and extraction as separate mechanisms

Blum and Furst’s original paper describes the planning graph, its mutex propagation, backward extraction and memoization. Its title page identifies the 1997 journal version; the authors’ maintained project page confirms the bibliographic entry. The argument about graph level-off is in §5.1, while the stronger Graphplan failure argument is in §5.3. Keeping those sections separate prevents the most consequential implementation mistake in this chapter. Paper, authors’ Graphplan archive.

The CMU lecture offers a visual route through alternating layers, mutex cases and extraction. Compare slides 10–11 with the two mutex computations, then slides 21–22 with the search intentionally omitted here. CMU 15-381, Fall 2016, lecture 6.

For the surrounding knowledge map, read the chapters on classical planning and STRIPS. They concern problem formulation and search; this chapter supplies a compact representation that can reject some impossible subgoals and guide that search.

Make a prediction, then check

At a stable planning graph, all three goals appear and no goal pair is mutex. What does construction alone establish?

Choose one answer

Learning objectives

  • Construct alternating fact and action layers with persistence and delete-aware mutex.
  • Prove why graph conditions are necessary and distinguish pairwise compatibility from a joint plan.
  • Test stability using both facts and mutex, and interpret finite horizons without overstating reachability.

Prerequisites & connections

Explore related knowledge →

References

  1. Fast Planning Through Planning Graph Analysis
    Avrim L. Blum; Merrick L. Furst · 1997
  2. Planning — CMU 15-381, Fall 2016, Lecture 6
    Carnegie Mellon University, 15-381 course · 2016

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-05 · Codex technical check: primary-source locations, original runnable models, independent finite-state oracles, bilingual review and second-agent cross-checks; not independent human peer review.

  • AI author check: eight tests passed using identical Python extracted from both MDX articles. Concrete parallel-state enumeration checks 2,668 two-atom models exactly and soundness on 60 seeded four-atom models.
  • The input-size parameter L explicitly includes one constant unit, following an independent AI clarity check; the code is unchanged. The token model has 13 reachable concrete states and no three-task solution; every two-task goal is reachable. The envelope graph keeps the same facts while losing a mutex before filing first appears at layer 3.
  • Strict MDX, KaTeX and actual React HTML passed in both languages: six display equations, six anchors and four rendered answers. Formulas and executable code match; review remains written pending independent AI cross-check.
  • Read complete bilingual prose, code, eight tests and metadata. Ground positive-precondition STRIPS, action independence, persistence, both mutex levels and non-self-mutex supporters are correct. Level-off compares facts and mutex together; not-ruled-out is not a plan, and full extraction/failure memoization is separately required.
  • A focused third reference uses positive Boolean compatibility matrices: admit an action when its preconditions form a clique including diagonals in C, form action compatibility K, then compute C next = E transpose K E from add incidence E. This differs from the author concrete parallel-state enumeration. Ten fixtures times five horizons give 50 complete graphs, 122 fact layers, 72 action layers and 275 matching queries, including shared supporters, competing needs, unseeded cycles, exact stability and a triple-precondition gap.
  • Independently enumerated sixteen allocations assigning each token to no task or A/B/C, yielding thirteen distinct reachable states, every pair achievable and the triple impossible. A new joint action with three prerequisites is nevertheless admitted in the second action layer, with all_done not ruled out at fact layer two, confirming even a single derived goal can be a false positive. Checked envelope mutex disappearance before filing and the three-token concrete witness. All eight author tests reran successfully.
  • Separately checked soundness induction and finite level-off bound: facts and present nonmutex pairs accumulate, giving h <= 1+Q+choose(Q,2). Costs account for precondition/action/supporter pairs and retained layers. Suggested explicitly including one constant unit in L for zero-horizon empty inputs; the author updated both locales and metadata without changing code/formulas, and the final wording was reread.
  • Final strict MDX/KaTeX and actual React HTML pass with six displays, six anchors and four answers per locale. Displays and complete Python match byte for byte and actual cost annotations are complete; Chinese adds inline i/G when explaining the English display text, not different mathematics. No emphasis residue outside code. Independent AI technical review, not human peer review; no author/repository edits or browser/whole-site acceptance.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation check: linked completed chapters directly and removed their obsolete planned labels. Unfinished topics still link to the catalogue with their status stated. Reversible replacements are recorded; other technical content is unchanged and both hashes are rebound.

Source locations checked:

  • Fast Planning Through Planning Graph Analysis · Author-hosted 20-page PDF, native text and web text: title page identifies Artificial Intelligence 90:281–300 (1997), independently confirmed by the author’s Graphplan homepage. Sections 2 and 2.1, PDF pages 4–5: independent parallel steps, persistence and alternating layers. Section 2.2, pages 5–6: interference, competing needs and universal supporter-pair mutex. Sections 3.1–3.2.1, pages 7–9: admission, extraction and memoization. Sections 5.1–5.3, pages 15–16: monotonic facts and present nonmutex pairs; stable graph versus the stronger memoized failure test. No reproduction of historical performance claims or implementation assets.
  • Planning — CMU 15-381, Fall 2016, Lecture 6 · Official PDF downloaded after web fetch failed. Native text omitted most prose, so rendered and OCR-read slides 6–11 and 19–24; visually inspected slide 11. Slides 6–8: layers and no-ops. Slides 10–11: inconsistent effects, interference, competing needs and inconsistent support. Slide 19: leveling off. Slides 20–22: set-level estimate and separate extraction. Slide 24 concerns the full Graphplan algorithm, not the construction-only code. Slide footers verify Fall 2016 and course attribution.
  • Fast Planning Through Planning Graph Analysis · Independently opened author-hosted 20-page PDF through web: title confirms Artificial Intelligence 90:281–300 (1997), also verified on the author archive page. Read sections 2/2.1 (PDF pages 4–5, parallel independence and persistence), 2.2 (pages 5–6, interference, competing needs and every supporter pair), and sections 5.1–5.3 (pages 15–16, monotone present nonmutex pairs, fact/mutex equality, the necessary-condition failure test and separate memoized failed-goal termination argument). Did not adopt historical benchmark claims or copy implementation assets.
  • Planning — CMU 15-381, Fall 2016, Lecture 6 · The remote official lecture PDF web request returned Internal Error. Instead actually viewed the author-retained rendered slides cmu-slide-11.png, cmu-later-19.png, cmu-later-21.png and cmu-later-22.png. Slide 11 confirms competing needs versus universal inconsistent support; 19 confirms adjacent-level stability and Fall 2016/course footer; 21 separates construction from extraction and further horizon expansion; 22 specifies backward search over jointly compatible supporter sets and prerequisite goals. Native text omits this prose; no independent OCR run or successful remote fetch is claimed.

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.