Suppose $Y=\{y_1,\ldots,y_m\}$ partitions the set $X=\{x_1,\ldots,x_n\}$. I would like to define a function $y: X \to Y$ which returns $y \in Y$ if and only if $x \in y$. Is there a way to write this more formally?
I came up with
$$y(x) = \{y \in Y :y \ni x\}$$
or
$$y(x) = \{y:y \in Y \ \land \ x \in y \}$$
but I am not sure this makes sense.
The idea $$y(x) = \{y \in Y :y \ni x\}$$ is fine for me (but*). Since $Y$ is a partitions elements of it are not $\emptyset$ and for all $x\in X$ there are only one $y\in Y$ such that $x\in y$. If you like equivalence relation there is one connected with partition. So if $\sim\subset X\times X$ would be a equivalence relation such that $X/_\sim=Y$ your function could be represented as mapping $$X \ni x\mapsto [x]_{\sim}\in X/_\sim. $$
Edit*: Of course $\{y \in Y :y \ni x\}$ is a singleton of our point of interest as it was pointed out. I missed that sorry and thanks to @LeanderTilstedKristensen. However if you really want be fancy you can write $$y(x) = \bigcup\{y \in Y :y \ni x\}$$ in the spirit of descriptive set theory. But this is more like joke than real application thing.