Once the file is consulted, it will become "inappropriate" for Prolog. Therefore, I think that in general the answer should be no . But SWI-Prolog has a rich set of built-in functions that allows you to control your programs. For instance,
?- [stackoverflow]. ?- predicate_property(P, file('/home/carlo/prolog/stackoverflow.pl')). P = yield(_G297, _G298) ; P = now _G297 ; P = x(_G297) ; ... ?- abolish(yield/2). true. ?- predicate_property(P, file('/home/carlo/prolog/stackoverflow.pl')). P = now _G297 ; P = x(_G297) ; ...
Please note that undoing is not required for the file name to work; you can remove predicates loaded from other source files.
clause , clause_property and erase should give more control, but I get an error message that I don't understand (it's undocumented) when I try to use erase:
?- clause(strip_spaces(_G297, _G298),X,Y),erase(Y). ERROR: erase/1: No permission to clause erase `<clause>(0x29acc30)'
source share