Synthesizing Data Structure Refinements from Integrity Constraints
Fri 25 Jun 2021 01:35 - 01:40 at PLDI-A - Talks 4A: Analysis and Synthesis
Implementations of many data structures use several correlated fields to improve their performance; however, inconsistencies between these fields can be a source of serious program errors. To address this problem, we propose a new technique for automatically refining data structures from integrity constraints. In particular, consider a data structure $D$ with fields $F$ and methods $M$, as well as a new set of auxiliary fields $F'$ that should be added to $D$. Given this input and an integrity constraint $\Phi$ relating $F$ and $F'$, our method automatically generates a refinement of $D$ that satisfies the provided integrity constraint. Our method is based on a \emph{modular} instantiation of the CEGIS paradigm and uses a novel inductive synthesizer that augments top-down search with three key ideas. First, it computes \emph{necessary preconditions} of partial programs to dramatically prune its search space. Second, it augments the grammar with promising new productions by leveraging the computed preconditions. Third, it guides top-down search using a \emph{probabilistic} context-free grammar obtained by statically analyzing the integrity checking function and the original code base. We evaluated our method on 25 data structures from popular Java projects and show that our method can successfully refine 23 of them. We also compare our method against two state-of-the-art synthesis tools and perform an ablation study to justify our design choices. Our evaluation shows that (1) our method is successful at refining many data structure implementations in the wild, (2) it advances the state-of-the-art in synthesis, and (3) our proposed ideas are crucial for making this technique practical.