% ------------------------------------------------------------------------------------------------------
% This test illustrates the cache implementation to memorize results of subgoals.
% ------------------------------------------------------------------------------------------------------

%set up cache

% cache size: -1 = unlimited; 0 = no cache; 
cacheSize(-1). % unlimited  (see ws.prova.reference.Cache.java)
% cache timeout: -1 = no timeout; 0 = locally for one query
cacheTimeout(-1). % no timeout (see ws.prova.reference.Cache.java)


% Propositional

a():-cache(a1()).

a1().
a1().
a1().

% Datalog

a(java.lang.Integer.Y):-cache(a1(java.lang.Integer.Y)).

a1(1).
a1(2).
a1(3).


% Tests Propositional
:-solve(a()).
:-solve(a()). % use cache to answer subgoals

% Test Datalog
:-solve(a(Y)). 
:-solve(a(Y)). % use cache to answer subgoals