Skip to main content

Crate pddl_validate

Crate pddl_validate 

Source
Expand description

§PDDL plan validation

An independent plan validator for PDDL, a second opinion next to VAL. It implements the published semantics on the pddl syntax tree and shares no grounding or search code with any planner, so it does not share their bugs either.

use pddl::{Domain, Parser, Problem};
use pddl_validate::{ValidationStatus, Validator, ViolationKind};

let domain = Domain::from_str(
    "(define (domain logistics) (:requirements :typing)
       (:types truck place)
       (:predicates (at ?t - truck ?p - place))
       (:action drive
         :parameters (?t - truck ?from ?to - place)
         :precondition (at ?t ?from)
         :effect (and (not (at ?t ?from)) (at ?t ?to))))",
).unwrap();
let problem = Problem::from_str(
    "(define (problem deliver) (:domain logistics)
       (:objects t1 - truck home shop - place)
       (:init (at t1 home))
       (:goal (at t1 shop)))",
).unwrap();
let validator = Validator::new(&domain, &problem).unwrap();

let report = validator.validate_text("(drive t1 home shop)\n; cost = 1 (unit cost)");
assert_eq!(report.status(), ValidationStatus::Valid);

let report = validator.validate_text("(drive t1 shop home)");
let violation = report.violation().unwrap();
assert_eq!(violation.step.as_ref().unwrap().number, 1);
assert!(matches!(violation.kind, ViolationKind::PreconditionUnsatisfied(_)));
assert_eq!(violation.advice(),
    "(drive t1 shop home) has an unsatisfied precondition at step 1: (Set (at t1 shop) to true)");

§Scope

  • Classical plans (level 1): STRIPS, typing, negative and disjunctive preconditions, equality, exists, forall, imply, conditional effects and stratified derived predicates.

  • Numeric plans (level 2): numeric fluents in conditions and effects (assign, increase, decrease, scale-up, scale-down), action costs and the problem’s :metric, which Report::metric returns for a valid plan.

  • Temporal plans (level 3): durative actions with at start, over all and at end conditions and effects, timestamped plans (t: (action args) [d]), duration constraints and inequalities, conditional effects with at start or at end conditions, linear continuous effects (#t), timed initial literals, the epsilon separation of interfering events (Validator::with_epsilon) and total-time as the makespan.

  • PDDL+ (level 4): processes, which run while their precondition holds and change fluents linearly, and events, which fire as soon as their precondition holds, in cascades of up to 1000 rounds at one time. The validator finds the times at which processes switch and events trigger exactly, at the roots of the linear conditions.

Every construct outside this scope makes the report ValidationStatus::Unsupported, never valid: continuous change whose rate depends on a changing fluent (such as acceleration), conditions that are not linear in time, discrete effects of processes, dynamics that switch without end, derived predicates in temporal plans, preferences, constraints and object fluents.

§Semantics

  • Names are case-insensitive. Reports show them in ASCII lowercase.
  • Closed world: an atom not in the state is false.
  • A step’s precondition and the conditions of its when effects are evaluated in the state before the step. The next state is the old one minus deleted atoms plus added ones, so an atom that a step both deletes and adds stays true.
  • Derived predicates are the least fixpoint of their rules, stratum by stratum, and are recomputed after every step.
  • Numbers are f64. Comparisons allow a relative tolerance (Validator::with_tolerance, DEFAULT_TOLERANCE). A comparison that reads a fluent without a value, divides by zero or leaves the finite range is unknown, and conditions follow three-valued (Kleene) logic: (or (p) (> (f) 0)) holds if (p) holds, and (and (q) (> (f) 0)) fails on (q) if (q) is false. A precondition or goal that is still unknown makes the plan invalid, and so does an effect or when condition that reads an undefined value. A derived predicate whose rule is unknown is not derived. A metric with an undefined value leaves the plan valid, without a Report::metric. A nullary total-cost without an initial value starts at 0.
  • Updates of one fluent in one step combine if all are increase or decrease; any other combination is a ViolationKind::ConflictingUpdates.
  • In a metric, total-time is the number of steps of a sequential plan and the makespan of a temporal one.
  • Temporal plans follow PDDL 2.1 and VAL. Events at one time form a happening whose conditions are checked in the state before it and whose effects apply at once. over all conditions must hold strictly between an action’s start and end, and interfering events must be at least epsilon apart. Durations satisfy their constraints within an absolute tolerance (Validator::with_duration_tolerance, DEFAULT_DURATION_TOLERANCE), and a ground durative action must not overlap itself.
  • PDDL+ work is bounded: at most 100 000 segments (process switches and event firings) between two plan happenings and 1000 event rounds at one time. A model past either bound, even a legal but very busy one, is reported unsupported as Construct::ZenoDynamics, never valid.
  • Validation stops at the first violation. Steps count from 1, as in VAL.

The crate is no_std with alloc. That is nominal for now: the pddl crate it reads needs std.

Structs§

Atom
A predicate or function symbol applied to objects, such as (at t1 home) or (fuel t1).
FluentChange
A numeric fluent a step updated.
Metric
The value of the problem’s :metric for a valid plan.
ModelError
The domain or problem is malformed, so no plan can be validated against it.
Plan
A plan: ground actions, executed one after the other or, with timestamps, at the times given.
PlanError
Why a plan file could not be read, and where.
PlanStep
One ground action of a plan, such as (drive t1 home shop), with its start time and duration in a temporal plan.
Report
What Validator::validate found.
StepRef
A step of the plan, as diagnostics name it.
StepTrace
The ground changes one step made to the state.
Unsupported
A construct the validator does not interpret, and where it is.
Validator
Validates plans for one domain and problem.
Violation
Why a plan is invalid.

Enums§

Construct
The PDDL constructs the validator does not interpret yet.
ModelErrorKind
The kinds of ModelError. All names are in ASCII lowercase.
Outcome
The verdict of a Report, with its diagnostic.
PlanErrorKind
The kinds of PlanError.
Unmet
The part of a condition that does not hold, as specific as the condition allows.
ValidationStatus
The overall result of validating a plan.
ViolationKind
The kinds of Violation. All names are in ASCII lowercase.

Constants§

DEFAULT_DURATION_TOLERANCE
The default absolute tolerance of duration constraints, 0.0005.
DEFAULT_EPSILON
The default least time between interfering events of a temporal plan, VAL’s default.
DEFAULT_TOLERANCE
The default relative tolerance of numeric comparisons, 1e-12.
MAX_ALTERNATIVES
The most alternatives an Unmet::NoneOf lists. An existential quantifier over many objects would otherwise list every one of them.