How to prove that $\frac{\int_{\{X\in B\}} P(A|X)(\omega)dP(\omega)}{P(X\in B)}=P(A\mid X\in B)$? Let $(\Omega, \mathcal{A}, P)$ be a sample space and $X: (\Omega, \mathcal{A}) \rightarrow (\mathbb{R}, \mathcal{B})$ is a random variable. The conditional probability is given by
$$\frac{1}{P(X\in B)}\int_{\{X\in B\}} P(A|X)(\omega)dP(\omega)=P(A\mid X\in B)$$
for $P( X\in B)>0$. I have seen the above equation in several sources but I have not seen any proof for it. Could you please show me why this is true or direct me to a textbook where it is proved.
 A: The answer is a one-liner, but that's disingenuous because (as you can see) it's going to take me some time to get to it!
Before setting out, let's establish a general yet accurate way to visualize what's going on.
Seeing things

This figure schematically draws $\Omega$ as the interior of a rectangle.
When $X:\Omega\to \mathbb R$ is any function, it has a "contour map" of level sets of the form $X^{-1}(b)$ for any contour level $b\in\mathbb R.$  Clearly, no distinct level sets may intersect and so they partition (a set-theoretic term), "dissect" (a statistical term), or "foliate" (a topological term) $\Omega.$  For our purposes the geometrical details of this dissection won't matter, so I have felt free to sketch each of the level curves as a vertical line segment, even though they needn't have the same shapes, sizes, or cardinalities.

Below, I will be discussing two kinds of events: measurable subsets of $\Omega.$ $\mathcal A$ is an arbitrary event in $\Omega.$  Because it could be anywhere, and we are free in this schematic to re-order the points within each of the vertical lines of the dissection any way we please (and separately from each other), I have drawn things so that the intersections of $\mathcal A$ with the level curves $X^{-1}(b)$ are segments originating at the bottom (dashed) axis.  In this fashion we may conceive, with wide generality and accuracy, of any (single) event as being a region under some curve.
The event $\mathcal B$ bordered on the left and right by dashed lines is special because it is comprised of entire level curves.  This means it is of the form $X^{-1}(B)$ where $B\subset \mathbb R$ is the set of "heights" of $X$ within $\mathcal B$ on the contour map.  This helps us visualize the distinction between arbitrary events and events relative to the subalgebra generated by $X.$  The latter are all unions of level sets: collections of vertical strips.
It will do no harm to think of the probability measure $\mathbb P$ as being uniform: thus, areas in this figure represent probabilities, with the entire rectangle understood as having a unit area.
Finally, here is a sketch of the conditional expectation of the indicator function $\mathscr I_\mathcal A$ with respect to this dissection.  (Recall that $\mathscr I_\mathcal A$ assigns the value $1$ to all points in $\mathcal A$ and the value $0$ to all other points.)

The horizontal line labeled with the conditional expectation $E[\mathscr I_\mathcal A\mid X\in B]$ is drawn at the average height of $A$ within $\mathcal B.$  As we are taught in Calculus (for real functions), that average is the integral of the height divided by the width of the strip representing $\mathcal B.$  That is, we have replaced the area of an arbitrary shape $\mathcal A \cap \mathcal B$ by a rectangle of the same area, spanning the same width as $\mathcal B$ in the horizontal direction.

This height equals the probability of $\mathcal A$ conditional on $\mathcal B.$

If you have managed to follow my descriptions, this is obvious in the picture, for if you were to throw darts randomly (and uniformly) at it, the (limiting) fraction of darts landing within $\mathcal B$ that are also in $\mathcal A$ is the same as the (limiting) fraction landing within $\mathcal B$ at heights between $0$ and $E[\mathscr I_\mathcal A\mid \mathscr B].$
Let's do this again in algebraic notation.  As is common in such measure-theoretic situations, this result is a matter of notation and definitions, so let's begin with these simple preliminaries.
Conditioning on a sigma-algebra
When  $\mathfrak G\subset \mathfrak F$ is a subalgebra of the probability space $(\Omega,\mathfrak F, \mathbb P),$ a conditional expectation $E$ for any integrable $\mathfrak F$-measurable random variable $Y$ is its "projection" $E[Y\mid\mathfrak G]$  onto some $\mathfrak G$-measurable random variable $E[Y\mid \mathfrak G]$ for which
$$\int_{\mathscr B} Y\mathrm d \mathbb P = \int_{\mathscr B} E[Y\mid\mathfrak G]\mathrm d \mathbb P\tag{1}$$
for any $\mathfrak G$-measurable event $\mathscr B.$
Applying $(1)$ to $Y = \mathscr I_\mathcal A,$ the indicator of some $\mathfrak F$-measurable event $\mathcal A,$ gives
$$\Pr(\mathcal A \cap \mathcal B) = \int_{\mathcal A \cap \mathcal B} \mathrm{d}\mathbb P = \int_{\mathcal B} \mathscr I_{\mathcal A}\mathrm\, d \mathbb P = \int_{\mathcal B}E[\mathscr I_{\mathcal A}\mid \mathfrak G]\mathrm d \mathbb P.\tag{2}$$
Conditioning on an event
When $\Pr(\mathcal B)\ne 0,$ according to the definition of conditioning on a single event $\mathcal B$,
$$\Pr(\mathcal A\mid \mathcal B) = \frac{\Pr(\mathcal A \cap \mathcal B)}{\Pr(\mathcal B)}.
\tag{3}$$
Substituting the conditional expectation expression $(2)$ for $\Pr(\mathcal A \cap \mathcal B)$ into $(3)$ yields
$$\Pr(\mathcal A \mid \mathcal B) = \frac{1}{\Pr(\mathcal B)} \int_{\mathcal B}E[\mathscr I_{\mathcal A}\mid \mathfrak G]\mathrm d \mathbb P.\tag{4}$$
Measure-theoretic definition of conditional probability
Apply the preceding remarks to the case where $X$ is a $\mathfrak F$-measurable random variable, $B$ is a real Borel set, $\mathcal B = X^{-1}(B),$ and $\mathfrak G$ is the sigma-algebra generated by $X.$  The conditional probability is defined in terms of expectations as
$$\Pr(\mathcal A \mid X \in B) = \int_{X^{-1}(B)} E[\mathscr I_{\mathcal A}\mid \mathfrak G]\mathrm d \mathbb P = \int_{X^{-1}(B)} \Pr(\mathcal A \mid X)\mathrm d \mathbb P.\tag{5}$$
Answer to the question
Since $\Pr(\mathcal B) = \Pr(X \in B),$ the statement in the question is a restatement of $(4)$ using $(5).$
