Closed pudumagico closed 2 years ago
You're probably looking for use_module(library(assert)).
which unlocks assertz/1, retract/1, retractall/1
(cf. here). It doesn't require a dynamic call.
?- use_module(library(assert)).
?- listing.
?- query(p(X)).
No clauses found for 'p/1'.
?- assertz(p(a)).
p: 1.0;
---------------
?- listing.
p(a)
?- query(p(X)).
p(a): 1
source_code of the assert library: here
Thank you Vincent! Although I am not quite sure this is what I am looking for. I have a program that may or not contain facts that trigger some rule, for example: `color(a).
ans(X) :- color(X). ans(X) :- size(X).
query(ans(X)).`
I want the program to stop bothering me about not having a fact for size(X).
I see.
Well this is probably not the most elegant solution but my quick response would be to just add a dummy rule x :- false.
and call it a day.
color(a).
size(a) :- false. % This here will not affect the program results at all
ans(X) :- color(X).
ans(X) :- size(X).
query(ans(X)).
Alright, thanks a lot!
Does an option as #dynamic pred/x. exist in problog as in prolog?