Show that partitions and equivalence relations are interdefineable. I am trying to prove Proposition 4.32 in "Sets for Mathematics" by Lawvere and Rosebrugh. It goes like this.


*

*if $p$ is a partition of a set $X$, then $p=p_{R_p}$ and conversely if $R$ is an equivalence relation on $X$ then $R=R_{p_R}$.


Now, a partition $p$ of $X$ is just an epimorphism $p:X \rightarrow I$, the $R_p$ is gotten from taking the pullback of $p$ along itself, yielding an equivalence relation. Conversely, from an arbitrary equivalence relation $(p_0,p_1):R \rightarrow X \times X$, which is just a monomorphism into $X \times X$ we get a partition of $X$ by taking the coequalizer $p_R: X \rightarrow P_R$ of the $p_0,p_1:R \rightarrow X$ coming from composing $(p_0,p_1)$ with the projections.
A relation $R$ on $X$ is called an equivalence relations iff it is reflexive, symmetric and transitive.
$R$ is reflexive iff $R$ contains the opposite relation $R^{\text{op}}$.
$R$ is symmetric iff for all elements $(x,y)$ of $X \times X$, $(x,y) \in R$ implies $(y,x) \in R$.
$R$ is transitive iff for all elements $(x,y)$ and $(y,z)$ of $X \times X$, if $(x,y) \in R$ and $(y,z) \in R$ then $(x,z) \in R$.
Now, my problem is that the $p_{R_p}$ as above does not generally have the same codomain as the $p$ it is gotten from since $p_{R_p}:X \rightarrow P_{R_p}$ whereas $p:X \rightarrow I$. Perhaps one can get an isomorphism from $P_{R_p}$ to $I$ that does it, but as such it seems likely that the proposition is ill-framed. I think the problems are similar in the other case as well, since it really makes no sense to say that $R=R_{p_R}$ only that they are isomorphic as sets?
Many thanks in advance!
EDIT:
Okay let me try for the first part, $p \cong p_{R_p}$. It is enough to show that $(p,I)$ is a coequalizer of $p_0,p_1:R_p \rightarrow X$. Since $R_p$ is a pullback of $p$ along itself, $pp_0=pp_1$ so $p$ coequalizes $p_0$ and $p_1$. Since $P_{R_p}$ and $p_{R_p}$ is a coequalizer of $p_0$ and $p_1$ there exists a unique $\bar{p}:P_{R_p} \rightarrow I$ such that $p=\bar{p}p_{R_p}$. To show the UMP of coequalizers of $p_0,p_1$ let $T$ be arbitrary and $t:X \rightarrow T$ such that $tp_0=tp_1$. Then a $\bar{t}:I \rightarrow T$ must be found such that $t=\bar{t}p$. How can such a $\bar{t}$ be found? 
UPDATE:
Okay now I think I got it, for any $i$ in $I$ let $x$ be any preimage of $i$ under $p$, which exists since $p$ is surjective. Define $\bar{t}(i)$ for any $i$ in $I$ as follows $\bar{t}(i)=t(x)$ for the $x$ in the preimage of $i$ under $p$ as above. This is well-defined since if $y$ in $X$ is another preimage of $i$ under $p$, $p(y)=i$ and then by the UMP of $R_p$ there is a unique $\phi$ such that $x=p_1 \phi$ and $y=p_0 \phi$. Then, since $t p_0 = t p_1$, also $t p_0 \phi = t p_1 \phi$ and so it follows that $t x = t (p_1 \phi) = t (p_0 \phi) = t y$, so $\bar{t}$ is well defined. In order to prove that $t = \bar{t}p$ let $x$ be any element of $x$ and let $i=p(x)$. Then $(\bar{t}p)(x)=\bar{t}(p(x))= \bar{t}(i)=t(x)$ since $x$ is in the preimage of $i$ under $p$.
For the other part we prove ($\star$) first:
Let $x,x' \in X$ such that $p_R x = p_R x'$ then we need to prove, there is an $r \in R$ such that $p_0r = x$ and $p_1r= x'$. How to prove that such an $r$ exists? My thinking is that since $R$ is reflexive, there is an $r:X \rightarrow R$ such that $p_0r = 1_X =p_1 r$ which means that $p_0r x' = p_1rx'= x'$ and also $p_0 r x =p_1 r x = x$. But then $(p_Rp_0)rx = (p_Rp_1)rx$ since $p_R p_0= p_R p_0$ but how does that bring me any further?
Also, afterwards I need to check that $t_0 = p_0 \bar{t}$ and $t_1 = p_1 \bar{t}$ and uniqueness. But to show e.g. $t_0 = p_0 \bar{t}$ i would have to show $t_0(s) = (p_0 \bar{t})(s)$ for all $s \in T$, but the RHS of this equation reads $p_0 (\bar{t}(s)) = p_0 (t_0(s),t_1(s))$ which is not obviously equal to $t_0(s)$ even after projections, so how does this even work?
 A: I think what the authors want to say by $p=p_{R_p}$ is that $p$ "is" the coequalizer of $p_0,p_1 : R_p = X\times_I X \to X$. By $R=R_{p_R}$ they mean that $R$ "is" the pullback of $p_R: X\to X\amalg_R X$ along itself. 
As common in category theory, "being" a coequalizer or pullback of something just means it satifies the universal property. Usually two of such objects are isomorphic via a unique isomorphism.
Edit: Now for some hints:
Let $p: X\to I$ be an epimorphism and $p_0,p_1:R_p = X\times_I X\to X$ a pullback of $p$ along itself. Let $T$ be a set with morphism $t:X\to T$ such that $tp_0=tp_1$. Then $\bar t: I\to T$ can be defined as follows: Given $i\in I$ find a preimage $x\in X$ of $i$ via $p$. Then set $\bar t(i)=t(x)$. (Why is $\bar t$ well defined? And why is it unique?)
Now let $(p_0,p_1):R\to X\times X$ be an equivalence relation. Let $p_R:X\to P_R = X\amalg_RX$ be the coequalizer of $p_0,p_1$. Check the following property:


*

*$(\star)$ Since $R$ is an equivalence relation, two elements $p_R(x),p_R(x')\in X\amalg_RX$ are equal iff there is a $r\in R$ such that $p_0(r)=x$ and $p_1(r)=x'$, i.e. iff $(x,x')\in R$. (Check with concrete form of the coequalizer. Note that if $R$ is not an equivalence relation, we have to make the equivalence closure of $R$ first.)


Let $T$ be a set with morphisms $t_0,t_1:T\to X$ such that $p_Rt_0=p_Rt_1$. Then $\bar t: T\to R$ can be defined as follows: Given $s\in T$ consider $(t_0(s),t_1(s))\in X\times X$. Since $p_Rt_0(s)=p_Rt_1(s)\in X\amalg_RX$, by $(\star)$ we have $(t_0(s),t_1(s))\in R$. Set $\bar t(s)=(t_0(s),t_1(s))$. (Check uniqueness.)
P.S: You got the definition of a reflexive relation wrong. It should be:

$R$ is reflexive iff $(x,x)\in R$ for all $x\in X$.

