I think the best answer that adds something to the already existing answers is pretty much the same as this answer so I will write a similar answer here.
Without any assumptions about what properties distance follows, you can't prove anything about what the distance formula is. We could make the assumptions that distance is a binary function from $\mathbb{R}^2$ to $\mathbb{R}$, in otherwords, a function from $(\mathbb{R}^2)^2$ to $\mathbb{R}$ satisfying the following properties
- For any points $(x, y)$ and $(z, w)$ in $\mathbb{R}^2$, $d((0, 0), (z, w)) = d((x, y), (x + z, y + w))$
- $\forall x \in \mathbb{R}\forall z \in \mathbb{R}^+d((0, 0), (z\cos(x) ,z\sin(x))) = z$
Then we could derive the distance formula as follows. $\cos$ and $\sin$ are defined by the following differential equations.
- $\cos(0) = 1$
- $\sin(0) = 0$
- $\cos' = -\sin$
- $\sin' = \cos$
$\frac{d}{dx}\cos^2(x) + \sin^2(x) = \frac{d}{dx}\cos^2(x) + \frac{d}{dx}\sin^2(x) = 2\cos(x)(-\sin(x)) + 2\sin(x)\cos(x) = 0$ so $\cos^2(x) + \sin^2(x)$ is constant. Also $\cos^2(0) + \sin^2(0) = 1$ so $\forall x \in \mathbb{R}\cos^2(x) + \sin^2(x) = 1$. From this and those two assumptions, we can show that the distance formula is $d((x, y), (z, w)) = \sqrt{(z - x)^2 + (w - y)^2}$. This just shows that for any right angle triangle whose legs are parallel to the axes, the Pythagoren theorem holds. To prove the Pythagorean theorem holds for all right angle triangles, we have to show that distance also satisfies the following property.
- For any points $(x, y)$ and $(z, w)$ in $\mathbb{R}^2$, $d((0, 0), (xz - yw, xw + yz)) = d((0, 0), (x, y))d((0, 0), (z, w))$
That can be done as follows. $d((0, 0), (xz - yw, xw + yz)) = \sqrt{(xz - yw)^2 + (xw + yz)^2} = \sqrt{x^2z^2 - 2xyzw + y^2w^2 + x^2w^2 + 2xyzw + y^2z^2} = \sqrt{x^2z^2 + x^2w^2 + y^2z^2 + y^2w^2} = \sqrt{(x^2 + y^2)(z^2 + w^2)} = \sqrt{x^2 + y^2}\sqrt{z^2 + w^2} = d((0, 0), (x, y))d((0, 0), (z, w))$
Now how do we show that there actually exists a way of defining distance that satisfies the assumptions I made? Because it's trivial to show that the function $d((x, y), (z, w)) = \sqrt{(z - x)^2 + (w - y)^2}$ actually satisfies those properties.
Some people make other assumptions about what properties distance follows. Here are some assumptions about distance in $\mathbb{R}$ each of which some people make.
- $\forall x \in \mathbb{R}\forall y \in \mathbb{R}\forall z \in \mathbb{R}\forall w \in \mathbb{R}d((x, y), (x + z, y + w)) = d((0, 0), (z, w))$
- $\forall x \in \mathbb{R}\forall y \in \mathbb{R}\forall z \in \mathbb{R}\forall w \in \mathbb{R}d((x, y), (z, w))$ is nonnegative
- $\forall \text{ nonnegative } x \in \mathbb{R}d((0, 0), (x, 0)) = x$
- $\forall x \in \mathbb{R}\forall y \in \mathbb{R}d((0, 0), (x, -y)) = d((0, 0), (x, y))$
- $\forall x \in \mathbb{R}\forall y \in \mathbb{R}\forall z \in \mathbb{R}\forall w \in \mathbb{R}d((0, 0), (xz - yw, xw + yz)) = d((0, 0), (x, y))d((0, 0), (z, w))$
- The area of any square is the square of the length of its edges
- $\forall x \in \mathbb{R}d((0, 0), (\cos(x), \sin(x))) = 1$
How do we know there exists a way of defining distance that satisfies all 7 properties? Because it has been proven in this answer that $d((x, y), (z, w)) = \sqrt{(z - x)^2 + (w - y)^2}$ is the unique function satisfying the first 5 properties from this list and it also satisfies properties 6 and 7 from this list.
The second assumption I made earlier does not appear as one of them. That's because using properties 3, 5, and 7, we can deduce that that definition of distance satisfies the second assumption I made earlier.