Swapping arguments and results of recursive functions

  • Authors:
  • Akimasa Morihata;Kazuhiko Kakehi;Zhenjiang Hu;Masato Takeichi

  • Affiliations:
  • Graduate School of Information Science and Technology, University of Tokyo, Japan;Division of University Corporate Relations, University of Tokyo, Tokyo, Japan;Graduate School of Information Science and Technology, University of Tokyo, Japan;Graduate School of Information Science and Technology, University of Tokyo, Japan

  • Venue:
  • MPC'06 Proceedings of the 8th international conference on Mathematics of Program Construction
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

Many useful calculation rules, such as fusion and tupling, rely on well-structured functions, especially in terms of inputs and outputs. For instance, fusion requires that well-produced outputs should be connected to well-consumed inputs, so that unnecessary intermediate data structures can be eliminated. These calculation rules generally fail to work unless functions are well-structured. In this paper, we propose a new calculation rule called IO swapping. IO swapping exchanges call-time computations (occurring in the arguments) and return-time computations (occurring in the results) of a function, while guaranteeing that the original and resulting function compute the same value. IO swapping enables us to rearrange inputs and outputs so that the existing calculation rules can be applied. We present new systematic derivations of efficient programs for detecting palindromes, and a method of higher-order removal that can be applied to defunctionalize function arguments, as two concrete applications.