I was going through original GAN paper: Goodfellow, Ian, et al. "Generative adversarial nets." Advances in neural information processing systems. 2014. Link: http://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf
For proving optimal D, eq 2, they have rewritten the objective function in equation 3. It is:

So, essentially they have changed p(z) to p(x) and g(z) to x. My question is how can this be done?
p.s: Is this the correct place to ask such question? Is there a dedicated place where I can ask questions related to specific sub topics of ML?