Title: A Functional Hitchhikers Guide to Hereditarily Finite Sets, Ackermann Encodings and Pairing Functions
ArXiv ID: 0808.0754
Date: 2008-08-07
Authors: ** Paul Tarau (University of North Texas, Department of Computer Science and Engineering) **
📝 Abstract
The paper is organized as a self-contained literate Haskell program that implements elements of an executable finite set theory with focus on combinatorial generation and arithmetic encodings. The code, tested under GHC 6.6.1, is available at http://logic.csci.unt.edu/tarau/research/2008/fSET.zip . We introduce ranking and unranking functions generalizing Ackermann's encoding to the universe of Hereditarily Finite Sets with Urelements. Then we build a lazy enumerator for Hereditarily Finite Sets with Urelements that matches the unranking function provided by the inverse of Ackermann's encoding and we describe functors between them resulting in arithmetic encodings for powersets, hypergraphs, ordinals and choice functions. After implementing a digraph representation of Hereditarily Finite Sets we define {\em decoration functions} that can recover well-founded sets from encodings of their associated acyclic digraphs. We conclude with an encoding of arbitrary digraphs and discuss a concept of duality induced by the set membership relation. Keywords: hereditarily finite sets, ranking and unranking functions, executable set theory, arithmetic encodings, Haskell data representations, functional programming and computational mathematics
💡 Deep Analysis
Deep Dive into A Functional Hitchhikers Guide to Hereditarily Finite Sets, Ackermann Encodings and Pairing Functions.
The paper is organized as a self-contained literate Haskell program that implements elements of an executable finite set theory with focus on combinatorial generation and arithmetic encodings. The code, tested under GHC 6.6.1, is available at http://logic.csci.unt.edu/tarau/research/2008/fSET.zip
. We introduce ranking and unranking functions generalizing Ackermann’s encoding to the universe of Hereditarily Finite Sets with Urelements. Then we build a lazy enumerator for Hereditarily Finite Sets with Urelements that matches the unranking function provided by the inverse of Ackermann’s encoding and we describe functors between them resulting in arithmetic encodings for powersets, hypergraphs, ordinals and choice functions. After implementing a digraph representation of Hereditarily Finite Sets we define {\em decoration functions} that can recover well-founded sets from encodings of their associated acyclic digraphs. We conclude with an encoding of arbitrary digraphs and discuss a conc
📄 Full Content
A Functional Hitchhiker’s Guide to Hereditarily Finite Sets,
Ackermann Encodings and Pairing Functions
– unpublished draft –
Paul Tarau
Department of Computer Science and Engineering
University of North Texas
tarau@cs.unt.edu
Abstract
The paper is organized as a self-contained literate Haskell
program that implements elements of an executable fi-
nite set theory with focus on combinatorial generation and
arithmetic encodings. The code, tested under GHC 6.6.1,
is available at http://logic.csci.unt.edu/tarau/
research/2008/fSET.zip.
We introduce ranking and unranking functions generaliz-
ing Ackermann’s encoding to the universe of Hereditarily Fi-
nite Sets with Urelements. Then we build a lazy enumerator
for Hereditarily Finite Sets with Urelements that matches the
unranking function provided by the inverse of Ackermann’s
encoding and we describe functors between them resulting
in arithmetic encodings for powersets, hypergraphs, ordinals
and choice functions. After implementing a digraph repre-
sentation of Hereditarily Finite Sets we define decoration
functions that can recover well-founded sets from encodings
of their associated acyclic digraphs. We conclude with an en-
coding of arbitrary digraphs and discuss a concept of duality
induced by the set membership relation.
Keywords
hereditarily finite sets, ranking and unrank-
ing functions, executable set theory, arithmetic encodings,
Haskell data representations, functional programming and
computational mathematics
1.
Introduction
While the Universe of Hereditarily Finite Sets is best known
as a model of the Zermelo-Fraenkel Set theory with the
Axiom of Infinity replaced by its negation (Takahashi 1976;
Meir et al. 1983), it has been the object of renewed practical
Permission to make digital or hard copies of all or part of this work for personal or
classroom use is granted without fee provided that copies are not made or distributed
for profit or commercial advantage and that copies bear this notice and the full citation
on the first page. To copy otherwise, to republish, to post on servers or to redistribute
to lists, requires prior specific permission and/or a fee.
WXYZ ’08
date, City.
Copyright c⃝2008 ACM [to be supplied]...$5.00
interest in various fields, from representing structured data
in databases (Leontjev and Sazonov 2000) to reasoning with
sets and set constraints in a Logic Programming framework
(Dovier et al. 2000; Piazza and Policriti 2004; Dovier et al.
2001).
The Universe of Hereditarily Finite Sets is built from the
empty set (or a set of Urelements) by successively applying
powerset and set union operations. A surprising bijection,
discovered by Wilhelm Ackermann in 1937 (Ackermann
1937; Abian and Lamacchia 1978; Kaye and Wong 2007)
from Hereditarily Finite Sets to Natural Numbers, was the
original trigger for our work on building in a mathematically
elegant programming language, a concise and executable
hereditarily finite set theory. The arbitrary size of the data
objects brought in the need for arbitrary length integers.
The focus on potentially infinite enumerations brought in the
need for lazy evaluation. These have made Haskell a natural
choice.
We will describe our constructs in a subset of Haskell
(Peyton Jones 2002, 2003a,b) seen as a concrete syntax for
a generic lambda calculus based functional language1.
We will only make the assumptions that non-strict func-
tions (higher order included), with call-by-need evaluation
and arbitrary length integers are available in the language.
While our code will conform Haskell’s type system, we will
do that without any type declarations, by ensuring that the
types of our functions are all inferred. This increases chances
that the code can be ported, through simple syntax transfor-
mations, to any programming language that implements our
basic assumptions.
The paper is organized as follows: section 2 introduces
the reader to combinatorial generation with help of a bit-
string example, section 3 introduces Ackermann’s encod-
1 As a courtesy to the reader wondering about the title, the author confesses
being a hitchhiker in the world of functional programming, coming from
the not so distant galaxy of logic programming but still confused by recent
hitchhiking trips in the exotic worlds of logic synthesis, foundations of
mathematics, natural language processing, conversational agents and virtual
reality. And not being afraid to go boldly where . . . a few others have already
been before.
arXiv:0808.0754v1 [cs.MS] 6 Aug 2008
ing in the more general case when urelements are present
and shows an encoding for hypergraphs as a particular case.
Section 4 gives examples of transporting common set and
natural number operations from one side to the other. After
discussing some classic pairing functions, section 5 intro-
duces new pairing/unpairing on natural numbers. Section 6
discusses graph representations and decoration functions on
Hereditarily Finite Sets (6.1), and provides encodings for di-
rected acycli