I've got an assignment where I have to define a predicate named two(X,L), which is true if the list L contains at least two occurrences of the element X, using only the append predicate. The right-hand side of any of my rules may use only append, or use the predicate two(X,L). So for example, my desired output would look like this.
two(x,[a,a,b,a,c,b,a]).
X = a
X = b
two(c,[a,a,b,a,c,b,a]).
FALSE
I've been trying to think of a way to do this, but based off of my knowledge of append the only predicate we could really use within two(X,L)
is append(X,X,L)
. Append isn't a true/false thing is it, it just tries to put X within L twice.
I don't need someone to solve the assignment for me, I just need a stepping stone because I'm confused as to how to accomplish this task only using append.