TITLE: "Lifting" an algebraic structure on a codomain to the set of functions into it.
QUESTION [5 upvotes]: Let $ S$ be any set and $G$ be a group. The set of functions from $S$ to $G$ is clearly also a group. The identity element is the constant function whose value is the identity of $G$, and the (group) inverse of any function $g$ is the function that maps $x \in S$ to the group inverse of $g(x)$ in $G$.
If we replaced "group" with ring (also commutative ring, ring with identity, and both), vector space, or algebra (assuming for the last two that a scalar field is given), the analogous statement is still true.
This clearly isn't the case for fields though. Assuming we want to make this work, the "zero function" would be the one that maps identically to zero. A function $f$, such that $f(x) = 0$ for at least one $x \in S$, but is not $0$ for at least one other $x \in S$, is not equal to the zero function, but also doesn't have a multiplicative inverse.
Are there other algebraic structures for which this relationship holds or fails in interesting ways? Is there a specific field of mathematics that studies this?

REPLY [2 votes]: A nice intuitive way to look at this is to look at the smallest non-trivial case: the set of functions from a two element set into your algebraic structure $G$. Note that, imposing pointwise operations on this set gives the structure $G\times G$. The direct product of groups is a group. The direct product of fields is not a field. This is the heart of the issue and is worth pondering independently of any larger apparatus for understanding "why".

This all said, a convenient way to consider the issue is through the lens of universal algebra. In particular, this field defines a variety of algebra as a general means to define things like groups and rings. Loosely speaking, a variety consists of a set of operations along with some equalities between various expressions in these operations that must hold for all variables - it's a bit painful to write out a satisfying technical definition, but consider two examples:
First, groups form a variety because they can be defined as follows: Let $S$ be a set and $\cdot:S^2\rightarrow S$ be a binary operation, $^{-1}:S^1\rightarrow S$ be a unary operation, and $e:S^{0}\rightarrow S$ be a $0$-ary operation (i.e. a constant, since $S^0$ is a one element set). The tuple $(S,\cdot,^{-1},e)$ is a group if it satisfies
$$(x\cdot y)\cdot z = x\cdot (y\cdot z)$$
$$x\cdot x^{-1}=e$$
$$e\cdot x = x\cdot e = x$$
where all of these are quantized over all $x,y,z\in G$.
One can define rings and commutative rings similarly. With a bit of creativity, the set of vector spaces over a fixed field $F$ (or modules over a fixed ring) can also be expressed with an infinite set of operations and axioms, taking "multiplication by $c\in F$" to be a unary operation for each $c$. Essentially, the important fact is that these algebraic structures are defined solely by universally true axioms relating some constants - you can check that, so long as your algebraic structure is defined by these rules, we can impose the same structure on the set of functions into an example of that structure, since the rules will still hold pointwise (i.e. after evaluating the function anywhere). More generally, any direct product of members of a variety is still in that variety - the case of functions into a group is just one instance of that where all the factors are the same.
Fields are not a variety. At first glance, the usual formulation of a field does not obey the desired rules: how can we express the invertibility of all non-zero elements only by enforcing universal equalities between some compositions of functions? There is no provision to write "for all $x$ except $0$, we have...". The requirement that $0\neq 1$ is also problematic.
Delving a bit deeper, we see that this is actually impossible: the direct product of two fields is never a field, so it is not possible to define "field" in the manner of a variety. This is a fundamental difference between the concept of a field and the other concepts you list.