Guiding Safe Exploration with Weakest Preconditions