Functor

From Conservapedia
This is an old revision of this page, as edited by PatrickD (talk | contribs) at 19:26, October 1, 2009. It may differ significantly from current revision.
Jump to navigation Jump to search

The term functor has two distinct meanings.

In Pure Mathematics

In category theory, a functor is a map between categories satisfying certain relations. Functors, in a sense, provide for categories what group homomorphisms do for groups. To be precise, a function between two categories associates to each object an object Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(X) \in \textrm{Ob } \mathcal D} , and to each morphism Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle f \in \mathcal C(X,Y)} a morphism Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(f) \in \mathcal D(FX,FY)} such that:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(\textrm{id}_X) = id_{F(X)}\,}
Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(g \circ f) = F(g) \circ F(f)} .

Functors are the fundamental objects used to relate structures between different categories.

The above is sometimes called a "covariant functor", to distinguish it from the less common "contravariant functor". In a contravariant functor, the composition order is reversed:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(g \circ f) = F(f) \circ F(g)} .

Examples

Algebraic topology was the first field in which the usefulness of the notion of a functor was recognized. A basic example is the fundamental group functor Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \pi_1 : \textbf{Top}* \to \textbf{Grp}} . The action on objects is defined by sending a topological space to its fundamental group Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \pi_1(X)} . Recall that a map between two topological spaces Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle f : X \to Y} induces a map Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle f_* : \pi_1(X) \to \pi(Y)} by Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle f_*([\gamma]) = [f \circ \gamma]} . Set Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \pi_1(f) = f_*\,} so defined. The functoriality of Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \pi_1} boils down to the fact that Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(\textrm{id}_X) = \textrm{id}_{\pi_1(X)}} , that is, the identity map on a topological space induces the identity map on its fundamental group, together with the fact that Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle F(g \circ f) = F(g) \circ F(f)} , explained at fundamental group.

In Computer Science

In computer science, the term "functor" is short for "function operator", also called a "function object". It is essentially a class method with no name. Many modern programming languages support this. For example, in C++ one can define a function object with the "operator()" notation, that is, a definition of what parentheses mean after an object.

 class C {
 public:
    int operator()(int i, int j) { return k+i*j; }
    int k;
    .....
  };
  
  .....
  C MyObject;
  MyObject.k = 3;
  int r = MyObject(4,5);
  .....

We have effectively defined a nameless method for class C. Instead of making a named invocation like "MyObject.func(4,5)", we just write "MyObject(4,5)".