Hmmm… In the head of the predicate, mycomp(X,Y)
is a Prolog term. In the body, it is a goal that you evaluate (or query…).
This is it:
mypred(mycomp(Z, W)).
But now both are “singleton variables” without any further constraints on them, so that will succeed for any Z and any W.
What kind of data encapsulation do you mean? This sounds like a technique, not an aim…
When you say “compound term”, you do realize this is really just a data structure and not a predicate? You can evaluate it as a predicate though, this is what happens if you put it in the place of a goal.
I still have a feeling this is a terminology confusion
EDIT: if you want to pass a predicate to a predicate, then you have define a meta-predicate. There is nothing special about it, really. For example, maplist is a meta-predicate, so you can do something like this:
?- maplist(plus(1), [2,3], Result).
Result = [3, 4].
This is equivalent to:
?- plus(1, 2, X), plus(1, 3, Y), Result = [X, Y].
Is that at all relevant for your question??