The Full Abstraction Problem for Higher Order Functional-Logic Programs
Developing suitable formal semantics can be of great help in the understanding, design and implementation of a programming language, and act as a guide for software development tools like analyzers or partial evaluators. In this sense, full abstraction is a highly desirable property, indicating a perfect correspondence between the semantics and the observable behavior of program pieces. In this work we address the question of full abstraction for the family of modern functional logic languages, in which functions can be higher order and non-deterministic, and where the semantics adopted for non-determinism is \emph{call-time choice}. We show that, with respect to natural notions of \emph{observation}, any semantics based on \emph{extensional} functions is necessarily unsound; in contrast, we show that the higher order version of \emph{CRWL}, a well-known existing semantic framework for functional logic programming, based on an \emph{intensional} view of functions, turns out to be fully abstract and compositional.
💡 Research Summary
The paper addresses the long‑standing question of whether full abstraction can be achieved for modern functional‑logic programming languages that support higher‑order functions and non‑determinism under the call‑time‑choice semantics. Full abstraction is defined as a perfect match between a program fragment’s denotational meaning and the observable behaviour of that fragment; in other words, the semantics must neither over‑approximate nor under‑approximate what can be observed during execution. This property is crucial not only for language design but also for the correctness of analysis and transformation tools such as static analyzers and partial evaluators.
The authors begin by reviewing the landscape of functional‑logic programming (FLP). Unlike pure functional languages, FLP integrates logical variables and non‑deterministic operations, thereby offering richer expressive power. The handling of non‑determinism is a central design decision. Two main approaches exist: call‑by‑need, where each occurrence of a non‑deterministic expression may be evaluated independently, and call‑time‑choice, where an argument is evaluated once and the resulting choice is shared across all its uses. Contemporary FLP languages adopt the latter because it guarantees a consistent sharing of choices, which is essential for reasoning about program equivalence.
The paper then distinguishes between extensional and intensional semantic models. Extensional semantics abstracts a function solely by its input‑output relation; two functions are considered equal if they map every argument to the same set of results, regardless of how those results are produced. Intensional semantics, by contrast, treats functions as first‑class entities that carry internal information, including the point at which a non‑deterministic choice is made. This distinction becomes critical when higher‑order functions are passed as arguments, because the timing of the choice can affect observable outcomes under call‑time‑choice.
The core technical contribution is a negative result: any semantics that is purely extensional cannot be fully abstract for FLP with call‑time‑choice. The authors construct a concrete counter‑example involving two higher‑order functions, f and g, that have identical extensional behaviour (they produce the same set of results for each input) but differ in the moment they resolve a non‑deterministic choice. Under call‑time‑choice, the earlier resolution in f leads to a different sharing pattern than the later resolution in g, and this difference is observable through the language’s standard observation predicates (e.g., existence of a normal form, the set of possible results). Because an extensional model collapses f and g into the same denotation, it fails to distinguish these observable differences, violating soundness and thus full abstraction.
In contrast, the paper shows that the higher‑order version of CRWL (Constructive ReWriting Logic) satisfies both full abstraction and compositionality. CRWL models programs as sets of rewrite rules and explicitly represents non‑deterministic choices as a choice operator. Functions are treated as intensional objects; when a higher‑order function is applied, the call‑time‑choice rule is enforced by fixing the choice at the moment of argument evaluation and propagating it unchanged through subsequent calls. The authors prove two main theorems: (1) the CRWL denotation precisely captures the observable behaviours defined by the language’s natural observation predicates, and (2) the denotation is compositional, meaning the meaning of a whole program can be derived from the meanings of its sub‑programs without loss of information. This compositionality is essential for modular reasoning and for building scalable analysis tools.
The practical implications are discussed in depth. Tools built on an extensional semantics may incorrectly optimise or transform programs because they ignore the timing of non‑deterministic choices, potentially leading to unsound transformations or missed optimisation opportunities. In contrast, CRWL‑based tools retain the choice information, enabling safe partial evaluation, precise dead‑code elimination, and accurate static analysis. The paper illustrates how a partial evaluator that respects call‑time‑choice can avoid redundant evaluations by caching the result of a choice once it is made, thereby preserving both correctness and efficiency.
Finally, the authors outline several avenues for future research. They suggest comparing CRWL with other intensional frameworks such as monadic or effect‑system based semantics, investigating implementation techniques to improve the runtime performance of CRWL (e.g., choice caching, rule indexing), and extending the full‑abstraction results to broader settings like parallel FLP or probabilistic extensions. By establishing that an intensional, CRWL‑based semantics is both fully abstract and compositional, the paper provides a solid theoretical foundation for the next generation of reliable, high‑performance functional‑logic language tools.
Comments & Academic Discussion
Loading comments...
Leave a Comment