I wish to define a predicate powerset(X, P) which is true when P is the powerset of X. Should work whether or not P is ground.
Alexander Serebrenik
Since you use SICStus Prolog you can use the subseq0(+Sequence, ?SubSequence) from library(lists), which "is true when SubSequence is a subsequence of Sequence, but may be Sequence itself" (Quoting from the manual http://www.sics.se/sicstus/docs/4.0.2/html/sicstus/lib_002dlists.html).
?- setof(X, subseq0([a,b,c],X), Xs).
Xs = [[],[a],[a,b],[a,b,c],[a,c],[b],[b,c],[c]]
If you are not allowed to use library predicates you can implement the subseteq0 as explained in gnu Prolog powerset modification, which I quote here for the sake of completeness (with thanks to gusbro)
powerset([], []).
powerset([H|T], P) :- powerset(T,P).
powerset([H|T], [H|P]) :- powerset(T,P).
来源:https://stackoverflow.com/questions/10338666/prolog-powerset-predicate