Morse theory and the yang-mills equations