The functional properties of a program are often specified by providing a contract for each of its functions. A contract of a function consists of a pair of formulas, called a precondition and a postcondition, which, respectively, should hold before and after execution of that function. It might be the case that the contracts supplied by the programmer are not adequate to allow a verification system to prove program correctness, that is, to show that for every function, if the precondition holds and the execution of the function terminates, then the postcondition holds. We address this problem by providing a technique which may strengthen the postconditions of the functions, thereby improving the ability of the verifier to show program correctness. Our technique consists of four steps. First, the translation of the given program, which may manipulate algebraic data structures (ADTs), and its contracts into a set of constrained Horn clauses (CHCs) whose satisfiability implies the validity of the given contracts. Then, the derivation, via CHC transformation performed by the VeriCaT tool, of a new set of CHCs that manipulate only basic sorts (such as booleans or integers) and whose satisfiability implies the satisfiability of the original set of clauses. Then, the construction of a model, if any, of the new, derived CHCs using the CHC solver SPACER for basic sorts. Finally, the translation of that model into the formulas that suitably strengthen the postconditions of the given contracts. We will present our technique through an example consisting of a Scala program for reversing lists. Note that the Stainless verifier is not able to prove the correctness of that program when considering the given contracts, while it succeeds when considering the contracts with the strengthened postconditions constructed by applying our technique.
翻译:一个程序的功能属性通常通过为其每一项功能提供合同来指定。一个函数的合同通常由一对公式组成,称为先决条件和后期条件,这些公式在执行该功能之前和之后应分别保留。程序员提供的合同可能不足以使一个核查系统证明程序正确性,也就是说,表明每个功能的功能,如果先决条件存在并且函数的履行存在,那么后期条件将保持。我们通过提供一种技术来解决这个问题,这种技术可以加强功能的后期条件,从而提高校验者显示程序正确性的能力。我们的技术由四个步骤组成。首先,将特定程序(可能操纵代数数据结构(ADTs)及其合同转换成一套约束性 Horn条款(CHCs),其可视性意味着给定合同的有效性。然后,通过由VericC的变现变现工具(例如使用Booleans)或变现后期程序(如果Sqlifilable性),则通过我们目前变现的变现性合同的变现性模型(如果Sterlifility)的变现,则会显示我们的变现性规则的变现性规则,当我们的变现为S&liflical 的变现性规则的变现性规则,当我们的变现的变现性规则的变现,而变现为变现的变现的变现性规则的变现到的变现的变现的变现程序将意味着我们的变的变的变的变的变的变的变的变的变的变的变的变的变的变的变的变的变现性方案,如果变现性能性)) 。