Transformations of logic programs with goals as arguments