Find all clauses related to an atom
- by Luc Touraille
This is probably a very silly question (I just started learning Prolog a few hours ago), but is it possible to find all the clauses related to an atom? For example, assuming the following knowledge base:
cat(tom).
animal(X) :- cat(X).
, is there a way to obtain every possible information about tom (or at least all the facts that are explicitly stated in the base)? I understand that a query like this is not possible:
?- Pred(tom).
so I thought I could write a rule that would deduce the correct information:
meta(Object, Predicate) :-
Goal =.. [Predicate, Object],
call(Goal).
so that I could write queries such as
?- meta(tom, Predicate).
but this does not work because arguments to call are not sufficiently instantiated. So basically my question is: is this at all possible, or is Prolog not design to provide this kind of information? And if it is not possible, why?