How is this random variable $Y$ defined rigorously? I have come across this question and gave it a try. To not distort the content, I post the original question in French.

On se donne $X$ une variable aléatoire tirée selon une loi de Poisson de paramètre $2$. On lance alors $X$ dés et on note $Y$ le nombre de $1$ obtenus sur les dés. Déterminer $\mathbb{E}[Y | X]$.

Translation: Let $X$ be a random variable drawn according to a Poisson distribution of parameter $2$. We throw $X$ dice and we note $Y$ the number of $1$ obtained on the dice. Determine $\mathbb{E}[Y \mid X]$.
Could you please confirm if my solution is correct?

We have $Y1_{\{X=n\}} \sim \operatorname{Binomial}(n, 1/6)$. Then $\mathbb E[Y1_{\{X=n\}}] = n/6$. Also, $$\mathbb E[Y|X] = \sum_{n=0}^\infty \frac{\mathbb E [Y1_{\{X=n\}}]}{\mathbb P[X=n]}1_{\{X=n\}} = \sum_{n=0}^\infty \frac{n/6}{2^n e^{-2}/n!}1_{X=n} = \sum_{n=0}^\infty \frac{nn!}{6.2^n e^{-2}}1_{\{X=n\}}.$$

Updates:

*

*Naively, I write "$Y|X \sim \operatorname{Binomial}(X, 1/6)$" and get $\mathbb E[Y|X] = X/6$. But we never define $Y|X$ in probability theory. As such, I feel the the crux is to write the mathematical form of $Y$.


*What is the mathematical expression of the sentence "We throw $X$ dice and we note $Y$ the number of $1$ obtained on the dice"?


*If $A$ is a measurable set and $f$ a measurable function, the expression $Y := X1_A$ or $Y := f(X)$ makes sense to me. Another example is the expression of conditional expectation $\mathbb E[Z|X]$. This is what I meant by "mathematical expression", i.e., a well-defined formula.


*Of course, $Y$ and $X$ in the exercise is related by "We throw $X$ dice and we note $Y$ the number of $1$ obtained on the dice". What I'm looking for is a mathematical expression of this sentence.


*To avoid subtle misconception, I prefer a measure-theoretic construction of $Y$.

Let $X$ be a random number following a Poisson distribution with parameter $\lambda = 2$. $X$ dice are thrown and $Y$ is observed, where $Y$ is the number of $1$'s rolled on the dice. Determine $E[Y|X]$.
Recall these base formulas, conditional probability:
$P[Y=y |  X=x] =  \frac{P( (Y=y)  \cap  (X=x) )}{P(X=x)}$
and conditional expectation:
$$\mathbb E[Y|  X=x] = \sum_{y}  y \times P[Y=y |  X=x] $$
For the conditional probability, the probability in the numerator for $X$ is Poisson with $\lambda = 2$ and for $Y$ is binomial based on the value of $X$ - a $1$ can appear on any of $X$ dice with a probability of $\frac16$ on each fair die. The denominator is also Poisson with parameter $\lambda = 2$, so these cancel.  The purpose of the denominator in this formula is to scale the sum of probabilities to one.  If the value for $X$ is given then the overall distribution is binomial.  It does not matter from which distribution $X$ was drawn, since $Y$ is defined as an indicator over all values $0$ to $X$.
For example, if there are $7$ fair dice, then the value of $Y$ will range from $0$ to $7$.
$$P[Y=y |  X=7] =  \left[ {7 \choose y}\biggl(\frac16\biggr)^y \biggl(\frac56\biggr)^{(7-y)} \times \frac{2^7e^{(-2)}}{7!} \right] \div \frac{2^7e^{(-2)}}{7!} $$
For a given $X$ in general, the expected value is over all possible values of $Y$ from $0$ to $X$, the expected (average) number of $1$'s appearing on $X$ dice is:
$$\mathbb E[Y|X] = \sum_{y}  y \times {X \choose y}\biggl( \frac16\biggr) ^y \biggl(\frac56\biggr)^{(X-y)} = \frac{X}{6}$$
The expected value of a binomial distribution is $np$ where $n = X$ and $p = \frac16$.
The value of the Random Variable $Y$ is given by $Y \in \{{0, 1, 2, ..., X}\}$ since it is the count of $1$'s appearing on $X$ dice.  Each throw of a die to observe whether a $1$ appears is a Bernoulli random trial.  In this case the appearance of a $1$ on a die is a success (assigned value $1$) and the appearance of any other number on a die is a failure (assigned value $0$).  This is an indicator function for the value $1$ appearing.  The distribution of a throw of multiple dice (where the number of dice is given by random variable $X$) to count the number of $1$'s that appear is collectively a Binomial Distribution.  So the formulas relevant to random variable $Y$ are:
$$Y \in \{0, 1, 2, ..., X\}$$
$$Y = \sum_{i=1}^X{\mathbf1_{[x_i = 1]}}$$
$$P[Y=y |  X=n] =  {n \choose y}\biggl(\frac16\biggr)^y \biggl(\frac56\biggr)^{(n-y)} $$
Given $X$, the values for $Y$ and $P[Y]$ can be tabulated in columns where $\sum_{y}{P[Y]} = 1$.
The indicator function could be written in longer form as follows:
Let $A$ be the event of rolling a $1$ on a throw of one die.
$$Y = \mathbf1_{A_1} + \mathbf1_{A_2} + ... + \mathbf1_{A_X}$$
$$Y = \sum_{i=1}^X{\mathbf1_{A_i}}$$
$\mathbf1_A = 1$ if $x_i = 1$
$\mathbf1_A = 0$ if $x_i \neq 1$
where $x_i$ is the value on the $i^{th}$ die for $i = 0, 1, 2, ..., X.$
This can also be notated as $$Y = \mathbb{I}_{A_1} + \mathbb{I}_{A_2} + ... + \mathbb{I}_{A_X} =  \sum_{i=1}^X{\mathbb{I}_{A_i}}$$
