Warning, I am in a rush and so this only does β-reduction. If α-conversion is required, this will give the incorrect answer.