I’m using: SWI-Prolog version threaded, 64 bits, version 9.3.13-13-g530b2d433
I want the code to:
Take into account the assertions on diagnosis/2
and condition/2
made after compilation when running my predicate minimal_dataset/2
.
expected result:
%test query
?- minimal_dataset([[1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1]],[D,C]).
D=[0.5, 0.5, 0.7, 0.7, 0.5, 0.7]
C=[t, t, f, f, f, t]
But what I’m getting is:
The assertions are there to simulate interactive user input. What would happen is that diagnosis(1,_)
would represent a positive diagnosis criterion, diagnosis(0,_)
a negative criterion, and the same for condition/2
. When compiling my source, the only thing known is that diagnosis/2
and condition/2
will acquire meaning only after user input. Currently, my assertions do not hold when running the test query. So, I guess I have to tell prolog to recompile minimal_dataset/2
somehow ?
My code looks like this:
%source
:-dynamic diagnosis/2.
:-dynamic condition/2.
minimal_dataset([D,C],[Diagnosis,Condition]):-
maplist(diagnosis,D,Diagnosis),
maplist(condition,C,Condition).
%assertion queries (run after compiling source)
?- asserta(diagnosis(1,0.5)).
?- assertz(diagnosis(0,0.7)).
?- asserta(condition(1,t)).
?- assertz(condition(0,f)).
%test query
?- minimal_dataset([[1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1]],[D,C]).
false.
Thanks !