An Intelligent Backtracking Scheme for Prolog