I’m using the current SWI-Prolog version (but ideally looking for a portable solution).
Consider a simple logicbase such as this:
color(red).
color(green).
color(blue).
color(yellow).
rule1(X) :- color(X), X == red.
rule2(X) :- color(X), X == green.
rule3(X) :- color(X), X == blue.
complex_rule(A, B) :- rule1(A), rule2(B), rule3(B).
with a query like this:
complex_rule(A, B).
It will fail, because rule2 and rule3 are contradicting each other (as is expected).
If one of the goals is removed however:
complex_rule(A, B) :- rule1(A), rule2(B).%, rule3(B).
the same query will succeed, and bind variables as wanted.
Is there a way to make Prolog remove goals, when the conjunction of all the goals is not satisfiable? In other words, instead of deactivating goals manually, is there some automated exhaustive combinatorial test? Ideally this would work by leveraging Prolog without essentially reimplementing a changed form of satisfiablility test.
Also, is there a way to get a list of conflicting goals?
The purpose is to find solutions that may not be perfect, but satisfy as many constraints/goals as possible(, possibly prioritzing some goals over others).