## Recursion from Iteration (1994)

Venue: | Lisp and Symbolic Computation |

Citations: | 10 - 0 self |

### BibTeX

@INPROCEEDINGS{Filinski94recursionfrom,

author = {Andrzej Filinski},

title = {Recursion from Iteration},

booktitle = {Lisp and Symbolic Computation},

year = {1994},

pages = {11--38}

}

### Years of Citing Articles

### OpenURL

### Abstract

. In a simply-typed, call-by-value (CBV) language with first-class continuations, the usual CBV fixpoint operator can be defined in terms of a simple, infinitelylooping iteration primitive. We first consider a natural but flawed definition, based on exceptions and "iterative deepening" of finite unfoldings, and point out some of its shortcomings. Then we present the proper construction using full first-class continuations, with both an informal derivation and a proof that the behavior of the defined operator faithfully mimics a "built-in" recursion primitive. In fact, given an additional uniformity assumption, the construction is a two-sided inverse of the usual definition of iteration from recursion. Continuing, we show that the CBV looping primitive is in fact the direct-style equivalent of a continuation-passing-style fixpoint, and that this correspondence extends all the way to traditional definitions of these operators in terms of reflexive types. 1. Introduction 1.1. Background ...

### Citations

1618 | The Definition of Standard ML
- Milner, Tofte, et al.
- 1990
(Show Context)
Citation Context ...xceptions carrying functional values. In a language with no computational effects other than named exceptions, there is a simple correspondence between exception names (expressions of type exn in SML =-=[15]-=-) and functions of type 1!0, because such a function must essentially have the form (): raise X for some exception expression X. And then we need only to introduce an exception Psi carrying values of ... |

455 | Computational lambda-calculus and monads
- Moggi
- 1989
(Show Context)
Citation Context ...nal -calculus (a strict superset of Plotkin'ssv -calculus) is valid for CBV functional languages with a large variety of computational effects (state, nondeterminism, exceptions, continuations, etc.) =-=[16]-=-. The inherent modularity of the axiomatic approach makes feasible program-behavior theories of considerable scope and generality, e.g., [22]. Of particular interest to us are equational theories Th (... |

308 | Definitional interpreters for higher-order programming languages
- Reynolds
- 1972
(Show Context)
Citation Context ...be simulated using call=cc and set!. There are a number of essentially equivalent ways of introducing firstclass continuations in a functional language, all tracing back to Reynolds's escape-operator =-=[19]-=- (or, less directly, to Landin's J-operator [14]). In general, we need an operator C such that an expression CM invokes the proceduresM with a representation K of the evaluation context [6] surroundin... |

273 |
Semantics of Programming Languages: Structures and Techniques
- Gunter
- 1992
(Show Context)
Citation Context ...al to values). Both Plotkin's proof technique and others (e.g., taking advantage of typing to use logical relations) can be generalized to larger languages and different evaluation orders (see, e.g., =-=[10]-=- for examples and further references). In our proofs, we will be using Felleisen's extensions for modeling control operators. RECURSION FROM ITERATION 23 Since the language we are using is a proper su... |

267 | The revised report on the syntactic theories of sequential control and state
- FELLEISEN, HIEB
- 1989
(Show Context)
Citation Context ...lf-contained presentation not directly tied to category theory or symmetry considerations. This will allow us to draw directly upon the substantial body of existing results about continuations, e.g., =-=[4, 5, 9, 17]-=- for reasoning about the construction. An outline of the categorical approach is sketched in section 5. In many functional programming languages, it is actually possible to write recursive functions w... |

250 | A formulae-as-types notion of control
- Griffin
- 1990
(Show Context)
Citation Context ...official policies, either expressed or implied, of the U.S. Government. 12 FILINSKI terization of languages with first-class continuations [7] in terms of what could now be called "classically-ty=-=ped" [9]-=- categories. Specifically, one can interpret the difference between data-driven (or, call-by-value) and demand-driven (call-by-name) evaluation in such a language as an instance of a categorical symme... |

220 |
Call-by-name, call-by-value, and the *-calculus
- Plotkin
- 1975
(Show Context)
Citation Context ...lf-contained presentation not directly tied to category theory or symmetry considerations. This will allow us to draw directly upon the substantial body of existing results about continuations, e.g., =-=[4, 5, 9, 17]-=- for reasoning about the construction. An outline of the categorical approach is sketched in section 5. In many functional programming languages, it is actually possible to write recursive functions w... |

173 |
Introduction to Combinators and Calculus
- Hindley, Seldin
- 1986
(Show Context)
Citation Context ...erization of C will be given in section 3.1. 1.4. The problem A crucial property underlying the entire development presented here is that reduction in a simply-typed -calculus is strongly normalizing =-=[12]-=-, and in particular a CBV strategy is sufficient to reduce every closed term to a value. It can be proved (by CPS conversion back to the original case) that the latter property holds even if we extend... |

164 | Reasoning about programs in continuation-passing style
- Sabry, Felleisen
- 1993
(Show Context)
Citation Context ...age we are using is a proper subset of Felleisen's untyped one, we can directly use the equational reasoning principles developed for the latter. In particular, we have the following rules taken from =-=[5, 20]-=-, with the addition of (A uniq ), which captures the property noted above about 0. Further, this rule was used to replace two instances of A in Felleisen's original rules with the identity functions, ... |

158 |
editors. Revised report on the algorithmic language Scheme
- Kelsey, Clinger, et al.
- 1998
(Show Context)
Citation Context ... approach is sketched in section 5. In many functional programming languages, it is actually possible to write recursive functions without any "explicit" recursion. For example, the Scheme d=-=efinition [1]-=- expresses letrec in terms of set!. More fundamentally, the well-known Y-combinator provides a uniform way of introducing selfreference. However, a closer analysis shows that all such definitions rely... |

135 |
A correspondence between ALGOL 60 and Church’s lambda-notation: Part II
- Landin
- 1965
(Show Context)
Citation Context ... number of essentially equivalent ways of introducing firstclass continuations in a functional language, all tracing back to Reynolds's escape-operator [19] (or, less directly, to Landin's J-operator =-=[14]-=-). In general, we need an operator C such that an expression CM invokes the proceduresM with a representation K of the evaluation context [6] surrounding CM . If M ever invokes K with a value V , the ... |

133 |
Continuous lattices
- Scott
- 1972
(Show Context)
Citation Context ... left of an odd number of arrows) in the ��-expression. This is the hallmark of a "reflexive" definition, which requires us to go from set-theoretic models to domain-theoretic ones to fi=-=nd a solution [21]-=-. (In ML, we would use a parameterized datatype to define the recursive type sapp ff;fi : \Psi is the constructor; we get \Phi by pattern matching.) We can now write the Y-combinator as Y F = [s: a: F... |

95 | Typing First Class Continuations in ML
- Duba, Harper, et al.
- 1993
(Show Context)
Citation Context ...lf-contained presentation not directly tied to category theory or symmetry considerations. This will allow us to draw directly upon the substantial body of existing results about continuations, e.g., =-=[4, 5, 9, 17]-=- for reasoning about the construction. An outline of the categorical approach is sketched in section 5. In many functional programming languages, it is actually possible to write recursive functions w... |

82 | Filinski “Representing Control, a Study of the CPS Transformation
- Danvy, A
- 1992
(Show Context)
Citation Context ... an j v -redex x: t x before transformation. The CPS version of the iteration equation then becomes, after some administrative simplifications (which can actually be built into the translation itself =-=[2, 20]-=-): loop c 0 f c = a: f c (a 0 : loop c 0 f c a 0 ) a 2\Thetaj = f c (loop c 0 f c ) I.e, loop satisfies the CBV iteration equation precisely when loop c 0 is a fixpoint combinator (with type ((ff ! o)... |

59 |
Reasoning with continuations
- Felleisen, Friedman, et al.
- 1986
(Show Context)
Citation Context ...-operator [19] (or, less directly, to Landin's J-operator [14]). In general, we need an operator C such that an expression CM invokes the proceduresM with a representation K of the evaluation context =-=[6]-=- surrounding CM . If M ever invokes K with a value V , the then current context of evaluation is abandoned, and control returns to the context represented by K, as if CM had just returned V . For exam... |

52 | Lawall “Back to Direct Style II: First-Class Continuations
- Danvy, L
- 1992
(Show Context)
Citation Context ...n need control operators to recover fix from loop? The reason is that in fix c 0 , the continuations are permuted in an "illegal" way, so that the term does not have a C-free direct-style co=-=unterpart [3]. Another -=-way of seeing this is that the type of the "loop-to-fixpoint transformer", loop2fix = loop: FIX(loop) : [(ff \Theta :fi ! ff \Theta :fi) ! :(ff \Theta :fi)] ! [((ff ! fi) ! ff ! fi) ! ff ! f... |

41 | GEDANKEN - a simple typeless language based on the principle of completeness and the reference concept
- Reynolds
- 1970
(Show Context)
Citation Context ...n a simply-typed framework with explicit domain isomorphisms. This lets us analyze exactly what properties of our semantic domain we rely on to make the definition work. Consider the CBV Y-combinator =-=[18]: Y F = -=-[x: a:F (x x) a] [x: a: F (x x) a] This Y is untypable because x needs to have a type �� which is itself of the form �� ! \Delta \Delta \Delta. While we can clearly not get such an identity in... |

40 |
Declarative continuations: an investigation of duality in programming language semantics (lecture notes in computer science 389
- Filinski
- 1989
(Show Context)
Citation Context ...the author and should not be interpreted as representing the official policies, either expressed or implied, of the U.S. Government. 12 FILINSKI terization of languages with first-class continuations =-=[7] in terms -=-of what could now be called "classically-typed" [9] categories. Specifically, one can interpret the difference between data-driven (or, call-by-value) and demand-driven (call-by-name) evalua... |

36 | Polymorphic Type Assignment and CPS Conversion
- Harper, Lillibridge
- 1993
(Show Context)
Citation Context ... introduction would thus be written as: 2 + callcc(k: 3 + throw k 4) The details can be found in [4]; in the context of full ML, one must also worry about potential interactions with let-polymorphism =-=[11]. The main-=- pragmatic problem with this approach is that it is awkward to "prepend" an ordinary procedure f : ff ! fi to a continuation k : :fi and get a new continuation (k ffi f) : :ff. More generall... |

13 |
Theory of Program Structures
- Greibach
- 1975
(Show Context)
Citation Context ...ork A fair amount is known about transforming recursive programs into iterative form, the so-called "flowchartability" problem. Most such work has been done in an explicitly procedural setti=-=ng (e.g., [8]-=-), or for first-order recursion equations [23]. However, some extensions to higher-order call-byname functional programs are reported in [13]. Interestingly, the methods in the latter work rely heavil... |

10 |
H.R.: "Characterization of Flowchartable Recursions
- Walker, Strong
- 1972
(Show Context)
Citation Context ... recursive programs into iterative form, the so-called "flowchartability" problem. Most such work has been done in an explicitly procedural setting (e.g., [8]), or for first-order recursion =-=equations [23]-=-. However, some extensions to higher-order call-byname functional programs are reported in [13]. Interestingly, the methods in the latter work rely heavily on a notion of contexts, but the author appa... |

9 |
A theory for program and data type specification
- Talcott
- 1992
(Show Context)
Citation Context ...s (state, nondeterminism, exceptions, continuations, etc.) [16]. The inherent modularity of the axiomatic approach makes feasible program-behavior theories of considerable scope and generality, e.g., =-=[22]. Of particular-=- interest to us are equational theories Th (usually axiomatized as "core" of generic equations together with a set of ffi-like rules for the primitive operations) that are "evaluation-c... |

1 |
The Translation of Functional Programs into TailRecursive Form (Part I
- Kfoury
- 1987
(Show Context)
Citation Context ...rk has been done in an explicitly procedural setting (e.g., [8]), or for first-order recursion equations [23]. However, some extensions to higher-order call-byname functional programs are reported in =-=[13]-=-. Interestingly, the methods in the latter work rely heavily on a notion of contexts, but the author apparently never draws any connections to continuation-passing style, let alone first-class continu... |

1 | extended version to appear - Revised |