Added lemma for optimal substructure.