title: Swi Prolog Relation
body: <p>I am trying to write a relation split in Prolog that takes an integer N, a list L of integers, and other parameters, list L is flat. The relation split returns true if the list L can be divided into three subsets, such that the sum of the integers in each subset is strictly less than N. Otherwise, the relation returns false. This is the furthest I've gone so far:</p>
  
  <pre><code>split(list, list, list, list)
  split([],[],[],[]).
  list_sum([],0).
  split([X|L], [X|L1], [X|L2], L3):-
  list_sum([Head + Tail]),
  list_sum&gt;N,
  !,
  split(N, L,L1, L2, L3).
  </code></pre>
  
  <p>?- ERROR: toplevel: Undefined procedure: list_sum/2 (DWIM could not correct goal)
  Any help and explanation is highly appreciated.</p>