Learning Abstractions for Program Synthesis

Many example-guided program synthesis techniques use abstractions to prune the search space. While abstraction-based synthesis has proven to be very powerful, a domain expert needs to provide a suitable abstract domain, together with the abstract transformers of each DSL construct. However, coming up with useful abstractions can be non-trivial, as it requires both domain expertise and knowledge about the synthesizer. In this paper, we propose a new technique for learning abstractions that are useful for instantiating a general synthesis framework in a new domain. Given a DSL and a small set of training problems, our method uses tree interpolation to infer reusable predicate templates that speed up synthesis in a given domain. Our method also learns suitable abstract transformers by solving a certain kind of second-order constraint solving problem in a data-driven way. We have implemented the proposed method in a tool called ATLAS and evaluate it in the context of the BLAZE meta-synthesizer. Our evaluation shows that (a) ATLAS can learn useful abstract domains and transformers from few training problems, and (b) the abstractions learned by ATLAS allow BLAZE to achieve significantly better results compared to manually-crafted abstractions.


Introduction
Program synthesis is a powerful technique for automatically generating programs from high-level specifications, such as input-output examples.Due to its myriad use cases across a wide range of application domains (e.g., spreadsheet automation [1,2,3], data science [4,5,6], cryptography [7,8], improving programming productivity [9,10,11]), program synthesis has received widespread attention from the research community in recent years.
Because program synthesis is, in essence, a very difficult search problem, many recent solutions prune the search space by utilizing program abstractions [12,4,13,14,15,16].For example, state-of-the-art synthesis tools, such as Blaze [14], Morpheus [4] and Scythe [16], symbolically execute (partial) programs over some abstract domain and reject those programs whose abstract behavior is inconsistent with the given specification.Because many programs share the same behavior in terms of their abstract semantics, the use of abstractions allows these synthesis tools to significantly reduce the search space.
While the abstraction-guided synthesis paradigm has proven to be quite powerful, a down-side of such techniques is that they require a domain expert to manually come up with a suitable abstract domain and write abstract transformers for each DSL construct.For instance, the Blaze synthesis framework [14] expects a domain expert to manually specify a universe of predicate templates, together with sound abstract transformers for every DSL construct.Unfortunately, this process is not only time-consuming but also requires significant insight about the application domain as well as the internal workings of the synthesizer.
In this paper, we propose a novel technique for automatically learning domainspecific abstractions that are useful for instantiating an example-guided synthesis framework in a new domain.Given a DSL and a training set of synthesis problems (i.e., input-output examples), our method learns a useful abstract domain in the form of predicate templates and infers sound abstract transformers for each DSL construct.In addition to eliminating the significant manual effort required from a domain expert, the abstractions learned by our method often outperform manually-crafted ones in terms of their benefit to synthesizer performance.
The workflow of our approach, henceforth called Atlas 3 , is shown schematically in Fig. 1.Since Atlas is meant to be used as an off-line training step for a general-purpose programming-by-example (PBE) system, it takes as input a DSL as well as a set of synthesis problems E that can be used for training purposes.Given these inputs, our method enters a refinement loop where an Abstraction Learner component discovers a sequence of increasingly precise abstract domains A 1 , ••, A n , and their corresponding abstract transformers T 1 , ••, T n , in order to help the Abstraction-Guided Synthesizer (AGS) solve all training problems.While the AGS can reject many incorrect solutions using an abstract domain A i , it may still return some incorrect solutions due to the insufficiency of A i .Thus, whenever the AGS returns an incorrect solution to any training problem, the Abstraction Learner discovers a more precise abstract domain and automatically synthesizes the corresponding abstract transformers.Upon termination of the algorithm, the final abstract domain A n and transformers T n are sufficient for the AGS to correctly solve all training problems.Furthermore, because our method learns general abstractions in the form of predicate templates, the learnt abstractions are expected to be useful for solving many other synthesis problems beyond those in the training set.
From a technical perspective, the Abstraction Learner uses two key ideas, namely tree interpolation and data-driven constraint solving, for learning useful abstract domains and transformers respectively.Specifically, given an incorrect program P that cannot be refuted by the AGS using the current abstract domain A i , the Abstraction Learner generates a tree interpolant I i that serves as a proof of P's incorrectness and constructs a new abstract domain A i+1 by 3 Atlas stands for AuTomated Learning of AbStractions.
extracting templates from the predicates used in I i .The Abstraction Learner also synthesizes the corresponding abstract transformers for A i+1 by setting up a second-order constraint solving problem where the goal is to find the unknown relationship between symbolic constants used in the predicate templates.Our method solves this problem in a data-driven way by sampling input-output examples for DSL operators and ultimately reduces the transformer learning problem to solving a system of linear equations.
We have implemented these ideas in a tool called Atlas and evaluate it in the context of the Blaze program synthesis framework [14].Our evaluation shows that the proposed technique eliminates the manual effort involved in designing useful abstractions.More surprisingly, our evaluation also shows that the abstractions generated by Atlas outperform manually-crafted ones in terms of the performance of the Blaze synthesizer in two different application domains.
To summarize, this paper makes the following key contributions: -We describe a method for learning abstractions (domains/transformers) that are useful for instantiating program synthesis frameworks in new domains.-We show how tree interpolation can be used for learning abstract domains (i.e., predicate templates) from a few training problems.-We describe a method for automatically synthesizing transformers for a given abstract domain under certain assumptions.Our method is guaranteed to find the unique best transformer if one exists.-We implement our method in a tool called Atlas and experimentally evaluate it in the context of the Blaze synthesis framework.Our results demonstrate that the abstractions discovered by Atlas outperform manuallywritten ones used for evaluating Blaze in two application domains.

Illustrative Example
Suppose that we wish to use the Blaze meta-synthesizer to automate the class of string transformations considered by FlashFill [1] and BlinkFill [17].In the original version of the Blaze framework, a domain expert needs to come up with a universe of suitable predicate templates as well as abstract transformers for each DSL construct [14].We will now illustrate how Atlas automates this process, given a suitable DSL and its semantics (e.g., the one used in [17]).
In order to use Atlas, one needs to provide a set of synthesis problems E (i.e., input-output examples) that will be used in the training process.Specifically, let us consider the three synthesis problems given below: E1 : "CAV" → "CAV2018", "SAS" → "SAS2018", "FSE" → "FSE2018" , E2 : "510.220.5586"→ "510-220-5586" , E3 : "\Company\Code\index.html" → "\Company\Code\", "\Company\Docs\Spec\specs.html" → "\Company\Docs\Spec\" In order to construct the abstract domain A and transformers T , Atlas starts with the trivial abstract domain A 0 = { } and transformers T 0 , defined as F ( , ••, ) = for each DSL construct F .Using this abstraction, Atlas invokes Blaze to find a program P 0 that satisfies specification E 1 under the current abstraction (A 0 , T 0 ).However, since the program P 0 returned by Blaze is incorrect with respect to the concrete semantics, Atlas tries to find a more precise abstraction that allows Blaze to succeed.
Towards this goal, Atlas enters a refinement loop that culminates in the discovery of the abstract domain A 1 = { , len( α ) = c, len( α ) = c}, where α denotes a variable and c is an integer constant.In other words, A 1 tracks equality and inequality constraints on the length of strings.After learning these predicate templates, Atlas also synthesizes the corresponding abstract transformers T 1 .In particular, for each DSL construct, Atlas learns one abstract transformer for each combination of predicate templates used in A 1 .For instance, for the Concat operator which returns the concatenation y of two strings x 1 , x 2 , Atlas synthesizes the following abstract transformers, where denotes any predicate: Since the AGS can successfully solve E 1 using (A 1 , T 1 ), Atlas now moves on to the next training problem.
For synthesis problem E 2 , the current abstraction (A 1 , T 1 ) is not sufficient for Blaze to discover the correct program.After processing E 2 , Atlas refines the abstract domain to the following set of predicate templates: Observe that Atlas has discovered two additional predicate templates that track positions of characters in the string.Atlas also learns the corresponding abstract transformers T 2 for A 2 .
Moving on to the final training problem E 3 , Blaze can already successfully solve it using (A 2 , T 2 ); thus, Atlas terminates with this abstraction.

Overall Abstraction Learning Algorithm
Our top-level algorithm for learning abstractions, called LearnAbstractions, is shown in Fig. 2. The algorithm takes two inputs, namely a domain-specific language L (both syntax and semantics) as well as a set of training problems E, where each problem is specified as a set of input-output examples E i .The output of our algorithm is a pair (A, T ), where A is an abstract domain represented by a set of predicate templates and T is the corresponding abstract transformers.
At a high-level, the LearnAbstractions procedure starts with the most imprecise abstraction (just consisting of ) and incrementally improves the precision of the abstract domain A whenever the AGS fails to synthesize the correct program using A. Specifically, the outer loop (lines 4-10) considers each training example E i and performs a fixed-point computation (lines 5-10) that terminates when the current abstract domain A is good enough to solve training problem E i .Thus, upon termination, the learnt abstract domain A is sufficiently precise for the AGS to solve all training problems E. 1: procedure LearnAbstractions(L, E) input: Domain-specific language L and a set of training problems E. output: Abstract domain A and transformers T .

2:
A ← ; Initialization.3:  Specifically, in order to find an abstraction that is sufficient for solving E i , our algorithm invokes the AGS with the current abstract domain A and corresponding transformers T (line 6).We assume that Synthesize returns a program P that is consistent with E i under abstraction (A, T ).That is, symbolically executing P (according to T ) on inputs E in i yields abstract values ϕ that are consistent with the outputs E out i (i.e., ∀j.E out ij ∈ γ(ϕ j )).However, while P is guaranteed to be consistent with E i under the abstract semantics, it may not satisfy E i under the concrete semantics.We refer to such a program P as spurious.
Thus, whenever the call to IsCorrect fails at line 8, we invoke the LearnAb-stractDomain procedure (line 9) to learn additional predicate templates that are later added to A. Since the refinement of A necessitates the synthesis of new transformers, we then call LearnTransformers (line 10) to learn a new T .The new abstraction is guaranteed to rule out the spurious program P as long as there is a unique best transformer of each DSL construct for domain A.

Learning Abstract Domain using Tree Interpolation
In this section, we present the LearnAbstractDomain procedure: Given a spurious program P and a synthesis problem E that P does not solve, our goal is to find new predicate templates A to add to the abstract domain A such that the Abstraction-Guided Synthesizer no longer returns P as a valid solution to the synthesis problem E. Our key insight is that we can mine for such useful predicate templates by constructing a tree interpolation problem.In what follows, we first review tree interpolants (based on [18]) and then explain how we use this concept to find useful predicate templates.

Definition 1 (Tree interpolation problem).
A tree interpolation problem T = (V, r, P, L) is a directed labeled tree, where V is a finite set of nodes, r ∈ V is the root, P : (V \{r}) → V is a function that maps children nodes to their parents, and L : V → F is a labeling function that maps nodes to formulas from a set F of first-order formulas such that v∈V L(v) is unsatisfiable.
In other words, a tree interpolation problem is defined by a tree T where each node is labeled with a formula and the conjunction of these formulas is unsatisfiable.In what follows, we write Desc(v) to denote the set of all descendants of node v, including v itself, and we write NonDesc(v) to denote all nodes other than those in Desc(v) (i.e., V \Desc(v)).Also, given a set of nodes V , we write L(V ) to denote the set of all formulas labeling nodes in V .
Given a tree interpolation problem T , a tree interpolant I is an annotation from every node in V to a formula such that the label of the root node is false and the label of an internal node v is entailed by the conjunction of annotations of its children nodes.More formally, a tree interpolant is defined as follows: Definition 2 (Tree interpolant).Given a tree interpolation problem T = (V, r, P, L), a tree interpolant for T is a function I : V → F that satisfies the following conditions: Fig. 3: A tree interpolation problem and a tree interpolant (underlined).
Intuitively, the first condition ensures that I establishes the unsatisfiability of formulas in T , and the second condition states that I is a valid annotation.As standard in Craig interpolation [19,20], the third condition stipulates a "shared vocabulary" condition by ensuring that the annotation at each node v refers to the common variables between the descendants and non-descendants of v.
Example 1.Consider the tree interpolation problem T = (V, r, P, L) in Fig. 3, where L(v) is shown to the right of each node v.A tree interpolant I for this problem maps each node to the corresponding underlined formula.For instance, we have I(v 1 ) = (len(v 1 ) = 7).It is easy to confirm that I is a valid interpolant according to Definition 2.
To see how tree interpolation is useful for learning predicates, suppose that the spurious program P is represented as an abstract syntax tree (AST), where each non-leaf node is labeled with the axiomatic semantics of the corresponding DSL construct.Now, since P does not satisfy the given input-output example (e in , e out ), we can use this information to construct a labeled tree where the conjunction of labels is unsatisfiable.Our key idea is to mine useful predicate templates from the formulas used in the resulting tree interpolant.
With this intuition in mind, let us consider the LearnAbstractDomain procedure shown in Fig. 4: The algorithm uses a procedure called Construct-Tree to generate a tree interpolation problem T for each input-output example 1: procedure LearnAbstractDomain(P, E) input: Program P that does not solve problem E (set of examples).output: Set of predicate templates A .
(e in , e out )4 that program P does not satisfy (line 4).Specifically, letting Π denote the AST representation of P, we construct T = (V, r, P, L) as follows: -V consists of all AST nodes in Π as well as a "dummy" node d.
-The root r of T is the dummy node d.
-P is a function that maps children AST nodes to their parents and maps the root AST node to the dummy node d. -L maps each node v ∈ V to a formula as follows: φF [v /x, v/y] v represents DSL operator F with axiomatic semantics φF (x, y) and v represents children of v.
Essentially, the ConstructTree procedure labels any leaf node representing the program input with the input example e in and the root node with the output example e out .All other internal nodes are labeled with the axiomatic semantics of the corresponding DSL operator (modulo renaming). 5Observe that the formula v∈V L(v) is guaranteed to be unsatisfiable since P does not satisfy the I/O example (e in , e out ); thus, we can obtain a tree interpolant for T .Example 2. Consider program P : Concat(x, "18") which concatenates constant string "18" to input x.Fig. 3 shows the result of invoking ConstructTree for P and input-output example ("CAV", "CAV2018").As mentioned in Example 1, the tree interpolant I for this problem is indicated with the underlined formulas.
Since the tree interpolant I effectively establishes the incorrectness of program P, the predicates used in I serve as useful abstract values that the synthesizer (AGS) should consider during the synthesis task.Towards this goal, the LearnAbstractDomain algorithm iterates over each predicate used in I (lines 7-8 in Fig. 4) and converts it to a suitable template by replacing the constants and variables used in I(v) with symbolic names (or "holes").Because the original predicates used in I may be too specific for the current input-output example, extracting templates from the interpolant allows our method to learn reusable abstractions.

Synthesis of Abstract Transformers
In this section, we turn our attention to the LearnTransformers procedure for synthesizing abstract transformers T for a given abstract domain A. Following presentation in prior work [14], we consider abstract transformers that are described using equations of the following form: Here, F is a DSL construct, χ i , χ j are predicate templates6 , x i is the i'th input of F , y is F 's output, c 1 , ••, c n are vectors of symbolic constants, and f j denotes a vector of affine functions over c = c 1 , ••, c n .Intuitively, given concrete predicates describing the inputs to F , the transformer returns concrete predicates describing the output.Given such a transformer τ , let Outputs(τ ) be the set of pairs (χ j , f j ) in Eqn. 1.We define the soundness of a transformer τ for DSL operator F with respect to F 's axiomatic semantics φ F .In particular, we say that the abstract transformer from Eqn. 1 is sound if the following implication is valid: That is, the transformer for F is sound if the (symbolic) output predicate is indeed implied by the (symbolic) input predicates according to F 's semantics.
Our key observation is that the problem of learning sound transformers can be reduced to solving the following second-order constraint solving problem: where f = f 1 , ••, f m and V includes all variables and functions from Eqn. 2 other than f .In other words, the goal of this constraint solving problem is to find interpretations of the unknown functions f that make Eqn. 2 valid.Our key insight is to solve this problem in a data-driven way by exploiting the fact that each unknown function f j,k is affine.
Towards this goal, we first express each affine function f j,k (c) as follows: where each p j,k,l corresponds to an unknown integer constant that we would like to learn.Now, arranging the coefficients of functions f j,1 , ••, f j,|f j | in f j into a |f j | × (|c| + 1) matrix P j , we can represent f j (c) in the following way: where c † is c appended with the constant 1.
Given this representation, it is easy to see that the problem of synthesizing the unknown functions f 1 , ••, f m from Eqn. 2 boils down to finding the unknown matrices P 1 , ••, P m such that each P j makes the following implication valid: Our key idea is to infer these unknown matrices P 1 , ••, P m in a data-driven way by generating input-output examples of the form for each f j .In other words, i and o correspond to instantiations of c and f j (c) respectively.Given sufficiently many such examples for every f j , we can then reduce the problem of learning each unknown matrix P j to the problem of solving a system of linear equations.
Based on this intuition, the LearnTransformers procedure from Fig. 5 describes our algorithm for learning abstract transformers T for a given abstract domain A. At a high-level, our algorithm synthesizes one abstract transformer for each DSL construct F and n argument predicate templates χ 1 , ••, χ n .In particular, given F and χ 1 , ••, χ n , the algorithm constructs the "return value" of the transformer as: where f j is the inferred affine function for each predicate template χ j .
The key part of our LearnTransformers procedure is the inner loop (lines 5-8) for inferring each of these f j 's.Specifically, given an output predicate template χ j , our algorithm first generates a set of input-output examples E of the form [p 1 , ••, p n ] → p 0 such that F (p 1 , ••, p n ) = p 0 is a sound (albeit overly specific) transformer.Essentially, each p i is a concrete instantiation of a predicate template, so the examples E generated at line 6 of the algorithm can be viewed as sound input-output examples for the general symbolic transformer given in Eqn. 1. (We will describe the GenerateExamples procedure in Section 5.1).
Once we generate these examples E, the next step of the algorithm is to learn the unknown coefficients of matrix P j from Eqn. 5 by solving a system of linear equations (line 7).Specifically, observe that we can use each input-output example [p 1 , ••, p n ] → p 0 in E to construct one row of Eqn. 4. In particular, we can directly extract c = c 1 , ••, c n from p 1 , ••, p n and the corresponding value of f j (c) from p 0 .Since we have one instantiation of Eqn. 4 for each of the inputoutput examples in E, the problem of inferring matrix P j now reduces to solving a system of linear equations of the form AP T j = B where A is a |E| × (|c| + 1) 1: procedure LearnTransformers(L, A) input: DSL L and abstract domain A. output: A set of transformers T for constructs in L and abstract domain A.
(input) matrix and B is a |E| × |f j | (output) matrix.Thus, a solution to the equation AP T j = B generated from E corresponds to a candidate solution for matrix P j , which in turn uniquely defines f j .
Observe that the call to Solve at line 7 may return null if no affine function exists.Furthermore, any non-null f j returned by Solve is just a candidate solution and may not satisfy Eqn. 5.For example, this situation can arise if we do not have sufficiently many examples in E and end up discovering an affine function that is "over-fitted" to the examples.Thus, the validity check at line 8 of the algorithm ensures that the learnt transformers are actually sound.

Example Generation
In our discussion so far, we assumed an oracle that is capable of generating valid input-output examples for a given transformer.We now explain our Genera-teExamples procedure from Fig. 6 that essentially implements this oracle.In a nutshell, the goal of GenerateExamples is to synthesize input-output examples of the form [p 1 , ••, p n ] → p 0 such that F (p 1 , ••, p n ) = p 0 is sound where each p i is a concrete predicate (rather than symbolic).
Going into more detail, GenerateExamples takes as input the semantics φ F of DSL construct F for which we want to learn a transformer for as well as the input predicate templates χ 1 , ••, χ n and output predicate template χ 0 that are supposed to be used in the transformer.For any example [p 1 , ••, p n ] → p 0 synthesized by GenerateExamples, each concrete predicate p i is an instantiation of the predicate template χ i where the symbolic constants used in χ i are substituted with concrete values.
Conceptually, the GenerateExamples algorithm proceeds as follows: for each (p0, Fig. 6: Example generation for learning abstract transformers. [p 1 , ••, p n ] → p 0 (line 6).Specifically, we assume that the return value (A 0 , ••, A n ) of Abstract at line 6 satisfies the following properties for every p i ∈ A i : -p i is an instantiation of template χ i .
-p i is a sound over-approximation of s i (i.e., s i ∈ γ(p i )).
-For any other p i satisfying the above two conditions, p i is not logically stronger than p i .
In other words, we assume that Abstract returns a set of "best" sound abstractions of (s Next, given abstractions (A 0 , ••, A n ) for (s 0 , ••, s n ), we consider each candidate abstract example of the form [p 1 , ••, p n ] → p 0 where p i ∈ A i .Even though each p i is a sound abstraction of s i , the example [p 1 , ••, p n ] → p 0 may not be valid according to the semantics of operator F .Thus, the validity check at line 8 ensures that each example added to E is in fact valid.
Example 4. Given abstract domain A = {len( α ) = c}, suppose we want to learn an abstract transformer τ for the Concat operator of the following form: We learn the affine function f used in the transformer by first generating a set E of I/O examples for f (line 6 in LearnTransformers).In particular, GenerateExamples generates concrete input values for Concat at random and obtains the corresponding output values by executing Concat on the input values.For instance, it may generate s 1 = "abc" and s 2 = "de" as inputs, and obtain s 0 = "abcde" as output.Then, it abstracts these values under the given templates.In this case, we have an abstract example with p 1 = len(x 1 ) = 3 , p 2 = len(x 2 ) = 2 and p 0 = len(y) = 5 .Since [p 1 , p 2 ] → p 0 is a valid example, it is added in E (line 8 in GenerateExamples).At this point, E is not yet full rank, so the algorithm keeps generating more examples.Suppose it generates two more valid examples len(x 1 ) = 1, len(x 2 ) = 4 → len(y) = 5 and len(x 1 ) = 6, len(x 2 ) = 4 → len(y) = 10 .Now E is full rank, so Learn-Transformers computes f by solving the following system of linear equations:

Soundness and Completeness
In this section we present theorems stating some of the soundness, completeness, and termination guarantees of our approach.All the proofs can be found in the appendix.
Theorem 1 (Soundness of LearnTransformers).Let T be the set of transformers returned by LearnTransformers.Then, every τ ∈ T is sound according to Eqn. 2.
The remaining theorems are predicated on the assumptions that for each DSL construct F and input predicate templates χ 1 , ••, χ n (i) there exists a unique best abstract transformer and (ii) the strongest transformer expressible in Eqn. 2 is logically equivalent to the unique best transformer.Thus, before stating these theorems, we first state what we mean by a unique best abstract transformer.

Definition 3 (Unique best function). Consider a family of transformers of the shape
We say that f is the unique best function for (F, χ 1 , ••, χ n , χ ) if (a) replacing with f yields a sound transformer, and (b) replacing with any other f yields a transformer that is either unsound or strictly worse (i.e., χ (y, f ) ⇒ χ (y, f ) and χ (y, f ) ⇒ χ (y, f ). ) We now define unique best transformer in terms of unique best function: Definition 4 (Unique best transformer).Let F be a DSL construct and let (χ 1 , ••, χ n ) ∈ A n be the input templates for F .We say that the abstract transformer τ is a unique best transformer for F, χ 1 , ••, χ n if (a) τ is sound, and (b) for any predicate template χ ∈ A, we have (χ, f ) ∈ Outputs(τ ) if and only if f is a unique best function for (F, χ 1 , ••, χ n , χ) for some affine f .Definition 5 (Complete sampling oracle).Let F be a construct, A an abstract domain, and R F a probability distribution over Domain(F ) with finite support S. Futher, for any input predicate templates χ 1 , ••, χ n and output predicate template χ 0 in A admitting a unique best function f , let The following theorem states that LearnTransformers is guaranteed to synthesize the best transformer if a unique one exists: Theorem 2 (Completeness of LearnTransformers).Given an abstract domain A and a complete sampling oracle R F for A, LearnTransformers terminates.Further, let T be the set of transformers returned and let τ be the unique best transformer for DSL construct F and input predicate templates χ 1 , ••, χ n ∈ A n .Then we have τ ∈ T .
Using this completeness (modulo unique best transformer) result, we can now state the termination guarantees of our LearnAbstractions algorithm: Theorem 3 (Termination of LearnAbstractions).Given a complete sampling oracle R F for every abstract domain and the unique best transformer assumption, if there exists a solution for every problem E i ∈ E, then LearnAbstractions terminates.

Implementation and Evaluation
We have implemented the proposed method as a new tool called Atlas, which is written in Java.Atlas takes as input a set of training problems, an Abstraction-Guided Synthesizer (AGS), and a DSL and returns an abstract domain (in the form of predicate templates) and the corresponding transformers.Internally, Atlas uses the Z3 theorem prover [21] to compute tree interpolants and the JLinAlg linear algebra library [22] to solve linear equations.
To assess the usefulness of Atlas, we conduct an experimental evaluation in which our goal is to answer the following two questions: 1. How does Atlas perform during training?That is, how many training problems does it require and how long does training take? 2. How useful are the abstractions learnt by Atlas in the context of synthesis?

Abstraction Learning
To answer our first question, we use Atlas to automatically learn abstractions for two application domains: (i) string manipulations and (ii) matrix transformations.We provide Atlas with the DSLs used in [14] and employ Blaze as the underlying Abstraction-Guided Synthesizer.Axiomatic semantics for each DSL construct were given in the theory of equality with uninterpreted functions.
Training set information.For the string domain, our training set consists of exactly the four problems used as motivating examples in the BlinkFill paper [17].Specifically, each training problem consists of 4-6 examples that demonstrate the desired string transformation.For the matrix domain, our training set consists of four (randomly selected) synthesis problems taken from online forums.Since almost all online posts contain a single input-output example, each training problem includes one example illustrating the desired matrix transformation.
Main results.Our main results are summarized in Fig. 7.The main take-away message is that Atlas can learn abstractions quite efficiently and does not require a large training set.For example, Atlas learns 5 predicate templates and 30 abstract transformers for the string domain in a total of 10.2 seconds.Interestingly, Atlas does not need all the training problems to infer these four predicates and converges to the final abstraction after just processing the first training instance.Furthermore, for the first training instance, it takes Atlas 4 iterations in the learning loop (lines 5-10 from Fig. 2) before it converges to the final abstraction.Since this abstraction is sufficient for solving the remaining training problems, the loop takes just one iteration.Looking at the right side of Fig. 7, we also observe similar results for the matrix domain.In particular, Atlas learns 10 predicate templates and 59 abstract transformers in a total of 22.5 seconds.Furthermore, Atlas converges to the final abstract domain after processing the first three problems7 and the number of iterations for each training instance is also quite small.

Evaluating the Usefulness of Learnt Abstractions
To answer our second question, we integrated the abstractions synthesized by Atlas into the Blaze meta-synthesizer.In the remainder of this section, we refer to all instantiations of Blaze using the Atlas-generated abstractions as Blaze .To assess how useful the automatically generated abstractions are, we compare Blaze against Blaze † , which refers to the manually-constructed instantiations of Blaze described in [14].Benchmark information.For the string domain, our benchmark suite consists of (1) all 108 string transformation benchmarks that were used to evaluate Blaze † and (2) 40 additional challenging problems that are collected from online forums which involve manipulating file paths, URLs, etc.The number of examples for each benchmark ranges from 1 to 400, with a median of 7 examples.For the matrix domain, our benchmark set includes (1) all 39 matrix transformation benchmarks in the Blaze † benchmark suite and (2) 20 additional challenging problems collected from online forums.We emphasize that the set of benchmarks used for evaluating Blaze are completely disjoint from the set of synthesis problems used for training Atlas.
Experimental setup.We evaluate Blaze and Blaze † using the same DSLs from the Blaze paper [14].For each benchmark, we provide the same set of input-output examples to Blaze and Blaze † , and use a time limit of 20 minutes per synthesis task.
Main results.Our main evaluation results are summarized in Fig. 8.The key observation is that Blaze consistently improves upon Blaze † for both string and matrix transformations.In particular, Blaze not only solves more benchmarks than Blaze † for both domains, but also achieves about an order of magnitude speed-up on average for the common benchmarks that both tools can solve.Specifically, for the string domain, Blaze solves 133 (out of 148) benchmarks within an average of 2.8 seconds and achieves an average 8.3× speed-up over Blaze † .For the matrix domain, we also observe a very similar result where Blaze leads to an overall speed-up of 9.2× on average.In summary, this experiment confirms that the abstractions discovered by Atlas are indeed useful and that they outperform manually-crafted abstractions despite eliminating human effort.

Related Work
To our knowledge, this paper is the first one to automatically learn abstract domains and transformers that are useful for program synthesis.We also believe it is the first to apply interpolation to program synthesis, although interpolation has been used to synthesize other artifacts such as circuits [23] and strategies for infinite games [24].In what follows, we briefly survey existing work related to program synthesis, abstraction learning, and abstract transformer computations.
Program synthesis.Our work is intended to complement example-guided program synthesis techniques that utilize program abstractions to prune the search space [15,16,4,14].For example, Simpl [15] uses abstract interpretation to speed up search-based synthesis and applies this technique to the generation of imperative programs for introductory programming assignments.Similarly, Scythe [16] and Morpheus [4] perform enumeration over program sketches and use abstractions to reject sketches that do not have any valid completion.Somewhat different from these techniques, Blaze constructs a finite tree automaton that accepts all programs whose behavior is consistent with the specification according to the DSL's abstract semantics.We believe that the method described in this paper can be useful to all such abstraction-guided synthesizers.
Abstraction refinement.In verification, as opposed to synthesis, there have been many works that use Craig interpolants to refine abstractions [20,25,26].Typically, these techniques generalize the interpolants to abstract domains by extracting a vocabulary of predicates, but they do not generalize by adding parameters to form templates.In our case, this is essential because interpolants derived from fixed input values are too specific to be directly useful.Moreover, we reuse the resulting abstractions for subsequent synthesis problems.In verification, this would be analogous to re-using an abstraction from one property or program to the next.It is conceivable that template-based generalization could be applied in verification to facilitate such reuse.
Abstract transformers.Many verification techniques use logical abstract domains [27,28,29,30,31].Some of these, following Yorsh, et al. [32] use sampling with a decision procedure to evaluate the abstract transformer [33].Interpolation has also been used to compile efficient symbolic abstract transformers [34].However, these techniques are restricted to finite domains or domains of finite height to allow convergence.Here, we use infinite parameterized domains to obtain better generalization; hence, the abstract transformer computation is more challenging.Nonetheless, the approach might also be applicable in verification.

Limitations
While this paper takes a first step towards automatically inferring useful abstractions for synthesis, our proposed method has the following limitations: Shapes of transformers.Following prior work [14], our algorithm assumes that abstract transformers have the shape given in Eqn. 1.We additionally assume that constants c used in predicate templates are numeric values and that functions in Eqn. 1 are affine.This assumption holds in several domains considered in prior work [4,14] and allows us to develop an efficient learning algorithm that reduces the problem to solving a system of linear equations.DSL semantics.Our method requires the DSL designer to provide the DSL's logical semantics.We believe that giving logical semantics is much easier than coming up with useful abstractions, as it does not require insights about the internal workings of the synthesizer.Furthermore, our technique could, in principle, also work without logical specifications although the learnt abstract domain may not be as effective (see Footnote 3 in Section 4) and the synthesized transformers would not be provably sound.
UBT assumption.Our completeness and termination theorems are predicated on the unique best transformer (UBT) assumption.While this assumption holds in our evaluation, it may not hold in general.However, as mentioned in Section 6, we can always guarantee termination by including the concrete predicates used in the interpolant I in addition to the symbolic templates extracted from I.

Conclusion
We proposed a new technique for automatically instantiating abstraction-guided synthesis frameworks in new domains.Given a DSL and a few training problems, our method automatically discovers a useful abstract domain and the corresponding transformers for each DSL construct.From a technical perspective, our method uses tree interpolation to extract reusable templates from failed synthesis attempts and automatically synthesizes unique best transformers if they exist.We have incorporated the proposed approach into the Blaze metasynthesizer and show that the abstractions discovered by Atlas are very useful.
While we have applied the proposed technique to program synthesis, we believe that some of the ideas introduced here are more broadly applicable.For instance, the idea of extracting reusable predicate templates from interpolants and synthesizing transformers in a data-driven way could also be useful in the context of program verification.

Fig. 2 :
Fig. 2: Overall learning algorithm.Constructs gives the DSL constructs in L.

Fig. 8 :
Fig. 8: Improvement of Blaze over Blaze † on string and matrix benchmarks.
Training results.|A|,|T|, Iters denote the number of predicate templates, abstract transformers, and iterations taken per training instance (lines 5-10 from Fig.2), respectively.T AGS , T A , T T denote the times for invoking the synthesizer (AGS), learning the abstract domain, and learning the abstract transformers, respectively.T total shows the total training time in seconds.