Use a “cut” — !
We can make rule 2 prevent backtracking with the “cut” operator, written !
delete_all([E|Tail], E, Res) :- delete_all(Tail, E, Res), !.
Now the search algorithm will not try any other rules for delete_all after the above rule succeeds
! succeeds and stops further backtracking for more results