Logic-Based Program Synthesis and Transformation