  This paper provides an explicit cofibrant resolution of the operad encoding
Batalin-Vilkovisky algebras. Thus it defines the notion of homotopy
Batalin-Vilkovisky algebras with the required homotopy properties.
  To define this resolution we extend the theory of Koszul duality to operads
and properads that are defind by quadratic and linear relations. The operad
encoding Batalin-Vilkovisky algebras is shown to be Koszul in this sense. This
allows us to prove a Poincare-Birkhoff-Witt Theorem for such an operad and to
give an explicit small quasi-free resolution for it.
  This particular resolution enables us to describe the deformation theory and
homotopy theory of BV-algebras and of homotopy BV-algebras. We show that any
topological conformal field theory carries a homotopy BV-algebra structure
which lifts the BV-algebra structure on homology. The same result is proved for
the singular chain complex of the double loop space of a topological space
endowed with an action of the circle. We also prove the cyclic Deligne
conjecture with this cofibrant resolution of the operad BV. We develop the
general obstruction theory for algebras over the Koszul resolution of a
properad and apply it to extend a conjecture of Lian-Zuckerman, showing that
certain vertex algebras have an explicit homotopy BV-algebra structure.
