A language-independent proof system for full program equivalence

Two programs are fully equivalent if, for the same input, either they both diverge or they both terminate with the same result. Full equivalence is an adequate notion of equivalence for programs written in deterministic languages. It is useful in many contexts, such as capturing the correctness of program transformations within the same language, or capturing the correctness of compilers between two different languages. In this paper we introduce a language-independent proof system for full equivalence, which is parametric in the operational semantics of two languages and in a state-similarity relation. The proof system is sound: a proof tree establishes the full equivalence of the programs given to it as input. We illustrate it on two programs in two different languages (an imperative one and a functional one), that both compute the Collatz sequence. The Collatz sequence is an interesting case study since it is not known whether the sequence terminates or not; nevertheless, our proof system shows that the two programs are fully equivalent (even if we cannot establish termination or divergence of either one).

[1]  Moshe Y. Vardi,et al.  Formal Verification of Backward Compatibility of Microcode , 2005, CAV.

[2]  Sorin Lerner,et al.  Proving optimizations correct using parameterized program equivalence , 2009, PLDI '09.

[3]  Claudia Elena Chirita,et al.  An Institutional Foundation for the K Semantic Framework , 2014, WADT.

[4]  Chung-Kil Hur,et al.  A Logical Step Forward in Parametric Bisimulations , 2014 .

[5]  Nick Benton,et al.  Simple relational correctness proofs for static analyses and program transformations , 2004, POPL.

[6]  Grigore Rosu Matching Logic - Extended Abstract (Invited Talk) , 2015, RTA.

[7]  John C. Mitchell,et al.  Representation independence and data abstraction , 1986, POPL '86.

[8]  Davide Sangiorgi,et al.  Environmental Bisimulations for Higher-Order Languages , 2007, 22nd Annual IEEE Symposium on Logic in Computer Science (LICS 2007).

[9]  John C. Reynolds,et al.  Separation logic: a logic for shared mutable data structures , 2002, Proceedings 17th Annual IEEE Symposium on Logic in Computer Science.

[10]  Chucky Ellison,et al.  Matching Logic: An Alternative to Hoare/Floyd Logic , 2010, AMAST.

[11]  Derek Dreyer,et al.  State-dependent representation independence , 2009, POPL '09.

[12]  Ofer Strichman,et al.  Regression Verification: Proving the Equivalence of Similar Programs , 2009, CAV.

[13]  Grigore Rosu,et al.  K-Java , 2015, POPL.

[14]  Richard K. Guy,et al.  Don't Try to Solve These Problems! , 1983 .

[15]  Grigore Roşu,et al.  Equality of streams is a Π02-complete problem , 2006, ICFP 2006.

[16]  Chung-Kil Hur,et al.  A kripke logical relation between ML and assembly , 2011, POPL '11.

[17]  Andrei Arusoaie,et al.  A Generic Framework for Symbolic Execution:Theory and Applications : Theory and Applications. (Un cadre générique pour exécution symbolique / Un cadre générique pour exécution symbolique : Theorie et Applications) , 2015 .

[18]  Dorel Lucanu,et al.  Program equivalence by circular reasoning , 2013, Formal Aspects of Computing.

[19]  José Meseguer,et al.  A rewriting logic approach to operational semantics , 2009, Inf. Comput..

[20]  Chucky Ellison,et al.  An executable formal semantics of C with applications , 2011, POPL '12.

[21]  Luciano Lavagno,et al.  Electronic Design Automation for Integrated Circuits Handbook , 2006 .

[22]  José Meseguer,et al.  Rewriting Logic Semantics: From Language Specifications to Formal Analysis Tools , 2004, IJCAR.

[23]  Stefan Ciobaca,et al.  Reducing Partial Equivalence to Partial Correctness , 2014, 2014 16th International Symposium on Symbolic and Numeric Algorithms for Scientific Computing.

[24]  Grigore Rosu,et al.  One-Path Reachability Logic , 2013, 2013 28th Annual ACM/IEEE Symposium on Logic in Computer Science.

[25]  Grigore Rosu,et al.  Checking reachability using matching logic , 2012, OOPSLA '12.

[26]  Chung-Kil Hur,et al.  The marriage of bisimulations and Kripke logical relations , 2012, POPL '12.

[27]  Friederike Nickl,et al.  Pushouts of Order-Sorted Algebraic Specifications , 1996, AMAST.

[28]  Shuvendu K. Lahiri,et al.  SYMDIFF: A Language-Agnostic Semantic Diff Tool for Imperative Programs , 2012, CAV.

[29]  Grigore Rosu,et al.  A Theoretical Foundation for Programming Languages Aggregation , 2014, WADT.

[30]  Grigore Rosu,et al.  Towards a Unified Theory of Operational and Axiomatic Semantics , 2012, ICALP.

[31]  Robin Milner,et al.  Communication and concurrency , 1989, PHI Series in computer science.

[32]  Daejun Park,et al.  KJS: a complete formal semantics of JavaScript , 2015, PLDI.

[33]  D. Sangiorgi Introduction to Bisimulation and Coinduction , 2011 .

[34]  George C. Necula,et al.  Translation validation for an optimizing compiler , 2000, PLDI '00.

[35]  Grigore Rosu,et al.  A Language-Independent Proof System for Mutual Program Equivalence , 2014, ICFEM.

[36]  Grigore Rosu Equality of streams is a ∏ 2 0-complete problem , 2006 .

[37]  João Saraiva,et al.  Applied Semantics, International Summer School, APPSEM 2000, Caminha, Portugal, September 9-15, 2000, Advanced Lectures , 2000 .

[38]  Xavier Leroy,et al.  Formal verification of a realistic compiler , 2009, CACM.

[39]  Sagar Chaki,et al.  Regression verification for multi-threaded programs (with extensions to locks and dynamic thread creation) , 2012, Formal Methods in System Design.

[40]  Grigore Rosu,et al.  All-Path Reachability Logic , 2014, RTA-TLCA.

[41]  Chung-Kil Hur,et al.  Biorthogonality, step-indexing and compiler correctness , 2009, ICFP.

[42]  Yves Bertot,et al.  Interactive Theorem Proving and Program Development: Coq'Art The Calculus of Inductive Constructions , 2010 .

[43]  Grigore Rosu,et al.  Equality of streams is a Π0 over 2-complete problem , 2006, ICFP '06.

[44]  BentonNick Simple relational correctness proofs for static analyses and program transformations , 2004 .

[45]  Ofer Strichman,et al.  Regression verification: proving the equivalence of similar programs , 2013, Softw. Test. Verification Reliab..

[46]  Sorin Craciunescu,et al.  Recurrence with affine level mappings is P-time decidable for binary CLP ( R ) Technical note , 2006 .

[47]  Andrew M. Pitts,et al.  Operational Semantics and Program Equivalence , 2000, APPSEM.

[48]  Lauretta O. Osho,et al.  Axiomatic Basis for Computer Programming , 2013 .