Introduction to Algorithms and Logic