aig-upf / tarski

Tarski - An AI Planning Modeling Framework
Apache License 2.0
59 stars 20 forks source link

FSTRIPS parser lowercases all symbols #67

Closed gfrances closed 5 years ago

gfrances commented 5 years ago

At the moment, parsing PDDL / FSTRIPS problem description results in a FOL language lang where all predicate / function symbols in the PDDL (say, "CONNECTED") are turned into lowercase. However, attempting to retrieve e.g. lang.get_predicate("CONNECTED") raises an error, since the symbol is registered as "connected". Fixing this is simple, but let's decide how we want to fix it. Options are:

  1. The framework is case-sensitive, and no transformation of case is ever made.
  2. The framework is case-sensitive, but in a consistent manner. A way of achieving this is to store everything in lowercase, and bring any query (such as get_predicate) into lowercase.

I prefer (1) for a simple reason. This is Python, and it is easy to restrict the way data is accessed. It is not inconceivable for me to see code like:

for c in lang.constants():
    if c == "CONNECTED":
        ...

which would fail as it fails now. For the record, Kovacs' grammar mentions nothing about case.

Opinions?

gfrances commented 5 years ago

Commit 8a6a019b5e9a contains a new test that fails to illustrate the issue

gfrances commented 5 years ago

Ok, I found one possible reason why we were lowercasing: in some IPC domains such as blocsworld, the cases in the domain and in the instance files are mixed: in domain.pddl the predicate is clear, whereas in probBLOCKS-4-0.pddl it is CLEAR.

Given this, I suggest the following: everything is lowercased as it was until now, but the query methods in the language object (e.g. get_predicate, etc.) do the lookup on the lowercased version as well. Other methods remain unchanged. The problem I was illustrating two comments above will remain, but at least the query methods will work.

gfrances commented 5 years ago

Upon further reflection, I correct my previous comment: this casing issue is purely a PDDL parsing issue, and we should contain it to that area, i.e. to the fstrips.io module of Tarski; other than that, we should do nothing special with symbols. If a user of Tarski wants to model a FOL with a predicate CLEAR, then she should be able to always deal with the uppercase string with no problems, and similar if she uses a lowercase version.

Hence, I'd rather not to any lowercasing on queries to language, and simply state in the documentation that for compatibility reasons, the PDDL parser represents all symbols in the language in lowercase. Other strings such as e.g. the name of the domain, or the problem instance, as well as the name of actions, remain in whatever case is used in the .pddl file.