# Understanding law of total expectation

I am trying to understand the law of total expectation from the wikipedia article.

It states:

$\operatorname{E} (X) = \operatorname{E}_Y ( \operatorname{E}_{X \mid Y} ( X \mid Y))$

Furthermore, "One special case states that if $A_1, A_2, \ldots, A_n$ is a partition of the whole outcome space, i.e. these events are mutually exclusive and exhaustive, then

$\operatorname{E} (X) = \sum_{i=1}^{n}{\operatorname{E}(X \mid A_i) \operatorname{P}(A_i)}.$"

This second formulation makes intuitive sense to me. I'm having trouble understanding why it is just a special case though.

Is it possible for to use the law of total expectation with a $Y$ that does not partition the whole outcome space?

The first formula contains the conditional expectation of an integrable random variable, $X$, in relation to the measure of a second random variable, $Y$.
The second formula contains the conditional expectation of the random variable, $X$, with respect to a series of discrete events, $A_1, A_2,..., A_n$ which partition the outcome space, mutually exclusively and exhaustively.
$\mathsf E(X\mid A_1)$ is a constant value. It's the expected value of random variable $X$ when given the event $A_1$ occurs.
$\mathsf E(X \mid Y)$ is itself a random variable. It's the conditional expectation of random variable $X$ in relation to the measure of random variable $Y$.