Consider $P(X,Y)$ discrete and $Z = f(Y)$ with $f$ deterministic. The function $f$ identifies a partition of the elements of the alphabet $\mathcal{Y}$ of $Y$. Each outcome $z \in \mathcal{Z}$ is a subset $z \subseteq \mathcal{Y}$. Let $Z' = f'(Y)$ be identical to $Z$ except for two elements $z\_1', z\_2' \in \mathcal{Z}'$ that are derived from $z\_1, z\_2 \in Z$ by "moving" one element $\bar{y} \in z\_1$ from $z\_1$ to $z\_2$. This means that $z\_1' = z\_1 \setminus \{\bar{y}\}$ and $f'(\bar{y}) = z\_2' = z\_2 \cup \{\bar{y}\}$. Does the following relationship hold?


$$
P(X=x, Y=y \mid Z=z\_1) = P(X=x, Y=y \mid Z'=z\_1') \cdot \frac{P(Z=z\_1)}{P(Z'=z\_1')}
\quad \text{for} \quad
y \ne \bar{y}
$$


If correct, does it also imply $P(X=x, Y=y, Z=z\_1) = P(X=x, Y=y, Z=z\_1')$ for $y \ne \bar{y}$? If not, please, provide a counterexample.



Identity for special case of Markov chain
$\newcommand{\Y}{\mathcal{Y}}\newcommand{\ZZ}{\mathcal{Z}}$It appears that for all $u\in\Y$ and all $z\in\ZZ$ we have
\begin{equation\*}
 f(u)=z\iff u\in z \tag{1}
\end{equation\*}
and
\begin{equation\*}
 f'(u)=\begin{cases}
 z\_1'&\text{ if }u\in z\_1'=z\_1\setminus\{\bar y\}, \\ 
 z\_2'&\text{ if }u\in z\_2'\cup\{\bar y\}, \\ 
 f(u)&\text{ if }u\notin z\_1'\cup z\_2'=z\_1\cup z\_2.
 \end{cases}
 \tag{2}
\end{equation\*}


Then the identity
\begin{equation\*}
 P(X=x,Y=y|Z=z\_1)=P(X=x,Y=y|Z'=z\_1')\frac{P(Z=z\_1)}{P(Z'=z\_1')} \tag{3}
\end{equation\*}
does not hold in general, even if $y\ne\bar y$. Indeed (assuming $P(Z=z\_1)\ne0$ and $P(Z'=z\_1')\ne0$), we can rewrite (3) as
\begin{equation\*}
 P(X=x,Y=y,Z=z\_1)=P(X=x,Y=y,Z'=z\_1')\frac{P(Z=z\_1)^2}{P(Z'=z\_1')^2}. \tag{5}
\end{equation\*}
However,
\begin{equation\*}
 P(Z=z\_1)=P(f(Y)=z\_1)=P(Y\in z\_1)=P(Y\in z\_1'\cup\{\bar y\})
 =P(Y\in z\_1')+P(Y=\bar y)
\end{equation\*}
and
\begin{equation\*}
 P(Z'=z\_1')=P(f'(Y)=z\_1')=P(Y\in z\_1'),
\end{equation\*}
so that
\begin{equation\*}
\text{$P(Z'=z\_1')=P(Z=z\_1)$ iff $P(Y=\bar y)=0$. }\tag{6} 
\end{equation\*}
Also,
\begin{multline\*}
 P(X=x,Y=y,Z=z\_1)=P(X=x,Y=y,f(y)=z\_1) \\ 
 =P(X=x,Y=y)1(f(y)=z\_1)=P(X=x,Y=y)\,1(y\in z\_1)
\end{multline\*}
and
\begin{multline\*}
 P(X=x,Y=y,Z'=z\_1')=P(X=x,Y=y,f'(y)=z\_1') \\ 
 =P(X=x,Y=y)\,1(f'(y)=z\_1')=P(X=x,Y=y)\,1(y\in z\_1'), 
\end{multline\*}
so that
\begin{equation\*}
 P(X=x,Y=y,Z=z\_1)=P(X=x,Y=y,Z'=z\_1') \tag{7}
\end{equation\*}
if $y\ne\bar y$.
Thus, (5) does not hold for all $y\ne\bar y$ unless $P(Y=\bar y)=0$, and hence (3) does not hold for all $y\ne\bar y$ unless $P(Y=\bar y)=0$.


On the other hand, the identity
\begin{equation\*}
 P(X=x,Y=y|Z=z\_1)=P(X=x,Y=y|Z'=z\_1')\frac{P(Z'=z\_1')}{P(Z=z\_1)}, 
\end{equation\*}
which is equivalent to (7) (which also was in question), will always hold for all $y\ne\bar y$.


