Proving Properties of Sorting Programs: A Case Study in Horn Clause Verification

The proof of a program property can be reduced to the proof of satisfiability of a set of constrained Horn clauses (CHCs) which can be automatically generated from the program and the property. In this paper we have conducted a case study in Horn clause verification by considering several sorting programs with the aim of exploring the effectiveness of a transformation technique which allows us to eliminate inductive data structures such as lists or trees. If this technique is successful, we derive a set of CHCs with constraints over the integers and booleans only, and the satisfiability check can often be performed in an effective way by using state-of-the-art CHC solvers, such as Eldarica or Z3. In this case study we have also illustrated the usefulness of a companion technique based on the introduction of the so-called difference predicates, whose definitions correspond to lemmata required during the verification. We have considered functional programs which implement the following kinds of sorting algorithms acting on lists of integers: (i) linearly recursive sorting algorithms, such as insertion sort and selection sort, and (ii) non-linearly recursive sorting algorithms, such as quicksort and mergesort, and we have considered the following properties: (i) the partial correctness properties, that is, the orderedness of the output lists, and the equality of the input and output lists when viewed as multisets, and (ii) some arithmetic properties, such as the equality of the sum of the elements before and after sorting.

[1]  Damien Doligez,et al.  The OCaml system release 4.07: Documentation and user's manual , 2013 .

[2]  Alberto Pettorossi,et al.  Predicate Pairing for program verification , 2017, Theory and Practice of Logic Programming.

[3]  Sandro Etalle,et al.  Transformations of CLP Modules , 1996, Theor. Comput. Sci..

[4]  Alberto Pettorossi,et al.  VeriMAP: A Tool for Verifying Programs through Transformations , 2014, TACAS.

[5]  Hisao Tamaki,et al.  Unfold/Fold Transformation of Logic Programs , 1984, ICLP.

[6]  Hiroshi Unno,et al.  Automating Induction for Solving Horn Clauses , 2016, CAV.

[7]  Andrey Rybalchenko,et al.  Synthesizing software verifiers from proof rules , 2012, PLDI.

[8]  Alberto Pettorossi,et al.  Lemma Generation for Horn Clause Satisfiability: A Preliminary Study , 2019, VPT@Programming.

[9]  Alberto Pettorossi,et al.  Program verification via iterated specialization , 2014, Sci. Comput. Program..

[10]  Nikolaj Bjørner,et al.  Horn Clause Solvers for Program Verification , 2015, Fields of Logic and Computation II.

[11]  Viktor Kuncak,et al.  Induction for SMT Solvers , 2015, VMCAI.

[12]  Alberto Pettorossi,et al.  Semantics-based generation of verification conditions via program specialization , 2017, Sci. Comput. Program..

[13]  Grigory Fedyukovich,et al.  Solving Constrained Horn Clauses Using Syntax and Data , 2018, 2018 Formal Methods in Computer Aided Design (FMCAD).

[14]  Nikolaj Bjørner,et al.  Z3: An Efficient SMT Solver , 2008, TACAS.

[15]  Grigory Fedyukovich,et al.  Synchronizing Constrained Horn Clauses , 2017, LPAR.

[16]  John P. Gallagher,et al.  Rahft: A Tool for Verifying Horn Clauses Using Abstract Interpretation and Finite Tree Automata , 2016, CAV.

[17]  Philipp Rümmer,et al.  The ELDARICA Horn Solver , 2018, 2018 Formal Methods in Computer Aided Design (FMCAD).

[18]  Alan Bundy,et al.  The Automation of Proof by Mathematical Induction , 1999, Handbook of Automated Reasoning.

[19]  Viktor Kuncak,et al.  A Verification Toolkit for Numerical Transition Systems - Tool Paper , 2012, FM.

[20]  Alberto Pettorossi,et al.  Solving Horn Clauses on Inductive Data Types Without Induction , 2018, Theory and Practice of Logic Programming.

[21]  Alberto Pettorossi,et al.  Proving correctness of imperative programs by linearizing constrained Horn clauses , 2015, Theory and Practice of Logic Programming.

[22]  Sagar Chaki,et al.  SMT-based model checking for recursive programs , 2014, Formal Methods in System Design.