KNOD: Domain Knowledge Distilled Tree Decoder for Automated Program Repair

Automated Program Repair (APR) improves software reliability by generating patches for a buggy program automatically. Recent APR techniques leverage deep learning (DL) to build models to learn to generate patches from existing patches and code corpora. While promising, DL-based APR techniques suffer from the abundant syntactically or semantically incorrect patches in the patch space. These patches often disobey the syntactic and semantic domain knowledge of source code and thus cannot be the correct patches to fix a bug. We propose a DL-based APR approach KNOD, which incorporates domain knowledge to guide patch generation in a direct and comprehensive way. KNOD has two major novelties, including (1) a novel three-stage tree decoder, which directly generates Abstract Syntax Trees of patched code according to the inherent tree structure, and (2) a novel domain-rule distillation, which leverages syntactic and semantic rules and teacher-student distributions to explicitly inject the domain knowledge into the decoding procedure during both the training and inference phases. We evaluate KNOD on three widely-used benchmarks. KNOD fixes 72 bugs on the Defects4J v1.2, 25 bugs on the QuixBugs, and 50 bugs on the additional Defects4J v2.0 benchmarks, outperforming all existing APR tools.

[1]  Martin Monperrus,et al.  Neural Transfer Learning for Repairing Security Vulnerabilities in C Code , 2021, IEEE Transactions on Software Engineering.

[2]  Sida I. Wang,et al.  InCoder: A Generative Model for Code Infilling and Synthesis , 2022, ICLR.

[3]  Xiapu Luo,et al.  SelfAPR: Self-supervised Program Repair with Test Execution Diagnostics , 2022, ASE.

[4]  Monperrus Martin,et al.  Neural Program Repair with Execution-based Backpropagation , 2021, 2022 IEEE/ACM 44th International Conference on Software Engineering (ICSE).

[5]  Baishakhi Ray,et al.  CODIT: Code Editing With Tree-Based Neural Models , 2018, IEEE Transactions on Software Engineering.

[6]  S. Savarese,et al.  A Conversational Paradigm for Program Synthesis , 2022, ArXiv.

[7]  Yue Wang,et al.  CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation , 2021, EMNLP.

[8]  Wojciech Zaremba,et al.  Evaluating Large Language Models Trained on Code , 2021, ArXiv.

[9]  Lu Zhang,et al.  A syntax-guided edit decoder for neural program repair , 2021, ESEC/SIGSOFT FSE.

[10]  Neel Sundaresan,et al.  DeepDebug: Fixing Python Bugs Using Stack Traces, Backtranslation, and Code Skeletons , 2021, ArXiv.

[11]  Thibaud Lutellier,et al.  CURE: Code-Aware Neural Machine Translation for Automatic Program Repair , 2021, 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE).

[12]  Frank F. Xu,et al.  Learning Structural Edits via Incremental Tree Transformations , 2021, ICLR.

[13]  Denys Poshyvanyk,et al.  SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repair , 2018, IEEE Transactions on Software Engineering.

[14]  S. Sagar Imambi,et al.  PyTorch , 2021, Programming with TensorFlow.

[15]  Xavier Bresson,et al.  A Generalization of Transformer Networks to Graphs , 2020, ArXiv.

[16]  Yitong Li,et al.  CoCoNuT: combining context-aware neural translation models using ensemble for program repair , 2020, ISSTA.

[17]  Yongxin Yang,et al.  A Tree-Structured Decoder for Image-to-Markup Generation , 2020, ICML.

[18]  Shaohua Wang,et al.  DLFix: Context-based Code Transformation Learning for Automated Program Repair , 2020, 2020 IEEE/ACM 42nd International Conference on Software Engineering (ICSE).

[19]  Jacques Klein,et al.  On the Efficiency of Test Suite based Program Repair A Systematic Assessment of 16 Automated Repair Systems for Java Programs , 2020, 2020 IEEE/ACM 42nd International Conference on Software Engineering (ICSE).

[20]  Eran Yahav,et al.  A structural model for contextual code changes , 2020, Proc. ACM Program. Lang..

[21]  Le Song,et al.  Hoppity: Learning Graph Transformations to Detect and Fix Bugs in Programs , 2020, ICLR.

[22]  Ting Liu,et al.  CodeBERT: A Pre-Trained Model for Programming and Natural Languages , 2020, FINDINGS.

[23]  Lili Mou,et al.  TreeGen: A Tree-Based Transformer Architecture for Code Generation , 2019, AAAI.

[24]  Andrew Rice,et al.  Learning to Fix Build Errors with Graph2Diff Neural Networks , 2019, ICSE.

[25]  Wolfgang Banzhaf,et al.  ARJA: Automated Repair of Java Programs via Multi-Objective Genetic Programming , 2017, IEEE Transactions on Software Engineering.

[26]  Monperrus Martin Automatic Software Repair: a Bibliography , 2020 .

[27]  Claire Le Goues,et al.  Automated program repair , 2019, Commun. ACM.

[28]  Jaewoo Kang,et al.  Graph Transformer Networks , 2019, NeurIPS.

[29]  Seemanta Saha,et al.  Harnessing Evolution for Multi-Hunk Program Repair , 2019, 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE).

[30]  Tegawendé F. Bissyandé,et al.  TBar: revisiting template-based automated program repair , 2019, ISSTA.

[31]  Gabriele Bavota,et al.  On Learning Meaningful Code Changes Via Neural Machine Translation , 2019, 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE).

[32]  Gabriele Bavota,et al.  An Empirical Study on Learning Bug-Fixing Patches in the Wild via Neural Machine Translation , 2018, ACM Trans. Softw. Eng. Methodol..

[33]  Graham Neubig,et al.  Learning to Represent Edits , 2018, ICLR.

[34]  Lingming Zhang,et al.  Practical program repair via bytecode mutation , 2018, ISSTA.

[35]  Graham Neubig,et al.  TRANX: A Transition-based Neural Abstract Syntax Parser for Semantic Parsing and Code Generation , 2018, EMNLP.

[36]  Graham Neubig,et al.  A Tree-based Decoder for Neural Machine Translation , 2018, EMNLP.

[37]  Hongyu Zhang,et al.  Shaping program repair space with existing patches and similar code , 2018, ISSTA.

[38]  Ming Wen,et al.  Context-Aware Patch Generation for Better Automated Program Repair , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE).

[39]  Matias Martinez,et al.  Ultra-Large Repair Search Space with Automatically Mined Templates: The Cardumen Mode of Astor , 2017, SSBSE.

[40]  Martin Monperrus,et al.  Nopol: Automatic Repair of Conditional Statement Bugs in Java Programs , 2018, IEEE Transactions on Software Engineering.

[41]  Hiroaki Yoshida,et al.  Elixir: Effective object-oriented program repair , 2017, 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE).

[42]  Armando Solar-Lezama,et al.  QuixBugs: a multi-lingual program repair benchmark set based on the quixey challenge , 2017, SPLASH.

[43]  Alexey Zhikhartsev,et al.  Better test cases for better automated program repair , 2017, ESEC/SIGSOFT FSE.

[44]  Lukasz Kaiser,et al.  Attention is All you Need , 2017, NIPS.

[45]  Yann Dauphin,et al.  Convolutional Sequence to Sequence Learning , 2017, ICML.

[46]  Dan Klein,et al.  Abstract Syntax Networks for Code Generation and Semantic Parsing , 2017, ACL.

[47]  Jiachen Zhang,et al.  Precise Condition Synthesis for Program Repair , 2016, 2017 IEEE/ACM 39th International Conference on Software Engineering (ICSE).

[48]  Geoffrey E. Hinton,et al.  Layer Normalization , 2016, ArXiv.

[49]  Wang Ling,et al.  Latent Predictor Networks for Code Generation , 2016, ACL.

[50]  Eric P. Xing,et al.  Harnessing Deep Neural Networks with Logic Rules , 2016, ACL.

[51]  Mirella Lapata,et al.  Language to Logical Form with Neural Attention , 2016, ACL.

[52]  Navdeep Jaitly,et al.  Pointer Networks , 2015, NIPS.

[53]  Quoc V. Le,et al.  Sequence to Sequence Learning with Neural Networks , 2014, NIPS.

[54]  Michael D. Ernst,et al.  Defects4J: a database of existing faults to enable controlled testing studies for Java programs , 2014, ISSTA 2014.

[55]  Lior Rokach,et al.  Ensemble-based classifiers , 2010, Artificial Intelligence Review.

[56]  A.J.C. van Gemund,et al.  On the Accuracy of Spectrum-based Fault Localization , 2007, Testing: Academic and Industrial Conference Practice and Research Techniques - MUTATION (TAICPART-MUTATION 2007).

[57]  R. Polikar,et al.  Ensemble based systems in decision making , 2006, IEEE Circuits and Systems Magazine.

[58]  Thomas D. LaToza,et al.  Maintaining mental models: a study of developer work habits , 2006, ICSE.

[59]  Dianne P. O'Leary,et al.  The mathematics of information coding, extraction, and distribution , 1999 .

[60]  Huaiyu Zhu On Information and Sufficiency , 1997 .