Finished correctness proof for problem 2.