TITLE: Is there a "partial function" approach to subobjects in category theory?
QUESTION [5 upvotes]: Given a relation $f : X \rightarrow Y$, lets define that the source of $f$ is $X$, and that the domain of $f$ is the set of all $x$ such that there exists $y \in Y$ satisfying $(x,y) \in f$. Thus the domain of a partial function is the set of all inputs for which it is defined.
Now given a set $X$, a subset of $X$ can be characterized as a partial function $f : X \rightarrow 1$. (Intuitively, the subset represented by $f$ is precisely the domain of $f$). This is rather convenient, because the preimage of a "subset" $f$ under a relation $g$ can simply by written $f \circ g$, where $\circ$ denotes the composition of relations.
Similarly, given a group $G$, a subgroup of $G$ can be characterized as a partial function $f : G \rightarrow 1$ with the property that the domain of $f$ is in fact a subgroup of $G$ in the classical sense.
My question is, do the above observations have any interesting category-theoretic applications or interpretations? And is there a "partial function" approach to subobjects in category theory, whatever that may mean?

REPLY [2 votes]: The usual way of internalizing the notion of subobject is by that of a subobject classifier. See wikipedia and nLab.
Rather than partial functions, the main idea is, in the case of $\mathbf{Set}$, to define $\Omega = \{ F, T \}$ and to represent a subobject by its indicator function
$$\chi_S : X \to \{ F, T \} : x \mapsto \begin{cases} F & x \notin S \\ T & x \in S \end{cases} $$
The condition that $S$ is the subobject classified by $\chi_S$ is that the following square
$$ \begin{matrix}S &\to& 1 \\ \downarrow & & \downarrow \\ X &\xrightarrow{\chi_S}& \Omega \end{matrix} $$
is a pullback diagram, where $1 \to \Omega$ is the function picking out the element $T$. In $\mathbf{Set}$, the canonical pullback is defined by
$$ \{ (x, *) \in X \times 1 \mid \chi_S(x) = T \} $$
which is naturally bijective to the set
$$ \{ x \in X \mid \chi_S(x) = T \} = S $$

If you're really keen on partial functions, there's a special kind of category called an allegory that is analogous to sets and binary relations rather than sets and functions. See Berci's answer for more detail.