PLOGHELP PREDICATE_INFO                        Robert Duncan, March 1988
                                                       Revised July 1993

Determining the status of a predicate.

    ?- predicate_info(Spec, Info).


predicate_info/2 reports on the status of the predicate denoted by Spec.
Spec must be a term of the form:

    Fn/Arity

where Fn is an atom (representing the functor name of a predicate) and
Arity an integer (its arity). Info is then bound to a list of terms
giving information about that predicate. A call to predicate_info/2 will
always succeed.

The Info list will contain a subset of the following atoms:

    undefined
        The predicate is undefined: either no procedure definition has
        been read for the predicate, or it has since been abolished. If
        called, the predicate will raise an 'UNDEFINED PREDICATE' error.
        See PLOGHELP * UNKNOWN.

    nonprolog
        The predicate has been defined from outside Prolog, e.g. in
        Pop-11, using prolog_valof (see PLOGHELP * PROLOG_VALOF).

    dynamic
        The predicate is dynamic: either it has been explicitly declared
        with dynamic/1 or it has become dynamic because of compilation
        defaults or because it has been asserted or retracted. See
        PLOGHELP * DYNAMIC.

    static
        The predicate is static: either it has been explicitly declared
        with static/1 or it has become static because of compilation
        defaults. See PLOGHELP * STATIC.

    no_clauses
        The predicate has been declared as having no clauses. See
        PLOGHELP * NO_CLAUSES.

    clauses
        The predicate has been declared as having clauses. See
        PLOGHELP * CLAUSES.

    system_predicate
        The predicate has been declared as a system predicate. See
        PLOGHELP * SYSTEM_PREDICATE.

    user_predicate
        The predicate has been declared as a user predicate. See
        PLOGHELP * USER_PREDICATE.

    spied
        There is a spy-point on the predicate. See PLOGHELP * SPY.

The order of atoms in the Info list is unspecified: you should use
member/2 to determine whether a particular atom occurs in the list.

In addition, if the source file in which the predicate was defined is
known, the Info list will contain a term of the form:

    file = File

where File is the source file pathname as an atom.

As an example, suppose the predicate last/2 is initially undefined:

    ?- predicate_info(last/2, Info).
    Info = [undefined] ?

Compiling the definition:

    last([X], X).
    last([_|Xs], X) :-
        last(Xs, X).

in the default environment, with no prior declarations, gives:

    ?- predicate_info(last/2, Info).
    Info = [user_predicate, static, clauses] ?

This shows the defaults applied by the compiler. Executing the
declaration:

    :- no_clauses last/2.

will strip the clauses from the definition (leaving only the compiled
code) and give:

    ?- predicate_info(last/2, Info).
    Info = [user_predicate, static, no_clauses] ?

Finally, after placing a spy-point on the predicate:

    :- spy last/2.
    Spypoint placed on last/2

    ?- predicate_info(last/2, Info).
    Info = [user_predicate, static, no_clauses, spied] ?


See also:

PLOGHELP * CURRENT_OP
    Determines whether an atom has been declared as an operator.


--- C.all/plog/help/predicate_info
--- Copyright University of Sussex 1993. All rights reserved.
