natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism = propositions as types +programs as proofs +relation type theory/category theory
In a strict sense of the term, a function is a homomorphism $f : S \to T$ of sets. We may also speak of a map or mapping, but those terms are used in other ways in other contexts.
A function from a set $A$ to a set $B$ is determined by giving, for each element of $A$, a specified element of $B$. The process of passing from elements of $A$ to elements of $B$ is called function application. The set $A$ is called the domain of $f$, and $B$ is called its codomain.
A function is sometimes called a total function to distinguish it from a partial function.
More generally, every morphism between objects in a category may be thought of as a function in a generalized sense. This generalized use of the word is wide spread (and justified) in type theory, where for $S$ and $T$ two types, there is a function type denoted $S \to T$ and then the expression $f : S \to T$ means that $f$ is a term of function type, hence is a function.
In this generalized sense, functions between sets are the morphisms in the category Set. This is cartesian closed, and the function type $S \to T$ is then the function set.
For more on this more general use of “function” see at function type.
The formal definition of a function depends on the foundations chosen.
In material set theory, a function $f$ is often defined to be a set of ordered pairs such that for every $x$, there is at most one $y$ such that $(x,y)\in f$. The domain of $f$ is then the set of all $x$ for which there exists some such $y$. This definition is not entirely satisfactory since it does not determine the codomain (since not every element of the codomain may be in the image); thus to be completely precise it is better to define a function to be an ordered triple $(f,A,B)$ where $A$ is the domain and $B$ the codomain.
In structural set theory, the role of functions depends on the particular axiomatization chosen. In ETCS, functions are among the undefined things, whereas in SEAR, functions are defined to be particular relations (which in turn are undefined things).
In type theory, functions are simply terms belonging to function types.
See set theory and type theory for more details.
If we regard sets as discrete categories, then a function is a functor between sets. The functoriality structure becomes the property that a function preserves equality:
See the MathOverflow: what-are-maps-between-proper-classes