This paper presents a formal framework for the automatic transformation of ineecient generate and test programs into equivalent programs by learning from the proofs of example queries. In the resulting program the search is guided by strategies based on abstracted proof traces obtained from the interpretation of example computations. Strategies are incre-mentally improved in an iterative proces...