We introduce a novel approach to the automated termination analysis of computer programs: we train neural networks to act as ranking functions. Ranking functions map program states to values that are bounded from below and decrease as the program runs. The existence of a valid ranking function proves that the program terminates. While in the past ranking functions were usually constructed using static analysis, our method learns them from sampled executions. We train a neural network so that its output decreases along execution traces as a ranking function would; then, we use formal reasoning to verify whether it generalises to all possible executions. We present a custom loss function for learning lexicographic ranking functions and use satisfiability modulo theories for verification. Thanks to the ability of neural networks to generalise well, our method succeeds over a wide variety of programs. This includes programs that use data structures from standard libraries. We built a prototype analyser for Java bytecode and show the efficacy of our method over a standard dataset of benchmarks.
翻译:我们引入了计算机程序自动终止分析的新办法: 我们训练神经网络, 以作为排序函数。 排序功能映射程序显示从下到下不等的值, 并随着程序运行而减少。 有效的排序功能的存在证明程序终止。 虽然在过去的排名函数通常使用静态分析来构建, 我们的方法从抽样处决中学习这些功能。 我们训练了一个神经网络, 以便其输出随着执行痕迹的排序功能而减少; 然后, 我们用正式的推理来验证它是否概括了所有可能的处决。 我们为学习词汇排序函数提供了一种自定义损失函数, 并使用可比较性模版理论进行校验。 由于神经网络有能力进行概括, 我们的方法在各种各样的程序上成功。 这包括使用标准图书馆的数据结构的程序。 我们为爪哇建立了原型分析器, 并展示了我们方法在标准数据集上的效率 。