Identity for special case of Markov chain 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.
 A: $\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$.
