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 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.
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.
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. 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.
Read more about this topic: Initial Algebra
Famous quotes containing the words computer and/or science:
“Family life is not a computer program that runs on its own; it needs continual input from everyone.”
—Neil Kurshan (20th century)
“The method of political science ... is the interpretation of life; its instrument is insight, a nice understanding of subtle, unformulated conditions.”
—Woodrow Wilson (18561924)