Recall that we obtain $\Bbb Q$ by quoting the set $\Bbb Z\times (\Bbb Z-\\{0\\})$ with the equivalence relation $$(a,b)\sim (a',b')\iff ab'=a'b$$
This hints that we should see $v$ as a map $$\
u:\Bbb Z\times (\Bbb Z-\\{0\\})\to\Bbb N$$ defined as $$\
u(a,b)=f(a)-f(b)$$
and we ought to prove (or disprove) that $ab'=a'b\implies \
u(a,b)=\
u(a',b')$.
Note that if $m$ is odd, $$\
u(mn,mk)=\
u(n,k)$$ since $\text{odd}\times \text{odd}=\text{odd}$. Similarily, if $m=2^j$ is even, $$\
u(2^jn,2^jk)=j+f(n)-(j+f(k))=f(n)-f(k)=\
u(n,k)$$
Since this considers all possible alterations on the pair $n,k$, we conclude $\
u$ is well-defined.
**OBS** $\
u(a,b)$ simply returns the exponent of $2$ (negative or positive) in $$\frac{a}{b}$$