English

While Loops in Coq

Programming Languages 2023-09-26 v1 Logic in Computer Science

Abstract

While loops are present in virtually all imperative programming languages. They are important both for practical reasons (performing a number of iterations not known in advance) and theoretical reasons (achieving Turing completeness). In this paper we propose an approach for incorporating while loops in an imperative language shallowly embedded in the Coq proof assistant. The main difficulty is that proving the termination of while loops is nontrivial, or impossible in the case of non-termination, whereas Coq only accepts programs endowed with termination proofs. Our solution is based on a new, general method for defining possibly non-terminating recursive functions in Coq. We illustrate the approach by proving termination and partial correctness of a program on linked lists.

Keywords

Cite

@article{arxiv.2309.13802,
  title  = {While Loops in Coq},
  author = {David Nowak and Vlad Rusu},
  journal= {arXiv preprint arXiv:2309.13802},
  year   = {2023}
}

Comments

In Proceedings FROM 2023, arXiv:2309.12959

R2 v1 2026-06-28T12:31:02.154Z