English

Transformers for Program Termination

Programming Languages 2026-04-02 v1 Machine Learning

Abstract

Determining whether a program terminates is a core challenge in program analysis with direct implications for correctness, verification, and security. We investigate whether transformer architectures can recognise termination patterns directly from source code and how their strengths can be amplified through ensembles. To overcome the extreme scarcity of non-terminating examples, we design an ensemble framework of compact transformer encoders, systematically trained with a suite of imbalance-aware loss functions and class-aware sampling techniques. By combining models trained with distinct loss functions, our ensembles achieve substantially stronger performance than any single transformer, outperforming both powerful off-the-shelf LLMs and graph-based methods. Finally, we introduce an attribution pipeline that produces syntax-aware explanations for the termination estimation.

Keywords

Cite

@article{arxiv.2604.00039,
  title  = {Transformers for Program Termination},
  author = {Yoav Alon and Cristina David},
  journal= {arXiv preprint arXiv:2604.00039},
  year   = {2026}
}

Comments

12 pages