- Initial algebra
In
mathematics , an initial algebra is aninitial object in the category of "F"-algebras for a givenendofunctor "F". The initiality provides a general framework for induction andrecursion .For instance, consider the endofunctor 1+(-) on the category of sets. An algebra for this endofunctor is a set "X" together with a point "x"ε"X" and a function "X"→"X". The set of
natural number s is 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 "x"ε"X" and a function N×"X"→"X". The set of 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 list, and returning a new list with the number at the head.Theorems
* Initial algebras are minimal (have no proper subalgebra), final coalgebras are simple (have no proper quotients [ [http://tunes.org/wiki/induction_20and_20co-induction.html Induction and Co-induction] from CLiki] ). [http://tunes.org/wiki/initiality_20and_20finality.html Initiality and finality] from CLiki]
Example
Consider the endofunctor sending to . Then the set of
natural number s together with the functions , where and are the obvious functions suggested by their names, is an initial -algebra. The initiality (theuniversal property for this case) is not hard to establish; the uniquehomomorphism to an arbitrary "F"-algebra , for an element of "A" and a function on "A", is the function sending the natural number "n" to , that is, , the "n"-fold application of "f" to "e".Use in programming theory
Various finite
data structures used inprogramming , such as lists andtree s, can be obtained as initial algebras of specific endofunctors.While there may be several initial algebras for a given endofunctor, they areunique 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 of lists whose elements are members of set "A", consider that the list-forming operations are:
*
*Combined into one function, they give:
*,
which makes this an "F"-algebra for the endofunctor "F" sending to . It is, in fact, "the" initial "F"-algebra. Initiality is established by the function known as "foldr" in functional
programming language s such as Haskell and ML.Likewise,
binary tree s with elements at the leaves can be obtained as the initial algebra*.
Types obtained this way are known as
algebraic data type s.Types defined by using
least fixed point construct with functor F can be regarded as an initialF-algebra , provided thatparametricity holds for the type.Philip Wadler: [http://homepages.inf.ed.ac.uk/wadler/papers/free-rectypes/free-rectypes.txt Recursive types for free!] University of Glasgow, July 1998. Draft.]In a dual way, similar relationship exists between notions of
greatest fixed point and terminalF-coalgebra , these can be used for allowing potentially infinite objects while maintaining strong normalization property. 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 theAckermann function . [Robin Cockett: Charitable Thoughts ( [ftp://ftp.cpsc.ucalgary.ca/pub/projects/charity/literature/papers_and_reports/charitable.ps ps] and [ftp://ftp.cpsc.ucalgary.ca/pub/projects/charity/literature/papers_and_reports/charitable.ps.gz ps.gz] )]See also
*
Algebraic data type
*Catamorphism
*Final algebra Notes
External links
* [http://www.cs.ut.ee/~varmo/papers/thesis.pdf Categorical programming with inductive and coinductive types] by Varmo Vene
* Philip Wadler: [http://homepages.inf.ed.ac.uk/wadler/papers/free-rectypes/free-rectypes.txt Recursive types for free!] University of Glasgow, July 1998. Draft.
* [http://citeseer.ist.psu.edu/rutten94initial.html Initial Algebra and Final Coalgebra Semantics for Concurrency] by J.J.M.M. Rutten and D. Turi
* [http://tunes.org/wiki/initiality_20and_20finality.html Initiality and finality] from CLiki
Wikimedia Foundation. 2010.