Abstract
The transformational programming method of algorithm derivation starts with a formal specification of the result to be achieved, plus some informal ideas as to what techniques will be used in the implementation. The formal specification is then transformed into an implementation, by means of correctness-preserving refinement and transformation steps, guided by the informal ideas. The transformation process will typically include the following stages: (1) Formal specification (2) Elaboration of the specification, (3) Divide and conquer to handle the general case (4) Recursion introduction, (5) Recursion removal, if an iterative solution is desired, (6) Optimisation, if required. At any stage in the process, sub-specifications can be extracted and transformed separately. The main difference between this approach and the invariant based programming approach (and similar stepwise refinement methods) is that loops can be introduced and manipulated while maintaining program correctness and with no need to derive loop invariants. Another difference is that at every stage in the process we are working with a correct program: there is never any need for a separate “verification” step. These factors help to ensure that the method is capable of scaling up to the development of large and complex software systems. The method is applied to the derivation of a complex linked list algorithm and produces code which is over twice as fast as the code written by Donald Knuth to solve the same problem.
Similar content being viewed by others
References
ISO JTC 1/SC 7 (2006) Software engineering—software life cycle processes—maintenance. ISO/IEC 14764:2006
Abrial J-R, Butler M, Hallerstede S, Voisin L (2006) An open extensible tool environment for Event-B. ICFEM, New York
Back R-J (2009) Invariant based programming: basic approach and teaching experiences. Form Asp Comput 21: 227–244
Bauer FL (1979) Program development by stepwise transformations—the project CIP. In: Goos G, Hartmanis H (eds) Program construction. Lecture Notes in Computer Science. #69, Springer, New York, pp 237–266
Bauer FL, Berghammer R et al, The CIP Language Group (1985) The Munich Project CIP. Volume I: the wide spectrum language CIP-L. Lecture Notes in Computer Science #183, Springer, New York
Bauer FL, Moller B, Partsch H, Pepper P (1989) Formal construction by transformation—computer aided intuition guided programming. IEEE Trans Softw Eng 15 #2
Bauer FL, The CIP System Group (1987) The Munich Project CIP, Volume II: the program transformation system CIP-S. Lecture Notes in Computer Science #292, Springer, New York
Bicarregui JC, Matthews BM (1999) Proof and refutation in formal software development. In: 3rd Irish workshop on formal software development
Bird R, de Moor O (1996) The algebra of programming. Prentice-Hall, Englewood Cliffs
Broy M (1984) Algebraic methods for program construction: the project CIP. In: Pepper P (ed) Program transformation and programming environments report on a workshop directed by F. L. Bauer and H. Remus. Springer, New York, pp 199–222
Bundy A, Grov G, Lin Y (2011) Productive use of failure in top-down formal methods. In: Automated reasoning workshop ARW 2011, Glasgow, 11th–12th April
Burstall RM, Darlington JA (1977) A transformation system for developing recursive programs. J. Assoc. Comput. Mach. 24: 44–67
Butler M (2006) On the verified-by-construction approach. BCS FACS, Electronics & Computer Science EPrints Service, oai:eprints.soton.ac.uk:265110
Darlington J (1978) A synthesis of several sort programs. Acta Inform 11: 1–30
Dijkstra EW. A constructive approach to the problem of program correctness. Technische Hogeschool Eindhoven, EWD209. http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD209.PDF
Dijkstra EW (1976) A discipline of programming. Prentice-Hall, Englewood Cliffs
Dijkstra EW (1970) Notes on structured programming. Technische Hogeschool Eindhoven, EWD249. http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD249.PDF
Dijkstra EW (1972) The humble programmer. Commun. ACM 15: 859–866
Gries D (1981) The science of programming. Springer, New York
Hoare CAR, Hayes IJ, Jifeng HE, Morgan CC, Roscoe AW, Sanders JW, Sørensen IH, Spivey JM, Sufrin BA (1987) Laws of programming. Commun. ACM 30: 672–686
Jones CB, Jones KD, Lindsay PA, Moore R (1991) mural: A formal development support system. Springer, New York
Knuth DE (1974) Structured programming with the GOTO statement. Comput. Surv. 6: 261–301
Knuth DK (1968) Fundamental algorithms, the art of computer programming #1. Addison Wesley, Reading
Leiserson CE, Prokop H, Randall KH (1998) Using de Bruijn Sequences to Index a 1 in a Computer Word. CiteSeer. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.37.8562
Morgan CC (1994) Programming from specifications, 2nd edn. Prentice-Hall, Englewood Cliffs
Morgan CC, Robinson K, Gardiner P (1988) On the refinement calculus. Technical Monograph PRG-70. Oxford University, Oxford
Morgan CC, Vickers T (1993) On the refinement calculus. Springer, New York
Neilson M, Havelund K, Wagner KR, Saaman E (1989) The RAISE language, method and tools. Form Asp Comput 1: 85–114
Priestley HA, Ward M (1994) A multipurpose backtracking algorithm. J Symb Comput 18:1–40. http://www.cse.dmu.ac.uk/~mward/martin/papers/backtr-t.ps.gz doi:10.1006/jsco.1994.1035
Sennett CT (1990) Using refinement to convince: lessons learned from a case study. Refinement workshop, 8th–11th January, Hursley Park, Winchester
Tammet T (1995) Lambda lifting as an optimization for compiling Scheme to C. Chalmers University of Technology, Department of Computer Sciences, Goteborg, Sweden. ftp://ftp.cs.chalmers.se/pub/users/tammet/hobbit.ps
Thomas M (2003) The modest software engineer In: Sixth international symposium on autonomous decentralized systems, ISADS
Ward M (1989) Proving program refinements and transformations. Oxford University, DPhil Thesis. http://www.cse.dmu.ac.uk/~mward/martin/thesis
Ward M (1990) Derivation of a sorting algorithm. Durham University, Technical Report. http://www.cse.dmu.ac.uk/~mward/martin/papers/sorting-t.ps.gz
Ward M (1994) Reverse engineering through formal transformation knuths “polynomial addition” Algorithm Comput J 37:795–813. http://www.cse.dmu.ac.uk/~mward/martin/papers/poly-t.ps.gz. doi:10.1093/comjnl/37.9.795
Ward M (1996) Program analysis by formal transformation. Comput J 39. http://www.cse.dmu.ac.uk/~mward/martin/papers/topsort-t.ps.gz. doi:10.1093/comjnl/39.7.598
Ward M (1999) Recursion removal/introduction by formal transformation: an aid to program development and program comprehension. Comput J 42:650–673. http://www.cse.dmu.ac.uk/~mward/martin/papers/recursion-t.ps.gz. doi:10.1093/comjnl/42.8.650
Ward M (1999) Assembler to C migration using the FermaT transformation system. In: International conference on software maintenance, 30th Aug–3rd Sept 1999, Oxford, England
Ward M (1993) Abstracting a specification from code. J Softw Maint Res Pract 5:101–122. http://www.cse.dmu.ac.uk/~mward/martin/papers/prog-spec.ps.gz
Ward M (1996) Derivation of data intensive algorithms by formal transformation. IEEE Trans Softw Eng 22:665–686. http://www.cse.dmu.ac.uk/~mward/martin/papers/sw-alg.ps.gz, http://doi.ieeecomputersociety.org/10.1109/32.541437
Ward M (2001) The FermaT assembler re-engineering workbench. In: International conference on software maintenance (ICSM), 6th–9th November 2001, Florence, Italy
Ward M (2004) Pigs from sausages? Reengineering from assembler to C via FermaT transformations. Sci Comput Progr Spec Issue Progr Transform 52:213–255. http://www.cse.dmu.ac.uk/~mward/martin/papers/migration-t.ps.gz, http://dx.doi.org/10.1016/j.scico.2004.03.007
Ward M, Zedan H (2005) MetaWSL and meta-transformations in the FermaT transformation system. In: 29th Annual international computer software and applications conference, Edinburgh, UK, November 2005
Ward M, Zedan H (2007) Slicing as a program transformation. Trans Progr Lang Syst 29:1–52. http://www.cse.dmu.ac.uk/~mward/martin/papers/slicing-t.ps.gz, http://doi.acm.org/10.1145/1216374.1216375
Ward M, Zedan H (2010) Deriving a slicing algorithm via FermaT transformations. IEEE Trans Softw Eng IEEE Comput Soc Digit Libr. http://www.cse.dmu.ac.uk/~mward/martin/papers/derivation2-a4-t.pdf, http://doi.ieeecomputersociety.org/10.1109/TSE.2010.13
Ward M, Zedan H, Hardcastle T (2004) Legacy assembler reengineering and migration. In: 20th IEEE international conference on software maintenance, 11th–17th Sept, Chicago, Illinois, USA
Ward M, Zedan H, Ladkau M, Natelberg S (2008) Conditioned semantic slicing for abstraction; industrial experiment. Softw Pract Exp 38:1273–1304. http://www.cse.dmu.ac.uk/~mward/martin/papers/slicing-paper-final.pdf, http://doi.wiley.com/10.1002/spe.869
Wirth N (1971) Program development by stepwise refinement. Commun ACM 14: 221–227
Yang H, Ward M (2003) Successful evolution of software systems. Artech House, Boston, London. ISBN-10 1-58053-349-3. ISBN-13 978-1580533492
Zhang X, Munro M, Harman M, Hu L (2002) Mechanized operational semantics of WSL. In: IEEE international workshop on source code analysis and manipulation (SCAM), Los Alamitos, California, USA
Zhang X, Munro M, Harman M, Hu L (2002) Weakest precondition for general recursive programs formalized in coq. Lecture Notes in Computer Science. In: Proceedings of the 15th international conference on theorem proving in higher order logics (TPHOLs). Springer, New York
Author information
Authors and Affiliations
Corresponding author
Additional information
by J. Woodcock
Rights and permissions
About this article
Cite this article
Ward, M., Zedan, H. Provably correct derivation of algorithms using FermaT. Form Asp Comp 26, 993–1031 (2014). https://doi.org/10.1007/s00165-013-0287-2
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00165-013-0287-2