title: Prolog program to find equality of two lists in any order
body: <p>I wanted to write a Prolog program to find equality of two lists, where the order of elements<br>
  doesn't matter. So I wrote the following:</p>
  
  <pre><code>del(_, [], []) .
  del(X, [X|T], T).  
  del(X, [H|T], [H|T1]) :-
     X \= H,
     del(X, T, T1).
  
  member(X, [X|_]).  
  member(X, [_|T]) :- 
     member(X, T).
  
  equal([], []).  
  equal([X], [X]).  
  equal([H1|T], L2) :-
     member(H1, L2),
     del(H1, L2, L3),
     equal(T, L3).  
  </code></pre>
  
  <p>But when I give input like <code>equal([1,2,3],X).</code>, it doesn't show all possible values of <code>X</code>. Instead, the program hangs in the middle. What could be the reason?</p>