The dead-end elimination theorem: mathematical aspects, implementation, optimizations, evaluation, and performance.