I have the following rule:
noRepetition([]).
noRepetition([Elem|Rest]):- not(member(Elem,Rest)), !, noRepetition(Rest).
This rule is made to decide if a list has no repeating elements in it and the member rule decides if a particular element belongs to a list. My question is relating to the cut operator in this rule as I am not sure what it does.
I have drawn up the following trace for ?-noRepetition([a,b,b,c,d])
and have run across a problem(probably relating to my lack of understanding of the cut operator):
?-noRepetition([a,b,b,c,d])
Unfies with the second noRepetion rule and instantiates variables to:
noRepetition([a|b,b,c,d] :- not(member(a,[b,b,c,d])), !, noRepetition([b,b,c,d]).
Now I am stuck as not member returns true in this case thus the cut is proven true, however I am not sure if this cut prevents the program from going to noRepetition(the 3rd goal) or if it does something else. If it indeed prevents the program from going to noRepetition then this rule would be evaluated to true, which is not the case as there is repetition in the list.