let p_exists x p =
  match val_of p with
    | Ptrue | Pfalse | Papp ("dummy",_) -> p
    | _ -> if p_has_var [x] p then Pexists(x,p) else p