Building Problem Solvers in Prolog