As is always the case with category-theoretic constructions, there is a construction "dual" to that of the direct product of modules, called the direct sum of modules. It is characterized by the property "dual" to that of direct product. (It really should have been called the coproduct instead of the direct sum, but we'll save that discussion for later.)
The direct sum of two modules
First suppose and are two -modules. We can construct an -module called their direct sum, denoted , whose elements consist of all formal sums[1] of the form , with "component-wise" addition and scaling.[2] We also have two "inclusion" module morphisms , which send an element to the element (for or (for ).
These data satisfy the usual universal property for a coproduct, in that it is universal among all such modules equipped with morphisms from and . More precisely, for each module and pair of module morphisms and there is a unique module morphism such that the diagram below commutates:
As with the direct product, we can actually deduce the unique map from the commutativity conditions. First suppose we take any element of . We must have
So, the only possible map with the required factorization properties is defined by . All that remains is to verify that this map is indeed an -module morphism.
Coproducts in related categories
Observe that, as an abelian group, is the usual direct sum (i.e., coproduct) of abelian groups; however, as a set, is not (bijective to) the usual disjoint union (i.e., coproduct) of sets.
More precisely, let and denote the usual forgetful functors. Then but . We might reasonably say that the forgetful functor preserves binary coproducts, but the forgetful functor does not.
What is a "formal sum"?
In the construction above, we wrote that the elements of consist of "formal sums" of the form with . But what is a "formal sum" and why is it not just called a "sum"? For an initial answer to that question, note that for elements and there is no ambient operation that allows us to add to . That's because we are not given any module in which we can simultaneously view and as submodules. In fact, you can view the construction of as precisely the construction of such a module.
The question still remains, however, as to what we're precisely doing here. In which previously existing set is the formal sum supposed to be contained? We'll give an answer to that question at the bottom of this note.
The direct sum of an arbitrary family of modules
As with product of modules, let's now jump to the general case. Suppose is a family of -modules indexed by some set ; i.e., a functor . Following the pattern we've established, the direct sum of this family is an -module, denoted , together with module morphisms for every , universal among all such data. As an abelian group, this is the usual direct sum of the corresponding abelian groups.
How is the module constructed? Recall that with the infinite direct product, we formally defined the elements of as set maps such that for every , where was any set containing all of the elements of every . Here we do the same, with one small twist. The elements of are the set maps such that:
for every
for all but finitely many .
With this description of the direct sum, the "inclusion" morphism is the morphism that sends each to the map defined by
You might feel that this formal description is clunky, but there is one immediate benefit. Written this way, it is clear that there is a "canonical" injective module morphism
which is an isomorphism when is finite (but usually not an isomorphism when is finite).
But why the requirement that for all but finitely many ? This new restriction turns out to be a consequence of the desired universal property, one that was not implied/required for the universal property of the direct product.
Indeed, suppose we did not require this. Now suppose we had a collection of -module morphisms , one for every element . The desired universal property of would then require the existence of a unique module morphism through which every factored. This factorization property would force to satisfy
However, that sum occurs in the module , where arbitrary sums of elements are not necessarily defined. (As an -module, is endowed with a binary operation, which can be repeated to define an -ary operation, but not necessarily anything beyond that.) In other words, it's not clear such a map is well defined (or even possible).
The finiteness condition on our formal sums removes this issue, and indeed the desired universal property is now straightforward to verify.