Skip to main content

Loki: PDDL Parsing and Translation in C++ and Python

Loki is a C++20 library with Python bindings for parsing and translation of PDDL files. Loki separates the parsing and translation of domain and problem files, allowing users to effectively work with collection of problems.

The parser is based on the canonical parser structure proposed in the Boost Spirit X3 library.

The translator is based on the method presented in section four of the paper "Concise finite-domain representations for PDDL planning tasks by Malte Helmert (AIJ 2009)".

Supported PDDL Requirements

  • :strips
  • :typing
  • :negative-preconditions
  • :disjunctive-preconditions
  • :equality
  • :existential-preconditions
  • :universal-preconditions
  • :quantified-preconditions
  • :conditional-effects
  • :numeric-fluents
  • :adl
  • :derived-predicates
  • :action-costs
  • :non-deterministic
  • :probabilistic-effects
  • :durative-actions
  • :duration-inequalities
  • :timed-initial-literals
  • :rewards (PPDDL)
  • :preferences
  • :constraints
  • :trajectory-formulas (loki: LTLf, PLTLf and MTLf formulas over the state trajectory)

The language reference describes how loki reads and translates choices, the competitions' syntax, constraints and preferences, formulas over the state trajectory, and durative actions.

Dependencies

Loki depends on a fraction of Boost's header-only libraries (Fusion, Spirit x3, Container) and on Boost.Charconv (1.85 or newer, which reads real numbers correctly rounded), its performance benchmarking framework depends on GoogleBenchmark, and its testing framework depends on GoogleTest.

Loki consumes native dependencies from Python packages:

  • pyyggdrasil >= 0.14.0, < 0.15 for shared third-party native dependencies.
  • pypddl-datasets >= 0.0.22, < 0.1 for the PDDL benchmark data used by the C++ test suite and the example executables (resolved from its cache at CMake configure time).

The shared workspace layout, layered install order, and the common build-from-source and CMake-integration patterns are documented in the Planning and Learning build instructions; the sections below cover loki/pypddl-specific details.

For offline/local development, install pyyggdrasil from the sibling source checkout instead:

cd ../yggdrasil
uv pip install --python ../loki/.venv/bin/python .

Build C++

Install Loki's native dependency providers into the active Python environment, then configure CMake with their native prefixes:

python -m pip install 'pyyggdrasil>=0.14.0,<0.15' 'pybrokkr>=0.3.1,<0.4' 'pypddl-datasets>=0.0.22,<0.1'

cmake -S . -B build

CMake discovers the installed provider packages automatically: it finds the build helpers of brokkr (pybrokkr, installed with the package), whose brokkr_find_python_native_prefix adds pyyggdrasil's native prefix to CMAKE_PREFIX_PATH; find_package(yggdrasil) then resolves the rest of the chain and links against the yggdrasil::yggdrasil target. To point at a different prefix explicitly:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -m pyyggdrasil --prefix)"

cmake --build build -j4

CMake options:

Option Default Description
LOKI_BUILD_TESTS OFF Build Loki tests.
LOKI_BUILD_EXECUTABLES OFF Build Loki executables.
LOKI_BUILD_BENCHMARKS OFF Build Loki benchmark targets.
LOKI_BUILD_PYPDDL OFF Build Loki for the pypddl Python wheel.
LOKI_USE_LLD ON Use LLVM lld with Clang when available.
LOKI_ENABLE_LTO ON Enable link-time optimization for Release builds.

Single-config CMake builds default to Release. On GCC and Clang, Debug builds use -Og with debug symbols, RelWithDebInfo keeps frame pointers and disables LTO, and Release LTO uses GCC LTO or Clang ThinLTO. Editable installs and wheels disable LOKI_USE_LLD and LOKI_ENABLE_LTO by default for build reliability.

Run tests from a build configured with -DLOKI_BUILD_TESTS=ON:

ctest --test-dir build --output-on-failure

Install Loki from a configured build directory with:

cmake --install build --prefix=<path/to/installation-directory>

Build Python

The Python package requires Python 3.11 or newer.

python -m pip install .

Python API

The Python package exposes the semantic parser, translator, and reparseable PDDL formatter through pypddl.formalism:

from pypddl import formalism as pddl

parser = pddl.Parser("""
(define (domain ready-domain)
  (:predicates (ready))
)
""")

translation = pddl.translate_domain(parser.domain())
domain_text = str(translation.translated_domain)
reparsed = pddl.Parser(domain_text)
assert reparsed.domain().get_name() == "ready-domain"

With default options the parser completes :action-costs artifacts and the translator compiles typing and materializes equality; see Parser and Translator Options to override.

Programmatic construction inserts mutable data into a repository and returns (view, inserted). Repeated insertion returns the existing view with False. The returned Python view keeps its repository alive after the tuple is unpacked.

repository = pddl.Repository()
object_type, inserted = repository.insert(pddl.TypeData("object", []))
same_type, inserted_again = repository.insert(pddl.TypeData("object", []))
assert inserted and not inserted_again and object_type == same_type

Template and include rules

Headers and templates follow the template and include rules.

C++ API

The umbrella header includes the semantic parser (loki::semantic), translator (loki::semantic), and reparseable PDDL formatter (loki::formalism::format):

#include <loki/loki.hpp>

#include <string>

int main()
{
    auto parser = loki::semantic::Parser(std::string { "(define (domain ready-domain) (:predicates (ready)))" });
    const auto translation = loki::semantic::translate(parser.get_domain());
    const auto domain_text = loki::formalism::format::to_string(translation.get_translated_domain());
    auto reparsed = loki::semantic::Parser(domain_text);
    return reparsed.get_domain().get_name() == "ready-domain" ? 0 : 1;
}

For programmatic C++ construction, loki::formalism::insert(repository, data) prepares the record and returns std::pair<View, bool>. Symbol views reuse Ygg's internal accessors and require a context whose repository supports their specific entity type. The canonical and phase-copy contexts expose copy(domain_or_task, context) with the same pair result; repeated copies reuse the context's memoized destination values and report false.

Parser and Translator Options

Both APIs accept options at construction/translation time. The library defaults are normalization-friendly for downstream consumers; every option can be turned off individually.

ParserOptions (second argument of Parser):

Option Default Description
strict false Strict semantic validation for requirements, arity, and type compatibility. Numeric-fluents violations error even in permissive mode: reads require :fluents/:numeric-fluents/:action-costs, and writes other than (increase (total-cost) ...) require :fluents/:numeric-fluents.
add_action_costs true Complete missing :action-costs artifacts (total-cost function, initial value, minimize metric) instead of erroring. If the domain declares neither :action-costs nor :fluents/:numeric-fluents, additionally injects the requirement and a unit-cost effect (increase (total-cost) 1) into every action that does not already write total-cost. Genuine numeric domains are left untouched: an absent metric means unit costs.

The raw syntax AST remains permissive and preserves empty and unary +/* nodes. Semantic construction always maps empty addition and multiplication to 0 and 1, maps unary forms to their operand, and lexicographically sorts the immediate operands of each remaining multi-expression.

TranslatorOptions (last argument of translate; translate_domain/translate_task in Python):

Option Default Description
compile_typing true Compile typing away into type predicates and remove type annotations.
compile_conditional_effects false Multiply conditional effects out into unconditional actions; the normalization phases re-run afterwards so preconditions stay conjunctive (quantified when-conditions become derived predicates). Worst case exponential in the number of conditional effects per action.
materialize_equality true Add the = predicate and (= o o) initial literals. Turn off for consumers with native equality handling.
normalize_arithmetic_expressions false Recursively flatten addition and multiplication, remove exact identity operands, and lexicographically sort the remaining leaves while preserving duplicates. Reassociation can change IEEE-754 evaluation order and rounding.

Pass the same TranslatorOptions to the domain and the task translation; mismatched options between the two can fail (e.g. equality materialization requires the = predicate added during domain translation).

options = pddl.TranslatorOptions()
options.materialize_equality = False
translation = pddl.translate_domain(parser.domain(), options)

The loki executable exposes the same options as opt-in flags (all off by default): --strict, --add-action-costs, --compile-typing, --compile-conditional-effects, --materialize-equality, and --normalize-arithmetic-expressions.

CMake Integration

This section covers pypddl-specific paths and targets; the general pattern for consuming the native prefixes from CMake is in the common CMake integration instructions.

The Python package pypddl installs Loki's native headers, shared library, and CMake package config under pypddl.native_prefix(). It depends on pyyggdrasil>=0.14.0,<0.15 for third-party native dependencies:

import pypddl
import pyyggdrasil

print(pypddl.cmake_prefix())       # prefix to put on CMAKE_PREFIX_PATH
print(pypddl.cmake_dir())          # directory containing lokiConfig.cmake
print(pyyggdrasil.cmake_prefix())

The same paths are available from the shell via python -m pypddl --prefix, --cmake-dir, --include-dir, and --version.

Downstream CMake projects should include the native prefixes of pypddl and its native package dependencies in CMAKE_PREFIX_PATH:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -m pypddl --prefix);$(python -m pyyggdrasil --prefix)"

Loki exports the loki::parsers target.

Running the Executables

The executable illustrates how to use Loki. It is disabled by default and can be enabled with -DLOKI_BUILD_EXECUTABLES=ON. Example PDDL inputs come straight from the pypddl-datasets cache:

./build/exe/loki $(python -c "import pypddl_datasets as pb; t = pb.fetch_task('classical/tests/gripper/test-1.pddl'); print(t.domain_path, t.task_path)")

Use --out-domain/--out-problem to write the translated PDDL to files, and see ./build/exe/loki --help for the parser and translator flags (--strict, --add-action-costs, --compile-typing, --compile-conditional-effects, --materialize-equality, --normalize-arithmetic-expressions).

Citing Loki

If you use Loki in your research, please cite it as follows:

@misc{drexler-zenodo2026,
  author =       "Dominik Drexler",
  title =        "{Loki}: A {PDDL} Parser and Normalizer",
  publisher =    "Zenodo",
  year =         "2026",
  doi =          "10.5281/zenodo.20081136",
  url =          "https://doi.org/10.5281/zenodo.20081136",
}

Acknowledgements

This work was partially supported by the Wallenberg AI, Autonomous Systems and Software Program (WASP) funded by the Knut and Alice Wallenberg Foundation.

Metadata

Release files for pypddl 1.15.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypddl 1.15.1
File Size Uploaded Provenance Actions
pypddl-1.15.1.tar.gz 224.7 kB With provenance Details for pypddl-1.15.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pypddl 1.15.1
File Actions
pypddl-1.15.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for pypddl-1.15.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pypddl-1.15.1-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details for pypddl-1.15.1-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
pypddl-1.15.1-cp311-abi3-macosx_11_0_x86_64.whl CPython 3.11 abi3 macOS 11.0+ x86-64 Details for pypddl-1.15.1-cp311-abi3-macosx_11_0_x86_64.whl
pypddl-1.15.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for pypddl-1.15.1-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 7.7 MB

Release files / pypddl-1.15.1.tar.gz

Download URL pypddl-1.15.1.tar.gz
Size 224.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7cefe8e6f302f0aa81dc9170f160622db4ed5aee42d58a5c80681c5f6a1055eb
BLAKE2b-256 checksum
How to use checksums
183486efdd5bbc448c2ab9f83499a38fa12ff314e274481ef20222403ba71ae1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / pypddl-1.15.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypddl-1.15.1-cp311-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.2 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
96af8df04f6f7cfec29f2359832bdafa72255a3a92e80a455b88d13d55e24dc7
BLAKE2b-256 checksum
How to use checksums
977655a2b7fb6df03cfef228cef6b8378521ee556286e4099ab382ec785bb047
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / pypddl-1.15.1-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL pypddl-1.15.1-cp311-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 1.9 MB
Tags CPython 3.11 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
80d4b96800588bb8879dc627b4a4ddf00b3b42fbd9ee7073fa316edff2986ddb
BLAKE2b-256 checksum
How to use checksums
416b70a1b339fa8d9acd99f45ccad15b26993b0824ce7b8af1395c3e8ab7bde7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / pypddl-1.15.1-cp311-abi3-macosx_11_0_x86_64.whl

Download URL pypddl-1.15.1-cp311-abi3-macosx_11_0_x86_64.whl
Size 1.8 MB
Tags CPython 3.11 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
8a8cc1267ad3e58c284e28675ab7a98ef4a35bbf793b8a53292085e5a2602802
BLAKE2b-256 checksum
How to use checksums
439c5d542c9b7b48578bc981258406bd04a861f66043d517d547ec9ece425a57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / pypddl-1.15.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL pypddl-1.15.1-cp311-abi3-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1707383258c24ae3fc0d2903a34ceb7dd088b25de5141ea24882fb43b19d908e
BLAKE2b-256 checksum
How to use checksums
c9722dc8f4c5f77b62144e8a07016f55c668d0cca023954458e056899aa51356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for pypddl 1.15.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for pypddl-1.15.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.15.1 This release

5 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page