I'm trying to work through this proof of Nike's tick. Statement of the lemma:
Let $ U_{i} = Spec\ A_{i} $ for $ i\in\{1,2\} $ be two open affine subschemes of a scheme $ X $. For $ x\in U_{1}\cap U_{2} $ there exists an open affine subscheme $V $ such that $ x\in V\subset U_{1}\cap U_{2} $ and $ V $ is distinguished in both $ U_{1}$ and $ U_{2 }$.
Distinguished here means it has the form $ D(f )$ for some $f \in A_1 $ and similarly for $A_2$.
The proof picks $f\in A_1$ such that $x\in D(f) \subset U_{1}\cap U_{2} $. Then replaces $U_1$ with $D(f)$ and considers the homomorphism $\varphi $ induced by the inclusion $U_1 \to U_2$. It then picks $g\in A_{2} $ such that $x\in D(g) \subset U_1$. All understood up to this point.
It then claims $D(g) = D(\varphi(g))$. Since both are open subsets of the same scheme, it is sufficient to show that they are the same subset. To show this, the proof just shows that $\varphi^{-1}(D(g)) = D(\varphi(g))$. This is the part I don't understand. Why is this sufficient? Don't we have to show inclusions in both directions? Is there some implicit assumption that taking $\varphi^{-1}$ gives a bijection?