
arc(1,2).
arc(2,3).
arc(2,4).
arc(4,1).

:- table upath/2.

upath(X,Y) :- arc(X,Y).
upath(X,Y) :- upath(X,Z), arc(Z,Y).

:- import mpath/2 from abol_test2_module.
:- import abolish_module_tables/1, get_residual/2 from tables.

:- prolog_load_context(module, M),
   abol_test2_module:import(M:arc/2).

test:- upath(1,_),fail.
test:- mpath(1,_),fail.
test:- get_residual(upath(1,Y),_),writeln(answer(u(a,Y))),fail.
test:- get_residual(mpath(1,Y),_),writeln(answer(m(a,Y))),fail.
test:- writeln('-------'),fail.
test:- abolish_module_tables(abol_test2_module),fail.
test:- get_residual(upath(1,Y),_),writeln(answer(u(b,Y))),fail.
test:- get_residual(mpath(1,Y),_),writeln(answer(m(b,Y))),fail.
test:- context_module(M), abolish_module_tables(M),fail.
test:- writeln('-------'),fail.
test:- get_residual(upath(1,Y),_),writeln(answer(u(c,Y))),fail.
test:- get_residual(mpath(1,Y),_),writeln(answer(m(c,Y))),fail.
test:- gc_tables(_N),writeln(remaining(0)).

