Invariants are the predominant approach to verify the correctness of loops. As an alternative, loop contracts, which make explicit the premise and conclusion of the underlying induction proof, can sometimes capture correctness conditions more naturally. But despite this advantage, the second approach receives little attention overall, and the goal of this paper is to lift it out of its niche. We give the first comprehensive exposition of the theory of loop contracts, including a characterization of its completeness. We show concrete examples on standard algorithms that showcase their relative merits. Moreover, we demonstrate a novel constructive translation between the two approaches, which decouples the chosen specification approach from the verification backend.
翻译:各种变数是核实循环的正确性的主要办法。作为一种替代办法,循环合同明确了基本上岗证明的前提和结论,有时可以更自然地捕捉正确性条件。但尽管有这一优势,第二种办法总体上很少受到重视,本文的目标是将其从位置上移走。我们首先全面阐述循环合同理论,包括对其完整性的定性。我们展示了展示其相对优点的标准算法的具体实例。此外,我们展示了两种办法之间新的建设性翻译,将所选规格方法与核查后端脱钩。