|
|
Line 1: |
Line 1: |
| In [[mathematics]], an '''initial algebra''' is an [[initial object]] in the [[F-algebra|category of ''F''-algebras]] for a given [[endofunctor]] ''F''. The initiality provides a general framework for [[mathematical induction|induction]] and [[recursion]].
| | Hello and welcome. My title is Numbers Wunder. California is where her house is but she needs to transfer because of her family members. Managing people is his profession. To do aerobics is a factor that I'm completely addicted to.<br><br>My homepage [https://www.machlitim.org.il/subdomain/megila/end/node/9243 www.machlitim.org.il] |
| | |
| 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 {{nowrap|''x'' ∈ ''X''}} and a function {{nowrap|''X''→''X''}}. The set of [[natural number]]s 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 {{nowrap|''x'' ∈ ''X''}} and a function {{nowrap|'''N'''×''X'' → ''X''}}. The set of finite [[List (computing)|list]]s 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 [[F-coalgebra|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-value]]d test function {{nowrap|''p'' : ''X'' → 2}} and a [[partial function]] {{nowrap|''f'' : ''X'' → ''X''}} whose [[Domain of a function|domain]] is formed by those {{nowrap|''x'' ∈ ''X''}} for which {{nowrap|1=''p''(''x'') = 0}}. The set {{nowrap|'''N''' ∪ {ω}}} consisting of the natural numbers extended with a new element ω is the carrier of the final coalgebra in the category, where ''p'' is the test for zero: {{nowrap|1=''p''(0) = 1}}, {{nowrap|1=''p''(''n''+1) =}} {{nowrap|1=''p''(ω) = 0}}; and ''f'' is the predecessor function (the [[Inverse function|inverse]] of the successor function) on the positive naturals, but acts like the [[Identity function|identity]] on the new element ω: {{nowrap|1=''f''(''n''+1) = ''n''}}, {{nowrap|1=''f''(ω) = ω}}.
| |
| | |
| For a second example, consider the same functor 1+'''N'''×(-) as before. In this case the carrier of the final coalgebra consists of all lists of natural numbers, finite as well as [[Infinite list|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.
| |
| | |
| == Theorems ==
| |
| * Initial algebras are minimal (i.e., have no proper subalgebra<ref name=infin/>)
| |
| * Final coalgebras are [[Simple algebra|simple]] (i.e., have no proper quotients<ref>[http://tunes.org/wiki/induction_20and_20co-induction.html Induction and Co-induction] from CLiki</ref>).<ref name=infin>[http://tunes.org/wiki/initiality_20and_20finality.html Initiality and finality] from CLiki</ref>
| |
| | |
| == Example ==
| |
| | |
| Consider the endofunctor <math>F: \mathbf{Set} \longrightarrow \mathbf{Set}</math> sending <math>X</math> to <math>1+X</math>. Then the set <math>N</math> of [[natural number]]s together with the functions <math>[zero,succ] : 1+N \longrightarrow N</math>, where <math>zero : 1 \longrightarrow N</math> and <math>succ : N \longrightarrow N</math> are the obvious functions suggested by their names, is an initial <math>F</math>-algebra. The initiality (the [[universal property]] for this case) is not hard to establish; the unique [[homomorphism]] to an arbitrary ''F''-algebra <math>(A, [e,f])</math>, for <math>e : 1 \longrightarrow A</math> an element of ''A'' and <math>f : A \longrightarrow A</math> a [[function (mathematics)|function]] on ''A'', is the function sending the natural number ''n'' to <math>f^n(e)</math>, that is, <math>f(f(...(f(e))...))</math>, the ''n''-fold application of ''f'' to ''e''.
| |
| | |
| == Use in Computer Science ==
| |
| | |
| Various finite [[data structures]] used in [[Mathematical programming|programming]], such as [[List (computing)|list]]s and [[tree]]s, 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 [[datatype|type]] <math>List(A)</math> of lists whose elements are members of set ''A'', consider that the list-forming operations are:
| |
| | |
| *<math>nil : 1\longrightarrow List(A)</math>
| |
| *<math>cons : A\times List(A)\longrightarrow List(A)</math>
| |
| | |
| Combined into one function, they give:
| |
| | |
| *<math>[nil,cons] : 1 + (A\times List(A))\longrightarrow List(A)</math>,
| |
| | |
| which makes this an ''F''-algebra for the endofunctor ''F'' sending <math>X</math> to <math>1+(A\times X)</math>. It is, in fact, ''the'' initial ''F''-algebra. Initiality is established by the function known as ''[[Fold (higher-order function)|foldr]]'' in [[functional programming|functional]] [[programming language]]s such as [[Haskell (programming language)|Haskell]] and [[ML programming language|ML]].
| |
| | |
| Likewise, [[binary tree]]s with elements at the leaves can be obtained as the initial algebra
| |
| | |
| *<math>[tip,join] : A + (Tree(A)\times Tree(A))\longrightarrow Tree(A)</math>.
| |
| | |
| 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 initial [[F-algebra]], provided that [[parametricity]] holds for the type.<ref name=free-rectypes>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.
| |
| </ref>
| |
| | |
| In a [[Duality (mathematics)|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 [[Actual infinity|potentially infinite]] objects while maintaining [[Normalization property (lambda-calculus)|strong normalization property]].<ref name=free-rectypes/> In the strongly normalizing [[Charity (programming language)|Charity]] programming language (i.e. each program terminates), coinductive data types can be used achieving surprising results, e.g. defining [[Lookup table|lookup]] constructs to implement such [[Computability theory (computer science)|“strong”]] functions like the [[Ackermann function]].<ref>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])</ref>
| |
| | |
| == See also ==
| |
| * [[Algebraic data type]]
| |
| * [[Catamorphism]]
| |
| * [[Anamorphism]]
| |
| | |
| == Notes ==
| |
| | |
| <references/>
| |
| | |
| == 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
| |
| | |
| [[Category:Category theory]]
| |
| [[Category:Functional programming]]
| |
| [[Category:Type theory]]
| |
Hello and welcome. My title is Numbers Wunder. California is where her house is but she needs to transfer because of her family members. Managing people is his profession. To do aerobics is a factor that I'm completely addicted to.
My homepage www.machlitim.org.il