imported Rasmus's main prover loop