I'm sorry if this ends up being a duplicate, but I cannot find an answer to my question (or maybe I just can't phrase it right!).
Suppose we have two continuous random variables $X$ and $Y$. Suppose I want to write (with an awful abuse of notation but I hope it gets my idea across) $$ f_X(x)=\int f_X(x|C)dP_C $$ where $P_C$ is the probability of the event $C:=\{X<Y\}$. This feels very wrong! I think my intuition is coming from $P(A,B) = P(A,B)/P(B)$, but I don't think it makes sense to write $f_X(x|C) = f_{X,C}(x,C)/f(C)$, since $C$ doesn't have a 'density' as such. Does it make more sense to condition on the event $C$, or would it be better to do something like this: Let $Z = X-Y$ $$ f_X(x)=\int_0^\infty f_X(x|Z=z)f_Z(z)dz $$ But in this case I'm not sure whether the integration variable or limits are right. Any help would be greatly appreciated (as well as suggestions for better notation in the first part!!). Thanks.
Let $X$ be any random variable. Fix $n$ as a positive integer and let $\{B_i\}_{i=1}^n$ be a partition of the sample space into $n$ disjoint events, so $B_i\cap B_j=\phi$ for $i\neq j$, and $\cup_{i=1}^n B_i=\Omega$. Then for each $x \in \mathbb{R}$ we have by the law of total probability \begin{align*} F_X(x) &= P[X\leq x]\\ &=\sum_{i=1}^n P[X\leq x|B_i]P[B_i]\\ &= \sum_{i=1}^n F_{X|B_i}(x)P[B_i] \end{align*} which gives us the "law of total CDF" (where we implicitly remove those terms $i$ for which $P[B_i]=0$). If we assume PDFs exist that can be obtained by differentiation then by differentiating both sides we obtain the "law of total PDF" $$f_X(x) = \sum_{i=1}^n f_{X|B_i}(x)P[B_i]$$ For your case we can use $n=2$, $B_1=C, B_2=C^c$ to obtain $$\boxed{f_X(x) = f_{X|C}(x)P[C]+f_{X|C^c}(x)P[C^c]}$$ where we simply remove the corresponding term if $P[C]=0$ or $P[C^c]=0$.
Now let $Z$ be a continuous random variable for which marginal PDF $f_Z(z)$ and joint PDF $f_{X,Z}(x,z)$ exist. Then \begin{align*} f_X(x) &= \int_{-\infty}^{\infty}f_{X,Z}(x,z)dz\\ &=\int_{-\infty}^{\infty} f_{X|Z}(x|z)f_Z(z)dz \end{align*} where the integral is implicitly restricted to the support of $f_Z$ (the region where it is positive). Note that in general you need $\int_{-\infty}^{\infty}$ rather than $\int_0^{\infty}$.