abcorrea / asp-grounding-planning

0 stars 3 forks source link

Removing Action Predicates when Effect has same parameters #2

Open PLauerRocks opened 1 month ago

PLauerRocks commented 1 month ago

Hi, I think this condition is broken: https://github.com/abcorrea/asp-grounding-planning/blob/c64591f2336d97682c5c4c144397d69e13a6b193/src/translate/pddl_to_prolog.py#L136

The problem is that if you have an effect e(?x, ?x) in action a(?x, ?y, ?z) the rule generated will have two conditions:

e(?x, ?y) :- a(?x, ?y, ?z), =(?x, ?z)

and so the action predicate will not be removed.

I have domain/problem files where the behaviour occurs and a potential fix. Will put them here later. Just opening the issue already, so that I don't forget. (Update: done)

PLauerRocks commented 1 month ago

Here goes the example:

domain.pddl

(define (domain simple)
 (:requirements :strips)
 (:types
 )
 (:constants
   a - object
 )
 (:predicates
    (p1 ?x - object)
    (p2 ?x ?y - object)
 )
 (:action act
  :parameters (?x - object)
  :precondition
  (and
    (p1 ?x)
  )
  :effect
  (and
    (p2 ?x ?x)
  )
 )
)

problem.pddl

(define (problem simple-pf)
 (:domain simple)
 (:init
   (p1 a)
 )
 (:goal
   (and
     (p2 a a)
   )
 )
)

Output of python3 pddl_to_prolog.py domain.pddl problem.pddl --only-output-direct-program --remove-action-predicates is:

pddl_type_object(a).
p1(a).
equals(a,a).
p2(Var_x,Var_x0) :- action_act(Var_x),equals(Var_x,Var_x0).
goal__reachable :- p2(a,a).

where

p2(Var_x,Var_x0) :- action_act(Var_x),equals(Var_x,Var_x0).

is wrong and should be

p2(Var_x,Var_x0) :- pddl_type_object(Var_x),p1(Var_x),equals(Var_x,Var_x0).

Note that the rule for action_act was deleted, so it's not just about performance, but with the current implementation the grounder will not spot some reachable atoms.

PLauerRocks commented 1 month ago

Potential Fix https://github.com/abcorrea/asp-grounding-planning/pull/3