Relationships are often nouns, thus why nouns make more sense and created to work in both directions. If a predicate has two arguments either one can be ground and the predicate should work. If neither is ground then all the values for the predicate will be listed.
The reason the code from the book is using verbs, translate
and transform
is because it is not working in both directions, it is a function that takes in one pattern and returns a pattern so the first argument is to be ground and the second argument is to be a variable.
It is not an absolute rule. But if you can see how to change your verb thinking for a predicate into a noun then you will start to think more in relationships and the Prolog code will be better.
There are hundreds of them in the SWI-Prolog code in the GitHub repository. The code in there is often the inspiration for most of my better Prolog.