Overhauled problem solver's restart system

Also added existing/2 and hacked primitive actions to declare the
existence of their patients as preconditions.