Tail recursion transformation for invertible functions

Tail recursive functions allow for a wider range of optimisations than general recursive functions. For this reason, much research has gone into the transformation and optimisation of this family of functions, in particular those written in continuation passing style (CPS). Though the CPS transformation, capable of transforming any recursive function to an equivalent tail recursive one, is deeply problematic in the context of reversible programming (as it relies on troublesome features such as higher-order functions), we argue that relaxing (local) reversibility to (global) invertibility drastically improves the situation. On this basis, we present an algorithm for tail recursion conversion specifically for invertible functions. The key insight is that functions introduced by program transformations that preserve invertibility, need only be invertible in the context in which the functions subject of transformation calls them. We show how a bespoke data type, corresponding to such a context, can be used to transform invertible recursive functions into a pair of tail recursive function acting on this context, in a way where calls are highlighted, and from which a tail recursive inverse can be straightforwardly extracted.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
02/19/2021

Tail Modulo Cons

OCaml function calls consume space on the system stack. Operating system...
research
02/28/2022

Getting There and Back Again

"There and Back Again" (TABA) is a programming pattern where the recursi...
research
03/17/2022

A recursive function coding number theoretic functions

We show that there exists a fixed recursive function e such that for all...
research
07/28/2022

Regression verification of unbalanced recursive functions with multiple calls (long version)

Given two programs p_1 and p_2, typically two versions of the same progr...
research
02/18/2021

Interleaving classical and reversible

Given a simple recursive function, we show how to extract two interactin...
research
04/13/2020

A Simple Randomized O(n log n)–Time Closest-Pair Algorithm in Doubling Metrics

Consider a metric space (P,dist) with N points whose doubling dimension ...
research
07/15/2017

Memoisation: Purely, Left-recursively, and with (Continuation Passing) Style

Memoisation, or tabling, is a well-known technique that yields large imp...

Please sign up or login with your details

Forgot password? Click here to reset