Show that a morphism of algebraic sets which restricts to finite morphisms of principal sets is finite

I'm looking for some hint towards the solution of the following problem (which is a homework question, so I don't expect a complete solution) with which I'm having unexpected difficulties.

Problem statement: Let $\phi :X\rightarrow Y$ be a morphism between the affine varieties $X=Sp(A)$ and $Y=Sp(B)$. Let also $g_1, \dots ,g_s\in B$ be such that the corresponding principal open subsets $V_i=Y_{g_i}$ cover $Y$. Show that the restriction of $\phi$ to $U_i=\phi^{-1}(V_i)$ being a finite morphism to $V_i$ for all $1\le i\le s$ implies that $\phi$ is finite too.

Attempt at a solution: My ideas are rather vague, but I post them anyway, in case they are of any use. I don't know much machinery yet, so I try to prove the statement almost from the definitions. Let $\phi^\star$ denote the pullback of $\phi$. We want to show that $A$ is finitely generated over $\phi^\star(B)$. If we assume that the restriction of $\phi$ to $U_i$ indeed is finite, I conjecture that we can find a set of generators $\{ a_j \}\subset A$ of $A$ (thereby solving the problem) so that restrictions of the $a_j$ to appropriate $U_i$ generate the corresponding sets of regular functions.

I also suspect that this may be of use: The $U_i$ are principal open sets which cover $X$. Therefore the $\phi^\star (g_i)$ don't all have a common zero, so by a basic result, an arbitrary $a\in A$ can be written $a=\sum_{i=1}^s{f_i(a\phi^\star (g_i))}$, where $f_i\in A$.

All kinds of help is much appreciated!

Edit: By the definition I'm working with, $\phi$ is finite means precisely that $A$ is a finitely generated $B$-module (or equivalently that A is integral over $\phi^\star (B)$ ). So what I'm trying to show is that each $U_i$ being finitely generated over $V_i$ (with $\phi$ restricted accordingly) implies that $A$ is finitely generated over $B$.

• Do you wish to show directly that $A$ is a finite $B$-module? Working from the definition in e.g Hartshorne does not require us to show this, although it will be true. – Andrew Oct 13 '12 at 22:58
• @Andrew : I have edited my question to hopefully clarify my question and answer yours. – DanielF Oct 14 '12 at 7:05

You can prove a slightly more general result: let $M$ be a $B$-module such that $M_{g_i}$ is finitely generated over $B_{g_i}$ for all $i\le s$, then $M$ is finitely generated.
1. There exist $v_1, \dots, v_m\in M$ whose images in $B_{g_i}$ form a system of generators of $M_{g_i}$ for all $i\le s$.
2. Let $v\in M$. Consider the quotien module $N=(Bv+Bv_1+\dots +Bv_m)/(Bv_1+\dots +Bv_m)$. Then $\bar{v}=0$ in $N_{g_i}$ for all $i$.
3. Conclude that $\bar{v}=0$ (hence $v\in Bv_1+\dots+Bv_m$) using the fact that for any $N\ge 1$, $g_1^N,\dots, g_s^N$ generate the unit ideal of $B$.
• Got it now (the missing detail was the insight that the $g_1^N,\dots ,g_s^N$ generate the unit ideal not only over $A$ but even over $B$). Thank you! – DanielF Oct 14 '12 at 9:04