We present a new approach to example-guided program synthesis based on counterexample-guided abstraction refinement. Our method uses the abstract semantics of the underlying DSL to find a program P whose abstract behavior satisfies the examples. However, since program P may be spurious with respect to the concrete semantics, our approach iteratively refines the abstraction until we either find a program that satisfies the examples or prove that no such DSL program exists. Because many programs have the same input-output behavior in terms of their abstract semantics, this synthesis methodology significantly reduces the search space compared to existing techniques that use purely concrete semantics. While synthesis using abstraction refinement (SYNGAR) could be implemented in different settings, we propose a refinement-based synthesis algorithm that uses abstract finite tree automata (AFTA). Our technique uses a coarse initial program abstraction to construct an initial AFTA, which is iteratively refined by constructing a proof of incorrectness of any spurious program. In addition to ruling out the spurious program accepted by the previous AFTA, proofs of incorrectness are also useful for ruling out many other spurious programs. We implement these ideas in a framework called Blaze, which can be instantiated in different domains by providing a suitable DSL and its corresponding concrete and abstract semantics. We have used the Blaze framework to build synthesizers for string and matrix transformations, and we compare Blaze with existing techniques. Our results for the string domain show that Blaze compares favorably with FlashFill, a domainspecific synthesizer that is now deployed in Microsoft PowerShell. In the context of matrix manipulations, we compare Blaze against Prose, a state-of-the-art general-purpose VSA-based synthesizer, and show that Blaze results in a 90x speed-up over Prose. In both application domains, Blaze also consistently improves upon the performance of two other existing techniques by at least an order of magnitude. Abstract Synthesizer Checker Refiner candidate program Failure (no solution) Synthesized program counterexample & spurious program new abstraction End-users Domain expert Examples DSL w/ abstract semantics SYNGAR AFTA constr uction AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Rank Predicates Predicates 2 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Predicates 3 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Program: id(x) Program: id(x) + 2 Program: id(x) * 3 Predicates Program: (id(x) + 2) * 3 Iteration 1: The constructed AFTA is A 1 , Rank returns Π 1 , Π 1 is spurious, and the proof of incorrectness is I 1 . AFTA constr uction AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Rank Predicates Predicates 2 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Predicates 3 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Program: id(x) Program: id(x) + 2 Program: id(x) * 3 Predicates Program: (id(x) + 2) * 3 Iteration 2: The constructed AFTA is A 2 , Rank returns Π 2 , Π 2 is spurious, and the proof of incorrectness is I 2 . AFTA constr uction AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Rank Predicates Predicates 2 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Predicates 3 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Program: id(x) Program: id(x) + 2 Program: id(x) * 3 Predicates Program: (id(x) + 2) * 3 Iteration 3: The constructed AFTA is A 3 , Rank returns Π 3 , Π 3 is spurious, and the proof of incorrectness is I 3 . AFTA constr uction AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Rank Predicates Predicates 2 AST annotated with old abstract values AST annotated with concrete values Pr oof constr uction Predicates 3 AST annotated with old abstract values AST annotated with concrete values
SYNGAR REF uses predicate abstraction to prune the search space of a synthesisfrom-examples problem.
Program synthesis using abstraction refinement
PACMPL
Computer Science