Morphism of quasi affine varieties giving algebra homomorphism and back. $\newcommand{\set}[1]{\{#1\}}$ $\newcommand{\vp}{\varphi}$ $\newcommand{\mr}{\mathscr}$ $\newcommand{\mc}{\mathcal}$
$\newcommand{\A}{\mathbb A}$
I am new to algebraic geometry and in the following I ask two related questions that have come to my mind given the material I have read so far.
I believe the notation and terminology I have used is standard.
However, I have supplied most of the relevant definitions and notations in the appendix.
Please feel free to correct and inaccuracies.
In what follows $k$ is an algebraically closed field.
Question 1
Let $X$ and $Y$ be affine varieties.
It is a fact that a morphism $\vp:X\to Y$ is an isomorphism if the corresponding map $\vp^*:\mr O(Y)\to \mr O(X)$ is an isomorphism of $k$-algebras.

Question.
Can we extend this fact to the case when $X$ and $Y$ are quasi affine varieties, that is, is a morphism $\vp:X\to Y$ an isomorphism if and only if the corresponding map $\vp^*:\mr O(Y)\to \mr O(X)$ is an isomorphism of $k$-algebras?

The problem I am facing in proving this is the following.
When $X$ and $Y$ are affine varieties in $\A^m$ and $\A^n$ respectively, then we have $\mr O(X) = k[x_1, \ldots, x_m]/\mr I(X)$ and $\mr O(Y) = k[y_1, \ldots, y_n]/\mr I(Y)$.
Now once we have a $k$-algebra homomorphism $\mr O(Y)\to \mr O(X)$, we get a morphism of varieties $X\to Y$ by using the induced map $\text{MaxSpec}(\mr O(X))\to \text{MaxSpec}(\mr O(Y))$ and then use the nullstellensatz to get a map $X\to Y$.
However, when $X$ and $Y$ are quasi affine varieties in $\A^m$ and $\A^n$ respectively, then one cannot think of $\mr O(X)$ or as a quotient of $k[x_1, \ldots, x_m]$ (and similarly for $\mr O(Y)$).
For instance, let $X=\A^1\setminus \set{0}$. Then $\mr O(X) = k[x]_{x}$ which is not a quotient of $k[x]$ but of $k[x, y]$.
So I am unable to identify $\text{MaxSpec}(\mr O(X))$ and $\text{MaxSpec}(\mr O(Y))$ as subsets of $\A^m$ and $\A^n$.
Question 2
Let $\mc V$ be the category of affine varieties and $\mc A$ be the category of finitely generated $k$-algebras that are integral domains.
We get an equivalence between two categories by associating to an affine variety its coordinate ring and to a morphism its corresponding map between the algebras, namely the pullback map.

Question.
Is there such a statement for the category of quasi affine varieties, that is, is there a nice algebraic category to which the category of quasi affine varieties equivalent?


Question.
Suppose we consider the category of subsets of $\A^n$, $n\geq 0$.
We can still define $\mr O(X)$ for any such subset and form a category with morphisms as maps which pullback regular functions to regular functions.
Is this category useful in any way? Is there a reason why it is not studied?

Appendix
Let $k$ be an algebraically closed field.
We write $\A^n$ to denote $k^n$ with the Zariski topology.
An affine variety is an irreducible closed subset of some $\A^n$.
Given an affine variety $X$ in $\A^n$, the coordinate ring $\mr A(X)$ of $X$ is defined as $k[x_1, \ldots, x_n]/\mr I(X)$, where $\mr I(X)$ is the set of all the polynomials in $k[x_1, \ldots, x_n]$ which vanish on each point of $X$.
It turns out that $\mr I(X)$ is a prime ideal.
A quasi affine variety is any open subset of an affine variety.
A regular function on a quasi affine variety $Y\subseteq \A^n$ is a map $\vp:Y\to k$ which can be locally written as a quotient of polynomials in $k[x_1, \ldots, x_n]$.
The set of all the regular functions on $Y$ is denoted by $\mr O(Y)$.
It turns out that $\mr O(Y)$ has a natural $k$-algebra structure.
It is a fact that if $X$ is an affine variety, then $\mr A(X)$ can be naturally identified with $\mr O(X)$.
A morphism of quasi affine varieties $X$ and $Y$ is a map $\vp:X\to Y$ which is continuous (in the Zariski topology) such that $\vp$ pulls back regular functions on $Y$ to regular functions on $X$.
Given a morphism $\vp:X\to Y$, we get the pullback map $\vp^*:\mr O(Y)\to \mr O(X)$, and it is easy to check that $\vp^*$ is a $k$-algebra homomorphism.
 A: The problem with quasi-affine varieties is that, well, they are not affine. You should think of an affine variety as one that is ``determined by its global regular functions'' and this is not the case for arbitrary quasi-affine varieties.
Here is a classic example: let $X = \mathbb{A}^2 \setminus \{ (0,0) \}$. Then I claim $\mathcal{O}(X) \cong k[x,y]$ where the map $\mathcal{O}(\mathbb{A}^2) \to \mathcal{O}(X)$ induced by the inclusion $X \subset \mathbb{A}^2$ is an isomorphism. I highly recommend you try to prove this if you are not familiar with the example. It is often thought of as an algebraic version of the Harthogs's phenomenon.
This example shows that the answer to Question 1 is no. In Question 2, I don't know of any purely algebraic description and the category you suggest is useful it just does not give information about the quasi-affine varieties $X$ rather it tells you about the affine varieties $\mathrm{Spec}{(\mathcal{O}(X))}$.
Note: when you say subsets, I assume you mean locally closed subsets for the Zariski topology since an arbitrary subset of $\mathbb{A}^n$ need not have the structure of an algebraic variety.
A: "Question. Can we extend this fact to the case when $X$ and $Y$ are quasi affine varieties, that is, is a morphism $φ:X→Y$ an isomorphism if and only if the corresponding map $φ∗:O(Y)→O(X)$ is an isomorphism of k-algebras?"
Example 1. If $\phi: \mathbb{P}^1_k \rightarrow \mathbb{P}^d_k$ is the $d$-uple embedding with $d\geq 2$, it follows $\phi$ is not an isomorphism. But
$$\Gamma(\mathbb{P}^1_k, \mathcal{O}_{\mathbb{P}^1_k}) \cong \Gamma(\mathbb{P}^d_k, \mathcal{O}_{\mathbb{P}^d_k}) \cong k$$
Hence the global sections are isomorphic, but the varieties are not (a projective variety is quasi projective). Hence it seems the correspondence you mention can not be extended to quasi projective varieties. You find this construction in Hartshornes book, chapter I and II. The projective varieties $\mathbb{P}^1_k$ and $\mathbb{P}^d_k$ have different dimensions, but their structure sheaves $\mathcal{O}_{\mathbb{P}^1_k}$ and $\mathcal{O}_{\mathbb{P}^d_k}$ have the same number of global sections. In chapter I you find the definition of the $d$-uple embedding and in chapter II you find the definition of the structure sheaf.
Example 2. If $k$ is algebraically closed, $X:=Spec(k[x,y])$ and $U:=X-\{(0,0)\}$ it follows there is an isomorphism
$$i^{\#}: \Gamma(X, \mathcal{O}_X) \cong \Gamma(U, \mathcal{O}_U)\cong k[x,y]$$
(Hartshorne Exercise I.3.6) but $X$ and $U$ are not isomorphic. Hence the correspondence seems not to hold for quasi affine varieties either.
The map $i^{\#}$ is induced by the inclusion
$$ i: U \rightarrow X.$$
The scheme $U$ is not affine.
You may change the  notion "regular map" - this is discussed briefly here:
Regular rational functions over real projective lines and projective spaces.
Example 3. If $k:=\mathbb{R}$ is the field of real numbers and $f:=x^2+y^2$
it follows $Z:=V(f):=Spec(A)$ where $A:=k[x,y]/(f)$. $Z$ has $(0,0)$ as the only rational point: $x^2+y^2=0$ iff $(x,y)=(0,0)$. Why? Let
$$\phi: A \rightarrow k$$
be a map of $k$-algebras.It follows $\phi(x)=a, \phi(y)=b$ for $a,b\in k$.
Since the map $\phi$ is well defined it follows $\phi(x^2+y^2)=a^2+b^2=0$, and from this it follows $a=b=0$. Hence the only $k$-rational points of $Z$ is the point $(0,0)$. Hence we may claim that $Z=\{(0,0)\}$ is the "one point space"
with only rational point $(0,0)$. It is defined as closed subscheme of $X:=Spec(k[x,y])$ corresponding to the ideal $I:=(f)$, hence $Z$ is indeed a hypersurface in $X$.
Let $U:=X-Z:=X-\{(0,0)\}$. Since $U$ is the complement of the "hypersurface" $Z$, it follows $U\cong D(f)\cong Spec(B)$ where
$$B:=k[x,y,t]/(tf-1)$$
hence $U$ is affine. Hence over a non-algebraically closed field $k$ it follows $U:=\mathbb{A}^2_k-\{(0,0)\}$ may be an affine scheme.
Note: If $\mathfrak{m}:=(x,y)$ and $P:=Spec(k[x,y]/\mathfrak{m})$ we may realize $V(\mathfrak{m})$ as a closed subscheme of $Z$: There is a canonical surjective map
$$ A \rightarrow k[x,y]/\mathfrak{m}\cong  k.$$
Hence the hypersurface $Z$ is the rational point $(0,0)$ with a non-trivial scheme structure.
Example 4. This generalize as follows. Let $k$ be the field of real numbers and let $J:=(f_1,..,f_k)\subseteq A:=k[x_1,..,x_n]$ be an ideal generated by the polynomials $f_i$. Let
$$F(x_1,..,x_n):=f_1^2+\cdots +f_k^2 \in A.$$
It follows $F$ defines a hypersurface. Let $B_1:=A/J, B_2:=A/(F)$ and let $X_i:=Spec(B_i)$ for $i=1,2$.
Lemma: The two affine schemes $X_1,X_2$ have the same $k$-rational points.
Proof: Assume $\phi: B_1\rightarrow k$ is a map of $k$-algebras. It follows
$$ \phi(x_i)=a_i$$
for $i=1,..,n$ and since $\phi$ is well defined it follows $f_j(a_1,..,a_n)=0$
for all $j=1,..,k$. Hence the point $a:=(a_1,..,a_n)$ is a zero of the polynomials $f_j$. It follows
$$F(a_1,..,a_n):= \sum_j f_j(a_1,..,a_n)^2=0.$$
Conversely if $\phi: B_2\rightarrow k$ is a map of $k$-algebras with $\phi(x_i):=a_i\in k$ it follows
$$F(a_1,..,a_n)=0.$$
It follows
$$F(a_1,..,a_n):= \sum_j f_j(a_1,..,a_n)^2=0$$
and since $f_j(a_1,..,a_n)^2\geq 0$ it follows $f_j(a_1,..,a_n)=0$ for all $j=1,..,k$. This sets up a 1-1 correspondence between $k$-rational points of $X_1$ and $k$-rational points of $X_2$. QED.
Note: $X_1$ and $X_2$ have the same rational points but are not isomorphic as affine schemes in general. Over the field of real numbers, any "real affine algebraic variety" may set-theoretically be realized as the zero set of a single polynomial.
Since there is an inclusion of ideals $(F) \subseteq J$, we get a canonical map of affine schemes
$$\phi: X_2\rightarrow X_1$$
where $\phi$ induce a bijection $X_2(k)\cong X_1(k)$ at the level of $k$-rational points, but $\phi$ is not an isomorphism of schemes. Moreover the hypersurface $(F)$ depends on the choice of generators of the ideal $J$. If $X_i$ are "smooth algebraic varieties" we get an induced isomorphism of real smooth manifolds $(X_1)_k \cong (X_2)_k$.
