This predicate never fails.
"If Head refers to a predicate that is not defined, it is implicitly created as a dynamic predicate" means:
?- predicate_property(foo(_,_),dynamic). false. ?- retractall(foo(a,_)). true. ?- predicate_property(foo(_,_),dynamic). true.
Jan Burse writes (code comments added by me):
"[Similarly] there are differences in retract/1 and retractall/1 if the predicate is unknown. For example that SWI-Prolog creates a new dynamic entry during retractall/1, is not required by the standard. The usual
bootstrapping(*) would be:
retractall(Head) :- retract((Head :- _)), fail. % failure-driven loop to retract the whole shebang retractall(_). % "make this a success" catchall
(*) DRAFT TECHNICAL CORRIGENDUM 2 https://www.complang.tuwien.ac.at/ulrich/iso-prolog/dtc2#retractall