|
| 1 | +# PyVAL — Pure Python PDDL Plan Validator |
| 2 | + |
| 3 | +[](https://pypi.org/project/pddl-pyvalidator/) |
| 4 | +[](https://pypi.org/project/pddl-pyvalidator/) |
| 5 | +[](LICENSE) |
| 6 | + |
| 7 | +A pure-Python PDDL plan validator — a drop-in alternative to the compiled [VAL](https://github.com/KCL-Planning/VAL) binary. Built on [unified-planning](https://github.com/aiplan4eu/unified-planning), zero compiled dependencies, `pip install`-able everywhere. |
| 8 | + |
| 9 | +PyVAL produces rich, structured diagnostics designed for both humans and LLM consumption: per-step state changes, precondition deficit reporting, and repair-oriented messages. |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +```bash |
| 14 | +pip install pddl-pyvalidator |
| 15 | +``` |
| 16 | + |
| 17 | +## Quick Start |
| 18 | + |
| 19 | +```bash |
| 20 | +# Validate a plan against a domain and problem |
| 21 | +pyval domain.pddl problem.pddl plan.txt |
| 22 | + |
| 23 | +# JSON output for tool integration |
| 24 | +pyval domain.pddl problem.pddl plan.txt --json |
| 25 | + |
| 26 | +# Numeric fluent trajectory (one row per step) |
| 27 | +pyval domain.pddl problem.pddl plan.txt --trajectory --track fuel --track cost |
| 28 | + |
| 29 | +# Syntax check only (domain, or domain + problem) |
| 30 | +pyval domain.pddl |
| 31 | +pyval domain.pddl problem.pddl |
| 32 | +``` |
| 33 | + |
| 34 | +Exit code is `0` on a valid plan, `1` otherwise. |
| 35 | + |
| 36 | +## Python API |
| 37 | + |
| 38 | +```python |
| 39 | +from pyval import PDDLValidator |
| 40 | + |
| 41 | +validator = PDDLValidator() |
| 42 | +result = validator.validate( |
| 43 | + domain_path="domain.pddl", |
| 44 | + problem_path="problem.pddl", |
| 45 | + plan_path="plan.txt", |
| 46 | +) |
| 47 | + |
| 48 | +if result.is_valid: |
| 49 | + print("Plan is valid") |
| 50 | +else: |
| 51 | + for err in result.errors: |
| 52 | + print(err) |
| 53 | +``` |
| 54 | + |
| 55 | +## What Gets Validated |
| 56 | + |
| 57 | +PyVAL runs a three-phase pipeline and halts on the first fatal error: |
| 58 | + |
| 59 | +1. **Syntax & semantic** — PDDL parses, types/predicates/functions are well-formed, no duplicates or arity mismatches. |
| 60 | +2. **Plan structure** — every action name exists in the domain, parameters are declared objects with type-compatible (subtype-aware) bindings. |
| 61 | +3. **Plan execution** — each step's preconditions hold, effects apply, and goals are satisfied in the final state. Numeric fluents are tracked across steps; quality metrics (`minimize` / `maximize`) are evaluated on the final state. |
| 62 | + |
| 63 | +Unsupported PDDL features (durative actions, PDDL+ processes/events) are reported as warnings rather than silent failures. |
| 64 | + |
| 65 | +## Output Modes |
| 66 | + |
| 67 | +- **Plain text** (default, VAL-like, optionally `-v` for per-step detail) |
| 68 | +- **JSON** (`--json`) — structured for programmatic consumption |
| 69 | +- **Trajectory** (`--trajectory`) — numeric fluent values per step, optionally filtered via `--track` |
| 70 | + |
| 71 | +## Development |
| 72 | + |
| 73 | +```bash |
| 74 | +python3 -m venv .venv && source .venv/bin/activate |
| 75 | +pip install -e ".[dev]" |
| 76 | +pytest |
| 77 | +``` |
| 78 | + |
| 79 | +See `VALIDATOR_SPEC.md` for the full specification and `CLAUDE.md` for architecture notes. |
| 80 | + |
| 81 | +## License |
| 82 | + |
| 83 | +MIT — see [LICENSE](LICENSE). |
0 commit comments