A semantic approach to automatic program improvement