Variable substitution and solving