Solving Functional Constraints by Variable Substitution