我的不变量有效吗?学习方法
Are My Invariants Valid? A Learning Approach
摘要:
在大型复杂系统中,确保程序正确运行是一项艰巨的任务。在代码或注释中嵌入不变量(正确执行所需的属性)可以支持可维护性,并有助于保持正确性。因此,可以自动推断和推荐不变量的工具可能非常有益。然而,目前的不变式建议工具,如Daikon,遭受高误报率,部分原因是因为他们只利用跟踪程序值从可用的测试用例,而不是直接利用知识的源代码本身。我们提出了一种机器学习的方法来判断的有效性不变,特别是方法的前,后条件,直接基于一个方法的源代码。我们引入了一种新的,可扩展的方法来创建标记的不变量:使用大型测试套件的程序,我们生成的Daikon不变量使用这些测试套件的子集的痕迹,然后将这些标记为有效/无效的交叉验证他们举行了测试。这个过程会产生大量的标签,这些标签提供了一种噪声监督的形式,然后基于门控图神经网络,将其用于训练深度神经模型。我们的模型学习将给定方法主体的词汇,语法和语义结构映射到该方法主体上的候选前置或后置条件是正确的概率,并且能够基于噪声信号准确地标记不变量,即使在跨项目设置中。最重要的是,它在手工策划的不变量数据集上表现良好。
英文摘要:
Ensuring that a program operates correctly is a difficult task in large, complex systems. Enshrining invariants -- desired properties of correct execution -- in code or comments can support maintainability and help sustain correctness. Tools that can automatically infer and recommend invariants can thus be very beneficial. However, current invariant-suggesting tools, such as Daikon, suffer from high rates of false positives, in part because they only leverage traced program values from available test cases, rather than directly exploiting knowledge of the source code per se. We propose a machine-learning approach to judging the validity of invariants, specifically of method pre- and post-conditions, based directly on a method's source code. We introduce a new, scalable approach to creating labeled invariants: using programs with large test-suites, we generate Daikon invariants using traces from subsets of these test-suites, and then label these as valid/invalid by cross-validating them with held-out tests. This process induces a large set of labels that provide a form of noisy supervision, which is then used to train a deep neural model, based on gated graph neural networks. Our model learns to map the lexical, syntactic, and semantic structure of a given method's body into a probability that a candidate pre- or post-condition on that method's body is correct and is able to accurately label invariants based on the noisy signal, even in cross-project settings. Most importantly, it performs well on a hand-curated dataset of invariants.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。