title: Define the relation `subsum(Set,Sum,Subset)`
body: <p>I have a problem.</p>
  <blockquote>
  <p>Define the relation <code>subsum(Set,Sum,Subset)</code> such that Set is a multiset of numbers expressed using lists, Subset is a subset of Set, and Sum is the union of the elements of Subset. The following results are obtained.</p>
  <pre><code>?- subsum([1,2,5,3,2],5,Sub).
  Sub = [1, 2, 2] ;
  Sub = [2, 3] ;
  Sub = [5] ;
  Sub = [3, 2] ;
  false.
  ?-
  </code></pre>
  <p>The answers must not use any relationship other than the answer.</p>
  </blockquote>
  <p>My answer is:</p>
  <pre><code>subsum([], 0 ,[]).
  subsum([_ | Xs], Sum, Ys) :- subsum(Xs, Sum, Ys).
  subsum([X | Xs], Sum, [X | Ys]) :- subsum(Xs, Sum - X, Ys).
  </code></pre>
  <p>But this code does not work as I expected.
  Could you give me some hints?</p>