checking that there is a functor $\texttt{Nil}_n: Ring \longrightarrow Set$ I want to show that $\forall n \geq 1$, there is a covariant functor $\texttt{Nil}_n: Ring \longrightarrow Set$ that sends a ring $R$ to the set $\{x\in R | x^n = 0\}$.
I have being thinking that the functor sends ring homomorphisms $f:X\longrightarrow Y$ to $\texttt{Nil}_n(f):\texttt{Nil}_n(X) \longrightarrow \texttt{Nil}_n(Y)$ with $\texttt{Nil}_n(f)(x)= f(x)$ if $f(x) \in Y$ and $\texttt{Nil}_n(f)(x)=0$ if $f(x) \notin Y$.
With that, I should verify if all the conditions in functor's definition are satisfied.
I have seen:
(1) $\forall A \in Ring$, it specifies a unique object $F(A)$ in $Set$ (Checked)
(2) $\forall f \in Hom_C (A, B)$, it specifies a morphism $F(f) \in Hom_D(F(A), F(B))$. (Checked)
It should hold also:
(3) $\forall A \in Ring$, $F(Id_A)= Id_{F(A)}$ (Problem)
(4) $\forall f: A \longrightarrow B$, $g:B \longrightarrow C$ then $F(g\circ f) = F(g) \circ F(f)$. (Problem)
I have some problems verifying the last two conditions. Any help?
Is that suficient to show what I wrote in the first sentence?
If I want to do the same with the functor $\texttt{Nil}: Ring \longrightarrow Set$ that sends a ring $R$ to its nilradical. What should the functor do to the ring homomorphisms $f:X \longrightarrow Y$?
Thank you.
 A: Let $f : R\to S$ be a ring homomorphism.
Let's first examine $\texttt{Nil}_n(f).$ You've written that $\texttt{Nil}_n(f)(x) = f(x)$ if $f(x)\in S$ and $0$ if $f(x)\not\in S.$ But $f(x)$ is always in $S,$ by definition - $f$ is a ring morphism with codomain $S$! So, the condition is unnecessary; you simply have
$$
\texttt{Nil}_n(f)(x) = f(x)
$$
for all $x\in \texttt{Nil}_n(R).$
One should check that this is well-defined. Well, if $x\in\texttt{Nil}_n(R),$ then by definition $x^n = 0$ in $R.$ Hence, $f(x)^n = f(x^n) = f(0) = 0,$ so that $f(x)\in\texttt{Nil}_n(S),$ and we actually have a well-defined map of sets.
Let's check the identity condition. Let $S = R$ and $f = \operatorname{id}_R,$ and let $x\in\texttt{Nil}_n(R).$ Then
$$
\texttt{Nil}_n(\operatorname{id}_R)(x) := \operatorname{id}_R(x) = x,
$$
so that $\texttt{Nil}_n(\operatorname{id}_R)$ is the identity of $R$ restricted to the set $\texttt{Nil}_n(R).$ This means exactly that $\texttt{Nil}_n(\operatorname{id}_R) = \operatorname{id}_{\texttt{Nil}_n(R)}.$ 
Notice that the above holds essentially because all the functor $\texttt{Nil}_n$ does to morphisms is restrict them to the subset $\texttt{Nil}_n(R)\subseteq R.$ That is, if we have a ring homomorphism $f : R\to S,$ we may also say $\texttt{Nil}_n(f) = \left. f\right|_{\texttt{Nil}_n(R)}.$ 
Now, you could check element-wise that the assignment $f\mapsto \texttt{Nil}_n(f)$ behaves nicely with respect to composition, but you can also see this immediately via our new description of $\texttt{Nil}_n(f).$ Let $f : R\to S$ and $g : S\to T$ be ring homomorphisms. Then
\begin{align*}
\texttt{Nil}_n(g\circ f) &= \left. \left(g\circ f\right)\right|_{\texttt{Nil}_n(R)}\\
&= \left. g\right|_{\texttt{Nil}_n(S)}\circ \left.f\right|_{\texttt{Nil}_n(R)}\quad\textrm{(because }\left.f\right|_{\texttt{Nil}_n(R)}(\texttt{Nil}_n(R))\subseteq \texttt{Nil}_n(S).)\\
&= \texttt{Nil}_n(g)\circ \texttt{Nil}_n(f).
\end{align*}
Your functor $\texttt{Nil}$ which assigns to $R$ the nilradical of $R$ should do essentially the same thing - simply restrict a morphism $f : R\to S$ to the nilradical. Notice also that your work with the $\texttt{Nil}_n$ immediately implies this is well-defined, because $\texttt{Nil}(R) = \bigcup_{n\geq 1}\texttt{Nil}_n(R).$
