Commit d336d788 authored by Joaquin Arias's avatar Joaquin Arias

Preparing s(CASP) to deal with variant loops.

parent 50ad097c
[10:25] joaquin@:test_tabling$ scasp -w -i path.pl
Loading files: path.pl
?- p(a,c).
Answer 1 (in 2.695 ms):
{ p(a,c) , p(a,b) , p(b,c) , not p(b,d) }
[p(a,c)] ? ;
fail_pos_loop(variant,p(c,_64705),p(c,_64519))
fail_pos_loop(variant,p(b,_63987),p(b,_63859))
fail_pos_loop(variant,p(c,_64325),p(c,_64219))
fail_pos_loop(variant,p(c,_64753),p(c,_64567))
fail_pos_loop(variant,p(b,_64035),p(b,_63907))
fail_pos_loop(variant,p(b,_63123),p(b,_63075))
fail_pos_loop(variant,p(a,_63026),p(a,_62978))
false
?- p(a,d).
Answer 1 (in 2.816 ms):
{ p(a,d) , p(a,b) , p(b,d) , not p(b,c) }
[p(a,d)] ? ;
fail_pos_loop(variant,p(d,_64866),p(d,_64680))
fail_pos_loop(variant,p(b,_64148),p(b,_64020))
fail_pos_loop(variant,p(d,_64486),p(d,_64380))
fail_pos_loop(variant,p(d,_64914),p(d,_64728))
fail_pos_loop(variant,p(b,_64196),p(b,_64068))
fail_pos_loop(variant,p(b,_63284),p(b,_63236))
fail_pos_loop(variant,p(a,_63187),p(a,_63139))
false
?- p(a,X).
Answer 1 (in 3.077 ms):
{ p(a,b) , p(b,d) , not p(b,c) }
[p(a,b)] ? ;
fail_pos_loop(variant,p(d,_67140),p(d,_66954))
fail_pos_loop(variant,p(b,_66422),p(b,_66294))
fail_pos_loop(variant,p(d,_66760),p(d,_66654))
fail_pos_loop(variant,p(d,_67188),p(d,_67002))
fail_pos_loop(variant,p(b,_66470),p(b,_66342))
fail_pos_loop(variant,p(b,_65558),p(b,_65510))
Answer 2 (in 6.167 ms):
{ p(a,b) , not p(b,d) , p(b,c) }
[p(a,b)] ? ;
fail_pos_loop(variant,p(c,_67276),p(c,_67056))
fail_pos_loop(variant,p(c,_67276),p(c,_67056))
fail_pos_loop(variant,p(b,_66487),p(b,_66435))
fail_pos_loop(variant,p(c,_66432),p(c,_66326))
fail_pos_loop(variant,p(b,_66174),p(b,_66126))
fail_pos_loop(variant,p(a,_63274),p(a,_63111))
false
?-
\ No newline at end of file
p(X) :- p(X).
q(X):- X=1, not p(X).
p(a,b).
p(b,c) :- not p(b,d).
p(b,d) :- not p(b,c).
p(X,Y) :-
p(X,Z),
p(Z,Y).
?- p(a,d).
\ No newline at end of file
p(X) :- not q(X).
q(X) :- not p(X).
p(1).
?- q(X).
s(X) :- s(X).
s(1).
?- not s(X).
......@@ -24,7 +24,7 @@ echo -e '\n\n*************\t s(CASP): ?- holdsAt(light_red,6.99) \n'
time scasp -n0 ../light/bec_light_01.pl ../light/bec_query02.pl
echo -e '\n\n*************\t s(CASP): ?- holdsAt(light_red,6.999) \n'
time scasp -n0 ../light/bec_light_01.plb ../light/ec_query03.pl
time scasp -n0 ../light/bec_light_01.pl ../light/bec_query03.pl
echo -e '\n\n*************\t s(CASP): ?- holdsAt(light_red,T) \n'
time scasp -n0 ../light/bec_light_01.pl ../light/bec_query0x.pl
......
......@@ -638,7 +638,7 @@ type_loop_(Goal, Iv, N, [_S|Ss], Type) :-
type_loop_(Goal, NewIv, N, Ss, Type).
type_loop_(Goal, 0, 0, [S|_],fail_pos(S)) :- \+ \+ Goal == S.
type_loop_(Goal, 0, 0, [S|_],fail_pos(S)) :- \+ \+ variant(Goal, S).
type_loop_(Goal, 0, 0, [S|_],fail_pos(S)) :- \+ \+ variant(Goal, S), if_user_option(warning,format("\nWARNING: Failing in a positive loop due to a variant call (tabling required).\n\tCurrent call:\t~p\n\tPrevious call:\t~p\n",[Goal,S])).
%type_loop_(Goal, 0, 0, [S|_],fail_pos(S)) :- \+ \+ Goal = S.
type_loop_(Goal, 0, 0, [S|_],pos(S)) :- \+ \+ Goal = S.
......@@ -646,7 +646,8 @@ type_loop_(Goal, 0, 0, [S|_],pos(S)) :- \+ \+ Goal = S.
% It should be solved using tabling !!
%% type_loop_(not(Goal), 0, N, [not(S)|_],fail_pos(S)) :- Goal == S, N > 0, 0 is mod(N, 2).
type_loop_(not(Goal), 0, N, [not(S)|_],even) :- Goal == S, N > 0, 1 is mod(N, 2).
type_loop_(not(Goal), 0, _N, [not(S)|_],even) :- \+ \+ Goal == S. %% redundant, for debugging proposals
type_loop_(not(Goal), 0, _N, [not(S)|_],even) :- Goal = S.
type_loop_(Goal, 0, N, [S|_],even) :- Goal \= not(_), Goal == S, N > 0, 0 is mod(N, 2).
type_loop_(Goal, 0, N, [S|Ss],Type) :-
......
......@@ -333,6 +333,8 @@ set_user_option(Option) :- atom_chars(Option,['-','s'|Ns]),number_chars(N,Ns),se
set_user_option(Option) :- atom_chars(Option,['-','n'|Ns]),number_chars(N,Ns),set(answers,N).
set_user_option('-v') :- set(check_calls, on).
set_user_option('--verbose') :- set(check_calls, on).
set_user_option('-w') :- set(warning, on).
set_user_option('--warning') :- set(warning, on).
set_user_option('-j') :- set(print_all, on).
set_user_option('-j0') :- set(print_all, on).
set_user_option('--justification') :- set(print_all, on).
......@@ -365,6 +367,7 @@ help :-
display(' -a, --auto Run in automatic mode (no user interaction).\n'),
display(' -sN, -nN Compute N answer sets, where N >= 0. 0 for all.\n'),
display(' -v, --verbose Enable verbose progress messages.\n'),
display(' -w, --warning Enable warning messages (failing in variant loops).\n'),
display(' -j, --justification Print proof tree for each solution.\n'),
display(' -d0 Print the program translated (with duals and nmr_check).\n'),
display('\n'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment