How is changing the $t$ to a $s$ in $v(t) = \frac{ds}{dt} \implies \frac{dt}{ds} = \frac{1}{v(s)}$ justified? Sorry if the title wasn't descriptive enough as I didn't found a better way to formulate the question.
So I found this article that introduces you to calculus of variations by using it to solve the brachistochrone problem.
In page 2 lies the problem, as the article gets velocity in terms of position $x$ ($v(x) = \sqrt{2gy(x)}$).
Then the distance traveled (so the arclength) of $y(x)$ is defined as $s(x) = \int_0^x{\sqrt{1+y'(\hat{x})^2}}d\hat{x}$ as expected so its derivative over $x$ is $\frac{ds}{dx} = \sqrt{1+y'(x)^2}$.
Then by definition velocity is $v(t) = \frac{ds}{dt}$ (note it now depends on time).
Now here its the troublesome part, as the article rearranges the equation above in the following way: $\frac{dt}{ds} = \frac{1}{v(s)}$ and later on $v(s)$ is replaced somewhere with $\sqrt{2gy(x)}$ (so $v(x)$) and my question is:

*

*Why can we change the function from depending on $t$ to depending on the distance traveled $s$? Doesn't the function take a time and returns you the velocity? why you can just input $s$ like that?

 A: There's a joke that if you show $f(x,y)=\sqrt{x^2+y^2}$ to a mathematician and a physicist and ask them what $f(r,\theta)$ is, the mathematician will say $f(r,\theta)=\sqrt{r^2+\theta^2}$ and the physicist will say $f(r,\theta)=r$.
Do you get the joke?
The mathematician is viewing $f(\cdot,\cdot)$ formally as notation that says to plug two things into a formula, while the physicist is viewing $f$ as a variable that depends on the two things in parentheses. If $f=\sqrt{x^2+y^2}$, then we can say $f$ depends on $x$ and $y$ and call it $f(x,y)$, but since this is also $r$ we can say $f=r$ and that $f$ depends on $r$ and $\theta$ and call it $f(r,\theta)$, at least in the physicist's mind.
Thus, velocity $v$ may very well depend on $t$, but that would also depend on $s$ then too! Because you can write $s$ as a function of $t$ and vice-versa, that means you can write $v$ as a function of $s$ or of $t$ and take the derivative with respect to either variable.
Let's look at an example with different letters. Say $z=\sqrt{1-y}$ and $y=x^2$. Then a physicist would say $z(y)=\sqrt{1-y}$ but they might also say $z(x)=\sqrt{1-x^2}$, assuming $x,y,z$ represent physical quantities. Obviously this is at odds with the usual function notation that mathematicians understand.
