What is the definition of function in ZF/ZFC? In ZF there is axiom schema of replacement, which can be stated as


  the image of a set under any definable function will also fall inside a
  set


Is there a definition of the concept of function in ZF/ZFC? What is it? I mean set-theoretically speaking. That is, in naïve set theory function can be understood as a set of pairs (triples, etc.), but what about ZF/ZFC?
There are two different notions which are both called "function". A function internally to ZFC is a set of pairs, where the first element of the pair is understood to be mapped to the second by the function. For example, the successor function $S :\mathbb N \to \mathbb N$ is a function internally in ZFC, and it is given by
$$
S = \{(n,m) \in \mathbb N \times \mathbb N \mid m = n + 1\}.
$$
However, the function from the axiom schema of replacement refers to a function on the universe given by a formula. Slightly simplified, if $\phi(x,y)$ is a formula with two free variables such that ZFC proves that $\forall x \exists y \phi(x,y)$ and $\forall x \forall y \forall y'(\phi(x,y) \land \phi(x,y') \to y = y')$, then there is an instance of the schema axiom of replacement which states
$$
\forall X \exists Y(\forall x\forall y(\phi(x,y) \land x \in X \to y \in Y)).
$$
There are:


functions and
operators.


Functions are values in the formal theory (in ZF values are usually called "sets"). Operators don't exist within ZF--they are formulas, so as entities they are present in the metatheory, but not as values in the theory.

Kunen explains the distinction clearly in Sec. I.7.2 on pages 28--30 of "The Foundations of Mathematics". He notes that operators are simply abbreviations for formulas, and they correspond to formulas that can be regarded as "pseudorelations", in the sense that they aren't values in the formal theory.

Another name for operator is class function, because their value is specified for more values that how many values fit in a set. Unfortunately, operators are usually called "functions", causing confusion.

Another issue is how functions are defined in mathematics. Typically in ad hoc ways that don't tell you what $f[x]$ means for $x$ outside of the domain of function $f$.

Traditional presentations of set theory introduce the notion of relation first, as a set whose each element is a set with two elements, usually structured so that we can tell their order (e.g., Def. I.7.5 on page 25 of Kunen's "The Foundations of Mathematics"). They then define functions as syntax for relations. But they almost never talk about what $f[x]$ means for arbitrary $x$.

Whether we are allowed to write $f[x]$ for $x$ outside $\mathrm{DOMAIN}\ f$ or not is a matter of the theory's syntax rules. A typed logic may disallow this, but ZF is untyped, so $f[x]$ should be some value even when $x \notin \mathrm{DOMAIN}\ f$.

So it remains to decide what value $f[x]$ is in that case. One option is to use a default value (as for example on page 15 in Kunen's 2013 "Set Theory"). Such a choice is a little arbitrary. It is simpler to let $f[x]$ be unspecified, in that it is some value (maybe different for each $x \notin \mathrm{DOMAIN}\ f$), but we assume nothing about which value it is.

TLA+

This simple approach is taken in TLA+, the Temporal Logic of Actions + ZF, introduced by Leslie Lamport. Chapter 6 of the book "Specifying Systems" explains these issues clearly and with examples, especially the distinction between operators and functions (the book is available online). This thread discusses this distinction.

TLA+ axiomatizes functions directly, with the function constructor syntax

$$[x \in S \mapsto \mathit{SomeExpression}(x)]$$

Not any value is a function. Only those values $f$ that satisfy the formula:

$$IsAFunction(f) \triangleq f = [x \in \mathrm{DOMAIN}\ f \mapsto f[x]]$$

In doing so, TLA+ does not mention any structure of $f$. A function $f$ could happen to also be a relation that is the set of pairs

$$\{\mathit{KuratowskiPair}(x, f[x]): \quad x \in \mathrm{DOMAIN}\ f\}$$

or not (where $\mathit{KuratowskiPair}$ refers to Kuratowski's construction of ordered pairs). Contrast this approach with the traditional one, where functions necessarily are sets with this relation structure, which is a somewhat secondary to what the notion of mapping stands for. The notion of mapping is distilled by the axiomatization of functions in TLA+, without irrelevant structure.

It is also worth distinguishing undefined from unspecified. Undefined may mean that writing $f[x]$ for $x \notin \mathrm{DOMAIN}\ f$ is nonsensical, as happens in typed formalisms (see also Kunen's comment about "partial functions" on p.15 in "Set theory"). In untyped logic though this has to be some value. Kunen specifies which value this is, whereas TLA+ does not. Lamport cites "Avoiding the undefined by underspecification", which is quite relevant to these issues. Good reading about untypeness:


"Types considered harmful"
"Types are not harmless"
"Should your specification language be typed?"


Extensions by definitions

In more detail, any new symbol that we introduce actually changes the formal system that we are working in. So an identifier that names a function or an operator is introduced by a definition, which means the creation of an inessential extension of the formal system by the addition of a symbol (the identifier in question), together with an axiom about this identifier. Extensions are discussed in Sec. II.15 of Kunen's "The Foundations of Mathematics", as well as in an appendix of Kleene's "Introduction to Metamathematics".