Optimal Groundness Analysis Using Propositional Logic