title: Prolog: Getting unique atoms from propositional formulas
body: <p>I can easily write a predicate to get unique elements from a given list in Prolog e.g. </p>
  
  <pre><code>no_doubles( [], [] ).
  no_doubles( [H|T], F ) :-
   member( H, T ),
   no_doubles( T, F ).
  no_doubles( [H|T], [H|F] ) :-
   \+ member( H, T ),
   no_doubles( T, F ).
  </code></pre>
  
  <p>However, how can you do the same thing but for something other than a normal list i.e. not something like [a,b,c...]?  So in my case, I want to extract unique atoms for a propositional formula e.g. unique_atoms(and(x,and(x,y),z),[x,y,z]). is satisfied.  Do you use recursion just like in my no_doubles example but for a formula like this? </p>
  
  <p>Any ideas are welcomed :).  Thanks.</p>