AI-Planning / pddl

Unquestionable PDDL 3.1 parser
https://ai-planning.github.io/pddl/
MIT License
85 stars 27 forks source link

Types validation is case sensitive #95

Open francescofuggitti opened 1 year ago

francescofuggitti commented 1 year ago

Subject of the issue

When types are validated, if the same type is written with different cases (e.g., sometimes capitalized sometimes not), the parser throws an error.

The specific error happens at line 228 of pddl/_validation.py in the _check_types_are_available function.

def _check_types_are_available(
    self, type_tags: Collection[name_type], what: str
) -> None:
    """Check that the types are available in the domain."""
    if not self._types.all_types.issuperset(type_tags):
        raise PDDLValidationError(
            f"types {sorted(type_tags)} of {what} are not in available types {self._types.all_types}"
        )

Steps to reproduce

Minimal example to reproduce the error:

PDDL domain:

;Hello world domain to test numerical fluents (functions) 
(define (domain hello-world-functions)
    (:requirements :strips :typing :numeric-fluents)

    (:types Counter - object)
    (:functions
        (hello_counter)
    )

    (:action say-hello-world
        :parameters (?c - counter)
        :precondition (and (<= (hello_counter) 3))
        :effect (and (increase (hello_counter) 1))
    )
)

PDDL problem:

(define (problem hello-3-times)
    (:domain hello-world-functions)
    (:objects counter1 - counter)
    (:init
        (counter1)
        ; if this was undefined, some planners would not assumed `0`
        (= (hello_counter) 0)
    )

    (:goal
        (>= (hello_counter) 3)
    )
)

Actual behaviour

    raise VisitError(tree.data, tree, e)
lark.exceptions.VisitError: Error trying to process rule "domain":

types ['counter'] of term Variable(c) are not in available types {'Counter', 'object'}