How to understand $E(X) = E(X|\mathcal{D})P(\mathcal{D}) + E(X|\mathcal{D}^c)P(\mathcal{D}^c)$ when $P(\mathcal{D}) = 0$ Suppose $Y \in \mathbb{R}^n$ and $Z \in \mathbb{R}^n$ are random vectors, where $Y$ follows a $MVN(\mu, \Sigma)$ distribution. Let $X \in \mathbb{R}^{n \times p}$ be a full-rank fixed matrix of constants. Let $E = Y - \hat{Y}$ denote the residuals of performing OLS regression, where one would obtain $E$ by projecting $Y$ onto the orthogonal complement column space of $X$.
By the law of total expectation, does the following hold?
$$E[g(Z,Y)] = E[g(Z,Y)|\mathcal{D}]P(\mathcal{D}) + E[g(Z,Y)|\mathcal{D}^c]P(\mathcal{D}^c)$$
where $g(\cdot, \cdot)$ is a function, and $A \in \mathbb{R}^{n \times n}$ and $b \in \mathbb{R}^n$ are a matrix and vector of constants, respectively, and $\mathcal{D} = \{AY \geq b, E = E_0\}$.
I wasn't sure if it would hold because of the conditioning event $E=E_0$, which I interpret as conditioning on observing a particular vector of residuals $E_0$. Because the residuals $E$ are continuous, I think the probability of observing $E = E_0$ would be 0. Does that imply the following: $$E[g(Z,Y)] \overset{?}{=} 0 + E[g(Z,Y)|\mathcal{D}^c]P(\mathcal{D}^c)$$
 A: If $P(\mathcal{D}) = 0$ then $P(\mathcal{D}^c) = 1$, this is because $\{\mathcal{D}, \mathcal{D}^c\}$ are a disjoint set: $\mathcal{D}$ can happen or it cannot. Plugging these values into the relevant expression yields $E(X) = E(X|D^c)$, which will generalise to $E(g(Z,Y)) = E(g(Z,Y)|D^c)$.
In essence, if you know $\mathcal{D}$ did not happen for sure, then your expected value of $X$, $E(X)$ should be adjusted for the fact that $\mathcal{D}$ did not occur.
A: $\newcommand{\E}{\operatorname{E}}$I think this is something where a more rigorous definition of conditional expectation helps. Let $(\Omega, \mathscr F, P)$ be a probability space with $X : \Omega\to\mathbb R^n$ a random vector. For a sub-$\sigma$-algebra $\mathcal G$ of $\mathscr F$ the conditional expectation of $X$ on $\mathcal G$, denoted $\E[X\mid \mathcal G]$, is an almost surely unique random variable that is $(\mathcal G, \mathbb B)$-measurable and
$$
\int_A \E[X \mid \mathcal G] \,\text dP = \int_A X \,\text dP
$$
for all $A \in \mathcal G$.
This is for conditioning on a $\sigma$-algebra, not a single event. If we want to condition on a single event $D$ we can take $\mathscr D := \{\emptyset, D, D^c, \Omega\}$ as the $\sigma$-algebra generated by this event. $\E[X \mid \mathscr D]$ is constant on $D$ and $D^c$ otherwise it's not $\mathscr D$-measurable, so $\E[X\mid D] = \E[X \mid \mathscr D](\omega)$ for $\omega\in D$.
If $P(D)=1$ this means
$$
\E[X] = \int_D X\,\text dP = \int_D \E[X\mid \mathscr D]\,\text dP = \E[X \mid D] P(D) = \E[X \mid D].
$$
Thus if $P(D)=1$ then the value that $\E[X\mid\mathscr D]$ takes on $D$ is just $\E[X]$. Intuitively this makes sense because $D^c$ is just a measure zero slice of $\Omega$ that we're shaving off and since $\E[X\mid \mathscr D]$ is only defined almost surely, it would be very strange if we got different behavior by this modification on a null set.
If instead $P(D)=0$ then
$$
0 = \int_D X\,\text dP = \E[X \mid D] P(D)
$$
and we can define $\E[X \mid D]$ arbitrarily since its values don't actually affect anything.
