Flat schemes over artinian local ring with isomorphic special fibers I'm sure this is standard, but I don't know where to find it. 
If $A$ is a local artinian $k$-algebra, $X_1,X_2$ are finite type schemes flat over $A$, and $f:X_1\rightarrow X_2$ is a morphism over $A$ that is an isomorphism after restricting to closed fibers, why is $f$ is an isomorphism?
(This is Exercise 4.2 in Harthshorne's Deformation Theory, used to show that a smooth affine variety has no nontrivial infinitesimal deformations.)
 A: The key point is that over Artinian rings we have a generalization of Nakayama's lemma for not finitely generated modules:

Lemma: let $A$ be an Artinian $k$-algebra and let $M$ be an $A$-module such that $M\otimes_A k=0$. Then $M=0$
proof: let $\mathfrak{m}$ be the maximal ideal of $A$. Then the hypothesis means that $M=\mathfrak{m}M$, so that
$$ M =\mathfrak{m}M = \mathfrak{m}^2M = \mathfrak{m}^3 M = \dots $$
but since $A$ is Artinian, we know that $\mathfrak{m}^n=0$ for $n\gg 0$, so that $M=0$.

Now we can solve the exercise. First suppose that $X_1=\text{Spec }B$ and $X_2=\text{Spec }C$ are affine: then $B$ and $C$ are finitely generated flat $A$-algebras and we have a morphism of $A$-algebras
$$ \varphi\colon C \to B $$
such that
$$ \varphi\otimes k \colon C\otimes_A k \to B\otimes_A k  $$
is an isomorphism. We want to prove that $\varphi$ is an isomorphism. 
First we consider surjectivity: we have an exact sequence of $A$-modules
$$ C \overset{\varphi}{\to} B \to M \to 0 $$
and since tensoring is right exact, we have an exact sequence
$$ C\otimes_A k \overset{\varphi\otimes k}{\to} B\otimes_A k \to M\otimes_A k \to 0 $$ 
but since the map $\phi\otimes k$ is surjective, we get that $M\otimes_A k=0$ and by the Lemma this implies $M=0$, so that $\varphi$ is surjective. 
Now injectivity: we have an exact sequence of $A$-modules
$$ 0 \to N \to C \overset{\varphi}{\to} B \to 0 $$
and since $B$ is a flat $A$-module, this sequence stays exact when tensored:
$$ 0 \to N\otimes_A k \to C\otimes_A k \overset{\varphi\otimes k}{\to} B\otimes k \to 0 $$
then the hypothesis tells us that $N\otimes_A k =0$ so that $N=0$ and $\varphi$ is injective as well.
For the general case, it is enough to observe that $f\colon X_1 \to X_2$, as a map of topological spaces, is identical to the map on the closed fibers, so that in particular it is affine and then the above argument applies.
