# Chern classes and Gromov–Witten theory of projective bundles

Honglu Fan<EMAIL_ADDRESS>
###### Abstract.

We prove that the Gromov–Witten theory (GWT) of a projective bundle can be
determined by the Chern classes and the GWT of the base. It completely answers
a question raised in a previous paper. Its consequences include that the GWT
of the blow-up of X at a smooth subvariety Z is uniquely determined by GWT of
X, Z plus some topological data.

###### Contents

  1. 0 Introduction
    1. 0.1 Background
    2. 0.2 Techniques and difficulties
    3. 0.3 Consequences and remarks
    4. 0.4 Acknowledgement
  2. 1 Statement of the main theorem
  3. 2 Twisted Gromov–Witten invariants
  4. 3 Virtual localization
    1. 3.1 Localization
    2. 3.2 Decorated graph
  5. 4 Computing invariants on a projective bundle
    1. 4.1 Fiber classes
    2. 4.2 Set-ups for the main algorithm
    3. 4.3 Lifting of insertions
    4. 4.4 Localization formula
  6. 5 Proof of Theorem 1.1
  7. 6 An application to blow-up formula

##  0\. Introduction

In [FL], the following question was raised.

######  Question.

Let $S$ be a smooth variety and $V$ be a vector bundle. Is the Gromov–Witten
invariants of $\mathbb{P}_{S}(V)$ uniquely determined by that of the base $S$
and the total Chern class $c(V)$?

The main result of this paper is an affirmative answer to the above question
in all genera.

######  Theorem A (=Theorem 1.1).

Let $S$ be a smooth projective variety, and $V_{1},V_{2}$ be two vector
bundles on $S$. If $c(V_{1})=c(V_{2})$, we have the following equality between
Gromov–Witten invariants

(1)
$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{\mathbb{P}(V_{1})}=\langle\psi^{k_{1}}\mathfrak{F}(\alpha_{1}),\ldots{},\psi^{k_{n}}\mathfrak{F}(\alpha_{n})\rangle_{g,n,\Psi(\beta)}^{\mathbb{P}(V_{2})}$

for any cohomology classes $\alpha_{1},\ldots{},\alpha_{n}\in H^{*}(X_{1})$,
any set of natural numbers $k_{1},\ldots{},k_{n}$, any curve class $\beta\in
N_{1}(X_{1})$ and any genus $g\in\mathbb{Z}_{\geq 0}$.

Here $\mathfrak{F},\Psi$ are natural isomorphisms identifying
$H^{*}(\mathbb{P}(V_{1}))$ with $H^{*}(\mathbb{P}(V_{2}))$, and
$N_{1}(\mathbb{P}(V_{1}))$ with $N_{1}(\mathbb{P}(V_{2}))$, respectively (see
section 1).

###  0.1. Background

As a natural construction in geometry, the projectivization of vector bundles
(projective bundles) has appeared as key objects in various mathematical
theories. In particular, it’s important in Gromov–Witten theory as well. For
example, Gromov–Witten theory of projective bundles has appeared as a central
subject in crepant transformation conjecture for ordinary flops (e.g., [LLW1,
LLW2, LLQW]), and the later proposals of the _functoriality_ of Gromov–Witten
theory ([LLW-string, LLW-ams]) also emphasize the role of projective bundles.
Besides, projective bundle appears naturally in the degeneration to the normal
cone which is an important construction in some Gromov–Witten results (e.g.,
[MP, HLR]).

###  0.2. Techniques and difficulties

In [MP, GB, CGT], the virtual localization under the fiberwise torus action
has been very effective in the study of Gromov–Witten theory of split
projective bundles. In spite of this, it is difficult to establish Theorem A
in the case of split bundles using localization. The main hurdle is that
localization would not yield symmetric expressions in Chern roots until
nonequivariant limits are taken. A way to see this is probably the following.
For simplicity suppose we are given two split rank-$2$ bundles
$V_{1}=L_{1}\oplus L_{2}$ and $V_{2}=L_{1}^{\prime}\oplus L_{2}^{\prime}$ with
$c(V_{1})=c(V_{2})$ but $c_{1}(L_{1})\neq c_{1}(L_{i}^{\prime})$ for both
$i=1,2$. If we impose torus actions on $V_{1}$ and $V_{2}$ by scaling each
factor, one can compute that $c_{T}(V_{1})\neq c_{T}(V_{2})$. Therefore, we
cannot expect $\mathbb{P}(V_{1})$ and $\mathbb{P}(V_{2})$ to have the same
equivariant theory, and Theorem A only holds when passing to their
nonequivariant limits. One might notice that the I-function in [GB] packages
the localization computation into a form that admits a nonequivariant limit.
But unfortunately the I-function in [GB] is not symmetric in Chern roots
either.

When the projective bundle is not split, such a fiberwise torus action is
absent. A degeneration argument is applied in [LLQW] and has had some success
in a limited form of _quantum splitting principle_.

In this paper, Theorem A is established using a new method which works
regardless of the splitting of a projective bundle. The idea is the following.
We compactify a vector bundle $V$ into $\mathbb{P}(V\oplus\mathcal{O})$. The
scaling action on $V$ by $\mathbb{C}^{*}$ can be extended into
$\mathbb{P}(V\oplus\mathcal{O})$ and we use
$\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V\oplus\mathcal{O}),\beta)$ as a
master space. Using virtual localization, we obtain relations between
(twisted) Gromov–Witten invariants of $S$ and $\mathbb{P}(V)$ by integrating a
cohomology class of degree strictly less than the virtual dimension. By using
this kind of relations, we determine Gromov–Witten theory of $\mathbb{P}(V)$
out of the one of $S$, and the whole algorithm only involves Chern classes of
$V$.

###  0.3. Consequences and remarks

The result is surprising to us because Chern classes are merely topological
invariants which are not enough to classify topological types of vector
bundles. For example,

######  Fact ([AR]).

In $\mathbb{P}^{3}$, suppose $V$ is a rank $2$ holomorphic vector bundle with
even first Chern class. There exists a holomorphic vector bundle $V^{\prime}$
such that $c_{1}(V)=c_{1}(V^{\prime}),c_{2}(V)=c_{2}(V^{\prime})$ while
$V\not\cong V^{\prime}$ as complex vector bundles.

In the meantime, Theorem 1.1 has an interesting consequence. In section 6, we
explain that our result immediately applies to [HLR] to get the following
refinement of [MP, Lemma 1].

######  Theorem B (=Theorem 6.1).

Let $Z\subset Y$ be inclusions of smooth projective varieties and $N_{Z/Y}$ be
the normal bundle of $Z$. Let $\tilde{Y}$ be the blow-up of $Y$ at $Z$ and $E$
be the exceptional divisor. The absolute Gromov–Witten invariants of
$\tilde{Y}$ can be determined by the absolute Gromov–Witten invariants of $Y$
and $Z$, plus the following topological data:

  1. (a)

The cohomology rings $H^{*}(Y)$, $H^{*}(Z)$ and their pull-back maps under
inclusion.

  2. (b)

The Chern classes $c_{i}(N_{Z/Y})\in H^{*}(Y)$.

All the above results motivate us to ask some further questions. For example,

######  Question 1.

Can we establish a similar theorem for arbitrary $\mathbb{P}^{n}$-fibrations
(not necessarily the projectivization of a vector bundle)?

More precisely, a $\mathbb{P}^{n}$-fibration (smooth fibration with each fiber
$\mathbb{P}^{n}$) will still satisfy the condition of Leray–Hirsch theorem,
and we can impose a condition by requiring that the identification of the
first Chern class of relative canonical sheaves induces an isomorphism between
cohomology rings of given fibrations. One can see that this condition
generalizes the one in Theorem A. On the other hand, a
$\mathbb{P}^{n}$-fibration admits other invariants, for example, the Brauer
class. It might be interesting to study whether Brauer class or other
invariants play a role here.

Regarding the blow-up theorem, it would be interesting to see whether the
whole algorithm can be made explicit. A further question we have in mind is
the following.

######  Question 2.

Is it possible to state a relatively “nice” relationship (say, using
symplectic operators depending on $c_{i}(N_{Z/X})$) between Lagrangian cones
$\mathcal{L}_{Bl_{Z}X}$, $\mathcal{L}_{X}$ and $\mathcal{L}_{Z}$?

###  0.4. Acknowledgement

The author would like to thank his advisor Y. P. Lee for his guidance and
encouragement throughout the project. He would also like to thank Andrei
Mustaţă, Junliang Shen, Yang Zhou and for helpful discussions. The author is
supported by NSF and SwissMAP.

##  1\. Statement of the main theorem

In this paper, $c(V)$ refers to the total Chern class, i.e.

$c(V)=1+c_{1}(V)+\cdots{}+c_{r}(V).$

Let $S$ be a smooth projective variety. $V_{1},V_{2}$ are vector bundles of
rank $r$ over $S$. We further require that

$c(V_{1})=c(V_{2}).$

Let $X_{1}=\mathbb{P}(V_{1}),X_{2}=\mathbb{P}(V_{2})$ be the corresponding
projective bundles, and

$\pi_{i}:X_{i}\rightarrow S$

are the projections for $i=1,2$. From Leray–Hirsch we know

$H^{*}(X_{i})=H^{*}(S)[h_{i}]/(h_{i}^{r}+c_{1}(V_{i})h_{i}^{r-1}+\cdots{}+c_{r}(V_{i})),(i=1,2),$

where $h_{i}=\mathcal{O}_{X_{i}}(1)$. Because their Chern classes agree, we
have the following isomorphism

$\mathfrak{F}_{V_{1},V_{2}}:H^{*}(X_{1})\cong H^{*}(X_{2})$

satisfying
$\mathfrak{F}_{V_{1},V_{2}}(\pi_{1}^{*}\sigma)=\pi_{2}^{*}\sigma,~{}\mathfrak{F}(h_{1})=h_{2}$.
There is also an isomorphism

$\Psi_{V_{1},V_{2}}:N_{1}(X_{1})\cong N_{1}(X_{2})$

determined by the intersection property

$(D,\beta)=(\mathfrak{F}_{V_{1},V_{2}}(D),\Psi_{V_{1},V_{2}}(\beta)),$

for any $D\in H^{2}(X_{1})$. To shorten the notation, we adopt the following
convention,

######  Convention 1.

When the context is clear, we write $\mathfrak{F}$ instead of
$\mathfrak{F}_{V_{1},V_{2}}$, and $\Psi$ instead of $\Psi_{V_{1},V_{2}}$.

Now we state our main theorem.

######  Theorem 1.1.

Let $S$ be a smooth projective variety, and $V_{1},V_{2}$ be two vector
bundles on $S$. Let $X_{1},X_{2},\mathfrak{F}$ also be the same as above.
Suppose $c(V_{1})=c(V_{2})$. Then we have the following equality between
Gromov–Witten invariants.

(2)
$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{X_{1}}=\langle\psi^{k_{1}}\mathfrak{F}(\alpha_{1}),\ldots{},\psi^{k_{n}}\mathfrak{F}(\alpha_{n})\rangle_{g,n,\Psi(\beta)}^{X_{2}}$

for any cohomology classes $\alpha_{1},\ldots{},\alpha_{n}\in H^{*}(X_{1})$,
any set of natural numbers $k_{1},\ldots{},k_{n}$, any curve class $\beta\in
N_{1}(X_{1})$ and any genus $g\in\mathbb{Z}_{\geq 0}$.

Let’s make a preliminary observation towards the theorem.

######  Lemma 1.2.

$(K_{X_{1}},\beta)=(K_{X_{2}},\Psi(\beta))$.

As a result, the virtual dimensions of the involved moduli spaces of stable
maps are the same, which is one of the first things one can check directly for
the theorem.

###### Proof.

Recall the Euler sequence

$0\rightarrow\mathcal{O}_{X_{i}}\rightarrow\pi_{i}^{*}V_{i}\otimes\mathcal{O}_{\mathbb{P}(V_{i})}(1)\rightarrow
T_{\pi_{i}}\rightarrow 0,$

where the $T_{\pi_{i}}$ is the relative tangent sheaf of the morphism
$\pi_{i}$. We also know that for $i=1,2$

$K_{X_{i}}=K_{\pi_{i}}\otimes\pi_{i}^{*}K_{S}=det(T_{\pi_{i}}^{\vee})\otimes\pi_{i}^{*}K_{S}.$

Thus, it suffices to prove

$\mathfrak{F}(c_{1}(det(T_{\pi_{1}}^{\vee})))=c_{1}(det(T_{\pi_{2}}^{\vee})).$

We see from the Euler sequence that

$c(T_{\pi_{i}})=c(\pi_{i}^{*}V_{i}\otimes\mathcal{O}_{\mathbb{P}(V_{i})}(1))$

for $i=1,2$. The proof can be easily finished with a splitting principle
calculation using the fact that $\mathfrak{F}\circ\pi_{1}^{*}=\pi_{2}^{*}$,
$\mathfrak{F}(c_{1}(\mathcal{O}_{\mathbb{P}(V_{1})}(1)))=c_{1}(\mathcal{O}_{\mathbb{P}(V_{2})}(1))$
and $c(V_{1})=c(V_{2})$. ∎

Note that in proving the theorem, we are free to twist both $V_{1}$ and
$V_{2}$ by a fixed line bundle _simultaneously_. To be more precise, for any
line bundle $L$ on $S$, we still have

$c(V_{1}\otimes L^{-1})=c(V_{2}\otimes L^{-1})$

and

$\mathbb{P}(V_{i}\otimes L^{-1})\cong\mathbb{P}(V_{i}).$

Throughout this paper, we choose $L$ to be sufficiently ample so that
$\mathcal{O}_{\mathbb{P}(V_{i}\otimes
L^{-1})}(1)=\mathcal{O}_{\mathbb{P}(V_{i})}(1)+\pi_{i}^{*}L$ is ample on
$X_{i}$. Therefore,without loss of generality, we make the following
assumption in this paper.

######  Assumption 1.

We assume that $\mathcal{O}_{\mathbb{P}(V_{i})}(1)$ is ample on
$\mathbb{P}(V_{i})$ for $i=1,2$.

Later, more specific requirements about the ampleness of $L$ will be made.

##  2\. Twisted Gromov–Witten invariants

The proof of Theorem 1.1 roughly goes by relating corresponding invariants on
$X_{1}$ and $X_{2}$ to the same expression of twisted invariants on $S$. In
this section, we set up the notations and recall basic facts about twisted
Gromov–Witten invariants.

Let $X$ be a smooth projective variety, $E$ be a vector bundle over $X$. Let

$ft_{n+1}:\overline{\mathcal{M}}_{g,n+1}(X,\beta)\rightarrow\overline{\mathcal{M}}_{g,n}(X,\beta)$

be the map forgetting the last marked point. Under this map
$\overline{\mathcal{M}}_{g,n+1}(X,\beta)$ can be viewed as the universal
family over $\overline{\mathcal{M}}_{g,n}(X,\beta)$. Furthermore, the
evaluation map of the last marked point

$ev_{n+1}:\overline{\mathcal{M}}_{g,n+1}(X,\beta)\rightarrow X$

serves as the universal stable map from the universal family over
$\overline{\mathcal{M}}_{g,n}(X,\beta)$.

Let $\mathbb{C}^{*}$ act on $X$ trivially and on $E$ by scaling (weight $1$ on
every $1$-dimensional linear subspace of a fiber). Let $\lambda$ be the
corresponding equivariant parameter. There exists a two-term complex of vector
bundles in $\overline{\mathcal{M}}_{g,n}(X,\beta)$

$0\rightarrow E_{g,n,\beta}^{0}\rightarrow E_{g,n,\beta}^{1}\rightarrow 0$

such that the $i$-th cohomology is $R^{i}(ft_{n+1})_{*}ev_{n+1}^{*}E$ for
$(i=0,1)$.

Let $\mathbb{C}^{*}$ act on $E_{g,n,\beta}^{i}$ by scaling as well. Write
$E_{g,n,\beta}$ for the two-term complex $[E_{g,n,\beta}^{0}\rightarrow
E_{g,n,\beta}^{1}]$ in $D^{b}(\overline{\mathcal{M}}_{g,n}(X,\beta))$. Define
the equivariant Euler class

$e_{\mathbb{C}^{*}}(E_{g,n,\beta})=\displaystyle\frac{e_{\mathbb{C}^{*}}(E_{g,n,\beta}^{0})}{e_{\mathbb{C}^{*}}(E_{0,n,\beta}^{1})}\in
H^{*}(\overline{\mathcal{M}}_{g,n}(X,\beta))\otimes_{\mathbb{C}}\mathbb{C}[\lambda,\lambda^{-1}].$

As a result,

$e_{\mathbb{C}^{*}}(E_{g,n,\beta}^{1})=\lambda^{r_{1}}+c_{1}(E_{g,n,\beta}^{1})\lambda^{{r_{1}}-1}+\cdots{}+c_{r}(E_{g,n,\beta}^{1})\in
H^{*}(\overline{\mathcal{M}}_{g,n}(X,\beta))\otimes_{\mathbb{C}}\mathbb{C}[\lambda],$

where $r_{1}=\text{rank}(E_{g,n,\beta}^{1})$. Since elements in
$H^{*}(\overline{\mathcal{M}}_{0,n}(X,\beta))$ are nilpotent, one easily sees
that $e_{\mathbb{C}^{*}}(E_{g,n,\beta})$ is well-defined if we invert
$\lambda$. Applying the same reason on $E^{0}_{g,n,\beta}$, we see
$e_{\mathbb{C}^{*}}(E_{g,n,\beta})$ is invertible if $\lambda$ can be
inverted.

Define the twisted Gromov–Witten invariants to be

$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{X,tw,E}=\displaystyle\int_{[\overline{\mathcal{M}}_{0,n}(X,\beta)]^{vir}}\frac{1}{e_{\mathbb{C}^{*}}(E_{g,n,\beta})}\cup\prod\limits_{i=1}^{n}\psi_{i}^{k_{i}}ev_{i}^{*}\alpha_{i}\in\mathbb{C}[\lambda,\lambda^{-1}].$

######  Remark 2.1.

Under the more general framework in [cg], our twisted invariants are only
their special case by choosing the multiplicative characteristic class to be
$\displaystyle\frac{1}{e_{\mathbb{C}^{*}}(\cdot)}$. Throughout our paper, this
is the only case we need.

######  Lemma 2.2.

If the insertions are homogeneous and satisfy

$\sum\limits_{i=1}^{n}k_{i}+\sum\limits_{i=1}^{n}deg(\alpha_{i})=dim([\overline{\mathcal{M}}_{g,n}(X,\beta)]^{vir}),$

then

$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{X,tw,E}=\displaystyle\frac{\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{X}}{\lambda^{r}}$

for some $r$.

###### Proof.

One can expand to see that

$\displaystyle\frac{1}{e_{\mathbb{C}^{*}}(E_{g,n,\beta})}=\frac{1}{\lambda^{r}}\left(1+\cdots{}\right),$

where $r=\text{rank}(E_{g,n,\beta}^{0})-\text{rank}(E_{g,n,\beta}^{1})$. Each
summand in $\cdots{}$ at the end involves cohomology classes of nonzero
degrees. Since the insertion already agrees with the virtual dimension of the
moduli space, only the leading term may produce a nonzero number. ∎

##  3\. Virtual localization

In order to carry out the recursive algorithm in Section 4, we need to use
virtual localization developed in [GP]. We would like to briefly recall their
technique and make the set-up in the next subsection.

###  3.1. Localization

Let $X$ be a smooth projective variety admitting an action by a torus
$T=\mathbb{C}^{m}$. It induces an action of $T$ on
$\overline{\mathcal{M}}_{g,n}(X,\beta)$. Let $\overline{\mathcal{M}}_{\alpha}$
be the connected components of the fixed loci
$\overline{\mathcal{M}}_{g,n}(X,\beta)^{T}$ labeled by $\alpha$ with the
inclusion
$i_{\alpha}:\overline{\mathcal{M}}_{\alpha}\rightarrow\overline{\mathcal{M}}_{g,n}(X,\beta)$.
The virtual fundamental class $[\overline{\mathcal{M}}_{g,n}(X,\beta)]^{vir}$
can be written as

$[\overline{\mathcal{M}}_{g,n}(X,\beta)]^{vir}=\sum_{\alpha}(i_{\alpha})_{!}\displaystyle\frac{[\overline{\mathcal{M}}_{\alpha}]^{vir}}{e_{T}(N^{vir}_{\alpha})},$

where $[\overline{\mathcal{M}}_{\alpha}]^{vir}$ is constructed from the fixed
part of the restriction of the perfect obstruction theory of
$\overline{\mathcal{M}}_{g,n}(X,\beta)$, and the virtual normal bundle
$N^{vir}_{\alpha}$ is the moving part of the two-term complex in the perfect
obstruction theory of $\overline{\mathcal{M}}_{g,n}(X,\beta)$. The indices
$\alpha$ in the above virtual localization formula can be replaced by
decorated graphs introduced later in this section.

We will focus on the case $T=\mathbb{C}^{*}$. The set-up of our localization
computation is the following. Let $S$ be a smooth projective variety and $V$ a
vector bundle on $S$. We would like to focus on
$\mathbb{P}(V\oplus\mathcal{O})$. Denote

$X=\mathbb{P}(V\oplus\mathcal{O}).$

There is a natural inclusion

$\mathbb{P}(V)\hookrightarrow X$

whose complement can be naturally identified as the total space of the vector
bundle $V$, i.e.,

(3) $V\cong X-\mathbb{P}(V).$

The $\mathbb{C}^{*}$ action on $V$ by scaling extends to $X$ in the obvious
way. Under this $\mathbb{C}^{*}$ action, the fixed loci of $X$ are the
following.

  1. (a)

A copy of $S$ (denoted by $X_{0}$) which can be identified as the zero section
of $V$ under the isomorphism in (3).

  2. (b)

A copy of $\mathbb{P}(V)$ (denoted by $X_{\infty}$) which can be identified as
$X\backslash V$.

We denote $X^{T}=X_{0}\bigcup X_{\infty}$. Their normal bundles are the
following.

  1. (a)

$N_{X_{0}/X}=V$. There is an induced fiberwise $\mathbb{C}^{*}$ action of
character $1$ for any sub-representation.

  2. (b)

$N_{X_{\infty}/X}=\mathcal{O}_{\mathbb{P}(V)}(1)$. There is an induced
fiberwise $\mathbb{C}^{*}$ action of character $-1$ for any sub-
representation.

######  Proposition 3.1.

The equivariant cohomology

$H^{*}_{\mathbb{C}^{*}}(X)=H^{*}(S)[\lambda,h]/(h^{r}+c_{1}(V)h^{r-1}+\cdots{}+c_{r}(V))(h-\lambda),$

where $r=rank(V)$, $\lambda$ is the equivariant parameter, and $h$ is the
equivariant cohomology class that restricts to $\lambda$ on $X_{0}$ and to
$c_{1}(\mathcal{O}_{\mathbb{P}(V)}(1))$ on $X_{\infty}$.

We omit the standard computation.

###  3.2. Decorated graph

Consider an invariant stable map $f:(C,x_{1},\ldots{},x_{n})\rightarrow X$. We
can associate a graph $\Gamma$ (with decorations) to it. Let $V(\Gamma)$ and
$E(\Gamma)$ be the set of vertices and edges, respectively. The rule of the
assignment is the following.

Vertices:

  * •

The connected components in $f^{-1}(X^{T})$ are either curves or points.
Assign a vertex $v$ to a connected component $\mathfrak{c}_{v}$ in
$f^{-1}(X^{T})$.

  * •

Define $p_{v}=0$ or $\infty$ depending on whether $f(\mathfrak{c}_{v})\subset
X_{0}$ or $X_{\infty}$, respectively.

  * •

Define $\beta_{v}=f_{*}[\mathfrak{c}_{v}]\in N_{1}(X_{p_{v}})$ the numerical
class of $f_{*}([\mathfrak{c}_{v}])$ (if $f(\mathfrak{c}_{v})$ is a point,
$[\mathfrak{c}_{v}]=0$).

  * •

Define $g_{v}$ to be the arithmetic genus of $\mathfrak{c}_{v}$.

  * •

For the $i$-th marked point ($i=1,\ldots{},n$), define $s_{i}=v$ if
$x_{i}\in\mathfrak{c}_{v}$.

Edges:

  * •

Assign each component of $C-\mathop{\bigcup}\limits_{v\in
V(\Gamma)}\mathfrak{c}_{v}$ an edge $e$. Let $\mathfrak{c}_{e}$ be the closure
of the corresponding component.

  * •

We write $\beta_{e}=f_{*}[\mathfrak{c}_{e}]\in N_{1}(X)$.

We also introduce the following.

######  Notation.

  * •

$\beta_{\Gamma}=\sum\limits_{e\in E(\Gamma)}\beta_{e}+\sum\limits_{v\in
V(\Gamma)}\beta_{v}$

  * •

$g_{\Gamma}=\sum\limits_{v\in V(\Gamma)}g_{v}+h^{1}(\Gamma)$ where
$h^{1}(\Gamma)$ is the dimension of first singular cohomology of $\Gamma$ as a
one-dimensional CW complex.

  * •

$n_{v}$ is the number of markings on the component $\mathfrak{c}_{v}$.

The graph assignment is invariant under deformations of invariant stable maps.
Thus, we label each connected component of fixed loci of
$\overline{\mathcal{M}}_{g,n}(X,\beta)$ by the decorated graphs above. Denote
the component by $\overline{\mathcal{M}}_{\Gamma}$ and the virtual normal
bundle $N_{\Gamma}^{vir}$. Now one can construct the fixed component as
certain fiber product according to the decorated graph, and write down
$\displaystyle\frac{1}{e(N_{\Gamma})^{vir}}$ more explicitly. The general
framework is treated in [MM].

In order to write the virtual localization formula, we need to introduce a few
more definitions (following [liu, Definition 53]).

######  Definition 3.2.

A vertex $v\in V(\Gamma)$ is called stable if $2g_{v}-2+val(v)+n_{v}>0$ or
$\beta_{v}\neq 0$. Let $V^{S}(\Gamma)$ be the set of stable vertices in
$V(\Gamma)$. Let

$\displaystyle V^{1}(\Gamma)$ $\displaystyle=\\{v\in
V(\Gamma)~{}|~{}g_{v}=0,val(v)=1,n_{v}=0,\beta_{v}=0\\},$ $\displaystyle
V^{1,1}(\Gamma)$ $\displaystyle=\\{v\in
V(\Gamma)~{}|~{}g_{v}=0,val(v)=n_{v}=1,\beta_{v}=0\\},$ $\displaystyle
V^{2}(\Gamma)$ $\displaystyle=\\{v\in
V(\Gamma)~{}|~{}g_{v}=0,val(v)=2,n_{v}=0,\beta_{v}=0\\}.$

The union of $V^{1}(\Gamma),V^{1,1}(\Gamma),V^{2}(\Gamma)$ is the set of
unstable vertices.

Define an equivalence relation $\sim$ on the set $E(\Gamma)$ by setting
$e_{1}\sim e_{2}$ if there is a $v\in V^{2}(\Gamma)$ such that $e_{1},e_{2}\in
E_{v}$.

######  Definition 3.3.

Define $\overline{E}(\Gamma)=E/\sim$.

One easily sees that a class $[e]\in\overline{E}(\Gamma)$ consists of a chain
of edges, say $e_{1},e_{2},\ldots{},e_{m}$ such that $e_{i}$ and $e_{i+1}$
intersect at a $v_{i}\in V^{2}(\Gamma)$. There are also two vertices $v_{0}\in
e_{1}$ and $v_{m}\in e_{m}$ such that $v_{0},v_{m}\not\in V^{2}(\Gamma)$.

######  Definition 3.4.

Define $V^{2}_{[e]}=\\{v_{1},\ldots{},v_{m-1}\\}$ and
$V^{end}_{[e]}=\\{v_{0},v_{m}\\}$.

######  Definition 3.5.

Define $\overline{E}^{tail}(\Gamma)$ be the set of edge classes
$[e]\in\overline{E}(\Gamma)$ such that $V^{end}_{[e]}\bigcap
V^{1}(\Gamma)\neq\emptyset$ or $V^{end}_{[e]}\bigcap
V^{1,1}(\Gamma)\neq\emptyset$.

######  Definition 3.6.

Define $V^{\infty}(\Gamma)=\\{v\in V(\Gamma)~{}|~{}p_{v}=\infty\\}$ and
$V^{0}(\Gamma)=\\{v\in V(\Gamma)~{}|~{}p_{v}=0\\}$.

Definitions 3.2-3.6 are used to describe some summation index in the virtual
localization formula.

##  4\. Computing invariants on a projective bundle

Let $S$ be the smooth projective variety. In this section, we focus on a
single vector bundle $V$. Write $\pi:\mathbb{P}(V)\rightarrow S$ to be the
projection. Later in this section, we recursively establish an algorithm genus
by genus. For each genus $g$, there are some additional data we need to choose
before the recursion begins.

######  Lemma 4.1.

For any $g\in\mathbb{Z}_{\geq 0}$, there is a sufficiently ample line bundle
$L_{g}\in\text{Pic}(S)$ such that for any $\beta\in NE(\mathbb{P}(V))$ with
$\pi_{*}\beta\neq 0$, we have

$(\beta,\mathcal{O}_{\mathbb{P}(V)}(1)+\pi^{*}L_{g})>\text{max}\\{g-1,0\\},$

(where $NE(\cdots{})$ means the Mori cone).

###### Proof.

For an ample $L$, we always have $(\overline{\beta},L)\geq 1$ for any nonzero
$\overline{\beta}\in NE(S)$. By replacing $L$ by its multiple $mL$, we can
assume that $(\overline{\beta},L)\geq m$ holds for any integer $m$ and any
nonzero $\overline{\beta}\in NE(S)$. Back to the lemma, for any $\beta\in
NE(\mathbb{P}(V))$, notice that

$(\beta,\mathcal{O}_{\mathbb{P}(V)}(1)+\pi^{*}L_{g})=(\beta,\mathcal{O}_{\mathbb{P}(V)}(1))+(\beta,\pi^{*}L_{g})=(\beta,\mathcal{O}_{\mathbb{P}(V)}(1))+(\pi_{*}\beta,L_{g}),$

where the last equality follows from the projection formula and the last
intersection pairing $(\pi_{*}\beta,L_{g})$ is evaluated in $S$. Since $g-1$
is a fixed integer, the inequality can be achieved by choosing $L$ to be a
sufficiently high multiple of an ample line bundle. ∎

Now that the collection of ample line bundles $\\{L_{g}\\}_{g\in\mathbb{N}}$
are chosen, we can state the following theorem.

######  Theorem 4.2.

Let $f\in N_{1}(\mathbb{P}(V))$ be the class of a line in a fiber. Suppose the
fiber integrals $\langle\ldots{}\rangle_{g,n,kf}^{\mathbb{P}(V)}$ are known.
There is an algorithm determining genus $g$ untwisted invariants of
$\mathbb{P}(V)$ from the genus $g^{\prime}$ twisted invariants of $S$ (twisted
by $V\otimes L_{g^{\prime\prime}}$ where $g^{\prime\prime}\leq g$) with
$g^{\prime}\leq g$. Furthermore, besides the twisted invariants of $S$, this
algorithm only depends on the cohomology rings $H^{*}(S)$ and
$H^{*}(\mathbb{P}(V))$, the cohomology class
$c_{1}(\mathcal{O}_{\mathbb{P}(V)}(1))$, the group of numerical curve classes
$N_{1}(\mathbb{P}(V))$ with its intersection pairing with
$H^{2}(\mathbb{P}(V))$, the pull-back morphism $\pi^{*}:H^{*}(S)\rightarrow
H^{*}(\mathbb{P}(V))$, and the Mori cone $NE(\mathbb{P}(V))$.

We rule out the fiber integrals
$\langle\ldots{}\rangle_{g,n,kf}^{\mathbb{P}(V)}$ because they serve as the
initial case for an induction, obtained by a method different from
localization. We summarize the structure of this section as follows. We study
fiber integrals in Section 4.1. Next, we prove Theorem 4.2 by introducing the
set-up in sections 4.2, determining insertions to be used in the master space
in 4.3, and writing out the computation in 4.4.

###  4.1. Fiber classes

In this section, we determine integrals of the form
$\langle\ldots{}\rangle_{g,n,kf}^{\mathbb{P}(V)}$ where $f\in
N_{1}(\mathbb{P}(V))$ is the line class in a fiber. Similar to [MP, section
1.2], $\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)$ is fibered over $S$,
i.e. there is a morphism

$p:\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)\rightarrow S.$

In fact,
$\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)=\mathcal{P}\times\overline{\mathcal{M}}_{g,n}(\mathbb{P}^{r},k)/GL(r+1)$
where $\mathcal{P}$ is the principal $GL(r+1)$ bundle corresponding to $V$,
and $GL(r+1)$ acts on the product diagonally. We can decompose the virtual
class as

$[\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)]^{vir}=e(\mathbb{E}\boxtimes
T_{S})\cap[\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)]^{vir_{p}},$

where $\mathbb{E}$ is the Hodge bundle and
$[\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)]^{vir_{p}}$ is the relative
virtual class. This reduces our problem to the determination of integrals
against $[\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)]^{vir_{p}}$. This
relative virtual class can be described in terms of something that is well-
understood.

Without breaking Assumption 1, we can replace $V$ by $V\otimes L^{-1}$ where
$L$ is sufficiently ample. As a result, we can assume $V^{\vee}$ is globally
generated and there is a surjection map $\mathcal{O}^{N}\rightarrow V^{\vee}$
for some large integer $N$. By taking the dual, we embed $V$ into a trivial
bundle

$V\hookrightarrow\mathcal{O}^{N}.$

By the universal property of Grassmannian, it induces a morphism

$f:S\rightarrow Gr(r+1,N)$

such that $f^{*}U=V$ where $U$ is the tautological bundle of rank $r+1$. We
write $G=Gr(r+1,N)$ in short. In the meantime, we have the
$\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)$ whose base change via $f$
is isomorphic to $\overline{\mathcal{M}}_{g,n}(\mathbb{P}(V),kf)$. Now we have
the diagram

$\textstyle{\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{S}(V),kf)\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{p}$$\scriptstyle{\bar{f}}$$\textstyle{\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{\bar{p}}$$\textstyle{S\ignorespaces\ignorespaces\ignorespaces\ignorespaces}$$\scriptstyle{f}$$\textstyle{G}$

One sees that
$\bar{f}^{!}[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)]^{vir_{\bar{p}}}=[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{S}(V),kf)]^{vir_{p}}$.
As a result,

$\bar{p}^{*}f_{!}\sigma\cap[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)]^{vir_{\bar{p}}}=\bar{p}^{*}\sigma\cap\bar{f}_{!}[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{S}(V),kf)]^{vir_{p}},$

where $\sigma\in H^{*}(S)$.

An insertion is in the form $h^{i}\pi^{*}\sigma\in H^{*}(\mathbb{P}_{S}(V))$
where $h=c_{1}(\mathcal{O}_{\mathbb{P}_{S}(V)}(1))$, $\sigma\in H^{*}(S)$. It
corresponds to a factor $ev_{j}^{*}(h^{i}\pi^{*}\sigma)\in
H^{*}(\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{S}(V),kf))$ in the integrand.
Notice that $ev_{j}^{*}\pi^{*}\sigma=p^{*}\sigma$, and
$ev_{j}^{*}h=\bar{f}^{*}(ev_{j}^{*}h^{\prime})$ where
$h^{\prime}=c_{1}(\mathcal{O}_{\mathbb{P}_{G}(U)}(1))$. In view of this, we
can push forward the integrands against
$[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{S}(V),kf)]^{vir_{p}}$ and reduce it
to an integral against
$[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)]^{vir_{\bar{p}}}$. On the
other hand, $[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)]^{vir}$ and
$[\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)]^{vir_{\bar{p}}}$ are
computable since we can use the localization on the Grassmannian.

This method is enough for us to establish our main theorem in the special
cases of fiber classes.

######  Lemma 4.3.

Theorem 1.1 holds if $\beta=kf$ for some $k\in\mathbb{Z}_{>0}$.

###### Proof.

Given $V$, $V^{\prime}$ such that $c(V)=c(V^{\prime})$, we can twist them by
the inverse of a sufficiently ample line bundle to carry out all the above
constructions at the same time. In particular, we have morphisms

$f,f^{\prime}:S\rightarrow G=Gr(r+1,N)$

for some $N$ such that $f^{*}U=V$ and $f^{\prime*}U=V^{\prime}$. Notice that
the Chern classes $c_{i}(U)$ generates the cohomology ring $H^{*}(G)$. Because
$f^{*}c_{i}(U)=f^{\prime*}c_{i}(U)$, we conclude that $f,f^{\prime}$ induce
the same pull-back morphisms between cohomology rings, i.e.,
$f^{*}=f^{\prime*}\in Hom(H^{*}(G),H^{*}(S))$. As a result,
$f_{!}(\sigma)=f^{\prime}_{!}(\sigma)$ for any $\sigma\in H^{*}(S)$.
Therefore,if we carry out all the above reductions for $V$ and $V^{\prime}$ in
parellel and push the integrands forward into
$\overline{\mathcal{M}}_{g,n}(\mathbb{P}_{G}(U),kf)$, we get the same
integrals. ∎

###  4.2. Set-ups for the main algorithm

Starting from this subsection, we work towards Theorem 4.2. We say

$\beta<\beta^{\prime}\in NE(X)$

if either $(\pi_{X})_{*}\beta^{\prime}-(\pi_{X})_{*}\beta\in
NE(S)\backslash\\{0\\}$ or $\beta^{\prime}-\beta\in NE(X)\backslash\\{0\\}$.
We are ready to state the induction hypothesis.

######  Induction hypothesis.

We induct on the genus and the numerical curve classes. Fix a genus $g_{0}$
and an effective curve class $\beta_{0}\in NE(\mathbb{P}(V))$. For any
$g,\beta$ such that $\beta<\beta_{0}$ and $g\leq g_{0}$, assume that the
formulas of invariants of the form
$\langle\ldots{}\rangle^{\mathbb{P}(V)}_{g,n,\beta}$ in terms of the ones of
the form $\langle\ldots{}\rangle^{S,tw,V\otimes
L_{g^{\prime}}^{-1}}_{g^{\prime},n^{\prime},\overline{\beta}^{\prime}}$ (where
$g^{\prime}\leq g$) are found.

Since fiber classes are already determined in the previous section, we may
assume the following.

######  Assumption 2.

For the rest of the section, we assume $\pi_{*}\beta_{0}\neq 0$.

######  Goal.

Express
$\langle\psi^{k_{1}}\alpha_{i},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g_{0},n,\beta_{0}}^{\mathbb{P}(V)}$
in terms of Gromov–Witten invariants of the form
$\langle\ldots{}\rangle_{g,n^{\prime},\beta}^{\mathbb{P}(V)}$ with
$\beta<\beta_{0}$ and $g\leq g_{0}$, plus the twisted invariants of $S$.

From now on, the genus $g_{0}$ is fixed and we stick to the line bundle
$L_{g_{0}}$ throughout the rest of the section. Consider the Gromov–Witten
invariants with target $\mathbb{P}_{S}(V\otimes
L_{g_{0}}^{-1}\oplus\mathcal{O})$. To simplify notations, we may replace $V$
by $V\otimes L_{g_{0}}^{-1}$ just as in Assumption 1, which is summarized as
the following.

######  Assumption 3.

For the rest of the section, in addition to the induction hypothesis and the
ampleness of $\mathcal{O}_{\mathbb{P}_{S}(V)}(1)$, we also assume
$(\beta,\mathcal{O}_{\mathbb{P}_{S}(V)}(1))>g_{0}-1$ for any $\beta\in
NE(\mathbb{P}_{S}(V))$ such that $\pi_{*}\beta\neq 0$.

Recall that in the previous section, we wrote
$X=\mathbb{P}(V\oplus\mathcal{O})$ and introduced $X_{\infty}$, $X_{0}$ along
with other notations. We continue to use those notations. Recall we have the
isomorphisms

$\mathbb{P}(V)\cong X_{\infty}\subset X,S\cong X_{0}\subset X.$

We are going to apply virtual localization to certain invariants on $X$ and
obtain relations between invariants of $\mathbb{P}(V)$ and the ones of $S$. In
order to write down the localization formula, we need to fix some notations.

######  Notation.

  1. (a)

To simplify notations, we write
$\mathcal{O}(1)=\mathcal{O}_{\mathbb{P}(V)}(1)$ and
$H=c_{1}(\mathcal{O}_{\mathbb{P}(V)}(1))$.

  2. (b)

Given a decorated graph $\Gamma$, for any $v\in\Gamma$, we label the markings
on the component $\mathfrak{c}_{v}$ by $m_{1}^{v},\ldots{},m_{n_{v}}^{v}$.

  3. (c)

Choose a $\mathbb{C}$-basis $\\{T_{i}\\}$ for the cohomology ring $H^{*}(S)$
with dual basis written as $\\{T^{i}\\}$ (under Poincaré pairing).

Besides, the following convention is used throughout the rest of the section.

######  Convention 2.

Let $\iota:X_{\infty}\hookrightarrow X$ be the inclusion. Since we have the
natural identification of the numerical curve classes
$\iota_{*}:N_{1}(X_{\infty})\cong N_{1}(X)$, we won’t distinguish curve
classes in $X$ and $X_{\infty}$ notation-wise. Furthermore, given $\beta\in
N_{1}(X_{\infty})$, since
$(\beta,\mathcal{O}_{X_{\infty}}(1))=(\iota_{*}\beta,\mathcal{O}_{X}(1))$, we
write $(\beta,\mathcal{O}(1))$ for this intersection pairing without
distinguishing whether it is evaluated on $X_{\infty}$ or $X$.

###  4.3. Lifting of insertions

Given a cohomology class $\alpha\in H^{*}(X_{\infty})$, we lift $\alpha$ to
$\tilde{\alpha}\in H^{*}_{\mathbb{C}^{*}}(X)$ in the way described in the
following.

$\alpha$ can always be written as

$\alpha=H^{e}\cup\pi^{*}\overline{\alpha}\in H^{*}(X_{\infty}),$

where $\overline{\alpha}\in H^{*}(S)$. Under the presentation in Proposition
3.1, recall $h=c_{1,T}(\mathcal{O}_{\mathbb{P}(V\oplus\mathcal{O})}(1))$. We
see $h$ is a lifting of $H$. Define

$\tilde{\alpha}=h^{e}\cup\pi_{X}^{*}\overline{\alpha}\in
H^{*}_{\mathbb{C}^{*}}(X),$

where $\pi_{X}:X\cong\mathbb{P}(V\oplus\mathcal{O})\rightarrow S$ is the
projection. Obviously $\tilde{\alpha}$ restricts to $\alpha$ on $X_{\infty}$
and to $\lambda^{e}\pi^{*}\overline{\alpha}$ on $X_{0}$.

###  4.4. Localization formula

Let’s introduce some notations.

######  Notation.

  1. (a)

Define

${\bf c}_{V}(x)=x^{r}+c_{1}(V)x^{r-1}+\cdots{}+c_{r}(V),$

where $r=rank(V)$.

  2. (b)

When we fix a class $[e]\in\bar{E}(\Gamma)$, denote $v_{+},v_{-}$ to be the
two vertices in $V_{[e]}^{end}$ (whichever is arbitrary).

  3. (c)

Define $\iota_{\pm}:\mathbb{P}(V)\rightarrow X_{0}$ to be the projection if
$p_{v_{\pm}}=0$, or $\iota_{\pm}:\mathbb{P}(V)\rightarrow X_{\infty}$ the
identity map if $p_{v_{\pm}}=\infty$, respectively.

  4. (d)

Let $e_{\pm}$ be the edge in the class $[e]$ that contains $v_{\pm}$,
respectively (they can be the same).

  5. (e)

For a vertex $v$, define $Vert(v)={\bf c}_{V}(\lambda),\delta_{v}=1$ if
$p_{v}=0$, or $Vert(v)=H-\lambda,\delta_{v}=-1$ if $p_{v}=\infty$,
respectively.

Consider the equivariant Gromov–Witten invariant

(4)
$\langle\psi^{k_{1}}\tilde{\alpha}_{1},\ldots{},\psi^{k_{n}}\tilde{\alpha}_{n}\rangle^{X}_{g_{0},n,\beta_{0}}\in\mathbb{C}[\lambda].$

Now let’s write down the virtual localization formula:

(5)
$\displaystyle\begin{split}&\langle\psi^{k_{1}}\tilde{\alpha}_{1},\ldots{},\psi^{k_{n}}\tilde{\alpha}_{n}\rangle^{X}_{g_{0},n,\beta_{0}}\\\
=&\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle^{X_{\infty},tw,\mathcal{O}(1)}_{g_{0},n,\beta_{0}}+\\\
&\sum\limits_{\Gamma\neq\Gamma_{0}}\displaystyle\frac{1}{Aut(\Gamma)}\prod\limits_{v\in
V^{S}(\Gamma)}\sum\limits_{\\{i_{[e]}\\}_{[e]\in\overline{E}(\Gamma)-\overline{E}^{tail}(\Gamma)}}\langle\psi^{k_{m_{1}^{v}}}\tilde{\alpha}_{m_{1}^{v}}|_{X_{p_{v}}},\ldots{},\psi^{k_{m_{n_{v}}^{v}}}\tilde{\alpha}_{m_{n_{v}}^{v}}|_{X_{p_{v}}},\ldots{}\rangle^{X_{p_{v}},tw,\star}_{g_{v},n,\beta_{v}}\end{split}$

A few explanations are in order:

  * •

We sum over all decorated graphs with $g_{\Gamma}=g_{0}$ and
$\beta_{\Gamma}=\beta_{0}$. $\Gamma_{0}$ is the decorated graph such that
$V(\Gamma)$ consists of a single element $v_{0}$, $E(\Gamma)=\emptyset$, and
$p_{v_{0}}=\infty$.

  * •

We adopt the obvious convention that when $X_{p_{v}}=X_{0}$, the invariant is
twisted by $V$ (with fiberwise $\mathbb{C}^{*}$ action of character $1$ for
any sub-representation), and when $X_{p_{v}}=X_{\infty}$, the invariant is
twisted by $\mathcal{O}(1)$ (with fiberwise $\mathbb{C}^{*}$ action of
character $-1$). In other words, the $\star$ symbol in the superscript at the
end of the last line needs to be replaced by either $V$ or $\mathcal{O}(1)$
depending on the situation.

  * •

Each $i_{[e]}$ in
$\\{i_{[e]}\\}_{[e]\in\overline{E}(\Gamma)-\overline{E}^{tail}(\Gamma)}$
determines an element $T_{i_{[e]}}$ in the basis $\\{T_{i}\\}$. As suggested
by the notation, they are indexed by
$\overline{E}(\Gamma)-\overline{E}^{tail}(\Gamma)$.

  * •

The last $\ldots{}$ sign in the twisted invariant should be inserted as
follows. For any $[e]\in\overline{E}(\Gamma)$, we have $v_{+},v_{-}\in
V^{end}_{[e]}$ as before. Some insertions are inserted into
$\langle\ldots{}\rangle_{g_{v_{\pm}},val({v_{\pm}}),\beta_{v_{\pm}}}^{X_{p_{v_{\pm}}},tw,*}$
which will be specified according to the following cases: (recall fiber
integrals are treated differently. Therefore,at least one of $v_{\pm}$ has
nontrivial degree.)

    1. (a)

Suppose one of $v_{+}$ and $v_{-}$ is in $V^{1}(\Gamma)$. Say $v_{-}\in
V^{1}(\Gamma)$. Then an insertion

$(\iota_{+})_{*}\left(\displaystyle\frac{\delta_{v_{-}}(\lambda-H)}{k_{e_{-}}Vert(v_{-})}\cdot\frac{Edge(\Gamma,[e])}{\delta_{v_{+}}(\lambda-H)/k_{e_{+}}-\psi}\right)$

is inserted into the summand
$\langle\ldots{}\rangle_{g_{v_{+}},val({v_{+}}),\beta_{v_{+}}}^{p_{v_{+}},tw,*}$.
We take $\psi$ to be a formal variable under the Gysin push-forward
$(\iota_{+})_{*}$, and then it is evaluated as the $\psi$-class in the
corresponding Gromov–Witten invariant. The same convention is used in the rest
of the section.

    2. (b)

Suppose one of $v_{+}$ and $v_{-}$ is in $V^{1,1}(\Gamma)$. Say $v_{-}\in
V^{1,1}(\Gamma)$. Then an insertion

$(\iota_{+})_{*}\left(\dfrac{1}{Vert(v_{-})}\cdot\dfrac{Edge(\Gamma,[e])}{\delta_{v_{+}}(\lambda-H)/k_{e_{+}}-\psi}\cdot\psi^{k_{m_{1}^{v_{-}}}}(\iota_{-})^{*}\left(\tilde{\alpha}_{m_{1}^{v_{-}}}|X_{p_{v_{-}}}\right)\right)$

is inserted into the summand
$\langle\ldots{}\rangle_{g_{v_{+}},val({v_{+}}),\beta_{v_{+}}}^{p_{v_{+}},tw,*}$.

    3. (c)

If none of the above applies, $v_{+},v_{-}$ must all be stable vertices. In
this case, an insertion

$(\iota_{+})_{*}\left(\displaystyle\frac{Edge(\Gamma,[e])T_{i_{[e]}}}{\delta_{v_{+}}(\lambda-H)/k_{e_{+}}-\psi}\right)$

should be placed in the summand
$\langle\ldots{}\rangle_{g_{v_{+}},val({v_{+}}),\beta_{v_{+}}}^{p_{v_{+}},tw,*}$.
In the meantime, an insertion

$(\iota_{-})_{*}\left(\displaystyle\frac{T^{i_{[e]}}}{\delta_{v_{-}}(\lambda-H)/k_{e_{-}}-\psi}\right)$

should be placed in the
$\langle\ldots{}\rangle_{g_{v_{-}},val({v_{-}}),\beta_{v_{-}}}^{p_{v_{-}},tw,*}$
summand.

In all the above expressions, the edge contribution $Edge(\Gamma,[e])$ can be
computed as

$Edge[\Gamma,[e]]=\displaystyle\frac{\displaystyle\prod\limits_{v\in
V^{2}_{[e]}\bigcup V^{end}_{[e]}}Vert(v)}{\displaystyle\prod\limits_{v\in
V^{2}_{[e]}}\left(\left(\sum\limits_{e^{\prime}\in
E_{v}}\displaystyle\frac{1}{k_{e^{\prime}}}\right)\delta_{v}(\lambda-H)\right)\prod\limits_{e\in[e]}\prod\limits_{m=1}^{k_{e}}\left(\dfrac{m}{k_{e}}(H-\lambda){\bf
c}_{V}\left(H+\dfrac{m}{k_{e}}(\lambda-H)\right)\right)}.$

We also left out some special cases (for example, when both $v_{+}$, $v_{-}$
lie in $V^{1}(\Gamma)$ or $V^{1,1}(\Gamma)$). We leave the details to the
readers as they are easy to figure out.

######  Lemma 4.4.

In Equation (5), take $\alpha_{i},k_{i}$ such that

$\sum\limits_{i=1}^{n}k_{i}+\sum\limits_{i=1}^{n}deg(\alpha_{i})=dim[\overline{\mathcal{M}}_{g_{0},n}(\mathbb{P}(V),\beta_{0})]^{vir}.$

If the curve class $\beta_{0}\in N_{1}(X)$ satisfies $\beta_{0}\in NE(X)$ and
$(\beta_{0},\mathcal{O}(1))>g_{0}-1$, the left-hand side of Equation (5) is
zero.

###### Proof.

It can be proven by dimension counting. First of all, recall

$\langle\psi^{k_{1}}\tilde{\alpha}_{1},\ldots{},\psi^{k_{n}}\tilde{\alpha}_{n}\rangle^{X}_{g_{0},n,\beta_{0}}=\displaystyle\int_{[\overline{\mathcal{M}}_{g_{0},n}(X,\beta_{0})]^{vir}}\prod\limits_{i=1}^{n}\psi_{i}^{k_{i}}ev_{i}^{*}\alpha_{i},$

where $[\overline{\mathcal{M}}_{g_{0},n}(X,\beta_{0})]^{vir}$ and the
integration should be understood equivariantly. Notice

(6)
$\begin{split}\sum\limits_{i=1}^{n}k_{i}+\sum\limits_{i=1}^{n}deg(\tilde{\alpha}_{i})&=\sum\limits_{i=1}^{n}k_{i}+\sum\limits_{i=1}^{n}deg(\alpha_{i})\\\
&=dim[\overline{\mathcal{M}}_{g_{0},n}(\mathbb{P}(V),\beta_{0})]^{vir}\\\
&=dim[\overline{\mathcal{M}}_{g_{0},n}(X,\beta_{0})]^{vir}-(1-g_{0}+(\beta_{0},\mathcal{O}(1)))\\\
&<dim[\overline{\mathcal{M}}_{g_{0},n}(X,\beta_{0})]^{vir}.\end{split}$

Here we used the assumption that $(\beta_{0},\mathcal{O}(1))>g_{0}-1$.
Integrating a lower degree equivariant cohomology class on a higher degree
equivariant homology class results in $0$, since there is no negative degree
element in $H^{*}_{\mathbb{C}^{*}}(\\{pt\\})$. ∎

Recall that if
$\sum\limits_{i=1}^{n}k_{i}+\sum\limits_{i=1}^{n}deg(\alpha_{i})=dim[\overline{\mathcal{M}}_{g_{0},n}(\mathbb{P}(V),\beta_{0})]^{vir}$,
by Lemma 2.2, we have

$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{X,tw,\mathcal{O}(1)}=\displaystyle\frac{\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{X}}{(-\lambda)^{r}}.$

The $(-\lambda)$ on the denominator is due to the induced action of
$\mathbb{C}^{*}$ on $\mathcal{O}(-1)$ that has weight $-1$ fiberwise.
Therefore, under this degree condition of insertions, the leading term of the
right-hand side of Equation (5) is in fact an untwisted invariant.

Back to the goal of this section. Note that in the last line of Equation (5),
we sum over $\Gamma$ with $\Gamma\neq\Gamma_{0}$. $E(\Gamma)$ has to be
nonempty. Notice that the edge component must have nontrivial numerical class.
As a result, for any $v\in V(\Gamma)$, we have $\beta_{v}<\beta_{0}$. Since
$g_{\Gamma}=g_{0}$, we have $g_{v}\leq g_{0}$ for all $v\in V(\Gamma)$. These
observation together with Lemma 4.4, our induction is achieved by applying
Equation (5) under the induction hypothesis and the degree condition of
insertions in Lemma 4.4. In other words, Equation (5) expresses
$\langle\psi^{k_{1}}\alpha_{i},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g_{0},n,\beta_{0}}^{\mathbb{P}(V)}$
in terms of Gromov–Witten invariants of the form
$\langle\ldots{}\rangle_{g,n^{\prime},\beta}^{\mathbb{P}(V)}$ with
$\beta<\beta_{0}$ and $g\leq g_{0}$, plus the twisted invariants of $S$.

######  Example 4.5.

If $S$ is a point, it provides a way to compute $g=0$ Gromov–Witten invariants
of $\mathbb{P}^{n}$ from the ones of a point. In this case, any curve class is
a fiber class in the sense of section 4.1. Note that our localization still
works for fiber integrals when $g=0$.

Let us compute $\langle\psi^{2n-1}\rangle_{0,1,1}^{\mathbb{P}^{n}}$. If we use
the hypergeometric $J$-function in the mirror theorem, we know the answer is

$\langle\psi^{2n-1}\rangle_{0,1,1}^{\mathbb{P}^{n}}=(-1)^{n}{{2n}\choose{n}}.$

Now we apply master space technique and consider
$\langle\psi^{2n-1}\rangle_{0,1,1}^{\mathbb{P}^{n+1}}$, which is $0$ due to
the virtual dimension. Let $\mathbb{C}^{*}$ act on $\mathbb{P}^{n+1}$ by
sending $[x_{0}:\ldots{}:x_{n+1}]$ to $[\lambda x_{0}:\ldots{}:\lambda
x_{n}:x_{n+1}]$. We have

(7)
$\displaystyle\begin{split}0=\langle\psi^{2n-1}\rangle_{0,1,1}^{\mathbb{P}^{n+1}}&=\langle\psi^{2n-1}\rangle_{0,1,1}^{\mathbb{P}^{n}}\lambda^{-2}+\displaystyle\int_{\mathbb{P}^{n}}\dfrac{(\lambda-H)^{2n-1}(\lambda-H)}{\lambda^{n+1}(H-\lambda)}+\int_{\mathbb{P}^{n}}\dfrac{(-\lambda+H)^{2n-1}(-\lambda+H)}{\lambda^{n+1}(H-\lambda)}\\\
&=\langle\psi^{2n-1}\rangle_{0,1,1}^{\mathbb{P}^{n}}\lambda^{-2}-2(-1)^{n}{2n-1\choose
n}\lambda^{-2}.\end{split}$

Notice $\displaystyle 2{2n-1\choose n}={2n\choose n}$. We are done.

##  5\. Proof of Theorem 1.1

Before the proof, let’s state a few lemmas.

######  Lemma 5.1.

Let $S$ be a smooth projective variety. Let $V_{1},V_{2}$ be vector bundles
over $S$ such that $c(V_{1})=c(V_{2})$. Let $\mathbb{C}^{*}$ act on
$V_{1},V_{2}$ by scaling. We have the equality of twisted invariants

$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{S,tw,V_{1}}=\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{S,tw,V_{2}}\in\mathbb{C}[\lambda,\lambda^{-1}].$

It has a similar appearance as the Theorem 1.1. But it’s all about invariants
on $S$ twisted by two different vector bundles.

###### Proof.

Since the $\mathbb{C}^{*}$ acts on $V_{i}$ by scaling, we have

$e_{\mathbb{C}^{*}}((V_{i})_{g,n,\beta})=\lambda^{r}+c_{1}((V_{i})_{g,n,\beta})\lambda^{r-1}+\cdots{}+c_{r}((V_{i})_{g,n,\beta}).$

It suffices to prove that $c((V_{i})_{g,n,\beta})$ depends only on the total
Chern class $c(V_{i})$ for $i=1,2$. But this can be seen using the
Grothendieck Riemann-Roch formula

$ch((V_{i})_{g,n,\beta})=(ft_{n+1})_{*}\left(ch(ev_{n+1}^{*}V_{i})\cdot
Td^{\vee}(\Omega_{ft_{n+1}})\right).$

One can get more precise formulas by following the analysis in [cg, Appendix
1] or [FP]. Since $c(V_{1})=c(V_{2})$, we have $ch(V_{1})=ch(V_{2})$. And we
readily have $ch(ev_{n+1}^{*}V_{1})=ch(ev_{n+1}^{*}V_{2})$ by functoriality.
The Todd class is determined by the moduli stacks
$\overline{\mathcal{M}}_{0,n}(X,\beta)$ and its universal family, which is
independent of $V_{1}$ and $V_{2}$. ∎

######  Lemma 5.2.

Let $S$ be a smooth projective variety. Let $V$ be a vector bundle with
$\mathbb{C}^{*}$ acting by scaling on fibers. Then

$\langle\psi^{k_{1}}\alpha_{1},\ldots{},\psi^{k_{n}}\alpha_{n}\rangle_{g,n,\beta}^{S,tw,V}$

can be determined by the Chern classes $c(V)$ and untwisted invariants of the
form

$\langle\psi^{k^{\prime}_{1}}\alpha^{\prime}_{1},\ldots{},\psi^{k^{\prime}_{n^{\prime}}}\alpha^{\prime}_{n^{\prime}}\rangle_{g^{\prime},n^{\prime},\beta^{\prime}}^{S},$

where $g^{\prime}\leq g$, $\beta^{\prime}\leq\beta$.

Again it can be done by Grothendieck Riemann-Roch formula and we omit the
details.

The proof of 1.1 proceeds by applying Theorem 4.2 to both $\mathbb{P}(V_{1})$
and $\mathbb{P}(V_{2})$. But there is still one issue. Now that the
corresponding twisted invariants on $S$ are identified, all the ingredients
for the two cases in Theorem 4.2 now agree except the Mori cones
$NE(\mathbb{P}(V_{1}))$ and $NE(\mathbb{P}(V_{2}))$. In general, the two Mori
cones can be different. However, the condition in Lemma 4.4 is enough for
Equation (5) to provide relations between invariants on projective bundles and
twisted invariants. Lemma 4.4 requires a weaker condition on the curve class
$\beta_{0}$ than being effective in $\mathbb{P}(V)$.

Fix an $i\in\\{1,2\\}$. Recall we identify $N_{1}(\mathbb{P}(V_{i}))$ with
$N_{1}(\mathbb{P}(V_{i}\oplus\mathcal{O}))$ via push-forward under inclusion
and we have $NE(\mathbb{P}(V_{i}))\subset
NE(\mathbb{P}(V_{i}\oplus\mathcal{O}))$ since push-forward preserves
effectiveness. Also recall that by Assumption 1 in section 1.1,
$\mathcal{O}_{\mathbb{P}(V_{i})}(1)$ is ample on $\mathbb{P}(V_{i})$. We prove
a few lemmas under this assumption.

######  Lemma 5.3.

$\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1)$ is nef on
$\mathbb{P}(V_{i}\oplus\mathcal{O})$.

###### Proof.

$\mathbb{P}(V_{i})$ can be realized as the zero locus of a section $s$ on the
line bundle $\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1)$. Let $C$ be
an effective curve on $\mathbb{P}(V_{i}\oplus\mathcal{O})$. If
$C\subset\mathbb{P}(V_{i})$,
$\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1)$ restricts to an ample
line bundle on $C$ by assumption. If otherwise, $s$ does not vanish on the
whole $C$. Therefore,$\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1)$
restricts to a line bundle of nonnegative degree as well. ∎

Recall $V_{i}\subset\mathbb{P}(V_{i}\oplus\mathcal{O})$. Let
$\iota_{i}:S\rightarrow\mathbb{P}(V_{i}\oplus\mathcal{O})$ be the inclusion
given by the zero section of $V_{i}$, and
$pr_{i}:\mathbb{P}(V_{i}\oplus\mathcal{O})\rightarrow S$ the projection. Let
$f_{i}\in NE(\mathbb{P}(V_{i}\oplus\mathcal{O}))$ be the class of degree $1$
curve on the fiber.

######  Lemma 5.4.

Any extremal curve class $\beta\in NE(\mathbb{P}(V_{i}\oplus\mathcal{O}))$
with $(pr_{i})_{*}\beta\neq 0$ must have
$\beta=(\iota_{i})_{*}(pr_{i})_{*}\beta$.

###### Proof.

First of all, $\beta-(\iota_{i})_{*}(pr_{i})_{*}\beta=kf$ for some integer
$k$. If $k>0$, $\beta=kf+(\iota_{i})_{*}(pr_{i})_{*}\beta$ contradicts with
$\beta$ being extremal. On the other hand, notice
$((\iota_{i})_{*}(pr_{i})_{*}\beta,\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1))=0$.
We have

$k=(kf,\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1))=(\beta-(\iota_{i})_{*}(pr_{i})_{*}\beta,\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1))=(\beta,\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1))\geq
0$

since $\mathcal{O}_{\mathbb{P}(V_{i}\oplus\mathcal{O})}(1)$ is nef. The only
case possible is $k=0$. ∎

Now $i\in\\{1,2\\}$ is no longer fixed, and we are going to compare the
$i=1,2$ cases. Recall $c(V_{1})=c(V_{2})$. We have the natural identification
$\Psi_{V_{1}\oplus\mathcal{O},V_{2}\oplus\mathcal{O}}:N_{1}(\mathbb{P}(V_{1}\oplus\mathcal{O}))\cong
N_{1}(\mathbb{P}(V_{2}\oplus\mathcal{O}))$ from section 1.

######  Lemma 5.5.

$\Psi_{V_{1}\oplus\mathcal{O},V_{2}\oplus\mathcal{O}}(NE(\mathbb{P}(V_{1}\oplus\mathcal{O})))=NE(\mathbb{P}(V_{2}\oplus\mathcal{O}))$.

###### Proof.

Certainly $\Psi_{V_{1}\oplus\mathcal{O},V_{2}\oplus\mathcal{O}}(f_{1})=f_{2}$.
One can also check that given a $\overline{\beta}\in NE(S)$,

$\Psi_{V_{1}\oplus\mathcal{O},V_{2}\oplus\mathcal{O}}((\iota_{1})_{*}\overline{\beta})=(\iota_{2})_{*}\overline{\beta}.$

As a result, extremal rays of the corresponding Mori cones are identified
under $\Psi_{V_{1}\oplus\mathcal{O},V_{2}\oplus\mathcal{O}}$. ∎

Under the isomorphism $\Psi_{V_{1}\oplus\mathcal{O},V_{2}\oplus\mathcal{O}}$,
we will not distinguish Mori cones for $\mathbb{P}(V_{1}\oplus\mathcal{O})$
and $\mathbb{P}(V_{2}\oplus\mathcal{O})$. We are ready to apply the
computation from section 4 to $V=V_{1}$ and $V=V_{2}$ separately and compare
the invariants. Before running the induction in section 4, the $L_{g}$ are
chosen so that
$(\beta,\mathcal{O}_{\mathbb{P}(V_{i})}(1)+L_{g})>\text{max}\\{g-1,0\\}$ for
both $i=1,2$. Fix $g_{0}\in\mathbb{Z}_{\geq 0}$ and $\beta_{0}\in
NE(\mathbb{P}(V_{1}))\bigcup NE(\mathbb{P}(V_{2}))$. Since Lemma 4.4 holds
under this condition, Equation (5) can be applied to both $V=V_{1}$ and
$V=V_{2}$ cases. Assume that invariants
$\langle\ldots{}\rangle_{g,n^{\prime},\beta}^{\mathbb{P}(V_{i})}$ with $g\leq
g_{0}$ and $\beta<\beta_{0}$ are identified as in Theorem 1.1 for $i=1,2$. Now
the lower order terms (the graph sums in Equation (5) starting with
$\sum\limits_{\Gamma\neq\Gamma_{0}}\displaystyle\frac{1}{Aut(\Gamma)}\cdots{}$)
are identified by induction and Lemma 5.1, so are the leading terms. Thus,
Theorem 1.1 is proven by induction.

##  6\. An application to blow-up formula

Theorem 1.1 can be applied to blow-ups at smooth centers to imply the
following

######  Theorem 6.1.

Let $Z\subset Y$ be inclusions of smooth projective varieties and $N_{Z/Y}$ be
the normal bundle of $Z$. Let $\tilde{Y}$ be the blow-up of $Y$ at $Z$ and $E$
be the exceptional divisor. The absolute Gromov–Witten invariants of
$\tilde{Y}$ can be determined by the absolute Gromov–Witten invariants of $Y$
and $Z$, plus the following topological data:

  1. (a)

The cohomology rings $H^{*}(Y)$, $H^{*}(Z)$ and their pull-back maps under
inclusion.

  2. (b)

The Chern classes $c_{i}(N_{Z/Y})\in H^{*}(Y)$.

In fact [HLR, Theorem 5.15] plus degeneration formula already implies a
similar determination of Gromov–Witten invariants that requires some
additional information. To be precise, [HLR, Theorem 5.15] and degeneration
formula implies

######  Theorem 6.2.

Under the same set-up of Theorem 6.1. The absolute Gromov–Witten invariants of
$\tilde{Y}$ can be determined by the absolute Gromov–Witten invariants of $Y$
and $Z$, plus the following data:

  1. (a)

The cohomology rings $H^{*}(Y)$, $H^{*}(Z)$ and their pull-back maps under
inclusion.

  2. (b)

The Chern classes $c_{i}(N_{Z/Y})\in H^{*}(Y)$.

  3. (c)

The absolute Gromov–Witten invariants of
$\mathbb{P}(N_{Z/Y}\oplus\mathcal{O})$

Apparently, our Theorem 1.1 adds to this known result by saying the invariants
of $\mathbb{P}(N_{Z/Y}\oplus\mathcal{O})$ can already be determined by the
invariants of $Z$ and Chern classes $c_{i}(N_{Z/Y})$, and thus, the
requirement (c) in Theorem 6.2 is redundant. The rest of the section is a
brief explanation that [HLR, Theorem 5.15] $+$ degeneration formula implies
Theorem 6.2.

First of all, by [MP], (3) is enough to determine all relative invariants of
the pair $(\mathbb{P}(N_{Z/Y}\oplus\mathcal{O}),\mathbb{P}(N_{Z/Y}))$. Let’s
recall the main theorem in [HLR]. In view of [HLR, Definition 5.6], its
content can be rephrased as the following.

######  Theorem 6.3.

Absolute Gromov–Witten invariants of $Y$ and (1), (2), (3) in Theorem 6.2 are
enough to determine relative Gromov–Witten invariants of the following form
(relative invariants of standard weighted relative graphs in [HLR]):

$\langle
p^{*}\sigma_{1},\ldots{},p^{*}\sigma_{n}|\mu\rangle_{g,\beta}^{\tilde{Y},E},$

where $p:\tilde{Y}\rightarrow Y$ is the contraction.

Although insertions are pull-backs from $Y$, we are going to see these
relative invariants are enough to determine the absolute Gromov–Witten
invariants of $\tilde{Y}$. Applying deformation to the normal cone, we form
$\mathfrak{X}=Bl_{E\times\\{0\\}}\tilde{Y}\times\mathbb{A}^{1}$. The fiber at
$0$ is a union of $Y$ and $\mathbb{P}_{E}(\mathcal{O}(-1)\oplus\mathcal{O})$
glued along $E$. Let

$\iota_{1}:\tilde{Y}\rightarrow\mathfrak{X},\iota_{2}:\mathbb{P}_{E}(\mathcal{O}(-1)\oplus\mathcal{O})\rightarrow\mathfrak{X}$

be the embeddings of corresponding irreducible components to the fiber at $0$.
An absolute invariant of $\tilde{Y}$ can thus be computed by relative
invariants of the pairs $(\tilde{Y},E)$ and
$(\mathbb{P}_{E}(\mathcal{O}(-1)\oplus\mathcal{O}),E)$.

During this process, one has different choices for the insertions of the
relative invariants. Given $\bar{\alpha}\in H^{*}(\tilde{Y})$ an insertion of
the absolute invariant of $\tilde{Y}$, to apply degeneration formula, one
needs to find a lifting $\alpha\in H^{*}(\mathfrak{X})$ whose restriction on a
general fiber is $\bar{\alpha}$. The corresponding insertions for relative
invariants of $(\tilde{Y},E)$ and
$(\mathbb{P}_{E}(\mathcal{O}(-1)\oplus\mathcal{O}),E)$ are
$\iota_{1}^{*}\alpha$ and $\iota_{2}^{*}\alpha$, respectively. One can make an
obvious choice by finding the $\alpha$ such that
$\iota_{1}^{*}\alpha=\bar{\alpha}$ and
$\iota_{2}^{*}\alpha=\pi^{*}(\bar{\alpha}|_{E})$ where
$\pi:\mathbb{P}_{E}(\mathcal{O}(-1)\oplus\mathcal{O})\rightarrow E$. However,
some flexibility exists. One can add to this $\alpha$ a cohomology class whose
Poincaré dual has support in $E$. Thus, we have

######  Lemma 6.4.

Given an $\bar{\alpha}\in H^{*}(\tilde{Y})$, there exists a lifting
$\alpha^{\prime}\in H^{*}(\mathfrak{X})$ such that

$\displaystyle\iota_{1}^{*}\alpha$
$\displaystyle=\bar{\alpha}+(\iota_{E})_{!}\sigma,$
$\displaystyle\iota_{2}^{*}\alpha$
$\displaystyle=\pi^{*}(\bar{\alpha}|_{E})-h\pi^{*}\sigma,$

where $\iota_{E}:E\rightarrow\tilde{Y}$ is the inclusion, $\sigma\in H^{*}(E)$
and
$h=c_{1}(\mathcal{O}_{\mathbb{P}_{E}(\mathcal{O}(-1)\oplus\mathcal{O})}(1))$.

The goal of this section is achieved if we can prove there exists a $\sigma$
such that $\bar{\alpha}+(\iota_{E})_{!}\sigma$ is the pull-back of a certain
class along $p$. But notice that
$\bar{\alpha}-p^{*}p_{!}\bar{\alpha}=(\iota_{E})_{!}\sigma^{\prime}$ for some
$\sigma^{\prime}\in H^{*}(E)$. Choosing $\sigma=\sigma^{\prime}$ is enough.
Therefore,Theorem 6.2 is proven.

## References


# Generation-Augmented Query Expansion For Code Retrieval

Dong Li1 , Yelong Shen2, Ruoming Jin1, Yi Mao2 ,
Kuan Wang3, and Weizhu Chen2
1Kent State University
2Microsoft
3Georgia Institute of Technology
{dli12<EMAIL_ADDRESS>{yelong.shen, maoyi<EMAIL_ADDRESS><EMAIL_ADDRESS>
Work was done when Dong Li were interning at Microsoft.

###### Abstract

Pre-trained language models have achieved promising success in code retrieval
tasks, where a natural language documentation query is given to find the most
relevant existing code snippet. However, existing models focus only on
optimizing the documentation code pairs by embedding them into latent space,
without the association of external knowledge. In this paper, we propose a
generation-augmented query expansion framework. Inspired by the human
retrieval process - sketching an answer before searching, in this work, we
utilize the powerful code generation model to benefit the code retrieval task.
Specifically, we demonstrate that rather than merely retrieving the target
code snippet according to the documentation query, it would be helpful to
augment the documentation query with its generation counterpart - generated
code snippets from the code generation model. To the best of our knowledge,
this is the first attempt that leverages the code generation model to enhance
the code retrieval task. We achieve new state-of-the-art results on the
CodeSearchNet benchmark and surpass the baselines significantly.

##  1 Introduction

Figure 1: Illustration of (a) code retrieval paradigm and (b) generation-
augmented code retrieval paradigm. Figure 2: An example that generated codes
help documentation query to find the ground truth. Given an NL presented
"Documentation", the primary goal is to retrieve the "Ground Truth" code
snippet from a candidate pool, while the "Code Retrieved by GraphCodeBERT" is
the actual one that the retrieval model (with doc query) Guo et al. (2021)
finds. After incorporating "Generated Code", the retrieval model proposed in
this paper is able to retrieve the "Ground Truth" Code as its first choice.

Benefiting from the development of transformers (Vaswani et al., 2017; Feng et
al., 2020b; Guo et al., 2021) as well as pre-training techniques (Li et al.,
2022a), there has been a great amount of progress in code-related tasks,
including code generation (Brown et al., 2020), code search (Husain et al.,
2020), code auto-completion (Lu et al., 2022), etc. Among these, Code search
or code retrieval (Husain et al., 2020) is an essential problem in software
engineering, which enables the efficient finding and reuse of existing code
snippets, boosting developers’ productivity. In general, it aims to retrieve
function-level code snippets given a natural language documentation query.
Recently, CodeBERT (Feng et al., 2020b) has achieved great performance in
code-related tasks by pre-training a bimodal model to learn a general-purpose
representation for both programming language (PL) and natural language (NL).
By considering the inherent code structure - data flow, GraphCodeBERT Guo et
al. (2021) further boost the performance on downstream tasks. Meanwhile,
CodeRetriever Li et al. (2022a) adopts the contrastive-training approach to
learn the semantic presentation of code on a large-scale pretraining corpus.

Despite of the success of all these code-specific frameworks (Feng et al.,
2020b; Guo et al., 2021; Li et al., 2022a; Guo et al., 2022; Husain et al.,
2020), they only focus on learning the information within the code-
documentation context (either by optimizing specific downstream tasks or by
contrastively learning general-purpose representations), without considering
external knowledge, which limits the expressiveness of the representations.
Specifically for code retrieval tasks, due to the intrinsic difference between
the NL and PL, the current end-to-end code search models are insufficient to
retrieve the most semantically similar code snippet. Since documentation
queries and code snippets are typically embedded into the same latent space,
the model would try to find an "efficient" shortcut - matching two vectors
once some keywords are triggered. For example, in Figure 2, "Documentation" on
the left-top is a natural language, an end-to-end model (Guo et al., 2021)
would find the "Retrieved Code by GraphCodeBERT" in the right-top whereas they
share a few common keywords. This misleading result testifies to the drawbacks
of these models.

To tackle this issue, we propose GACR, Generation-Augmented Code Retrieval, a
two stage framework for code retrieval task, illustrated in Figure 1. First,
the natural language (NL) text documentation is used to generate code snippets
by a code generation model (for example, GPT-3). Then the generated code
augmented NL documentation would serve as an expanded query for retrieval. The
benefit of GACR is that it could leverage extra domain knowledge specifically
generating code snippets according to a natural language-described
documentation prompt. This would bridge the gap between the NL and PL which
has been overlooked in current end-to-end code retrieval models. Considering
the same example in Figure 2, by leveraging the power of the generation model,
the "Documentation" could be used to generate a code snippet - the "Generated
Code", which is much more semantically close to the "Ground Truth". And thus,
our proposed model - GACR is able to find the desired code.

Though there are some work (Parvez et al., 2021b; Lu et al., 2022) that
leverage retrieval model to help generation, enhancing code retrieval tasks
with generation model lacks attention. The main challenges are how to generate
code snippets with good quality and fusion them with documentation queries.
Thanks to the promising achievement of GPT (Brown et al., 2020), we select the
Codex, an ad-hoc fine-tuned generation model on publicly available code
datasets. As to the utilization, we design a dual representation attention
paradigm that allows learning information from NL documentation and PL
generated code snippet respectively, and mutually. The expansion queries fuse
the contents from NL and PL, leading to informative and expressive
representations.

We evaluate the performance of the GACR on CodeSearchNet benchmark Husain et
al. (2020) with 6 programming languages. The empirical results show that the
proposed generation-augmented code retrieval models achieve significant
improvements compared to the baseline models Guo et al. (2021); Feng et al.
(2020a). To this end, we summarize our contributions as follows:

  * •

We propose a generation-augmented framework for code retrieval tasks. To the
best of our knowledge, this is the first attempt that leverages the power of
the generation model to help with code retrieval tasks.

  * •

We design generation-augmentation frameworks, spinning from the utilization of
a single generated code snippet to multiple distinct code snippets to adapt
various deployments and investigate the fusion pattern of the NL documentation
and PL generated code, as well as different pre-train models.

  * •

Extensive empirical experiments on the CodeSearchNet benchmark validate the
superiority of the proposed augmentation paradigm.

The following of the paper is organized as: in Section 2, we introduce the
background and formalize the notations. In Section 3, we talk about the
details of how we incorporate the generated code for retrieval tasks. In
Section 4, we conduct experiments and analysis empirical results. In Section
5, we summarize a few related works and in Section 6, we conclude the paper.
Further, in Appendix A, we show specific cases of how the generated code
snippets boost or depress the performance on retrieval tasks.

##  2 Background and Notation

Figure 3: An illustration of generation-augmented code retrieval framework.

###  2.1 Dense Retrieval

Encoder-based dense representation frameworks have achieved great success in
retrieval tasks (Shen et al., 2014; Karpukhin et al., 2020; Husain et al.,
2020; Zhang et al., 2022). In short, queries and documents are mapped into the
latent space, and similarity metrics are computed according to their distance
(in the latent space). Specifically for code retrieval tasks, there are
documentation - code snippet (${D},{C}$) pairs in the training sets. Denote
the sequence of natural language documentation tokens as
${D}=\\{d_{1},d_{2},\dots,d_{m}\\}$ with length $m$ and each
$d_{i}(i\in\\{1,2,\dots,m\\})$ is a token. Similarly, the sequence of code
snippet is denoted as $C=\\{c_{1},c_{2},\dots,c_{n}\\}$. The encoder would
take the pairs as input and map them into vector representations, such that we
have $V_{d}=\textbf{Encoder}({D})$ and $V_{c}=\textbf{Encoder}({C})$. The
semantic similarity between document and code can be simply defined as the dot
product:

$\begin{split}S_{score}=V^{T}_{d}\cdot V_{c}\end{split}$ (1)

In the training stage, the encoder is optimized to maximize the scores in
Equation 1 for related documentation - code snippet pairs which is analogous
to minimizing the distance between them in latent space. In the inference
stage, the similarity scores between the query vector (obtained by feeding
${D}$ into the encoder) and all the candidate code vectors would be computed
according to Equation 1. The retrieved code snippets are defined as the ones
that have large scores.

###  2.2 Prompt-based Code Generation

Large pre-trained language models have demonstrated an awesome power to
generate code (Chen et al., 2021; Brown et al., 2020; Wang and Komatsuzaki,
2021; Nijkamp et al., 2022; Li et al., 2022b). Prompt-based code generation or
completion model (Chen et al., 2021) would take the natural language prompt as
the input and output the corresponding code snippet. In this paper, we mainly
study Codex (Chen et al., 2021) model, a GPT (Brown et al., 2020) based
language model that is fine-tuned on publicly available code collected from
GitHub and particularly to generate functionally code snippets given NL
documentation strings. In our setting, the documentation ${D}$ is prompt.
After feeding it into the generation model (Codex), we would obtain the
generated code snippet: ${G}=\textbf{Gen}({D})$. Presenting in a sequence way:
${G}=\\{g_{1},g_{2},\dots,g_{p}\\}$ with length $p$, where $g_{i}$ is a code
token.

##  3 Methodology

We propose to enhance the documentation query with its generation counterpart
for code retrieval tasks in this section. At a high level, we first feed the
given query ${D}$ into a code generation model powered by Codex, which serves
as a prompt, and generates a code snippet ${G}$ accordingly. Afterward, the
documentation along with its generated auxiliary code would be treated as the
query vector jointly: $V_{query}=\textbf{Encoder}(D,G)$, used to retrieval the
most correlated code snippets from the candidate pool.

###  3.1 Query Augmentation with Single Generated Code

One strategy is to append the generated auxiliary code tokens to the end of
the documentation query and then feed it into the encoder model, obtaining the
vector representation. It is worth being aware that the generated code and
original documentation come from distinct semantic domains - natural language
(NL) and programming language (PL), leading to a drawback if we take one
single representation for them. Thus, we design a dual representation
attention paradigm - two semantic input sequences (documentation and generated
code) could possess their own vector representations respectively while the
attention mechanism would elegantly ensure learning the information mutually.

The overall model architecture is shown in Figure 3. Given a sequence of
documentation tokens $D$. We feed the documentation sequence $D$ into a well-
trained code generation model - Codex (aka GPT-3) and obtain the output -
generated code token sequence $G$. Further, two sequences are concatenated
together, by some special tokens, as a single input sequence:
$X=\\{D,G\\}=\\{[CLS],d_{1},\cdots,d_{m},[SEP],$
$[CLS],g_{1},\cdots,g_{p},[SEP]\\}$ and the length of which is $m+p+4$.

The input sequence $X$, consisting of fusion tokens from documentation and
generated code, shall further be converted as the vector representation $Y$.
We denote the transformer operation as $T$. After feeding the input $X$ into
the $K$ layers multi-head self-attention transformer model (Vaswani et al.,
2017; Guo et al., 2021), we shall obtain a vector sequence
$Y=\\{y_{1},y_{2}\cdots,y_{m+p+4}\\}$, with the same length as the input
sequence:

$\begin{split}Y=T_{K}\circ T_{K-1}\cdots T_{1}\circ H^{0}\end{split}$ (2)

The vectors at index $1$ and $m+3$ of $Y$, corresponding to the $CLS$ tokens
of documentation and generated code, would be extracted and concatenated as
the final query vector $V_{query}=[y_{1},y_{m+3}]$. Correspondingly, the
target vector is replicated for dimension: $V_{target}=[z_{1},z_{1}]$.

###  3.2 Augmentation with Multi-Generated Codes

In Section 3.1, we proposed the framework that allows the incorporation of a
single generated code snippet into the documentation query. Here we extend the
framework and include multiple distinct generated code snippets to further
generalize and boost the model. In short, multiple generated code snippets are
integrated before they are fed into the Encoder. To enable a diverse
expansion, we limit the length of each code snippet. Given $k$ unique
generated code snippets, the input token sequence can be formularized as
$X=\\{D,G_{1},\cdots,G_{k}\\}$, where $D$ represents the sequence of
documentation tokens and $G_{i},i\in\\{1,\cdots,k\\}$ is the $i$-th generated
code token sequence. Similar to Section 3.1, we still extract two special
vectors, corresponding to the first and second $CLS$ tokens (ahead of $D$ and
$G_{1}$), from the output vector sequence $Y$.

In this case, all generated codes are mixed together before they are fed into
the encoder, that’s so-called "pre-attention" - fusion before the attention.
This pre-attention mechanism allowed all distinct generated code snippets to
learn from each other mutually.

Table 1: Model performance on CodeSearchNet (Husain et al., 2020) benchmark
(further crafted by (Guo et al., 2021)). We highlight in bold the best model
and underline the second best one in each column. We also list the relative
improvements in percent w.r.t the initialization base models (reproduced ones
of GraphCodeBERT and CodeRetriever, respectively).

Model $\backslash$ Language | Ruby | Javascript | Go | Python | Java | Php | Overall
---|---|---|---|---|---|---|---
RoBERTa | 0.587 | 0.517 | 0.850 | 0.587 | 0.599 | 0.560 | 0.617
RoBERTa (Code) | 0.628 | 0.562 | 0.859 | 0.610 | 0.620 | 0.579 | 0.643
CodeBERT | 0.679 | 0.620 | 0.882 | 0.672 | 0.676 | 0.628 | 0.693
UniXcoder | 0.740 | 0.684 | 0.915 | 0.720 | 0.726 | 0.676 | 0.744
initialized by GraphCodeBERT pre-trained base
GraphCodeBERT (report) | 0.703 | 0.644 | 0.897 | 0.692 | 0.691 | 0.649 | 0.713
GraphCodeBERT (reproduce) | 0.703 | 0.644 | 0.890 | 0.693 | 0.695 | 0.646 | 0.712
GACR-S | 0.772 (9.7%) | 0.747 (16.0%) | 0.893 (0.4%) | 0.768 (10.8%) | 0.726 (4.4%) | 0.813 (25.8%) | 0.786 (10.4%)
GACR-M |  0.798 (13.5%) |  0.767 (19.1%) | 0.898 (0.9%) | 0.766 (10.6%) | 0.686 (-1.2%) |  0.825 (27.8%) | 0.790 (11.0%)
initialized by CodeRetriever pre-trained base
CodeRetriever (report) | 0.753 | 0.695 | 0.916 | 0.733 | 0.740 | 0.682 | 0.753
CodeRetriever (reproduce) | 0.727 | 0.668 | 0.901 | 0.704 | 0.707 | 0.656 | 0.727
GACR-S | 0.789 (8.5%) | 0.762 (14.1%) | 0.901 (-0.1%) |  0.780 (10.8%) |  0.741 (4.8%) | 0.814 (24.0%) |  0.798 (9.7%)
GACR-M |  0.808 (11.1%) |  0.778 (16.5%) |  0.902 (0.1%) |  0.782 (11.0%) | 0.727 (2.9%) |  0.828 (26.3%) |  0.804 (10.6%)

###  3.3 Optimization and Inference

In the training stage (for each batch $B$), we are given $|B|$
related/positive documentation-code pairs $(D^{b},C^{b})$,
$b\in\\{1,2,\cdots,|B|\\}$. Either with single-generated code augmentation or
multi one, we shall have vectors pairs $(V^{b}_{query},V^{b}_{target})$
correspondingly (see Figure 3). Similar to (Husain et al., 2020; Guo et al.,
2021; Li et al., 2022a), an in-batch optimization is utilized:

$\begin{split}\mathcal{L}=-\frac{1}{B}\sum\limits_{b\in
B}{\frac{\exp{\Big{(}(V^{b}_{query})^{T}\cdot
V^{b}_{target}}\Big{)}}{\sum\limits_{j\in
B}{\exp{\Big{(}(V^{b}_{query})^{T}\cdot V^{j}_{target}}\Big{)}}}}\end{split}$
(3)

As to the inference stage, the similarity score can be calculated by Equation
1 for each query $D$ w.r.t all the candidate code snippets. And the desired
retrieval code snippets can be obtained by ranking scores accordingly.

##  4 Experiments

We compare the performance of the proposed framework - GACR with a number of
state-of-the-art baseline models:

  * •

RoBERTa(Liu et al., 2019) is a robustly optimized BERT pretraining approach ,
while the RoBERTa (code) is pre-trained sorely on the code.

  * •

CodeBERT(Feng et al., 2020b), a bimodal pre-trained model for PL and NL.

  * •

GraphCodeBERT(Guo et al., 2021), extract the topological information from the
code and build a data flow graph, achieving state-of-the-art results on
several downstream tasks.

  * •

UniXcoder(Guo et al., 2022), a unified cross-modal pre-trained model enhancing
the representation by utilizing information from code comment and AST.

  * •

CodeRetriever(Li et al., 2022a), learning with unimodal and bimodal two
contrastive schemes and achieving the start-of-the-art in the code search
task.

The experiments are carried on CodeSearchNet code corpus datasets, which are
initially released by Husain et al. (2020) and further handcrafted by Guo et
al. (2021) for the code quality reason. Here, we take the same settings as Guo
et al. (2021). Overall, all models (both baselines and proposed ones) derive
the vector representations for query and candidates, then compute the dot
product of them as a score for rank and retrieve. The performance is measured
in terms of Mean Reciprocal Rank (MRR).

###  4.1 RQ1. How does the generation-augmented framework - GACR perform
compared to the baselines?

Figure 4: Generated code study on code retrieval task.

####  4.1.1 Overall Performance

Table 1 shows the main results of all models. GACR is our proposed model,
where ’S’ represents expanding documentation query with a single generated
code snippet (Section 3.1), ’M’ for multiple generated snippets (Section 3.2).
We highlight the best results for each coding language (each column).

Overall, our proposed models outperform all the baselines, validating the
efficacy of the generation-augmented query expansion framework. Even more,
GACR-M model exhibits up to $27.8\%$ significant improvement on the Php data
compared to GraphCodeBERT.

####  4.1.2 Better Query Quality

Figure 5 displays the superiority of the proposed generation-augmented
frameworks from the perspective of counting relative ranks. Specifically, we
compare the rank of the ground truth code snippet for the same documentation
query (with or without augmentation). Then we count how many each has a
smaller value (higher rank). From Figure 5, we can observe that augmented
query consistently obsess higher rank over all datasets, especially in php
language.

Figure 5: Comparison of GraphCodeBERT (with documentation query) and GACR-S
(with augmented query) w.r.t. counting of superior queries.

####  4.1.3 Pre-train Initialization

For different pre-training initialization - GraphCodeBERT and CodeRetriever,
GACR models consistently get better results while CodeRetreiver-based pre-
training is better than GraphCodeBERT-based one, owing to large scale
contrastive learning strategy.

###  4.2 RQ2. How could generated codes help retrieval tasks?

Figure 6: Attention mask paradigms. There A - D are four different types of
attention masks, where color graces represent 1 and white represents 0.

In this subsection, we would like to investigate and answer how the generated
code snippets could help the retrieval tasks. We aim to discuss two aspects:
the effect of each component in generated code function and a specific case of
why generation-augmentation works.

####  4.2.1 Function-level generated code performance

In general, the generated code snippet is presented at a function level. At
this point, a code of function can be divided into two parts in both semantic
and spatial meanings: the function name (typically the first line of a piece
of code, including the input arguments), and the remaining part called the
function body. Here we empirically investigate how these different components
could help the downstream code retrieval task. We separately treat
documentation, generated function (entire generated code), generated function
name, generated function body as queries to retrieve the code, and the results
are presented in Figure 4. For all the cases, we can find that the generated
function name of the generated code outperforms the generated function body,
which indicates that typically the name of a function contains sufficient or
even more information than the function body. And comparing the documentation
with generated function, sorely treating generated code as a query could
achieve comparable performance w.r.t the documentation and sometimes even
better. Thus, this confirms the benefit to combine these two pieces of
information (from generated code and from documentation).

####  4.2.2 Case Study

Figure 7: An example in python language where generated code boosts the
performance of documentation query.

Figure 7 gives a specific example of how the generated code helps the
documentation query to find the right code snippet. In the base model
(GraphCodeBERT), "Documentation" in Figure 7 serves as a query, aiming to find
the "(Ground Truth" while it actually retrieves the "Code Retrieved by
GraphCodeBERT". This can be interpreted that without an understanding of the
description - "inverse keys and values of a dictionary", the model finds the
code snippet by looking up and matching some keywords, for example, "merge",
and "values", etc. On the contrary, the generation model could get a better
understanding of the description of "Documentation". It indeed creates some
semantically meaningful functions ("Generated Code (Sample 1 and 2)"), which
share almost the same function name as "(Ground Truth)" as well as the real
functionality. By leveraging the power of the generation side, a better
interpretation of the documentation leads to more accurate retrieval.

###  4.3 RQ3. How effective of each component of the framework (Ablation
Study)?

####  4.3.1 Study of the Attention Mechanism

In this subsection, we study the affection of attention mechanisms in the
proposed framework. Largely, we design four types of masks shown in Figure 6
when fusion documentation and code. And the corresponding results are
presented in Table 2. The Type-A mask is the best overall.

Table 2: Effect of Attention Mechanism

Model | Ruby | Javascript | Go | Python | Java | Php | Overall
---|---|---|---|---|---|---|---
GraphCodeBERT | 0.703 | 0.644 | 0.897 | 0.692 | 0.691 | 0.649 | 0.713
GACR-S | A | 0.772 | 0.747 | 0.893 | 0.768 | 0.726 | 0.813 | 0.786
B | 0.755 | 0.741 | 0.895 | 0.760 | 0.708 | 0.800 | 0.776
C | 0.767 | 0.750 | 0.865 | 0.763 | 0.720 | 0.811 | 0.779
D | 0.766 | 0.743 | 0.893 | 0.768 | 0.699 | 0.804 | 0.779

####  4.3.2 Numbers of Augmented Code

In Table 1, we observe that GACR-M achieves generally better results than
GACR-S, concluding that with more generated code snippets incorporated, the
model can get better retrieval results due to more information. Due to the
limitation of the model, the total length of the input sequence (fusion of
documentation and generated code tokens) is limited (typically less than 256).
We are able to append more generated code snippets by limiting the maximum
length for each code snippet. In Table 3, we list three different code length
(from $32$ to 128) limits and the results tell that $64$ can be a good
balance.

Table 3: Trade-off of augmented code numbers and length limiting, studied on
GACR-S model.

length | Ruby | Javascript | Go | Python | Java | Php | Overall
---|---|---|---|---|---|---|---
32 | 0.786 | 0.761 | 0.894 | 0.769 | 0.739 | 0.825 | 0.796
64 | 0.798 | 0.767 | 0.898 | 0.766 | 0.686 | 0.825 | 0.790
128 | 0.794 | 0.763 | 0.896 | 0.772 | 0.679 | 0.813 | 0.786

####  4.3.3 Generation Hidden Representation

A generation model takes a prompt (NL documentation) as an input and turns it
into a hidden representation by an encoder, and further interprets it into the
code snippet by a decoder. Instead of utilizing the generated code (like our
approaches) to help retrieval, it is also possible to augment the
documentation query (in the format of embedding) with intermediate hidden
representations (also in the format of embedding vectors) from the generation
side. Due to the difficulty of obtaining the intermediate representation from
the Codex model, here we conduct the empirical experiments on
GPT-J111https://huggingface.co/NovelAI/genji-python-6B (Wang and Komatsuzaki,
2021), a pre-trained model on python language. Table 4 indicates that the
generated code plays a better role in retrieval tasks, which might be owed to
the interpretability of the decoder of generation model.

Table 4: Comparision the effects of generated code and hidden representation.
(GCB short for GraphCodeBERT, Gen short for generation.)

Gen | Retrieval | Query Format | Python
---|---|---|---
- | GCB | documentation | 0.692
Codex | GCB | generated code | 0.650
GACR-S | augmented with generated code | 0.768
GPT-J | GCB | generated embedding | 0.520
GCB | generated code | 0.566
GACR-S | augmented with generated embedding | 0.671
GACR-S | augmented with generated code | 0.758

##  5 Related Work

###  5.1 Code Retrieval Tasks

Code retrieval or code search, known as to retrieve a relevant code snippet
from the candidate pool given a natural language query, has been widely
studied for decades spinning from traditional techniques (Vinayakarao et al.,
2017) to deep learning methods (Li et al., 2022a; Feng et al., 2020b; Guo et
al., 2021). CODEnn (Gu et al., 2018) is the early deep learning model that
jointly learns embedding vectors for both code snippets and natural language
descriptions and further calculates the similarity in the embedding space.
CodeSearchNet (Husain et al., 2020) provides benchmark code search tasks in
different programming languages. On top of this benchmark, CodeBERT (Gao et
al., 2021) is the first large bimodal pre-trained model with Masked-Language
Modeling (MLM) and replaced token detection objectives. GraphCodeBERT (Guo et
al., 2021) further improves the performance by utilizing the semantic-level
code structure when designing attention pattern. UniXcoder (Guo et al., 2022)
is a unified cross-modal pre-trained model which enhance the code
representation by leveraging information from code comment and AST.
CodeRetriever (Li et al., 2022a) adopts unimodal and bimodal two contrastive
learning schemes and achieves the start-of-the-art in code search task.

###  5.2 Retrieval and Generation as Augmentation

Code retrieval or other information retrieval models can also serve as an
auxiliary unit to help enhance related domain tasks, like code generation,
code auto-completion or code summaries, etc (Xia et al., 2017). Hayati et al.
(2018) propose a model named RECODE to explicitly refer to existing code
snippets when generating code, relying on subtree retrieval. Hashimoto et al.
(2018) propose a retrieve-and-edit framework for code generation and
completion by optimizing a joint objective. Lewis et al. (2020) fine-tune the
retrieval-augmented generation (RAG) models end-to-end. REDCODER (Parvez et
al., 2021a) is a retrieval augmentation framework, where it supplies and
enhances the code generation or summarization model by searching the relevant
codes or summaries from the candidate database. ReACC (Lu et al., 2022) is a
code completion framework that is augmented by leveraging external context,
aka retrieving semantically and lexically similar code snippets. GAR (Mao et
al., 2021) is a Generation-Augmented Retrieval model for open-domain questions
answering.

##  6 Conclusion

In this paper, we propose a generation-augmented query expansion framework on
code retrieval task. To the best of knowledge, this is the first work that
leverage generation paradigm to help code retrieval. Specifically, we design
patterns that fusion documentation and its generated code function as a
expansion query to search related code. We show by cases that generated code
from natural language documentation would enhance the semantic similarity to
its ground truth code snippet. Extensive empirical experiments validate the
achievement of new state-of-the-art results on CodeSearchNet benchmark.

## References

  * Brown et al. (2020) Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, Sandhini Agarwal, Ariel Herbert-Voss, Gretchen Krueger, Tom Henighan, Rewon Child, Aditya Ramesh, Daniel Ziegler, Jeffrey Wu, Clemens Winter, Chris Hesse, Mark Chen, Eric Sigler, Mateusz Litwin, Scott Gray, Benjamin Chess, Jack Clark, Christopher Berner, Sam McCandlish, Alec Radford, Ilya Sutskever, and Dario Amodei. 2020.  Language models are few-shot learners.  In _Advances in Neural Information Processing Systems_ , volume 33, pages 1877–1901. Curran Associates, Inc.
  * Chen et al. (2021) Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harrison Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, Alex Ray, Raul Puri, Gretchen Krueger, Michael Petrov, Heidy Khlaaf, Girish Sastry, Pamela Mishkin, Brooke Chan, Scott Gray, Nick Ryder, Mikhail Pavlov, Alethea Power, Lukasz Kaiser, Mohammad Bavarian, Clemens Winter, Philippe Tillet, Felipe Petroski Such, Dave Cummings, Matthias Plappert, Fotios Chantzis, Elizabeth Barnes, Ariel Herbert-Voss, William Hebgen Guss, Alex Nichol, Alex Paino, Nikolas Tezak, Jie Tang, Igor Babuschkin, Suchir Balaji, Shantanu Jain, William Saunders, Christopher Hesse, Andrew N. Carr, Jan Leike, Joshua Achiam, Vedant Misra, Evan Morikawa, Alec Radford, Matthew Knight, Miles Brundage, Mira Murati, Katie Mayer, Peter Welinder, Bob McGrew, Dario Amodei, Sam McCandlish, Ilya Sutskever, and Wojciech Zaremba. 2021.  Evaluating large language models trained on code.  _CoRR_ , abs/2107.03374.
  * Feng et al. (2020a) Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, and Xiaocheng Feng. 2020a.  Codebert: A pre-trained model for programming and natural languages.
  * Feng et al. (2020b) Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, and Ming Zhou. 2020b.  CodeBERT: A pre-trained model for programming and natural languages.  In _Findings of the Association for Computational Linguistics: EMNLP 2020_ , pages 1536–1547, Online. Association for Computational Linguistics.
  * Gao et al. (2021) Luyu Gao, Yunyi Zhang, Jiawei Han, and Jamie Callan. 2021.  Scaling deep contrastive learning batch size under memory limited setup.  In _Proceedings of the 6th Workshop on Representation Learning for NLP_.
  * Gu et al. (2018) Xiaodong Gu, Hongyu Zhang, and Sunghun Kim. 2018.  Deep code search.  In _Proceedings of the 2018 40th International Conference on Software Engineering (ICSE 2018)_. ACM.
  * Guo et al. (2022) Daya Guo, Shuai Lu, Nan Duan, Yanlin Wang, Ming Zhou, and Jian Yin. 2022.  UniXcoder: Unified cross-modal pre-training for code representation.  In _Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)_ , pages 7212–7225, Dublin, Ireland. Association for Computational Linguistics.
  * Guo et al. (2021) Daya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng, Duyu Tang, Shujie Liu, Long Zhou, Nan Duan, Alexey Svyatkovskiy, Shengyu Fu, et al. 2021.  Graphcodebert: Pre-training code representations with data flow.  In _ICLR_.
  * Hashimoto et al. (2018) Tatsunori B. Hashimoto, Kelvin Guu, Yonatan Oren, and Percy Liang. 2018.  A retrieve-and-edit framework for predicting structured outputs.  In _Proceedings of the 32nd International Conference on Neural Information Processing Systems_ , NIPS’18, page 10073–10083, Red Hook, NY, USA. Curran Associates Inc.
  * Hayati et al. (2018) Shirley Anugrah Hayati, Raphael Olivier, Pravalika Avvaru, Pengcheng Yin, Anthony Tomasic, and Graham Neubig. 2018.  Retrieval-based neural code generation.  In _Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing_ , pages 925–930, Brussels, Belgium. Association for Computational Linguistics.
  * Husain et al. (2020) Hamel Husain, Ho-Hsiang Wu, Tiferet Gazit, Miltiadis Allamanis, and Marc Brockschmidt. 2020.  Codesearchnet challenge evaluating the state of semantic code search.
  * Karpukhin et al. (2020) Vladimir Karpukhin, Barlas Oguz, Sewon Min, Patrick Lewis, Ledell Wu, Sergey Edunov, Danqi Chen, and Wen-tau Yih. 2020.  Dense passage retrieval for open-domain question answering.  In _Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)_ , pages 6769–6781, Online. Association for Computational Linguistics.
  * Lewis et al. (2020) Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, and Douwe Kiela. 2020.  Retrieval-augmented generation for knowledge-intensive nlp tasks.  In _Proceedings of the 34th International Conference on Neural Information Processing Systems_ , NIPS’20, Red Hook, NY, USA. Curran Associates Inc.
  * Li et al. (2022a) Xiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu, Hang Zhang, Bolun Yao, Weizhen Qi, Daxin Jiang, Weizhu Chen, and Nan Duan. 2022a.  Coderetriever: Unimodal and bimodal contrastive learning for code search.
  * Li et al. (2022b) Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. 2022b.  Competition-level code generation with alphacode.
  * Liu et al. (2019) Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. 2019.  Roberta: A robustly optimized BERT pretraining approach.  _CoRR_ , abs/1907.11692.
  * Lu et al. (2022) Shuai Lu, Nan Duan, Hojae Han, Daya Guo, Seung-won Hwang, and Alexey Svyatkovskiy. 2022.  Reacc: A retrieval-augmented code completion framework.  _arXiv preprint arXiv:2203.07722_.
  * Mao et al. (2021) Yuning Mao, Pengcheng He, Xiaodong Liu, Yelong Shen, Jianfeng Gao, Jiawei Han, and Weizhu Chen. 2021.  Generation-augmented retrieval for open-domain question answering.  In _Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)_ , pages 4089–4100, Online. Association for Computational Linguistics.
  * Nijkamp et al. (2022) Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, and Caiming Xiong. 2022.  Codegen: An open large language model for code with multi-turn program synthesis.  _arXiv preprint_.
  * Parvez et al. (2021a) Md Rizwan Parvez, Wasi Ahmad, Saikat Chakraborty, Baishakhi Ray, and Kai-Wei Chang. 2021a.  Retrieval augmented code generation and summarization.  In _EMNLP-Finding_.
  * Parvez et al. (2021b) Md Rizwan Parvez, Wasi Uddin Ahmad, and Saikat Chakraborty. 2021b.  Retrieval augmented code generation and summarization.
  * Shen et al. (2014) Yelong Shen, Xiaodong He, Jianfeng Gao, Li Deng, and Grégoire Mesnil. 2014.  A latent semantic model with convolutional-pooling structure for information retrieval.  In _Proceedings of the 23rd ACM International Conference on Conference on Information and Knowledge Management_ , CIKM ’14, page 101–110, New York, NY, USA. Association for Computing Machinery.
  * Vaswani et al. (2017) Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017.  Attention is all you need.  In _Proceedings of the 31st International Conference on Neural Information Processing Systems_ , NIPS’17, page 6000–6010, Red Hook, NY, USA. Curran Associates Inc.
  * Vinayakarao et al. (2017) Venkatesh Vinayakarao, Anita Sarma, Rahul Purandare, Shuktika Jain, and Saumya Jain. 2017.  Anne: Improving source code search using entity retrieval approach.  In _Proceedings of the Tenth ACM International Conference on Web Search and Data Mining_ , WSDM ’17, page 211–220, New York, NY, USA. Association for Computing Machinery.
  * Wang and Komatsuzaki (2021) Ben Wang and Aran Komatsuzaki. 2021.  GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model.  https://github.com/kingoflolz/mesh-transformer-jax.
  * Xia et al. (2017) Xin Xia, Lingfeng Bao, David Lo, Pavneet Singh Kochhar, Ahmed E. Hassan, and Zhenchang Xing. 2017.  What do developers search for on the web? _Empir. Softw. Eng._ , 22(6):3149–3185.
  * Zhang et al. (2022) Hang Zhang, Yeyun Gong, Yelong Shen, Jiancheng Lv, Nan Duan, and Weizhu Chen. 2022\.  Adversarial retriever-ranker model for dense retrieval.  In _ICLR_.

##  Appendix A Case Study

###  A.1 Case Study: Augmentation Boosting

In this section, we show some examples (in Figures 8 and 9) that generation-
augmented frameworks retrieve better results (or even ground truth code
snippets) while models with only documentation queries retrieve unrelated
ones.

Figure 8: An example in ruby language where generated code snippets boost the
performance of documentation query. Figure 9: An example in php language where
generated code snippets boost the performance of documentation query.

###  A.2 Case Study: Augmentation Depressing

In this section, we show some examples (in Figures 11 and 10) that models with
only documentation queries are sufficient to retrieve good results while the
generation-augmented frameworks find worse ones.

Figure 10: An example in go language where generated code snippets depress the
performance of documentation query. Figure 11: An example in java language
where generated code snippets depress the performance of documentation query.