TITLE: Definition of Function
QUESTION [13 upvotes]: What is authoritative canonical formal definition of function?
For example,
According to Wolfram MathWorld,
$$isafun_1(f)\;\leftrightarrow\;
\forall a\in f\;(\exists x\exists y \;\langle x,y\rangle = a)
\; \wedge \;
\forall x\forall y_1\forall y_2\;((\langle x,y_1\rangle\in f\wedge\langle x,y_2\rangle \in f)\rightarrow y_1=y_2))$$
According to Bourbaki "Elements de Mathematiques, Theorie des Ensembles",
$$
isafun_2(f)\;\leftrightarrow\;
\exists d\exists g\exists c\;(\langle d,g,c\rangle=f
\;\wedge\;isafun_1(g)\;\wedge$$
$$\;\wedge\;
\forall x(x \in d\rightarrow \exists y(\langle x,y\rangle \in g))
\;\wedge\;
\forall x\forall y(\langle x,y\rangle \in g\rightarrow (x \in d\wedge y\in c)))
$$
How to make agree definition of function as triple with extensional equality
$$
\forall f\forall g\;[\;(isafun(f)\wedge isafun(g))
\; \rightarrow \;
[\;(\forall x(\;f(x)=g(x)\;))\leftrightarrow f=g\;]\;]
$$
?
Why such divergences in definitions exist?
Upd: Two additional questions:

Why function is not a pair in $isafun_2$? First component of triple is perfectly derivable from the second.
What word function exactly means if no underlying theory is specified in context? If I build fully formal knowledge base about mathematics for automated reasoning and want to add notion of contextless function -- how I must describe it?

REPLY [3 votes]: When we use the Bourbaki definition of function as a triple (domain, codomain, graph), then two functions are usually defined to be equal iff their domains and graphs are equal. So  equal functions can have different codomains. The problem is that the same sign "=" is used both for the  the equality of functions and the "universal" equality (In ZFC, for example, the "universal" equality is defined for all sets). That is, the sign "=" is overloaded. Normally, from the context one can determine what is the intended meaning.
But there is a more serious trouble (as Vag pointed out early) with the Bourbaki definition, when a function is an element of a set. So it seems that the  definition of function as a set of ordered pairs having the functional property is more preferable.