In mathematics, an initial algebra is an initial object in the category of F-algebras for a given endofunctor F.
Consider the endofunctor sending to . Then the set of natural numbers together with the function , where and are the obvious functions suggested by their names, is an initial -algebra. The initiality (the universal property for this case) is not hard to establish; the unique homomorphism 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.
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 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 languages such as Haskell and ML.
Likewise, binary trees with elements at the leaves can be obtained as the initial algebra
Types obtained this way are known as algebraic data types.
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Initial algebra".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world