Learning to Infer Run-Time Invariants from Source Code
Abstract
Source code is meant to be executed, as well as read. Developers reason about its run-time properties by inferring invariants, which constrain program behavior; but they rarely encode these explicitly, so machine-learning methods don't have much aligned data to learn from. We propose an approach that adapts cues within existing if-statements regarding explicit run-time expectations to generate aligned datasets of code and implicit invariants. We also propose a contrastive loss to inhibit generation of illogical invariants. Our model learns to infer a wide vocabulary of invariants for arbitrary code, which can be used to detect and repair real bugs. This is complementary to trace-based methods, such as Daikon. Our results confirm that neural models can learn run-time expectations directly from code.
Cite
Text
Hellendoorn et al. "Learning to Infer Run-Time Invariants from Source Code." NeurIPS 2020 Workshops: CAP, 2020.Markdown
[Hellendoorn et al. "Learning to Infer Run-Time Invariants from Source Code." NeurIPS 2020 Workshops: CAP, 2020.](https://mlanthology.org/neuripsw/2020/hellendoorn2020neuripsw-learning/)BibTeX
@inproceedings{hellendoorn2020neuripsw-learning,
title = {{Learning to Infer Run-Time Invariants from Source Code}},
author = {Hellendoorn, Vincent Josua and Devanbu, Premkumar and Polozov, Alex and Marron, Mark},
booktitle = {NeurIPS 2020 Workshops: CAP},
year = {2020},
url = {https://mlanthology.org/neuripsw/2020/hellendoorn2020neuripsw-learning/}
}