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, whichReport::metricreturns for a valid plan. -
Temporal plans (level 3): durative actions with
at start,over allandat endconditions and effects, timestamped plans (t: (action args) [d]), duration constraints and inequalities, conditional effects withat startorat endconditions, linear continuous effects (#t), timed initial literals, the epsilon separation of interfering events (Validator::with_epsilon) andtotal-timeas 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
wheneffects 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 orwhencondition 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 aReport::metric. A nullarytotal-costwithout an initial value starts at 0. - Updates of one fluent in one step combine if all are
increaseordecrease; any other combination is aViolationKind::ConflictingUpdates. - In a metric,
total-timeis 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 allconditions 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). - Fluent
Change - A numeric fluent a step updated.
- Metric
- The value of the problem’s
:metricfor a valid plan. - Model
Error - 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.
- Plan
Error - Why a plan file could not be read, and where.
- Plan
Step - 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::validatefound. - StepRef
- A step of the plan, as diagnostics name it.
- Step
Trace - 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.
- Model
Error Kind - The kinds of
ModelError. All names are in ASCII lowercase. - Outcome
- The verdict of a
Report, with its diagnostic. - Plan
Error Kind - The kinds of
PlanError. - Unmet
- The part of a condition that does not hold, as specific as the condition allows.
- Validation
Status - The overall result of validating a plan.
- Violation
Kind - 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::NoneOflists. An existential quantifier over many objects would otherwise list every one of them.