Contract-based Slicing Daniela da Cruz, Pedro Rangel Henriques and Jorge Sousa Pinto {danieladacruz,prh,jsp}@di.uminho.pt Departamento de Inform´atica / CCTC Universidade do Minho, 4710-057 Braga, Portugal Abstract. In the last years, the concern with the correctness of pro- grams has been leading programmers to enrich their programs with an- notations following the principles of design-by-contract, in order to be able to guarantee their correct behaviour and to facilitate reuse of veri- fied components without having to reconstruct proofs of correctness. In this paper we adapt the idea of specification-based slicing to the scope of (contract-based) program verification systems and behaviour specifi- cation languages. In this direction, we introduce the notion of contract- based slice of a program and show how any specification-based slicing algorithm can be used as the basis for a contract-based slicing algorithm. 1 Introduction Program slicing plays an important role in program comprehension, enabling engineers to focus on just a relevant part (with respect to a given criterion) of a program. After Weiser’s pioneering work [13], many researchers have searched for more effective or more powerful slicing techniques; since then, many application areas have been identified, including program debugging, software maintenance, software reuse, and so on. See [14] for a fairly recent survey of the area. Many studies have proposed the use of slicing for software testing. In the context of complex applications, which are by their very nature, size and archi- tecture difficult to comprehend and test, slicing may be an invaluable help when a certification process has to be carried out. On the other hand a strong demand for formal methods that help program- mers developing correct programs has been present in software engineering for some time now. The Design by Contract (DbC) approach to software develop- ment [12] facilitates modular verification and certified code reuse, and has be- come a standard approach to the design of architecturally complex systems. The contract for a component (a procedure) can be regarded as a form of enriched software documentation that fully specifies the behavior of that component. The development and broad adoption of annotation languages for the most popular programming languages reinforces the importance of using DbC princi- ples in the development of programs. These include for instance the Java Mod- eling Language (JML) [4]; Spec# [2], a formal language for C# API contracts, and the SPARK [1] subset of Ada.