  We give an explicit gauge invariant, off-shell and local double copy
construction of gravity from Yang-Mills theory to quartic order. To this end we
use the framework of homotopy algebras, and we identify a rich new algebraic
structure associated to color-stripped Yang-Mills theory. This algebra, which
is a generalization of a Batalin-Vilkovisky algebra, is the underlying
structure necessary for double copy. We give a self-contained introduction into
these algebras by illustrating them for Chern-Simons theory in three
dimensions. We then construct N = 0 supergravity in the form of double field
theory in terms of the algebraic Yang-Mills building blocks to quartic order in
interactions. As applications of the same universal formula, we re-derive the
4-graviton scattering amplitude and compute a chiral form of the Courant
algebroid gauge structure of double field theory.
