A strange behavior when adding extra ASP constraints to pruning by `clause`
Closed this issue · 6 comments
I understand that the pruning may make the whole search slower in the DCC version, but here the issue is about a possible bug.
For example, in the examples/filter
example, if I want to force the program contains 3 sub-clauses, adding
:-
not clause(2).
to
https://github.com/logic-and-learning-lab/Popper/blob/8e132faa0f1a7554275f70b0bb7546cc79cce901/examples/filter/bias.pl
should prune the learned programs with less than 3 sub rules. However, a resource_error raises.
pyswip.prolog.PrologError: Caused by: 'pos_covered(Xs)'. Returned: 'error(resource_error(stack), Atom('27909')(stack_overflow, 3355306, choicepoints, 6710615, depth, 3355312, environments, 235922, globalused, 524267, localused, [Functor(565645,3,6710615,:(user, f([], [1])),[]), Functor(565645,3,6710614,:(user, f([1], [1])),[])], non_terminating, 1048576, stack_limit, 0, trailused))'.
One more strange thing is that, if adding
:-
clause(2).
to the bias file, the learning is accelerated (with the correct result outputted).
I also test the same things in Popper 1.0, then expected pruning works.
% BEST PROG 4354:
f(A,B):-empty(A),empty(B).
f(A,B):-head(A,C),tail(A,D),odd(C),f(D,B).
f(A,B):-head(A,E),even(E),tail(A,C),f(C,D),prepend(E,D,B).
% Precision:1.00, Recall:1.00, TP:5, FN:0, TN:5, FP:0
vs
% BEST PROG 13759:
f(A,B):-empty(B),empty(A).
f(A,B):-tail(A,D),f(D,B),head(A,C),odd(C).
f(A,B):-tail(A,E),f(E,C),head(A,D),even(D),prepend(D,C,B).
% Precision:1.00, Recall:1.00, TP:5, FN:0, TN:5, FP:0
I failed to find the modification of clause
's meaning in alan.pl
. Could you please help?
To check, what do you mean by the DCC version? Which branch are you using?
The main branch of Popper. Maybe I'm misunderstanding, but I regard the Popper v2.0 as the DCC version (as mentioned in DCC repo).
Thanks for the clarification. I tried adding that constraint and indeed Popper crashes. I had a quick look and it is unclear what causes this crash.
I will investigate more and get back to you.
@yangdinglou I have fixed the issue. ce868ca
Popper was generating a non-terminating program that caused a stack overflow.
Regarding Popper, this code does not use the DCC approach. It uses a similar approach described in this paper: https://arxiv.org/pdf/2206.01614.pdf
@andrewcropper Thank you, it works well. May I know why the solution is still there when
:-
clause(2).
are given? I used to think it is a constraint to ignore solutions with more than 2 clauses. Should I use double negations?