# Bayes Theorem for Baum-Welch algorithm

I've been reading the Baum-Welch algorithm and somewhere it mentioned this statistical property: $$P(X \mid Y,Z) =\frac{ P(X,Y \mid Z)}{P(Y \mid Z)}$$ being based on Bayes' Theorem. I do understand the basic Bayes' Theorem, which is, $$P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)},$$ but I can't seem to figure out $$P(X \mid Y,Z) =\frac{ P(X,Y \mid Z)}{P(Y \mid Z)}$$.

$$\mathbb P( A \mid B) = \frac{\mathbb P(A , B) }{\mathbb P(B) }$$
From that, for three events $$X,Y$$ and $$Z$$, we have: \begin{align} \mathbb P( X \mid Y,Z ) = \frac{\mathbb P(X, Y,Z)}{\mathbb P(Y,Z)} \qquad (*) \end{align} Morevoer, $$\mathbb P(X,Y \mid Z) = \frac{\mathbb P(X, Y,Z)}{\mathbb P(Z)}$$ thus, $$\mathbb P(X, Y,Z) = \mathbb P(X,Y \mid Z) \mathbb P(Z).$$ If we use this equality in $$(*)$$ we get,
\begin{align*} \mathbb P(X \mid Y, Z) &= \frac{ \mathbb P(X,Y \mid Z) \mathbb P(Z)}{\mathbb P(Y,Z)} \\ &= \frac{ \mathbb P(X,Y \mid Z) }{\mathbb P(Y \mid Z)}. \end{align*} The last line comes from the fact that $$\frac{\mathbb P(Z)}{\mathbb P(Y,Z)} = \frac{1}{\mathbb P(Y \mid Z)}$$ So finally,
$$\mathbb P(X \mid Y, Z) = \frac{ \mathbb P(X,Y \mid Z) }{\mathbb P(Y \mid Z)}.$$