# MCMC - Metropolis Hasting: formal derivation of detailed balance

I do not understand the formal proof that the Metropolis Hastings update generates a Markov chain that satisfies detailed balance as it is given in the the Wikipedia article. Under "formal derivation" it states that

$$\frac{A(x'|x)}{A(x|x')}=\frac{P(x')}{P(x)}\frac{g(x|x')}{g(x'|x)}$$

is fulfilled by the acceptance probability

$$A(x'|x)=min\left(1,\frac{P(x')}{P(x)}\frac{g(x|x')}{g(x'|x)}\right)$$

where $x'$ is the candidate, $x$ the current state, $A(.)$ the acceptance probability, $P(.)$ the target distribution and $g(.)$ the proposal distribution.

I just do not see why this is formally correct.

That follows by an easy case distinction: If $$P(x')g(x|x')>P(x)g(x'|x)$$, then $$A(x'|x)=1$$ and, by symmetry, $$A(x|x')=\frac{P(x)g(x'|x)}{P(x')g(x|x')}$$ and the claim holds. The case $$P(x')g(x|x')\le P(x)g(x'|x)$$ works similarly.
$$A(x'|x)\cdot P(x)g(x'|x)= A(x|x')\cdot P(x')g(x|x')$$
is easier to see by plugging in the definition of $$A$$
$$\min(P(x)g(x'|x), P(x')g(x|x')) = \min(P(x')g(x|x'),P(x)g(x'|x))$$