World Library  
Flag as Inappropriate
Email this Article

Initial algebra

Article Id: WHEBN0004116488
Reproduction Date:

Title: Initial algebra  
Author: World Heritage Encyclopedia
Language: English
Subject: Catamorphism, Type theory, Abstract data type
Publisher: World Heritage Encyclopedia

Initial algebra

In mathematics, an initial algebra is an initial object in the category of F-algebras for a given endofunctor F. The initiality provides a general framework for induction and recursion.

For instance, consider the endofunctor 1+(-) on the category of sets, where 1 is the one-point set, the terminal object in the category. An algebra for this endofunctor is a set X (called the carrier of the algebra) together with a point xX and a function XX. The set of natural numbers is the carrier of the initial such algebra: the point is zero and the function is the successor map.

For a second example, consider the endofunctor 1+N×(-) on the category of sets, where N is the set of natural numbers. An algebra for this endofunctor is a set X together with a point xX and a function N×XX. The set of finite lists of natural numbers is the initial such algebra. The point is the empty list, and the function is cons, taking a number and a finite list, and returning a new finite list with the number at the head.

Final coalgebra

Dually, a final coalgebra is a terminal object in the category of F-coalgebras. The finality provides a general framework for coinduction and corecursion.

For example, using the same functor 1+(-) as before, a coalgebra is a set X together with a truth-valued test function p\colon X \to 2 and a partial function f\colon X \to X whose domain is formed by those x \in X for which p(x) = 0. The set \mathbb{N} \cup \{\omega\} consisting of the natural numbers extended with a new element \omega is the carrier of the final coalgebra in the category, where p is the test for zero: p(0)=1 and p(n+1) = p(\omega) = 0, and f is the predecessor function (the inverse of the successor function) on the positive naturals, but acts like the identity on the new element \omega: f(n+1) = n, f(\omega) = \omega.

For a second example, consider the same functor 1 + \mathbb{N}\times(\mathord{-}) as before. In this case the carrier of the final coalgebra consists of all lists of natural numbers, finite as well as infinite. The operations are a test function testing whether a list is empty, and a deconstruction function defined on nonempty lists returning a pair consisting of the head and the tail of the input list.


  • Initial algebras are minimal (i.e., have no proper subalgebra[1])
  • Final coalgebras are simple (i.e., have no proper quotients[2]).[1]


Consider the endofunctor F: \mathbf{Set} \to \mathbf{Set} sending X to 1+X. Then the set N of natural numbers together with the functions [\mathit{zero},\mathit{succ}]\colon 1+N \to N, where \mathit{zero} \colon 1 \to N and \mathit{succ}\colon N \to N are the obvious functions suggested by their names, is an initial F-algebra. The initiality (the universal property for this case) is not hard to establish; the unique homomorphism to an arbitrary F-algebra (A, [e,f]), for e\colon 1 \to A an element of A and f\colon A \to A a function on A, is the function sending the natural number n to f^n(e), that is, f(f(\dots(f(e))\dots)), the n-fold application of f to e.

Use in Computer Science

Various finite data structures used in programming, such as lists and trees, can be obtained as initial algebras of specific endofunctors. While there may be several initial algebras for a given endofunctor, they are unique up to isomorphism, which informally means that the "observable" properties of a data structure can be adequately captured by defining it as an initial algebra.

To obtain the type \mathit{List}(A) of lists whose elements are members of set A, consider that the list-forming operations are:

  • \mathit{nil}\colon 1 \to \mathit{List}(A)
  • \mathit{cons}\colon A \times \mathit{List}(A) \to \mathit{List}(A)

Combined into one function, they give:

  • [\mathit{nil},\mathit{cons}]\colon 1 + (A \times \mathit{List}(A))\to \mathit{List}(A),

which makes this an F-algebra for the endofunctor F sending X to 1+(A\times X). It is, in fact, the initial F-algebra. Initiality is established by the function known as foldr in functional programming languages such as Haskell and ML.

Likewise, binary trees with elements at the leaves can be obtained as the initial algebra

  • [\mathit{tip},\mathit{join}]\colon A + (\mathit{Tree}(A) \times \mathit{Tree}(A)) \to \mathit{Tree}(A).

Types obtained this way are known as algebraic data types.

Types defined by using least fixed point construct with functor F can be regarded as an initial F-algebra, provided that parametricity holds for the type.[3]

In a dual way, similar relationship exists between notions of greatest fixed point and terminal F-coalgebra, with applications to coinductive types. These can be used for allowing potentially infinite objects while maintaining strong normalization property.[3] In the strongly normalizing Charity programming language (i.e. each program terminates), coinductive data types can be used achieving surprising results, e.g. defining lookup constructs to implement such “strong” functions like the Ackermann function.[4]

See also


  1. ^ a b Initiality and finality from CLiki
  2. ^ Induction and Co-induction from CLiki
  3. ^ a b Philip Wadler: Recursive types for free! University of Glasgow, July 1998. Draft.
  4. ^ Robin Cockett: Charitable Thoughts (ps and ps.gz)

External links

  • Categorical programming with inductive and coinductive types by Varmo Vene
  • Philip Wadler: Recursive types for free! University of Glasgow, July 1998. Draft.
  • Initial Algebra and Final Coalgebra Semantics for Concurrency by J.J.M.M. Rutten and D. Turi
  • Initiality and finality from CLiki
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.