I'm just starting with Prolog, and I can't figure out why the the following doesn't work as I expect it to. I'm trying to create a predicate that returns true if list L2 is contained in L1. This is what I wrote:
assert(contains (L1, L1)).
assert(contains(L1, [X|L2]):-member(X, L1), contains(L1, L2)).
assert(contains(L1, [])).
I figured this will be the equivalent of "if X of 'L3=X|L2' is in L1, and also L2 is in L1 then true", with contains(L1, L2) being translated recursively until either all members have been traversed and we are left with the last option, or we find a member that is not in L1, and it will fail the predicate.
Unfortunately it doesn't seem to work that way. It seems to only return the value of member(X, L1), so contains([1,2,3],[1,4,5]) passes, but contains([1,2,3],[4,1,5]) doesn't.
What am i doing wrong?