Let \(J\) be a fixed set (object of \(\mathbf{Set}\)). Define the slice category \(\mathbf{Set}/J\) as follows.
Objects. An object of \(\mathbf{Set}/J\) is a function \(p:X\to J\) in \(\mathbf{Set}\).
Morphisms. A morphism from \(p:X\to J\) to \(q:Y\to J\) is a function \(f:X\to Y\) in \(\mathbf{Set}\) such that \(q\circ f = p\). Equivalently the triangle $$ \begin{matrix} X &\xrightarrow{f}& Y\\[2pt] &\searrow^{p} &\downarrow_{q}\\ && J \end{matrix} $$ commutes. Composition and identities are inherited from \(\mathbf{Set}\). This plainly makes \(\mathbf{Set}/J\) into a category.
(These definitions and the slice-point-of-view are standard; see Mac Lane & Moerdijk for exposition in topos theory.)
Each arrow \(p:X\to J\) determines the family of fibers \((X_j)_{j\in J}\) where \(X_j = p^{-1}(\{j\})\). Conversely, given any family of sets \((X_j)_{j\in J}\) the disjoint union \(\bigsqcup_{j\in J} X_j\) together with the projection to \(J\) is an object of the slice. This gives an equivalence of categories $$ \mathbf{Set}/J \simeq \prod_{j\in J}\mathbf{Set}, $$ sending \(p:X\to J\) to the family \((X_j)_{j\in J}\) and a morphism \(f\) over \(J\) to the family of fiber maps \(f_j:X_j\to Y_j\). This fiberwise viewpoint simplifies all constructions: limits, colimits and exponentials are formed fiberwise (i.e. independently for each \(j\)). The equivalence and the fiberwise computations are standard and appear in treatments of slice toposes.
Limits. Let \(D:\mathcal{I}\to\mathbf{Set}/J\) be a diagram. For each \(i\in\mathcal I\) write \(D(i)=p_i:X^{(i)}\to J\). Under the fiberwise identification, for each \(j\in J\) we get a diagram of sets \(i\mapsto X^{(i)}_j\). Because \(\mathbf{Set}\) has all (small) limits, each fiberwise diagram has a limit \(\varprojlim_i X^{(i)}_j\). Taking the disjoint union of these fiberwise limits over \(j\in J\) gives a set \(L=\bigsqcup_{j\in J}\varprojlim_i X^{(i)}_j\) with projection \(L\to J\). The universal property of limits holds fiberwise, hence \(L\to J\) is the limit of the original diagram in \(\mathbf{Set}/J\). Equivalently: the forgetful functor \(U:\mathbf{Set}/J\to\mathbf{Set}\) (which sends \(p:X\to J\) to \(X\)) creates limits: the limit of a diagram in the slice is the limit in \(\mathbf{Set}\) equipped with the induced map to \(J\). Thus \(\mathbf{Set}/J\) has all small limits.
Colimits. The same fiberwise argument works for colimits: for a diagram \(D:\mathcal I\to\mathbf{Set}/J\) form for each \(j\in J\) the colimit \(\varinjlim_i X^{(i)}_j\) in \(\mathbf{Set}\); assemble these fiberwise colimits into \(\bigsqcup_{j\in J}\varinjlim_i X^{(i)}_j\) with the projection to \(J\). Equivalently, the forgetful functor \(U\) also creates colimits (because the structure maps \(X^{(i)}\to J\) induce a canonical map \(\varinjlim_i X^{(i)}\to J\)). Hence \(\mathbf{Set}/J\) has all small colimits.
Thus \(\mathbf{Set}/J\) is complete and cocomplete; concretely all (co)limits are computed fiberwise (or as (co)limits in \(\mathbf{Set}\) equipped with the induced map to \(J\)). This is the usual fact that a slice of a cocomplete complete category is again complete and cocomplete (for \(\mathbf{Set}\) it is immediate).
Let \(p:X\to J\) and \(q:Y\to J\) be objects of \(\mathbf{Set}/J\). We claim there is an exponential object \(q^p: \underline{\operatorname{Hom}}_J(X,Y) \to J\) representing the functor $$ \operatorname{Hom}_{\mathbf{Set}/J}(-\times_J X,Y). $$
Concrete construction (fiberwise). For each \(j\in J\) let \(X_j\) and \(Y_j\) be the fibers of \(X\) and \(Y\) over \(j\). Define the set $$ \underline{\operatorname{Hom}}_J(X,Y) \;:=\; \bigsqcup_{j\in J} \operatorname{Hom}_{\mathbf{Set}}(X_j, Y_j), $$ with projection \(\pi:\underline{\operatorname{Hom}}_J(X,Y)\to J\) sending an element (a function \(X_j\to Y_j\)) to the index \(j\). There is an evaluation morphism in the slice $$ \operatorname{ev}:\underline{\operatorname{Hom}}_J(X,Y)\times_J X \longrightarrow Y $$ defined fiberwise by \((\varphi,x)\mapsto \varphi(x)\) in the fiber over \(j\). Given any \(r:Z\to J\) and a map \(h:Z\times_J X \to Y\) over \(J\), define \(\hat h:Z\to \underline{\operatorname{Hom}}_J(X,Y)\) by, for each \(z\in Z\) lying over \(j\), letting \(\hat h(z)\) be the function \(X_j\to Y_j\) given by \(x\mapsto h(z,x)\). Fiberwise this is well defined and gives a morphism over \(J\). Standard checking of naturality and the two triangular identities shows that \(\underline{\operatorname{Hom}}_J(X,Y)\) with \(\operatorname{ev}\) is the exponential in the slice. Thus \(\mathbf{Set}/J\) is cartesian closed. (Again this is the fiberwise cartesian-closure argument; see standard topos texts.)
In \(\mathbf{Set}\) the subobject classifier is \(\Omega=\{0,1\}\) with \(\text{true}:1\to\Omega\) picking \(1\). In the slice \(\mathbf{Set}/J\) the subobject classifier is the projection $$ \chi: J\times\Omega \longrightarrow J $$ (where \(\Omega=\{0,1\}\) and \(\chi\) is projection onto the first coordinate). The “true” morphism in the slice is the map $$ \mathrm{true}_J: J \to J\times\Omega,\qquad j\mapsto (j,1), $$ which lies over \(J\) (composing with projection gives the identity on \(J\)).
Given a monomorphism \(m:A\hookrightarrow X\) in the slice (so \(A\) and \(X\) are over \(J\), and \(m\) is over \(J\)), this is equivalent to a family of inclusions \(A_j\subseteq X_j\) for each \(j\in J\). Define the classifying map \(\chi_m:X\to J\times\Omega\) over \(J\) by sending an element \(x\in X_j\) to \((j, 1)\) if \(x\in A_j\) else \((j, 0)\). This map is over \(J\) and pulls back \(\mathrm{true}_J\) to exactly \(A\subseteq X\). The universal property of \((J\times\Omega\to J,\mathrm{true}_J)\) as subobject classifier in the slice is checked fiberwise (it reduces to the usual classifier in \(\mathbf{Set}\) on each fiber). Thus \(\mathbf{Set}/J\) has a subobject classifier.
Putting the pieces together:
Hence \(\mathbf{Set}/J\) is a (Grothendieck) topos; more precisely it is a (boolean, even) elementary topos, and all statements above are the standard slice-to-topos facts (see Mac Lane & Moerdijk for a textbook treatment).
Let’s do the full check that the evaluation map and the “curry/uncurry” construction give the adjunction $$ \operatorname{Hom}_{\mathbf{Set}/J}(Z,\underline{\operatorname{Hom}}_J(X,Y)) \cong \operatorname{Hom}_{\mathbf{Set}/J}(Z\times_J X,Y) $$ for objects \(p:X\to J, q:Y\to J, r:Z\to J\) of the slice \(\mathbf{Set}/J\). We’ll use the fiberwise concrete model of the exponential: $$ \underline{\operatorname{Hom}}_J(X,Y)=\bigsqcup_{j\in J}\operatorname{Hom}(X_j,Y_j) $$ with projection \(\pi:\underline{\operatorname{Hom}}_J(X,Y)\to J\) sending a map \(X_j\to Y_j\) to \(j\). Write \(E:=\underline{\operatorname{Hom}}_J(X,Y)\).
An element of \(E\) is a pair \((j,\varphi)\) where \(\varphi:X_j\to Y_j\). The fibered product \(E\times_J X\) consists of pairs \( ((j,\varphi),x) \) with \(x\in X_j\). Define $$ \mathrm{ev}:E\times_J X \longrightarrow Y,\qquad \mathrm{ev}(((j,\varphi),x)):=\varphi(x). $$ Check it is a map over \(J\): the composite \(q\circ\mathrm{ev}\) sends \(((j,\varphi),x)\) to the index of \(\varphi(x)\), namely \(j\); the projection \(E\times_J X\to J\) also sends \(((j,\varphi),x)\) to \(j\). So \(\mathrm{ev}\) lies in \(\mathbf{Set}/J\).
We will produce two maps $$ \Phi:\operatorname{Hom}_{\mathbf{Set}/J}(Z,E)\longrightarrow \operatorname{Hom}_{\mathbf{Set}/J}(Z\times_J X, Y) $$ and $$ \Psi:\operatorname{Hom}_{\mathbf{Set}/J}(Z\times_J X, Y)\longrightarrow \operatorname{Hom}_{\mathbf{Set}/J}(Z,E), $$ and show they are mutually inverse natural bijections.
(a) From \(h:Z\to E\) to \(\Phi(h):Z\times_J X\to Y\). Given \(h:Z\to E\) in the slice, form the map $$ h\times_J \mathrm{id}_X: Z\times_J X \longrightarrow E\times_J X,\qquad (z,x)\mapsto (h(z),x). $$ This is well-defined over \(J\) because if \(z\in Z\) lies over \(j\) then \(h(z)\) lies over the same \(j\), so \((h(z),x)\in(E\times_J X)_j\). Compose with evaluation and set $$ \Phi(h):=\mathrm{ev}\circ (h\times_J\mathrm{id}_X): Z\times_J X\longrightarrow Y. $$ Explicitly \(\Phi(h)(z,x)=\mathrm{ev}(h(z),x)\). \(\Phi(h)\) is a morphism in \(\mathbf{Set}/J\) because both factors are over \(J\).
(b) From \(g:Z\times_J X\to Y\) to \(\Psi(g):Z\to E\). Given \(g\) over \(J\), define \(\Psi(g)\) fiberwise: for each \(z\in Z\) lying over \(j\), define \(\Psi(g)(z)\in E\) to be the function $$ \Psi(g)(z) \;=\; \big( j, (X_j\to Y_j): x\mapsto g(z,x)\big). $$ In words: \(\Psi(g)(z)\) is the map \(X_j\to Y_j\) obtained by freezing the first coordinate \(z\) in \(g(z,-)\). This assignment is well-defined because \(g(z,x)\) lies in \(Y_j\) when \(x\in X_j\). So \(\Psi(g)(z)\) is indeed an element of the fiber \(E_j\), and thus \(\Psi(g):Z\to E\) is a map over \(J\).
We compute both composites and verify they are the identity.
(i) \(\Phi(\Psi(g)) = g\). Take \((z,x)\in Z\times_J X\) lying over \(j\). By definition of \(\Psi(g)\), \(\Psi(g)(z)\) is the function \(x'\mapsto g(z,x')\) in \(\operatorname{Hom}(X_j,Y_j)\). Then $$ \Phi(\Psi(g))(z,x)=\mathrm{ev}(\Psi(g)(z),x)=\big(\text{the function }x'\mapsto g(z,x')\big)(x)=g(z,x). $$ Thus \(\Phi(\Psi(g))=g\) pointwise.
(ii) \(\Psi(\Phi(h)) = h\). Take \(z\in Z\) with index \(j\). We must check \(\Psi(\Phi(h))(z)=h(z)\) (as elements of the fiber \(E_j\)). By definition, $$ \Psi(\Phi(h))(z) \;=\; \text{the function }(x\mapsto \Phi(h)(z,x)). $$ But \(\Phi(h)(z,x)=\mathrm{ev}(h(z),x)=h(z)(x)\). Hence the function \(x\mapsto\Phi(h)(z,x)\) is exactly the function \(h(z):X_j\to Y_j\). So \(\Psi(\Phi(h))(z)=h(z)\) for all \(z\), i.e. \(\Psi(\Phi(h))=h\).
Thus \(\Phi\) and \(\Psi\) are inverse maps between the Hom-sets, so we have a bijection.
The constructions \(\Phi\) and \(\Psi\) use only composition and product with \(\mathrm{id}_X\); checking naturality in \(Z\) (and also in \(Y\) and \(X\) as parameters) is routine: for a map \(u:Z'\to Z\) over \(J\), $$ \Phi(h\circ u) = \Phi(h)\circ (u\times_J\mathrm{id}_X), $$ and for \(g:Z\times_J X\to Y\), $$ \Psi(g\circ(u\times_J\mathrm{id}_X)) = \Psi(g)\circ u. $$ These equalities follow directly from the pointwise definitions \((u\times_J\mathrm{id}_X)(z',x)=(u(z'),x)\) and the fact that evaluation and composing commute in the obvious way. Therefore the bijection is natural in \(Z\) (and similarly in the other variable), so it is an adjunction isomorphism in the slice category.
We have exhibited:
and checked the two maps are inverses. This verifies the universal property of the exponential object in \(\mathbf{Set}/J\). Hence the slice is cartesian closed and the displayed \(E\) is indeed the exponential \(Y^X\) in \(\mathbf{Set}/J\).
Here’s another self-contained alternative proof of cartesian-closure for \(\mathbf{Set}/J\) by using the equivalence $$ \mathbf{Set}/J \simeq \prod_{j\in J}\mathbf{Set}, $$ and the elementary fact that a product of cartesian-closed categories is cartesian-closed with exponentials computed componentwise.
We'll (1) describe the equivalence of categories, (2) show the product \(\prod_{j\in J}\mathbf{Set}\) is cartesian closed and compute its exponentials, and (3) transport that structure back to \(\mathbf{Set}/J\).
Objects. An object of the slice \(\mathbf{Set}/J\) is a map \(p:X\to J\). For each \(j\in J\) define the fiber \(X_j := p^{-1}(\{j\})\). These fibers form a family \((X_j)_{j\in J}\). Conversely, given a family of sets \((A_j)_{j\in J}\) form the disjoint union \(\bigsqcup_{j\in J} A_j\) and equip it with the projection \(\pi:\bigsqcup_{j}A_j\to J\) sending each element of \(A_j\) to \(j\). Thus we have obvious assignments $$ F:\mathbf{Set}/J \longrightarrow \prod_{j\in J}\mathbf{Set},\qquad F(p:X\to J)=(X_j)_{j\in J}, $$ and $$ G:\prod_{j\in J}\mathbf{Set} \longrightarrow \mathbf{Set}/J,\qquad G((A_j)_{j\in J})=\Big(\bigsqcup_{j\in J}A_j \xrightarrow{\ \pi\ } J\Big). $$
Morphisms. A morphism \(f:(X\to J)\to(Y\to J)\) in the slice is a map \(f:X\to Y\) with the same composite to \(J\). This restriction implies \(f\) maps each fiber \(X_j\) into \(Y_j\), hence it corresponds to the family \((f_j:X_j\to Y_j)_{j\in J}\). Conversely a family \((g_j:A_j\to B_j)_{j\in J}\) induces a map on disjoint unions \(\bigsqcup_j A_j\to\bigsqcup_j B_j\) lying over \(J\).
Equivalence. The composites \(F\circ G\) and \(G\circ F\) are naturally isomorphic to the identities:
It is a general fact: if \(\{ \mathcal{C}_j \}_{j\in J}\) is a family of cartesian-closed categories, then the product category \(\prod_{j\in J}\mathcal{C}_j\) is cartesian closed and exponentials are computed componentwise. For completeness, sketch:
Since each \(\mathbf{Set}\) is cartesian closed (with exponentials \(B^A\) the set of functions \(A\to B\)), it follows immediately that \(\prod_{j\in J}\mathbf{Set}\) is cartesian closed, with exponentials computed componentwise: $$ \big( (Y_j)_{j\in J} \big)^{(X_j)_{j\in J}} \;=\; \big( Y_j^{X_j}\big)_{j\in J}. $$
Because \(F:\mathbf{Set}/J\to\prod_{j\in J}\mathbf{Set}\) is an equivalence, it preserves (up to isomorphism) all categorical structure that can be expressed by universal properties — in particular terminal object, products, and exponentials. Concretely:
Thus the equivalence makes it immediate that \(\mathbf{Set}/J\) is cartesian closed and that exponentials are computed fiberwise (i.e. by taking the disjoint union of the function-sets \(\operatorname{Hom}(X_j,Y_j)\) with projection to \(J\)).