ABSTRACT
In this paper we describe the formal verification of refactorings for untyped and typed lambda-calculi. This verification is performed in the proof assistant Isabelle/HOL.
Refactorings are program transformations applied to improve the design of source code. Well-structured source code is easier and cheaper to maintain, and this motivates the use of refactoring. These transformations have been implemented as programmer tools and, as with other metaprogramming tools, it is desirable that implementations of refactorings are correct. For a refactoring to be correct the refactored program must be identical in behaviour to the original program.
Since refactorings are source-to-source transformations, concrete program information matters: for example, names (of variables, procedures, etc) and program layout should also be preserved by refactoring. This is a particular characteristic of refactorings since general program transformations operate over machine representations of programs, rather than readable source code.
The paper describes the formalisation adopted, and the alternatives explored. It also reflects on some of the difficulties of performing such formalisations, the interaction between refactoring and phases such as type-checking and parsing, and the generation of correctimplementations from mechanised proofs.
- Z. M. Ariola and S. Blom. Lambda Calculi Plus Letrec. Vrije Universiteit, Faculteit der Wiskunde en Informatica, 1997.Google Scholar
- HP Barendregt. The Lambda Calculus, its Syntax and Semantics. North-Holland, 1984.Google Scholar
- S. Berghofer and C. Urban. A Head-to-Head Comparison of de Bruijn Indices and Names. Electronic Notes in Theoretical Computer Science, 174(5):53--67, 2007. Google ScholarDigital Library
- S. Blazy, Z. Dargaye, and X. Leroy. Formal Verification of a C Compiler Front-end. Symp. on Formal Methods, pages 460--475, 2006. Google ScholarDigital Library
- M. L. Cornélio. Refactorings as Formal Refinements. PhD thesis, Universidade Federal de Pernambuco, 2004.Google Scholar
- N. G. de Bruijn. Lambda-calculus notation with nameless dummies: a tool for automatic formula manipulation with application to the Church-Rosser theorem. Indag. Math, 34(5):381--392, 1972.Google ScholarCross Ref
- Ran Ettinger. Refactoring via Program Slicing and Sliding. PhD thesis, Oxford University Computing Laboratory, June 2007.Google Scholar
- A. Garrido. Program Refactoring in the Presence of Preprocessor Directives. PhD thesis, University of Illinois at Urbana-Champaign, 2005. Google ScholarDigital Library
- A. Garrido and J. Meseguer. Formal Specification and Verification of Java Refactorings. Proceedings of the Sixth IEEE International Workshop on Source Code Analysis and Manipulation (SCAM'06)-Volume 00, pages 165--174, 2006. Google ScholarDigital Library
- S. Glesner, J. Leitner, and J. O. Blech. Coinductive Verification of Program Optimizations Using Similarity Relations. Electronic Notes in Theoretical Computer Science, 176(3):61--77, 2007. Google ScholarDigital Library
- M. J. C. Gordon and T. F. Melham. Introduction to HOL: a theorem proving environment for higher order logic. Cambridge University Press New York, NY, USA, 1993. Google ScholarDigital Library
- W. G. Griswold. Program Restructuring as an Aid to Software Maintenance. PhD thesis, University of Washington, 1991. Google ScholarDigital Library
- S. P. Jones et al. Haskell 98 language and libraries. Cambridge University Press, 2003.Google Scholar
- A. C. Junior, L. Silva, and M. Cornélio. Using CafeOBJ to Mechanise Refactoring Proofs and Application. Electronic Notes in Theoretical Computer Science, 184:39--61, 2007. Google ScholarDigital Library
- X. Leroy. Formal certification of a compiler back-end or: programming a compiler with a proof assistant. ACM SIGPLAN Notices, 41(1):42--54, 2006. Google ScholarDigital Library
- Huiqing Li. Refactoring Haskell Programs. PhD thesis, Computing Laboratory, University of Kent, September 2006.Google Scholar
- Huiqing Li and Simon Thompson. Tool support for refactoring functional programs. In ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, January 2008. Google ScholarDigital Library
- Huiqing Li, Simon Thompson, László Lövei, Zoltán Horváth, Tamás Kozsik, Anikó Vig, and Tamás Nagy. Refactoring erlang programs. In The Proceedings of 12th International Erlang/OTP User Conference, Stockholm, Sweden, November 2006.Google Scholar
- Y. Minamide and K. Okuma. Verifying CPS transformations in Isabelle/HOL. In Proceedings of the 2003 ACM SIGPLAN workshop on Mechanized reasoning about languages with variable binding., pages 1--8. ACM Press, 2003. Google ScholarDigital Library
- Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. Isabelle/HOL: A Proof Assistant for Higher--Order Logic, volume 2283 of LNCS. Springer, 2002. Google ScholarDigital Library
- Michael Norrish. C formalised in HOL. PhD thesis, Computer Laboratory, University of Cambridge, 1998.Google Scholar
- G. D. Plotkin. LCF considered as a programming language. Theoretical Computer Science, 5(3):223--255, 1977.Google ScholarCross Ref
- D. B. Roberts. Practical Analysis for Refactoring. PhD thesis, University of Illinois at Urbana-Champaign, 1999. Google ScholarDigital Library
- Peter Sewell, Francesco Zappa Nardelli, Scott Owens, Gilles Peskine, Thomas Ridge, Susmit Sarkar, and Rok Strniša. Ott: Effective Tool Support for the Working Semanticist. 2007. To appear. Google ScholarDigital Library
- Nik Sultana. Verification of refactorings in Isabelle/HOL. Master's thesis, University of Kent, 2007.Google Scholar
- C. Urban and C. Tasson. Nominal techniques in Isabelle/HOL. CADE-20, 3632, 2005. Google ScholarDigital Library
- M. M. Wenzel. Isabelle, Isar-a Versatile Environment for Human Readable Formal Proof Documents. PhD thesis, Technische Universität Munchen, 2002.Google Scholar
Index Terms
- Mechanical verification of refactorings
Recommendations
Deriving refactorings for aspectJ
OOPSLA '04: Companion to the 19th annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applicationsIn this paper we present aspect-oriented programming laws that are useful for deriving refactorings for AspectJ. The laws help developers to verify if the transformations they define preserve behavior. We illustrate that by deriving several AspectJ ...
Static composition of refactorings
Special issue on program transformationThe number of possible refactorings is unlimited, so no tool vendor will ever be able to provide custom refactorings for all specific user needs. Therefore, we propose a new kind of refactoring tools, which allow users to create, edit and compose ...
Deriving refactorings for AspectJ
AOSD '05: Proceedings of the 4th international conference on Aspect-oriented software developmentIn this paper we present aspect-oriented programming laws that are useful for deriving refactorings for AspectJ. The laws help developers to verify if the transformations they define preserve behaviour. We illustrate that by deriving several AspectJ ...
Comments