Let $F: \mathbb R^2 \to \mathbb R^2, X: \mathbb R^2 \to \mathbb R, Y: \mathbb R^2 \to \mathbb R$ be smooth functions such that $$f(x,y) = \begin{bmatrix}X(x,y) \\ Y(x,y) \end{bmatrix}.$$ Show that there exists $P: \mathbb R^2 \to \mathbb R$ such that $\nabla P = F$ iff $X_y = Y_x$.
Notation: $X_x$ means $\frac{\partial X}{\partial x}$.
My proof is below, to which I request verification, critique, and suggests, on the proof and exposition. Is it correct, rigorous, and clear? How can the exposition be improved?
Note: Proofs are available; this question is to verify or critique this proof.
Proof: Let $A: \mathbb R^2 \to \mathbb R$ be a smooth function such that $A_x = X$. Such a function must exist since $X$ is assumed smooth. Then $$A_{yx} = A_{xy} = X_y = Y_x.$$ Integrating both sides with respect to $x$ gives $$Y(x,y) = A_y(x,y) + \beta(y)$$ for some continuous function $\beta: \mathbb R \to \mathbb R$. There exists a function $B: \mathbb R \to \mathbb R$ such that $B' = \beta$.
Let $$P(x,y) = A(x,y) + B(y).$$ Then $P_x = A_x = X$ and $P_y = A_y + \beta = Y$, giving $\nabla P = F$. The converse follows directly from Clairaut's Theorem.
Furthermore, it easily follows that for any function $Q, \nabla Q = F$ iff $Q = P + C$ for some $C \in \mathbb R$.