Find unused predicates in prolog module

Is their some way to collect all the predicates that are never used in the predicates defined in some module?

E.g. if I have something like this:

:- module(test_module, [test/0]).

test :- test3.

test3 :- true.
test2 :- false.

The output should be test2, cause its never used in the test predicate?

The graphical cross-referencer does this for you. If you have xpce installed, run this after loading your program.

?- gxref.

Possibly there should also be a commandline version as part of check/0.

3 Likes