f(1).
f(2).
f(3).
print_factbase(X) :- f(X), println(["Fact: ",X]).



:- solve(print_factbase(X)).
:- eval(print_factbase(X)).

% test loop resolution - naive approach 

%%% not
not([X|Args]) :-
	derive([X|Args]),
	!,
	fail().
not([X|Args]).

c(1).
c(2).
a(X) :- not(sp1()), assert(sp1()), b(X), retractall(sp1()).
b(X) :- a(X).
c(X) :- not(sp2()), assert(sp2()), b(X), retractAll(sp2()).
b(X) :- c(X).

:- solve(a(X)).

x(1).
x(2).
z(1,1).
z(1,2).
z(2,2).
z(2,2).
y(1).
y(2).

p(X) :- z(X,Z),println(["XZ=",X,Z]), x(X), println(["X=",X]),zz(A),println(["A=",A]), y(Z), println(["Z=",Z]).
:- solve(p(X)).

ax("",2).
:- solve(ax(X,Y)).

zz(1).
zz(2).
qs(X):-zz(X), assert(zz(3)), zz(X).
:- solve(qs(X)).


aa(1).
aa(2).
cc(X):-aa(X).
:- solve(cc(X)).