aig-upf / tarski

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

FSTRIPS Language: Change Syntax for External Procedures #22

Closed gfrances closed 3 years ago

gfrances commented 6 years ago

I'd like to change the syntax we use to declare external procedures in PDDL files to something simpler, inspired by the way GPT handles this. Specifically, I would get rid of the need to prefix external symbols with an @, and simply have an extra top-level block in the PDDL declaring which symbols (usually functions or predicates) are external, e.g:

(:predicates (valid ?p - position))
(:external valid)
gfrances commented 6 years ago

That change would simplify the grammar, but we should either wait until integration of Tarski with the FS planner (preferrable), or else do the change in both places at the same time (likely too much unnecessary work)

gfrances commented 6 years ago

@miquelramirez , the support for external symbols is not working, and I'm fixing it now, but I see that you might be using it in two places: in action names (rule "actionName" in the grammar) and in event names (rule "eventSymbol"). Are you? Is it working for you? What do you think of the suggestion above?

gfrances commented 6 years ago

Ok, actually the issue is more interesting than i thought. A few thoughts:

There are actually a few distinct dimensions along which we can qualify predicate and function symbols:

The problem with "fixing" this last point arises when, as with alldiff, a predicate is builtin and variadic at the same time. If we wanted to force the modeler to declare it in the :predicates section, then what would that declaration look like? We cannot do it unless we change other things, as the predicate does not have a fixed arity.

A possible way out of this:

(:variadic-predicates (alldiff ?b - block))

Of course, same for :variadic_functions, but this time the type of the return value of the function can be different from the type of the inputs. In these cases, the check for well-formedness should not take into account the arities, only types. I hate the proliferation of block names (i.e. :variadic_predicates, :variadic_functions, etc.), but among all alternatives I have considered, this one is the one I like best at the moment.

miquelramirez commented 6 years ago

Hello @gfrances,

I just processed this discussion, which is quite substantial.

I think that following Blai's lead and coming up with specific sections for these kind of predicates and functions is the most sensible way to go. I think that having several :variadic and independent external sections is not a good idea.

I propose introduce an entirely new concept into PDDL-like languages for anything else than action schemata: nested declarations. For instance something like

(:predicates
    (foo ?t1 ?t2 - object)

    :external(
        (baz ?t1 ?t2 - object)
        (@baz2 ?t1 ?t2 -object))

    :variadic (
        (bar ?t1 ?t2 - object))
)

where rather than @@ we use just @ for externally defined symbols that require full access to states rather than just the denotation of any subterms.

This kind of follows with the design of the language for complex constructs - action schemata - and also mimicks the way we will have tarski programming interface to handle this (i.e. by adding "tags" to existing standard syntactic elements).

gfrances commented 6 years ago

Miquel! Sorry again for the delay. I like the idea of nesting stuff! There is one problem though: as with all these types of hierarchical taxonomies, they don't look that well when you want to associate multiple "tags" to the same syntactic element. For instance, if I want a predicate which is variadic and has external denotation... how should I handle that? Repeating its declaration looks like a really bad option. Let me suggest a slightly different approach:

(:predicates
    (foo ?t1 ?t2 - object)
    (baz ?t1 ?t2 - object) is external
    (bar ?t1 ?t2 -object)) is external and variadic
    (baz2 ?t1 ?t2 -object)) is absolute
)

Ok, perhaps "absolute" is not the best adjective, but we would just need some better name there to make explicit that the denotation of the symbol requires the full state. In other words, we move to a tag-based declaration. What do you think? Not sure if this syntactic style clashes a bit with idiomatic Lisp, mostly because I never developed a taste for Lispian aesthetics :-) If that is the case, we could use some syntactic variation of the same idea? I'll wait for your feedback before changing the implementation.

gfrances commented 6 years ago

BTW do you get notified if I don't write @miquelramirez ? :-)

miquelramirez commented 6 years ago

I get notified since I am "watching" the repo.

Regarding the nesting, I hadn't considered the case of being both external and variadic, but perhaps it could just look like:

(:variadic (:external ...))

Same dilemma as with C++ const and virtual. I will never truly understand why virtual goes behind the method name, like const does :-) But easier, since return types can't be const here :-)

I like how close is to natural language, I think you're complicating the parsing a bit... but perhaps not that much. What I don't like is how it clashes frontally with the Lispian style. It is very much like mixing 1970s brutalism with baroque... something that looks like to have escaped from an H. P. Lovecraft novel...

gfrances commented 6 years ago

I like your approach better - I told you I lack this Lispian taste! My option is clearly too neat for Lisp :-) Thanks!