I have troubles to understand when an event is independent and when not. So I don't understand one step in the solution to this exercise:
We have $X,X_1,X_2,\dots$ be i.i.i. real random variable with density $f(x)$ and distribution function $F(x)$. Further $k\in \mathbb{N}$ and $t\in\mathbb{R}$ and $$N:=\inf\{k\in\mathbb{N}:X_k>X\}$$ Show $$P(N=k,X\leq t)=\int_{-\infty}^t F(x)^{k-1}(1-F(x))f(x) \, \mathrm{d}x$$
Then the solution says this:
By the definition of $N$ and independence of $(X,X_1,\dots,X_k)$ we have $$P(N=k,X\leq t)=P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t) \\ \underbrace{=}_{(*)} \int_{-\infty}^t P(X_1,\dots,X_{k-1}\leq X,X_k>X)f(x) \, \mathrm{d}x = \int_{-\infty}^t F(x)^{k-1}(1-F(x))f(x) \, \mathrm{d}x$$
Does this imply that $\{X_1,\dots,X_{k-1}\leq X,X_k>X\}$ is independent of $\{X<t\}$ or why can I write the integral after $(*)$ like that? Both events have the random variable $X$, so both events should be dependent?
Why can I write the event $\{X<t\}$ as an integral and the other event stays in $P(X_1\dots)$ form?
My second question is about $N$. $N$ is clearly dependent on $X_1,\dots,X_k$ but is it also dependent on $X$?
Thank you for explanation.
The formula below is not the result of the independence, but the definition of $N$ $$P(N=k,X\leq t)=P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)$$
If $N=k$, by definition ,it means that $$X_1,\dots,X_{k-1} \leq X $$ and $$ X_{k}>X$$
Now, how to derive $P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)$ ?
We use the law of total probability for the continuous variable $X$ that is $$P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)=\int\limits_{-\infty}^{\infty} P(X_1,\dots,X_{k-1}\leq x,X_k>x,x\leq t)f(x)\mathrm{d}x$$
This is where you made a mistake, you used $X$ instead of $x$. The former being a random variable, the latter a real.
We have one deterministic condition $x<t$, therefore $$P(X_1,\dots,X_{k-1}\leq x,X_k>x,x\leq t)=P(X_1,\dots,X_{k-1}\leq x,X_k>x)1_{x \leq t}$$
Thus, $$P(X_1,\dots,X_{k-1}\leq X,X_k>X,X\leq t)=\int\limits_{-\infty}^{t} P(X_1,\dots,X_{k-1}\leq x,X_k>x)f(x)\mathrm{d}x$$
How to derive $P(X_1,\dots,X_{k-1}\leq x,X_k>x)$ ? The only random variables in there are $X_1,..., X_k$ which are independent, and identically distributed in other words $$P(X_1,\dots,X_{k-1}\leq x,X_k>x)=F(x)^{k-1}(1-F(x))$$