  We use a description based on differential forms to systematically explore
the space of scalar-tensor theories of gravity. Within this formalism, we
propose a basis for the scalar sector at the lowest order in derivatives of the
field and in any number of dimensions. This minimal basis is used to construct
a finite and closed set of Lagrangians describing general scalar-tensor
theories invariant under Local Lorentz Transformations in a pseudo-Riemannian
manifold, which contains ten physically distinct elements in four spacetime
dimensions. Subsequently, we compute their corresponding equations of motion
and find which combinations are at most second order in derivatives in four as
well as arbitrary number of dimensions. By studying the possible exact forms
(total derivatives) and algebraic relations between the basis components, we
discover that there are only four Lagrangian combinations producing second
order equations, which can be associated with Horndeski's theory. In this
process, we identify a new second order Lagrangian, named kinetic Gauss-Bonnet,
that was not previously considered in the literature. However, we show that its
dynamics is already contained in Horndeski's theory. Finally, we provide a full
classification of the relations between different second order theories. This
allows us to clarify, for instance, the connection between different
covariantizations of Galileons theory. In conclusion, our formulation affords
great computational simplicity with a systematic structure. As a first step we
focus on theories with second order equations of motion. However, this new
formalism aims to facilitate advances towards unveiling the most general
scalar-tensor theories.
