# How is the equation $P(X_1>X_2) = \displaystyle \int_{0}^1 P(X_1>X_2 | X_2=x) f_{X_2}(x) dx$ derived?

In Probability and uniform distribution, the following equation is used:

$P(X_1>X_2) = \displaystyle \int_{0}^1 P(X_1>X_2 | X_2=x) f_{X_2}(x) dx$

How the equation is derived? Base on which definition or theorem?

It follows from conditioning on $X_2$. In the case when $X_2$ is a discrete random variable, we have
When $X$ is a continuous random variable, the idea is the same, but we replace $P(X_2=x_2)$ with the density of $X_2$, and replace the sum with an integral. This gives the expression you wrote in your question. There are some technical issues with doing this, but I think you are at a point where you can overlook that.