The variables appearing in Term should not appear anywhere else in the clause except within Goal.
The following table illustrates the difference between the all solutions predicates:
built-in choice pts duplicates sorted pruned * bagof/3 yes yes no no coverof/3 yes no no yes findall/3 no yes no no setof/3 yes no yes no * prune_instances/2 used on list of solutions.If Goal is not a callable term, exceptions are raised in call/2.
coverof/3 should not be used if Term is a variable. If the resulting list List contains no compound terms or variables, it is usually more efficient to use setof/3.
Note If there are uninstantiated variables in Goal which do not appear in Term, then coverof/3 can be resatisfied. It generates alternative values for List corresponding to different instantiations of the free variables of Goal not in Term. Such variables occurring in Goal will not be treated as free if they are explicitly bound within Goal through an existential quantification written as, for example,
coverof(X, Y^(X likes Y), S).Then coverof/3 will not backtrack over Y when getting a list of solutions of X.
Success: % example using existential quantification: [eclipse]: [user]. h(f(1,2),g(1,3)). h(f(2,3),g(2,4)). h(f(1,3),g(2,2)). h(f(2,3),g(2,2)). h(f(2,2),g(1,1)). user compiled 900 bytes in 0.00 seconds yes. [eclipse]: coverof(f(X,Y),h(f(X,Y),g(W,Z)),L), > writeln((X,Y,W,Z,L)), fail. _g66 , _g72 , 1 , 1 , [f(2, 2)] _g66 , _g72 , 1 , 3 , [f(1, 2)] _g66 , _g72 , 2 , 2 , [f(1, 3), f(2, 3)] _g66 , _g72 , 2 , 4 , [f(2, 3)] no (more) solution. [eclipse]: coverof(f(X,Y),g(W,Z)^h(f(X,Y),g(W,Z)),L). X = _g76 Y = _g78 W = _g70 Z = _g72 L = [f(1, 2), f(2, 3), f(1, 3), f(2, 2)] yes. Fail: coverof(Y,current_stream(X,Y,Z),[strin]). Error: coverof(X,G,L). (Error 4). coverof(X,"G",L). (Error 5). coverof(X,a,L). (Error 68).