projog

3.121. subset(X,Y) - checks if a set is a subset.

True if each of the elements in the list represented by X can be unified with elements in the list represented by Y.

Examples

?- subset([],[]).

yes

?- subset([],[a,b,c]).

yes

?- subset([a],[a,b,c]).

yes

?- subset([b,c],[a,b,c]).

yes

?- subset([a,b,c],[a,b,c]).

yes

?- subset([c,a,b],[a,b,c]).

yes

?- subset([c,a,c,b,b,c],[b,a,b,a,c]).

yes

?- subset([a,b,c,d],[a,b,c]).

no

?- subset([a,b,c],[]).

no

?- subset([a,b,c,d],[x,y,z|X]).
X = [a,b,c,d|_]

yes

?- subset([a,b,c,d,e,f],[a,b,e,g|X]).
X = [c,d,f|_]

yes

?- subset([X,Y,Z],[q,w,e,r,t,y]).
X = q
Y = q
Z = q

yes

?- subset([a,b,Y,Z,d,e,f],[a,b,e,g|X]).
X = [d,f|_]
Y = a
Z = a

yes