Initial Algebra Semantics for Cyclic Sharing Tree Structures

Initial Algebra Semantics for Cyclic Sharing Tree Structures

Terms are a concise representation of tree structures. Since they can be naturally defined by an inductive type, they offer data structures in functional programming and mechanised reasoning with useful principles such as structural induction and structural recursion. However, for graphs or “tree-like” structures - trees involving cycles and sharing - it remains unclear what kind of inductive structures exists and how we can faithfully assign a term representation of them. In this paper we propose a simple term syntax for cyclic sharing structures that admits structural induction and recursion principles. We show that the obtained syntax is directly usable in the functional language Haskell and the proof assistant Agda, as well as ordinary data structures such as lists and trees. To achieve this goal, we use a categorical approach to initial algebra semantics in a presheaf category. That approach follows the line of Fiore, Plotkin and Turi’s models of abstract syntax with variable binding.


💡 Research Summary

The paper tackles the long‑standing problem of giving an inductive, term‑based representation to graph‑like structures that contain cycles and sharing, which are otherwise difficult to model with conventional algebraic data types. The authors adopt a categorical framework based on initial algebras in a presheaf category, extending the Fiore‑Plotkin‑Turi approach that was originally designed for abstract syntax with variable binding.

First, they introduce the notion of an “address” – a finite list of natural numbers that records the path from the root to a node. Addresses serve as the objects of the underlying context category. Within each context, a term can be built from three constructors: (1) a leaf carrying a value, (2) a node that aggregates a finite list of sub‑terms, and (3) a pointer (ptr) that refers to an already existing address in the current context. The crucial well‑formedness condition requires that a pointer may only refer to a strictly shorter address, guaranteeing that cycles are finite and that the term syntax remains inductively generated.

Using these constructors the authors define a Σ‑functor on the presheaf category: for a presheaf X, ΣX maps a context C to the disjoint union of leaf, node, and pointer forms built from X(C). The initial Σ‑algebra μΣ exists because the presheaf category is locally finitely presentable, and μΣ inherits the usual universal property: for any other Σ‑algebra there is a unique homomorphism from μΣ. This universal morphism yields a generic “fold” (structural recursion) and its dual “unfold” (corecursion), thereby providing the desired structural induction and recursion principles for cyclic sharing structures.

The authors demonstrate that the theory is not merely abstract. In Haskell they encode the syntax with GADTs and type families, obtaining a datatype:

data Tree a where
  Leaf :: a -> Tree a
  Node ::