The concept of cartesian product makes sense for any family of sets, while the category-theoretic product makes sense for any family of objects. In each case, however, the family is indexed by a set; how can we get a purely category-theoretic product indexed by an object?
First we need to describe a family of objects indexed by an object; it's common to interpret this as a bundle, that is an arbitrary morphism . (In Set, would be the index set of the family, and the fiber of the bundle over an element of would be the set indexed by . Conversely, given a family of sets, can be constructed as its disjoint union.)
In these terms, the cartesian product of the family of sets is the set of (global) sections of the bundle. This set comes equipped with an evaluation map such that
equals the usual product projection; in other words, is a morphism in the over category . The universal property of is that, given any set and morphism in , there's a unique map that makes everything commute.
In other words, and define an adjunction from to in which taking the product with is the left adjoint and applying this universal property is the right adjoint. This is the basis for the definition below, but we add one further level of generality: we move everything from to an arbitrary over category .
For a category, the dependent product of the morphism indexed by the morphism is an object in the over category , where the operation is the right adjoint to the base change functor .
For this to make sense, must exist; that is, all pullbacks along must exist. So a category with all dependent products is necessarily a category with all pullbacks.
Note that the left adjoint to the base-change functor, the dependent coproduct or dependent sum , is much simpler. It is simply given by composition with , so it always exists when it makes sense (that is when has all pullbacks).
For a topos and any morphism in , both the left adjoint as well as the right adjoint to exist.
Moreover, preserves the subobject classifier and internal homs.
This is theorem 2 in section IV, 7 of