🤖 AI Summary
This paper investigates whether higher-order references inherently cause non-termination, particularly in Landin’s Knot—a pattern traditionally assumed to be intrinsically divergent. We challenge the conventional view by showing that higher-order references alone are insufficient for non-termination; the root cause lies in unrestricted impredicative quantification within function environments.
Method: We employ closure conversion to explicitly expose environment structure and model recursion within an impredicative polymorphic type system. Building on this, we propose a principled restriction on environment quantification—without imposing linear types or other complex syntactic constraints.
Contribution/Results: Our approach safely supports both higher-order references and general recursion while guaranteeing termination. Experimental evaluation confirms effective prevention of non-terminating behavior, preserving strong normalization and expressive power. The result is a novel language design paradigm that reconciles reliability with flexibility in functional programming with mutable references.
📝 Abstract
In this work, we explore Landin's Knot, which is understood as a pattern for encoding general recursion, including non-termination, that is possible after adding higher-order references to an otherwise terminating language. We observe that this isn't always true -- higher-order references, by themselves, don't lead to non-termination. The key insight is that Landin's Knot relies not primarily on references storing functions, but on unrestricted quantification over a function's environment. We show this through a closure converted language, in which the function's environment is made explicit and hides the type of the environment through impredicative quantification. Once references are added, this impredicative quantification can be exploited to encode recursion. We conjecture that by restricting the quantification over the environment, higher-order references can be safely added to terminating languages, without resorting to more complex type systems such as linearity, and without restricting references from storing functions.