Recursive Unsolvability of Determinacy, Solvable Cases of Determinancy and their Applications to Prolog Optimization