A Basis for a Theory of Program Synthesis