importprologswi-prologredefinition

No permission to redefine imported_procedure


I'm trying to create a predicate called vertices/2 defined as:

vertices(G, Vs):- findall(V, vertex(G, V), Vs).

When I consult my file prolog gives me the error:

No permission to redefine imported_procedure `ugraph:vertices/2'

How can I avoid the redefinition?

Thanks


Solution

  • SWI-Prolog provides a ugraphs library module, not ugraph. I assume that's only a typo?

    Assuming that you're loading ugraphs library module in the same context as your vertices/2 predicate, why not simply rename your predicate? E.g. my_vertices/2. Another possible option would be for you to load the ugraphs module without importing its predicates by using:

    :- use_module(library(ugraphs), []).
    

    This will solve the conflict but will also require that you call the ugraphs module predicate using explicit qualification.

    It may also be the case that the ugraphs module is not being loaded explicitly by you but as a consequence of other modules that you may be loading. If that's the case, turn on verbose auto-loading to find out why the module is being loaded:

    ?- set_prolog_flag(verbose_autoload, true).