We present a novel approach for resolving numerical program sketches under Boolean and quantitative objectives. The input is a program sketch, which represents a partial program with missing numerical parameters (holes). The aim is to automatically synthesize values for the parameters, such that the resulting complete program satisfies: a Boolean (qualitative) specification given in the form of assertions; and a quantitative specification that estimates the number of execution steps to termination and which the synthesizer is expected to optimize.
To address the above quantitative sketching problem, we encode a program sketch as a program family (a.k.a. Software Product Line) and use the specifically designed lifted analysis algorithms based on abstract interpretation for efficiently analyzing program families with numerical features. The elements of the lifted analysis domain are decision trees, in which decision nodes are labeled with linear constraints defined over numerical features and leaf nodes belong to an existing single-program analysis domain. First, we transform a program sketch into a program family, such that numerical holes correspond to numerical features and all possible sketch realizations correspond to variants in the program family. Then, we use a combination of forward (numerical) and backward (quantitative termination) lifted analysis of program families to find the variants (family members) that satisfy all assertions, and moreover are optimal with respect to the given quantitative objective. Such obtained variants represent the “correct & optimal” realizations of the given program sketch.
We present a prototype implementation of our approach within the FamilySketcher