Limit dereferencing of goal arguments to one level

This stops unnecessary repeated dereferencing of the arguments when
recursing over the lists.
Add memberchk/2 predicate to lists library

Memberchk/2 only checks if element is there, does not generate a list
and is non-backtracking.