This paper presents a study of the metaphorism pattern of relational specification, showing how it can be refined into recursive programs.Metaphorisms express input-output relationships which preserve relevant information while at the same time some intended optimization takes place. Text processing, sorting, representation changers, etc., are examples of metaphorisms.The kind of metaphorism refinement studied in this paper is a strategy known as change of virtual data structure. By framing metaphorisms in the class of (inductive) regular relations, sufficient conditions are given for such implementations to be calculated using relation algebra.The strategy is illustrated with examples including the derivation of the quicksort and mergesort algorithms, showing what they have in common and what makes them different from the very start of development.Keywords: Programming from specifications, Algebra of programming, Weakest precondition calculus.
Politicians and diapers should be changed often and for the same reason.(attributed to Mark Twain)
ContextThe witty quote by 19th century author Mark Twain that provided inspiration for the title of this paper embodies a metaphor which the reader will surely appreciate. But, what do metaphors of this kind have to do with computer programming?A synergy between metaphors in cognitive linguistics and some relational patterns common in the field of formal specification, termed metaphorisms, was suggested in our earlier conference paper [1], which the current paper extends by framing the approach into the study of the wider class of inductive regular