Table of Contents
Fetching ...

Beyond Cons: Purely Relational Data Structures

Rafaello Sanna, William E. Byrd, Nada Amin

TL;DR

The paper addresses the limitations of relational programming when dealing with abstract data like sets and association lists by introducing Kanren, an extension of miniKanren that adds first-class set objects, a complete set of set constraints, and association-list constraints. By adapting CLP(SET) concepts to miniKanren and building atop a modern constraint-enabled core, Kanren enables extensional equality, lazy constraint solving, and finite failure for relational programs, notably interpreters. The authors present concrete data-structures (set objects), a suite of constraints (!ino, disjo, uniono, subseto, etc.), and association-list constraints (listo, freeo, lookupo), along with case studies in programming-language semantics, relational environments, graph reasoning, and metaKanren integration. The work improves expressiveness and search behavior in relational programming and demonstrates practical benefits for interpreters and synthesis tasks, with a roadmap for future performance and extensibility improvements.

Abstract

We present {Kanren} (read: set-Kanren), an extension to miniKanren with constraints for reasoning about sets and association lists. {Kanren} includes first-class set objects, a functionally complete family of set-theoretic constraints (including membership, union, and disjointedness), and new constraints for reasoning about association lists with shadowing and scoped lookup. These additions allow programmers to describe collections declaratively and lazily, without relying on structural encodings and eager search over representation spaces. The result is improved expressiveness and operational behavior in programs that manipulate abstract data -- particularly interpreters -- by supporting set equality based on contents, enabling finite failure. We describe the design and implementation of {Kanren} in a constraint-enabled miniKanren system and illustrate its use in representative examples.

Beyond Cons: Purely Relational Data Structures

TL;DR

The paper addresses the limitations of relational programming when dealing with abstract data like sets and association lists by introducing Kanren, an extension of miniKanren that adds first-class set objects, a complete set of set constraints, and association-list constraints. By adapting CLP(SET) concepts to miniKanren and building atop a modern constraint-enabled core, Kanren enables extensional equality, lazy constraint solving, and finite failure for relational programs, notably interpreters. The authors present concrete data-structures (set objects), a suite of constraints (!ino, disjo, uniono, subseto, etc.), and association-list constraints (listo, freeo, lookupo), along with case studies in programming-language semantics, relational environments, graph reasoning, and metaKanren integration. The work improves expressiveness and search behavior in relational programming and demonstrates practical benefits for interpreters and synthesis tasks, with a roadmap for future performance and extensibility improvements.

Abstract

We present {Kanren} (read: set-Kanren), an extension to miniKanren with constraints for reasoning about sets and association lists. {Kanren} includes first-class set objects, a functionally complete family of set-theoretic constraints (including membership, union, and disjointedness), and new constraints for reasoning about association lists with shadowing and scoped lookup. These additions allow programmers to describe collections declaratively and lazily, without relying on structural encodings and eager search over representation spaces. The result is improved expressiveness and operational behavior in programs that manipulate abstract data -- particularly interpreters -- by supporting set equality based on contents, enabling finite failure. We describe the design and implementation of {Kanren} in a constraint-enabled miniKanren system and illustrate its use in representative examples.

Paper Structure

This paper contains 13 sections, 5 figures, 3 tables.

Figures (5)

  • Figure 1: An intensional definition of -calculus terms, written in both prose and in miniKanren
  • Figure 2: An extensional definition of the free variables in a -calculus term, written in both prose and miniKanren
  • Figure 3: An example implementation of set operations as lists
  • Figure 4: The core of the interpreter from byrdMiniKanrenLiveAndUntagged
  • Figure 5: The association list operations implemented in terms of primitive recursion and search