For example, is $y = \ln{x}$ a solution to $y^{\prime}=\frac{1}{x}$?
I have looked at this answer about what does it mean for a function to be a solution of a differential equation. According to that answer, $y = \ln{x}$ is not a solution since $$y = \ln{x}$$ $$y^{\prime}=\frac{1}{x}\ \ \ \ \ \ \ \ x >0$$ which is not the original equation.
But I could not find a formal definition of a solution to a differential equation so I would appreciate it if someone could help me decide if the solution must have the same domain? or give a source for a formal definition of what does it mean for a function to be a solution of a differential equation.
An ODE is given by a connected open set $\Omega\subset{\mathbb R}^2$ and a continuous function $f:\>\Omega\to{\mathbb R}$. The ODE is then written as $$y'=f(x,y)\quad \bigl((x,y)\in\Omega\bigr)\tag{1}$$ or as $$y'(x)=f(x,y(x))\quad \bigl((x,y)\in\Omega\bigr)\ .$$ If $I\subset{\mathbb R}$ is an open interval and $\phi: \>I\to{\mathbb R}$ a differentiable function then $\phi$ is called a solution of $(1)$ on $I$ if ${\rm graph}(\phi):=\bigl\{(x,\phi(x))\,|\,x\in I\bigr\}\subset\Omega$ and $$\phi'(x)=f\bigl(x,\phi(x)\bigr)\qquad(x\in I)\ .$$ In this sense $\ln:\>{\mathbb R}_{>0}\to{\mathbb R}$ is a solution of the ODE $y'={1\over x}$ when $\Omega$ is the right half plane.
Such a $\phi:\>I\to{\mathbb R}$ is called a maximal solution if there is no interval $J\supsetneqq I$ and a solution $\tilde \phi:\>J\to{\mathbb R}$ with $\tilde\phi\restriction I=\phi$.
In this sense $\ln:\>{\mathbb R}_{>0}\to{\mathbb R}$ is a maximal solution of the ODE $y'={1\over x}$ when $\Omega$ is the right half plane.
As $\Omega^?:={\mathbb R}^2\setminus(\{0\}\times{\mathbb R}\bigr)$ is disconnected it does not make sense to consider global solutions of ODEs defined on the open set $\Omega^?$.