AI Wiki中文/EN

Partial-order planning: protect conditions without fixing every position

偏序规划

Build causal links, resolve threats and verify every linearization of a fixed set of action occurrences.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A checklist needs some arrows, not necessarily one long queue

A fictional archive has selected four jobs for a scanning station. Calibration makes the scanner ready. Scanning needs that calibration. Resetting erases it. Labelling the document is independent of the scanner in this model. All four jobs must happen, and the final state must say both “scanned” and “labelled.”

OccurrencePreconditionsAddDelete
calibrate#1bench_readycalibrated—
scan#1calibratedscanned—
reset#1bench_ready—calibrated
label#1—labelled—

Initially, only bench_ready is true. One solution requires reset → calibrate → scan, leaving the label job anywhere among those three. That represents four sequences. Another solution allows resetting after scanning. Choosing a useful ordering does not require deciding every position in advance.

A partial-order plan represents action occurrences and required precedence. Two occurrences of the same action are different nodes: calibrate#1 and calibrate#2 may use identical instructions but happen at different points. A linearization is a total order consistent with every precedence constraint. A completed plan should make every such linearization executable and goal-achieving. Poole and Mackworth, §6.5.

General partial-order planners can add occurrences while choosing how to achieve goals. Our program solves a smaller problem: order all the supplied occurrences, each exactly once. It can neither invent another calibration nor silently discard an inconvenient reset. That restriction makes its success and failure claims precise.

Remember which occurrence supplies each condition

Use a finite vocabulary of Boolean atoms, a complete initial state and positive goals. Each ground action has positive preconditions and disjoint add/delete sets. Preconditions are checked before its effects; undeleted, unadded facts persist. Missing initial atoms are false. Actions are instantaneous, deterministic and sequential. This is the positive fragment introduced in STRIPS.

Add two artificial nodes. start has the initial facts as add effects; finish has the goals as preconditions. Every real occurrence must follow start and precede finish. The strict partial order is transitive and has no cycles. An open condition is a pair consisting of a consumer occurrence and one of its preconditions that still needs support.

A causal link records a producer, the supported atom and its consumer:

u→pv:p∈add⁡(u)∩pre⁡(v),u≺v.u\xrightarrow{p}v:\qquad p\in\operatorname{add}(u)\cap\operatorname{pre}(v),\qquad u\prec v.

The link protects an interval: after the producer establishes the atom, it must survive until the consumer checks it. An intervening deleter is a threat. For an acyclic order already containing the link, a distinct occurrence can fit between its endpoints precisely when neither outside ordering is forced:

t∉{u,v},p∈del⁡(t),¬(t≺u),¬(v≺t).Repair: t≺u or v≺t.t\notin\{u,v\},\quad p\in\operatorname{del}(t),\quad\neg(t\prec u),\quad\neg(v\prec t).\qquad\text{Repair: }t\prec u\ \text{or}\ v\prec t.

Putting the threat before the producer is demotion; putting it after the consumer is promotion. Search must consider the consistent alternatives rather than declare the first failed choice conclusive. This terminology and the protected-link construction follow Weld’s account of least-commitment planning. Weld, §4.2.

Endpoints matter. A consumer may delete its own precondition after checking it; it is not an intervening threat to its incoming link. A producer cannot simultaneously add and delete the same atom under our input rules. A threat to a link from start cannot be moved before start. A threat to a goal link cannot be moved after finish.

A certificate consists of an acyclic order and one protected causal link for every precondition of every real occurrence and finish. It guarantees:

∅≠LE⁡(≺)⊆Valid⁡(I,G,A),\varnothing\ne\operatorname{LE}(\prec)\subseteq\operatorname{Valid}(I,G,\mathcal A),

where LE is the set of linearizations and Valid contains executable sequences using exactly the supplied occurrence set. To prove it, take any linearization. Its first real action receives each precondition from start or an earlier producer. No deleter can fall inside the supporting interval. Induct over actions: every precondition therefore holds when needed. Apply the same argument to finish to obtain the goal. Acyclicity of a finite order supplies at least one linearization.

This is a sufficient certificate, not a promise to represent all valid sequences. In the scanning example, there are eight valid total orders. The first returned certificate represents four of them. “Least commitment” here means postponing unnecessary choices during refinement; this program does not optimize the number of order constraints or maximize flexibility.

Repair open conditions and threats with finite search

The stack contains partial certificates. A node first checks existing links for a threat. If it finds one, it branches on the two repairs and drops cyclic children. Otherwise, it selects the first open condition and branches over existing producers. A producer cannot support itself. A node with no threats or open conditions is a completed certificate. Branches use sorted occurrence IDs, with demotion tried before promotion; this is a reproducible search policy, not a quality ranking.

The search is complete for the fixed occurrence set. Suppose a valid total sequence exists. For each precondition, choose its latest earlier producer in that sequence, using start when appropriate. No deleter lies between that producer and consumer. Those choices appear among the search branches, and each threat can be placed on the side it occupies in the valid sequence. These refinements remain acyclic. Thus exhaustive search retains a route to some certificate whenever a valid permutation exists.

Let NN count all nodes, including start and finish, and let KK be the number of distinct precondition obligations, including goals. Each support refinement removes an open condition; each threat repair adds a previously absent ordering pair. A branch has depth at most H=K+N(N−1)/2H=K+N(N-1)/2, with at most NN children per node. The search is finite but can still be exponential. The implementation recomputes transitive closure with a cubic Boolean matrix routine. For RR inspected partial plans and raw input size D≥1D\ge1, loose bounds are:

T=O(Dlog⁡(1+D)+(R+1)(N4+NK)),S=O(D+N(K+N2)2).T=O\bigl(D\log(1+D)+(R+1)(N^4+NK)\bigr),\qquad S=O\bigl(D+N(K+N^2)^2\bigr).

Input size counts raw atom occurrences and action records, including duplicates. These bounds assume unit-cost names and expected hash-table operations. The N4N^4 term allows up to NN closure computations at one node. Each stored partial plan takes O(N2+K)O(N^2+K) space; depth-first search retains siblings along at most HH levels. Long strings and large counters have additional character and bit costs. The returned order is its full transitive closure, including implied pairs, rather than a diagram with redundant arrows removed.

Inputs use lists or tuples; each occurrence is a five-field tuple (step ID, action ID, pre, add, delete). Step IDs must be unique and cannot equal <start> or <finish>. Repeated action IDs are allowed only with identical definitions. Atom duplicates have set semantics. All referenced atoms must be declared. The function copies its inputs.

budget limits inspected partial plans, including failed nodes and completed certificates. At zero, even the empty problem returns unknown: this interface checks the budget before inspecting its first node. Frontier exhaustion returns no-plan-for-occurrences; neither failure status includes a partial certificate. A successful result includes every supplied occurrence through its boundary constraints.

# Python 3.10+; all supplied action occurrences must execute exactly once.
START, FINISH = '<start>', '<finish>'


def name(value):
    if type(value) is not str or not value:
        raise ValueError('names must be nonempty strings')
    return value


def collection(values):
    if type(values) not in (list, tuple):
        raise ValueError('collections must be lists or tuples')
    return frozenset(name(x) for x in values)


def order_closure(size, edges):
    before = [[False] * size for _ in range(size)]
    for a, b in edges:
        before[a][b] = True
    for k in range(size):
        for i in range(size):
            if before[i][k]:
                for j in range(size):
                    before[i][j] |= before[k][j]
    if any(before[i][i] for i in range(size)):
        return None
    return frozenset((i, j) for i in range(size)
                     for j in range(size) if before[i][j])


def partial_order_plan(atoms, initial, goal, occurrences, budget=None):
    universe = collection(atoms)

    def facts(values):
        result = collection(values)
        if not result <= universe:
            raise ValueError('undeclared atom')
        return result

    initial, goal = facts(initial), facts(goal)
    if type(occurrences) not in (list, tuple):
        raise ValueError('occurrences must be a list or tuple')
    if budget is not None and (type(budget) is not int or budget < 0):
        raise ValueError('budget must be None or a nonnegative integer')
    rows, definitions = {}, {}
    for row in occurrences:
        if type(row) is not tuple or len(row) != 5:
            raise ValueError('occurrence: (step id, action id, pre, add, delete)')
        step, action = name(row[0]), name(row[1])
        if step in rows or step in (START, FINISH):
            raise ValueError('duplicate or reserved step id')
        pre, add, delete = (facts(x) for x in row[2:])
        if add & delete:
            raise ValueError('add and delete must be disjoint')
        definition = (pre, add, delete)
        if action in definitions and definitions[action] != definition:
            raise ValueError('one action id must have one definition')
        definitions[action] = definition
        rows[step] = definition
    names = (START, *sorted(rows), FINISH)
    steps = ((frozenset(), initial, frozenset()),
             *(rows[s] for s in names[1:-1]),
             (goal, frozenset(), frozenset()))
    size = len(names)
    edges = {(0, size - 1)}
    edges.update((0, i) for i in range(1, size - 1))
    edges.update((i, size - 1) for i in range(1, size - 1))
    order = order_closure(size, edges)
    todo = tuple((i, p) for i in range(1, size)
                 for p in sorted(steps[i][0]))
    stack, checked = [(order, (), todo)], 0

    def result(status, order=None, links=None):
        return dict(status=status, checked=checked,
                    order=None if order is None else tuple(
                        (names[i], names[j]) for i, j in sorted(order)),
                    links=None if links is None else tuple(
                        (names[u], p, names[v]) for u, p, v in links))

    while stack:
        if budget is not None and checked >= budget:
            return result('unknown')
        order, links, todo = stack.pop()
        checked += 1  # Includes complete certificates and failed partial plans.
        threat = next(((u, p, v, t) for u, p, v in links
                       for t in range(1, size - 1)
                       if t not in (u, v) and p in steps[t][2]
                       and (t, u) not in order and (v, t) not in order), None)
        children = []
        if threat is not None:
            u, p, v, t = threat
            for edge in ((t, u), (v, t)):  # Demotion, then promotion.
                refined = order_closure(size, order | {edge})
                if refined is not None:
                    children.append((refined, links, todo))
        elif todo:
            v, p = todo[0]
            for u in range(size - 1):
                if u != v and p in steps[u][1]:
                    refined = order_closure(size, order | {(u, v)})
                    if refined is not None:
                        children.append((refined, links + ((u, p, v),), todo[1:]))
        else:
            return result('found', order, links)
        stack.extend(reversed(children))
    return result('no-plan-for-occurrences')


def scanner_task():
    atoms = ('bench_ready', 'calibrated', 'scanned', 'labelled')
    steps = (
        ('calibrate#1', 'calibrate', ('bench_ready',), ('calibrated',), ()),
        ('scan#1', 'scan', ('calibrated',), ('scanned',), ()),
        ('reset#1', 'reset', ('bench_ready',), (), ('calibrated',)),
        ('label#1', 'label', (), ('labelled',), ()),
    )
    return atoms, ('bench_ready',), ('scanned', 'labelled'), steps


if __name__ == '__main__':
    args = scanner_task()
    answer = partial_order_plan(*args)
    print('status:', answer['status'])
    print('checked:', answer['checked'])
    print('real order:', tuple((a, b) for a, b in answer['order']
                               if a != START and b != FINISH))
    print('links:', answer['links'])
    print('budget 0:', partial_order_plan(*args, budget=0)['status'])
    extra = args[3] + (('extra#1', 'extra', ('scanned',), (), ('labelled',)),)
    # This extra step can run before labelling: it is not silently discarded.
    print('extra retained:', any('extra#1' in edge for edge in
          partial_order_plan(*args[:3], extra)['order']))

The complete program prints:

status: found
checked: 7
real order: (('calibrate#1', 'scan#1'), ('reset#1', 'calibrate#1'), ('reset#1', 'scan#1'))
links: (('<start>', 'bench_ready', 'calibrate#1'), ('<start>', 'bench_ready', 'reset#1'), ('calibrate#1', 'calibrated', 'scan#1'), ('label#1', 'labelled', '<finish>'), ('scan#1', 'scanned', '<finish>'))
budget 0: unknown
extra retained: True

The seven inspections comprise the initial node, five support refinements and one threat repair. The real precedence relation contains reset → calibrate → scan and its implied reset → scan pair. Label has no real predecessor or successor, so inserting it into any of the four positions gives a valid linearization. The extra occurrence in the last output line remains required; its deletion of labelled is handled by placing it before labelling.

The accompanying tests use an independent reference: enumerate complete permutations and execute each by Boolean coordinate updates. They check that returned linearizations form a nonempty subset of the executable goal-achieving permutations. That factorial reference is deliberately limited to small cases; the planner itself does not enumerate total orders.

Ordering freedom is not a concurrency guarantee

Unordered jobs can be swapped in the abstract sequential model. They may still share one operator, scanner or power supply. The model contains no durations, capacity limits, overlap semantics or safety conditions during an action. It cannot authorize simultaneous physical execution.

Failure concerns the selected instances. With a reset and scan but no calibration or initially calibrated state, this program may find no order; adding a calibration instance can change that answer. Conversely, an empty goal does not excuse an impossible selected action. General POP must also search over action selection and occurrence counts; our finite completeness proof says nothing about those larger search spaces.

Positive ground facts avoid variable binding, negative conditions, conditional effects and temporal constraints. Those extensions change both support and threat reasoning. Nor is a causal link an empirical causal-discovery claim: it records dependence inside the supplied transition model.

Continue with classical planning, planning graphs and temporal planning. The catalogue identifies chapters still in progress.

Find the obligation before choosing its position

Exercise 1: list the first certificate’s linearizations

Answer: Preserve reset → calibrate → scan, then place label before reset, between reset and calibrate, between calibrate and scan, or after scan. There are four. Orders with reset after scan also work in this domain, but this certificate does not include them.

Exercise 2: support scanning from the initial state

Answer: Suppose calibrated is initially true and only scan and reset are supplied. The link is start → calibrated → scan. Reset cannot precede start, so demotion fails and promotion orders scan before reset. Scanning may itself delete calibrated after checking it; that does not invalidate its incoming link.

Exercise 3: does an empty goal guarantee success?

Answer: No. A selected action requiring an unavailable atom still has an open condition, even when finish has none. Every selected occurrence must execute. With no occurrences and an empty goal, one inspected node yields a certificate; budget zero instead yields unknown by this interface’s counting rule.

Exercise 4: can two copies of calibration share one ID?

Answer: They may share the action ID calibrate and identical definitions. Their occurrence IDs must differ, such as calibrate#1 and calibrate#2. Each is a separate node that executes once. Distinct IDs alone do not allow different definitions under the same action ID; the validator rejects that ambiguity.

Plan-space reasoning beyond the small model

Poole and Mackworth’s third-edition §6.5 describes support selection, occurrence creation and protection choices. This article fixes occurrence selection so that ordering and certificate correctness can be tested separately.

Weld’s An Introduction to Least Commitment Planning appeared in AI Magazine 15(4), pp. 27–61, in 1994, as recorded in the author’s publication list. The 52-page prepublication copy hosted by CMU has different pagination and a provisional seasonal label. Its §4.2 develops causal links and POP; later sections cover representations beyond this chapter’s scope. The program, scanning example and exercises here are original, not copied UCPOP code.

Make a prediction, then check

Initially the scanner is calibrated. The supplied scan depends on calibration, and reset deletes it. How can the initial-state link to scan be protected?

Choose one answer

Learning objectives

  • Distinguish action definitions from occurrences and describe partial plans through open conditions, causal links and precedence.
  • Prove that protected links make every linearization executable, including consumer self-deletion and start/finish threat boundaries.
  • Run finite search for a fixed occurrence set and distinguish found, no-plan-for-occurrences and budget-induced unknown without treating unordered actions as permission for concurrency.

Prerequisites & connections

Explore related knowledge →

References

  1. Artificial Intelligence: Foundations of Computational Agents, 3e — §6.5 Partial-Order Planning
    David L. Poole; Alan K. Mackworth · 2023
  2. An Introduction to Least Commitment Planning
    Daniel S. Weld · 1994
  3. Publications by Daniel S. Weld — Automated Planning
    Daniel S. Weld

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.

  • All nine standard-library tests passed on Python 3.12.4. Independent permutation enumeration and coordinate-wise transitions checked 234 queries, 1,335 permutations and 166 returned linearizations. Coverage includes all 36 one-atom/two-action definitions × four initial/goal combinations, 80 seed-50917 random models with at most five occurrences, and targeted counterexamples.
  • The example has eight valid total orders; its first certificate retains four, with exactly seven inspections. Checked both threat repairs, endpoint exclusion, unsupported cycles, failed self-support, retention of every selected occurrence, repeated action identities, copied inputs and invalid inputs. Zero budget gives unknown even for the empty problem; the exact completion budget agrees with the unrestricted result.
  • Reread the proofs of completeness for fixed occurrences and soundness for every linearization, including finite refinement depth and loose copying/closure costs. No claim of general action-selection completeness, maximum flexibility, physical concurrency or real scanning performance.
  • Both languages have six anchors, four identical display equations, identical full code and six actual output lines, and four answered exercises. Strict MDX/KaTeX and actual React HTML pass with exact display MathML annotations and no emphasis remnants outside code. A targeted Humanizer scan complemented paragraph-by-paragraph AI rereading. Author AI self-check only, review written; no human review, whole-site build or browser acceptance.
  • Read full English/Chinese prose, four matching display equations, code, nine tests and metadata. Checked fixed exactly-once occurrences, positive-ground effects, all-linearization soundness, latest-producer completeness argument, threat endpoint exclusion, finite refinement depth and stated closure/copying costs. No issues found.
  • Independent subset dynamic programming over executed-occurrence masks and fact masks, not author permutation enumeration: 67 instances (60 fresh-seed small models and seven targeted cases), 292 dynamic states. Checked existence against the planner and every allowed executable prefix under each returned order; 25 certificates represent 45 valid linearizations. Main example independently gives eight valid sequences and four represented sequences.
  • Checked each certificate’s boundary edges, complete acyclic transitive order via independent path traversal, exactly one valid protected link per obligation, start/finish threats and consumer self-deletion. Across 238 budget runs, zero and pre-completion caps give unknown without certificates; exact and larger caps match full success/exhaustion. Inputs remain unchanged.
  • Nine author tests passed via import, avoiding the test entrypoint’s result-file write. Final strict MDX/KaTeX and React HTML pass: four displays, six anchors and four answers per locale; math annotations match and final five hashes match the frozen manifest. AI technical review only.
  • 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: completed topics link to formal chapters with obsolete planned labels removed; temporal planning remains a catalogue topic in progress. Reversible replacements are recorded. Other prose, equations, programs, exercises and previous evidence are preserved, with final bilingual hashes rebound.

Source locations checked:

  • Artificial Intelligence: Foundations of Computational Agents, 3e — §6.5 Partial-Order Planning · Actually read the returned official §6.5 text: action instances versus action names; strict precedence and all linearizations; artificial start/finish; agenda conditions and existing/new supporters; causal link endpoints and protection choices. The source permits creating occurrences, whereas this program explicitly requires every supplied occurrence once. Source performance observations were not adopted as universal claims; no asset or code was copied.
  • An Introduction to Least Commitment Planning · Actually opened the 52-page CMU PDF and read extracted §4.2 passages around web lines 662–728 and 781–803: causal-link triples, possibility of an intervening deleter, demotion/promotion, artificial start/end, closed-world initial state, and nondeterministic support/protection choices. Also read the footnote at 766–780 distinguishing POP threats from SNLP systematicity, and closure-cost discussion at 891–898. The PDF header is a prepublication label; no full 52-page or visual-layout audit is claimed.
  • Publications by Daniel S. Weld — Automated Planning · Actually opened the author’s university publication list; the Automated Planning entry at web line 126 states AI Magazine 15(4), pages 27–61, Winter 1994. The chapter uses the publication year and explicitly separates the differently paginated provisional copy.
  • Artificial Intelligence: Foundations of Computational Agents, 3e — §6.5 Partial-Order Planning · Actually read official 3e section 6.5, especially occurrence identities, strict order and all linearizations; start/finish, support choices and protection at lines 14–34, and explicit endpoint exclusions in protect at line 103. Verified the chapter fixes all supplied instances instead of claiming the source’s occurrence-creation algorithm.
  • An Introduction to Least Commitment Planning · Actually read CMU-hosted 52-page prepublication PDF through web. Header identifies provisional Summer/Fall 1994 label. Section 4.2.1 at PDF pages 15–16 describes links, consistent intervening deleters and demotion/promotion. Section 4.2.2 supplies start/end and the closed-world footnote. Section 4.2.3, pages 17–18, separates agenda selection from searched supporter/repair choices and guarantees every final linearization. No visual or full-paper proof audit claimed.
  • Publications by Daniel S. Weld — Automated Planning · Actually opened the author’s university publication list. The 1994 entry explicitly records AI Magazine 15(4), pages 27–61, Winter 1994, supporting the chapter’s distinction from the provisional copy.

Related topics

No matches. Try a synonym or acronym.

0 results shown

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