Metric-affine cosmological models and the inverse problem of the calculus of variations. Part 1: variational bootstrapping -- the method

The method of variational completion allows one to transform an (in principle, arbitrary) system of partial differential equations -- based on an intuitive ``educated guess'' -- into the Euler-Lagrange one attached to a Lagrangian, by adding a canonical correction term. Here, we extend this technique to theories that involve at least two sets of dynamical variables : we show that an educated guess of the field equations with respect to one of these sets of variables only is sufficient to variationally complete these equations and recover a Lagrangian for the full theory, up to terms that do not involve the respective variables. Applying this idea to natural metric-affine theories of gravity, we prove that, starting from an educated guess of the metric equations only, one can find the full metric equations, together with a generally covariant Lagrangian for the theory, up to metric-independent terms; the latter terms (which can only involve the distortion of the connection) are then completely classified over 4-dimensional spacetimes, by techniques pertaining to differential invariants.


I. INTRODUCTION
General Relativity (GR) offers a model for gravity, based on Riemannian geometry, which is in excellent agreement with most observations but still exhibits problems at the largest (e.g., rotational curves of galaxies or the accelerated expansion of the Universe) and the smallest scales (e.g., tensions with quantum theory).This indicates that it is necessary to look for a more general gravitational theory.Whereas there is an ongoing debate on which extensions of Riemannian geometry are the most suitable, there is quite a wide consensus that the dynamics of such an extended model for gravity should be based on the principle of minimal action -i.e., on the calculus of variations.
Typically, in building extensions of GR, once fixed the kinematics, one then starts by postulating a Lagrangian; the associated field equations and their consequences being subsequently derived from it.Examples of such modified theories include Horndeski gravity, where the spacetime geometry is still described by Riemannian geometry but an additional scalar degree of freedom is present, see [1][2][3], and metric-affine theories of gravity, where the gravitational degree of freedom comes from both the spacetime metric and an independent affine connection, see [4][5][6][7].Yet, the choice of these Lagrangians is very often based on formal arguments, aimed to indirectly control the expected behaviour of the solutions of the associated Euler-Lagrange equations.While we would not argue against the soundness of this approach in itself, by first focusing on the Lagrangian, this sole procedure usually fails to single out a theory, or a class of theories, staying close from a desired phenomenological behaviour.One may then want to find a refined, or, at least, complementary, technique for selecting the best models.
On account for that, we propose to revert for a moment the roles and start from the field equations.More precisely, imagine we postulate a form of the desired field equations (which may be variational or not), based on some physical principles or phenomenological considerations.A Lagrangian, together with the "corrected" -fully variational -field equations, can then be derived from this "educated guess", by the so-called technique of canonical variational completion (or briefly, variational completion), introduced1 in [8].
To give an idea on this technique, a motivating example was the historically first version of the Einstein field equations: which accurately predicted some physical facts, but was inconsistent with local energymomentum conservation.In this case, the variational completion procedure gives precisely as "corrected" field equations; the canonical correction term (which is, in this example, − 1 2 Rg µν ) is expressed in terms of the Helmholtz form of the given PDE system, [9], which measures the obstruction from variationality of the original equations.This paper is the first of a two-part work aiming to formulate metric-affine theories of gravity using a procedure based on variational completion.
In the present paper, we extend the variational completion method to situations where one wants to build a theory depending on more than one dynamical variable, but only has an "educated guess" at the field equations of one of these dynamical variables, say y A .In this case, we show in Theorem 2 that one can still completely determine a Lagrangian for the theory, up to boundary terms and terms that have no dependence on y A or its derivatives.Such a setup is particularly appealing for the construction of modified theories of gravity, in general, since once can apply this procedure with y A = g µν , taking lessons from GR for the "educated guess" of the metric field equations.
Here, once formally established the procedure, we show how it applies to metric-affine theories of gravity.Starting from some postulated (variational or not) metric equations G µν = 0, we determine the closest variational equations to these.We then classify all possible corresponding generally covariant Lagrangians, up to boundary terms, as follows: 1.According to Theorem 2, all the terms in the Lagrangian containing the metric or its derivatives can be "bootstrapped" by variational completion.
2. Terms that do not involve the metric (and thus cannot be recovered by the above procedure) are then shown, using specific techniques for finding differential invariants, [10], [11], to be of order at most one in the connection and polynomial (of bounded degree) in the distortion tensor components and their derivatives.A full list of these possibilities, over 4-dimensional backgrounds, is presented in Appendix B.
In the forthcoming Part 2 of this work 2 , we apply the presented method to select the metricaffine models that produce equations closest to those of the ΛCDM model of cosmology.The present paper then aims to establish the formal aspects underlying the application presented in Part 2.
The paper is structured as follows : Section II is a somewhat minimalist (though, we hope, selfcontained) review of the method of variational completion.Section III then extends variational completion to the situation where one only has an educated guess at the form of a part of the equations.We also present one example showing how the procedure behaves in a well-known case.Further, in Section IV, we apply this method to the case of metric-affine theories, to find all possible metric-dependent terms in the Lagrangian, starting from an approximate form (educated guess) of the metric equations.All metric-independent generally covariant Lagrangians on 4dimensional spacetimes are then determined in Section V. Finally, in Section VI, we summarise our findings and present further directions of research.

II. VARIATIONAL COMPLETION OF DIFFERENTIAL EQUATIONS
This section presents in brief the method of canonical variational completion introduced in [8].For more details on the formalism of the calculus of variations on fibered manifolds, we refer to the monographs [9] and [12].
Consider an arbitrary PDE system of n equations of order r, in n dependent variables, say y B = y B (x µ ) : The inverse problem of the calculus of variations consists in finding out if the given system is (locally or globally) variational, i.e., if it arises (locally, respectively, globally) as the Euler-Lagrange system attached to some Lagrangian.The question of local variationality is usually answered by means of some differential relations involving E A , called the Helmholtz conditions.In the event of a negative answer, it is sometimes (under some quite strong constraints) possible to transform the given system into an equivalent one which is locally variational, by means of variational multipliers, see [13].
The method of variational completion proposes a completely different approach: it transforms the given PDE system (3) into a -generally, non-equivalent -variational one, by canonically adding a correction term.The canonical correction term, which is expressed in terms of the Helmholtz coefficients of the given system, is built so as to measure the obstructions from variationality of the original system and can, with a few exceptions, always be constructed.The method can thus also act as an elegant way of checking variationality.
A. Geometric setup : fields, Lagrangians, Euler-Lagrange forms and source forms In Lagrangian field theories, physical fields are understood as local sections of fibered manifolds.
A fibered manifold is a triple (Y, π, M ), where M and Y are smooth manifolds of dimensions m and m + n respectively, and π : Y → M is a surjective submersion of class C ∞ , called the projection.Y is called the total space and M the base manifold.This structure allows one to find on Y an atlas consisting of fibered charts (V, ψ), ψ = x µ , y A , in which π is represented as (π(V ), ψ M ), ψ M := (x µ ), being a chart on the base manifold M .Fibered manifolds are physically interpreted as configuration spaces of physical systems and include, as a subclass, fiber bundles.
Most typically, these configuration spaces actually belong to the more restrictive subclass of natural bundles, which are obtained via a "universal", functorial construction F : M → Y := FM that applies to the whole category of m-dimensional manifolds (e.g., the tangent/cotangent bundle, tensor bundles, connection bundles).On natural bundles, each local coordinate system (x µ ) on M induces so-called natural coordinates x µ , y A on Y ; accordingly, each coordinate change on M induces a natural coordinate change on Y (e.g., by a tensor, or connection coefficients rule).
In the following, unless elsewhere specified, by (Y, π, M ) we will denote a general fibered manifold (with no extra structure).
Local sections γ : U → Y , defined by π • γ = Id U (where U ⊂ M is open) are described in fibered coordinates by (x µ ) → x µ , y A (x µ ) , i.e., by specifying a dependence betweeen the (a priori independent) coordinates x µ and y A : These are, as announced above, physically interpreted as fields.
Adding derivatives of the field variables (up to some order r) into the picture is tantamount to considering jets of order r of sections : given a section γ : U → Y and x ∈ U , It is worth mentioning that the definition of the jet is independent of the choice of fibered charts, see [9].The set J r Y = {J r x γ | γ : U → Y -section, x ∈ U } of jets of all local sections of Y, at all points of their domains, is called the jet bundle of order r of Y .This is a smooth manifold, with naturally induced coordinate charts (V r , ψ r ), with The coordinate functions y A ν1•••νs (where ν 1 ≤ • • • ≤ ν s and s ≤ r) can be interpreted as slots into which, inserting a prolonged section J r γ : U → J r Y : x → J r x γ, one gets the partial derivatives up to order r at x of the functions y A = y A (x µ ) associated with γ; that is Jet bundles J r Y come naturally equipped with the structure of a fibered manifold (induced by that of Y ) in multiple ways : 1.With base M , with projection 2. With base J s Y , for s ≤ r, with projection which "forgets all derivatives of order more than s".
In principle, a locally defined differential form on J r Y is expressed, in fibered charts, as a linear combination of wedge products of the differentials dx µ , dy A , dy A µ , • • • , dy A µ1•••µr .Yet, for our purposes, only two classes of such forms will be relevant: 1. Horizontal k-forms, with k ≤ m, which can be written (in one, then, in any fibered chart) as linear combinations of wedge products dx µ1 ∧ • • • ∧ dx µ k only.Their set will be denoted by Ω k,M (V r ).
The most important subclass is represented by Lagrangians of order r, which are defined as horizontal forms of maximal rank k = m.In coordinates : where dx : In particular, on a natural bundle FM , a generally covariant, or natural, Lagrangian of order r is a globally defined Lagrangian λ ∈ Ω m,M (J r FM ) which is invariant under changes of natural coordinates on J r FM induced by completely arbitrary coordinate changes (local diffeomorphisms) of M ; in other words, a natural Lagrangian is a Lagrangian that makes sense globally, with the same formula, over any m-dimensional spacetime manifold M .
2. Source forms, or dynamical forms, which are locally defined (m + 1)-forms expressible (in any fibered chart) as : where For a coordinate-free definition of the concept, employing the notion of contact form and bundle projections, we refer to [9].The most notorious example of a source form is the Euler-Lagrange form E (λ) of a Lagrangian λ, given by More generally, any PDE system of m = dim M equations of order r, in the unknowns y A = y A (x µ ) can be encoded into a source form; for instance, equations (3) above can be encoded as : that is, using a fibered chart, where γ is the section given by y A = y A (x µ ).
A source form E on J r Y is called locally variational if, for any chart domain V r ⊂ J r Y, there exists a Lagrangian λ V whose Euler-Lagrange form is E. Accordingly, E is called globally variational if there exists a Lagrangian λ defined throughout J r Y, such that E = E (λ).
Before going further, we should introduce one operation allowing to build horizontal forms on jet bundles.The horizontalization operator is the unique mapping h : Ω(J r Y ) → Ω(J r+1 Y ), compatible with the wedge product3 (i.e.h is a morphism of exterior algebras) and obeying, in any fibered chart, •νr µ denotes the total derivative (of order r + 1) with respect to x µ .As a direct consequence of ( 16), one has Relations ( 17) and the compatibility with the wedge product then ensure that, given a form Actually, the latter relations point out a natural differential operator where d : Ω(J r Y ) → Ω(J r Y ) is the exterior derivative on J r Y .This operator is called the horizontal (or total) exterior derivative, [14], and obeys : (the latter relation can be easily checked as total derivatives commute).By construction, d H relates to what remains of the exterior derivative on J r Y when evaluated along a prolonged section in the sense that, given a form ρ ∈ Ω(J r Y ), where d M : Ω(M ) → Ω(M ) is the exterior derivative on the base manifold M .Furthermore, a Lagrangian λ ∈ Ω m,M (V r ) will be variationally trivial (have an identically vanishing Euler-Lagrange form) if and only if there exist a form µ ∈ Ω m−1 (V r−1 ) such that λ = d H µ, [9] p. 134.This requirement is further equivalent to the condition that, for any fibered chart (V, ψ), there exist functions g µ : V r → R such that λ = (d µ g µ ) dx, [9] p. 134.

B. Canonical variational completion
In the following, we will only study local variationality; thus, we can assume with no loss of generality that V r ⊂ R N (for an appropriate value of N ) and omit the explicit mention of ψ r .
Consider now an arbitrary PDE system (3) and build, as in (12), the corresponding source form E = E A dy A ∧dx ∈ Ω m+1 (V r ).We will assume from the beginning that the domain V r is vertically star-shaped with center (x µ , 0, , joining the center with the given point, lies in V r .
Under this assumption, one can introduce on the given chart domain V r , the Vainberg-Tonti Lagrangian λ E = L E dx, where4 , [9] : where χ t : V r → V r is given by Remarks: 1.The Vainberg-Tonti Lagrangian is, in general, just defined on a coordinate chart.Yet, on tensor bundles Y -which is our case of interest -if the quantities E A are tensor densities, then L E is a scalar density and λ E = L E dx is globally well defined.Actually, in this case, λ E is generally covariant provided that E itself is so.
2. If the coordinate chart domain V r is not vertically star-shaped with center (x µ , 0, • • • , 0) (which is obviously the case in gravity theories, where one cannot set all the field components g µν to zero), the Vainberg-Tonti Lagrangian will be understood as a limit : and it makes sense whenever this limit is finite, see [16].
The Vainberg-Tonti Lagrangian λ E gives rise to the Euler-Lagrange expressions δL E δy A .These are related to the coefficients of E by where of the so-called Helmholtz form, [9], [13], whose vanishing is equivalent to the local variationality of E (see also Appendix A, for their precise expressions in the case r = 2).Consequently : • If the original system is locally variational, then δL E δy A = E A , i.e., the Vainberg-Tonti Lagrangian λ E is a Lagrangian for the original system, • The quantities H A measure the "obstructions from variationality" of E A .
In other words, the canonical variational completion of a PDE system is obtained by adding, as correction terms, the "obstruction from local variationality", H A , to the respective system; one Lagrangian for the "corrected" (now variational) system being the Vainberg-Tonti Lagrangian (20).
Example : Einstein tensor as the canonical variational completion of the Ricci tensor, [8].As already mentioned in the introduction, a motivation for the above construction was given by the historically first variant of gravitational field equations proposed by Einstein The configuration bundle is, in this case, the fibered manifold (Met (M ) , π, M ), where Met(M ) is the set of symmetric and nondegenerate tensors of type (0, 2) over a given manifold M. Its sections are metric tensors g, locally described by (x ρ ) → (g µν (x ρ )) .On the jet bundle J 2 Met(M ), one can thus consider as local coordinates (x µ ; g µν , g µν,ρ , g µν,ρσ ) .With this choice, the left hand side of (25) can be encoded (after raising the indices and densitizing) into the invariant source form where R µν is the formal Ricci tensor (the word "formal" means that R µν is calculated by the usual formula but, in this expression, g µν , g µν,ρ and g µν,ρσ are regarded as independent coordinate functions on J 2 Met (M ) , not as functions of x µ ).
A direct calculation then shows that the Vainberg-Tonti Lagrangian of E is actually the Einstein-Hilbert Lagrangian where R is the formal Ricci scalar, leading to the Einstein equations (2).

III. WHAT IF WE ONLY KNOW A PART OF THE EQUATIONS?
The above procedure is helpful as such in the case of purely metric theories of gravity.Yet, in theories of gravity employing a metric and another variable (e.g., a scalar field or a connection), one often has an "educated guess" on the form of the metric equations only -e.g., resemblance with the Einstein equations with a cosmological constant.For such situations, we prove below that one can recover the Lagrangian, up to boundary terms and terms that do not involve the metric or its derivatives; as a byproduct, we find the variationally completed metric equations, which are the closest variational equations to our initial guess.Possible Lagrangian terms that are independent of the metric remain to be found by other means.
More generally, assume one wants to build a variational theory involving two groups of dynamical variables, say y A = y A (x µ ) and z I = z I (x µ ), but only have an educated guess about the field equations with respect to y A : where the number of equations is equal to the number of y A -variables.In the following, we will try to recover the variationally completed y A -equations and, in so far as possible, the missing z I -equations.

A. Variational bootstrapping
The configuration manifold corresponding to the situation described above is a fibered product manifold where × M denotes the fibered product, which has as fibered charts (V, ψ) , ψ = x µ ; y A , z I .On the jet bundle J r Y ≡ J r Y 1 × M J r Y 2 , we will denote the naturally induced charts (V r , ψ r ) , the projections onto the two factors of J r Y.
Any source form on V r is then uniquely written as a sum of two components where Our postulated equations ( 28) are thus completely encoded into the component E (1) of E; we do not have any input information about E (2) .Hence, the best thing we can do is to variationally complete E (1) , as follows : Fix a vertically star-shaped fibered chart (V r , ψ r ) on J r Y and define the partial fiber homothety χ t,1 := (χ t , Id) : V r → V r , acting on the variables and, accordingly, the partial Vainberg-Tonti Lagrangian We then obtain the following result : Theorem 2 (Variational bootstrapping): If the partial differential system (28) is locally variational and the Vainberg-Tonti-type Lagrangian λ 1 = L 1 dx as in (33) can be defined, then : 1. λ 1 is a locally defined Lagrangian for (28); 2. Any other Lagrangian λ producing (28) as y A -field equations can only differ from λ 1 by a y A -independent term and a boundary term : where , λ 2 is projectable onto the second factor J r Y 2 ) and λ 0 = (d µ f µ ) dx is a boundary term.
Proof.As discussed above, the configuration system for (28) is the fibered product Y = Y 1 × M Y 2 , as in (29).Fix a vertically star-shaped fibered chart domain V r ⊂ J r Y and encode the left-hand sides of our equations into the source form 1. Proving that λ 1 is indeed a Lagrangian for E (1) is done by direct computation, in a completely similar way to, e.g., [9], Sec.4.9, or [16] -with the only difference that here we have an extra variable z I , which, yet, remains unaffected.For courtesy to the reader, we briefly reproduce in Appendix A the calculation for r = 2.
2. Since λ and λ 1 should produce the same Euler-Lagrange expressions with respect to y A , it follows that they can only differ by terms that do not contribute in any way to these expressions -that is, terms that do not have any dependence on y If the given equations (28) are not locally variational, then, the partial variational completion procedure guarantees that the correction terms δL 1 δy A − E A still have the meaning of obstructions from y A -variationality of E (1) .

B. A first example: Einstein-Klein-Gordon equations
Before passing to our case of interest, which are metric-affine theories of gravity, let us check how the variational bootstrapping method works in a case where a Lagrangian is already known.A straightforward such example is the one of a single real-valued scalar field φ minimally coupled to the metric g in the context of General Relativity.
In this case, the dynamical variables are a metric tensor and a scalar field; the corresponding configuration space is thus Accordingly, we can consider on J 2 Y the naturally induced fibered coordinates (x µ ; g µν , g µν,ρ , g µν,ρτ ; φ, φ ρ , φ ρτ ).This situation is notoriously described by the Einstein-Klein-Gordon Lagrangian λ EKG = L EKG dx, with (where κ ∈ R 0 is a constant and V = V (φ) is a real-valued smooth function), which produces the field equations where = g µν ∇ µ ∇ ν is the covariant d'Alembertian and Let us pretend for one moment to have no idea about the Lagrangian (36) and recover it from the metric equations (37) by Met (M )-variational completion.Considering g µν as our dynamical variables, the relevant source form is E g = E µν dg µν ∧ dx, where with φ α := g αβ φ β .The Vainberg-Tonti Lagrangian λ = L φ dx is then given by : where the lower integration point is understood as a limit and the partial fibered homotheties χ t,1 : (x µ , g µν , g µν,ρ , g µν,ρτ ; φ, φ ρ , φ ρτ ) → (x µ , tg µν , tg µν,ρ , tg µν,ρτ ; φ, φ ρ , φ ρτ ) only affect g µν and their derivatives.We then have where • R µν are, respectively, the formal Christoffel symbols, formal curvature tensor and formal Ricci tensor of the Levi-Civita connection associated to g.This then gives us : as expected.Variation with respect to φ then allows to also recover the second equation of (37), the Klein-Gordon equation.
According to Theorem 2, Lagrangians that cannot be recovered by Met(M )-variational completion are either variationally trivial (boundary terms), or metric-independent.Let us investigate the second possibility, corresponding to the λ 2 -term of (34).In other words, we are looking for Lagrangians that could induce modifications of the second equation of (37) without altering the first one.Such Lagrangians λ 2 = L 2 dx should be horizontal m-forms built using φ and its partial derivatives only.The only natural (generally covariant) operators we can use, without employing the metric or its derivatives, are the exterior derivative and the wedge product (see also the discussion in the beginning of Section V B below).From the coordinate function φ, one can build d H φ = φ µ dx µ ∈ Ω 1,M (J 1 Y ) but this does not allow to go further, considering that d H (d H φ) ≡ 0 and d H φ ∧ d H φ ≡ 0. In other words, if dim(M ) > 1 (which is our case of interest), there are no natural Lagrangians that can be built from a scalar field and its partial derivatives alone.Of course, one could think, e.g., of building an m-form by multiplication of (a function of) φ by an invariant volume form ǫ; yet, there is no natural choice for such an m-form -at least, not without resorting to extra geometric structures such as a metric or a connection.To conclude, in the case of a single, real-valued scalar field φ minimally coupled to the metric g, any natural Lagrangian can be fully recovered, up to boundary terms, from the metric equations only. 5

IV. THE CASE OF METRIC-AFFINE THEORIES
In metric-affine theories, the dynamical variables are, a priori, a metric g and an independent connection Γ.Yet, since, on the one hand, a metric automatically determines its Levi-Civita connection -which we will in the following denote by • Γ -and, on the other hand, the difference between two connections is tensorial, it is customary to split Γ as where L is a tensor field of type (1, 2) over the spacetime manifold M called the distortion tensor.This way, the problem of determining the pair (g, Γ) is equivalent to the one of determining the pair (g, L) .The latter pairs are local sections of the fibered product : where T 1 2 M is the vector bundle of all tensors of type (1, 2) over M ; with local fibered coordinates, say, (x µ ; g µν , L µ νρ ).A general source form of order r on Y will then have a g µν -part and an L µ νρ one : In the following, we assume that we have an educated guess for the metric equations E µν = 0, that is, we know Assuming that we are only looking for generally covariant metric-affine Lagrangians, the following result is known : Theorem 3 (Janyska, [10]) : All generally covariant Lagrangians λ = Ldx, of order r in a metric tensor and another tensor variable Φ are given by : where Picking Φ = L leads to an immediate consequence : Corollary 4 All the variationally nontrivial (non-boundary) terms of a generally covariant metric-affine Lagrangian containing the metric tensor or its derivatives can be recovered by Met(M )-variational completion.The only terms that cannot be recovered by this procedure are purely affine terms; these are built from the distortion tensor and its Levi-Civita covariant derivatives, in such a way that the Christoffel symbols (and their derivatives) eventually cancel out.
Let us explore, in the following, all the possibilities of building natural purely affine Lagrangians, over 4-dimensional spacetimes.

V. PURELY AFFINE INVARIANTS
Fix dim M = 4.We will determine all generally covariant (or natural ) Lagrangians which can be built on 4-dimensional metric-affine backgrounds (M, g, Γ), from the components of the distortion tensor L of the connection Γ = • Γ + L and their derivatives -briefly, on L, ∂L, ∂∂L, • • • alone -i.e. that are completely independent of the metric g.In other words, we are looking for a differential form The technique we use below is the so-called algebraic method for finding differential invariants by Kolar, Michor and Slovak, [11].

A. The polynomial property
We will first prove that natural Lagrangians depending on distortion alone must actually be polynomial in the components of L and their derivatives.To this aim, we start by using Theorem 3 in the previous section, which shows that any natural metric-affine Lagrangian λ must, apart from derivatives of the curvature tensor R( • Γ), be expressed as a smooth function of L α βγ and their • Γ-(formal) covariant derivatives6 up to some order r.According to Corollary 4, purely affine terms must then be of the form : The advantage of the latter writing is that all the building blocks of λ are tensor fields; in other words, we transfer our problem of finding a mapping λ defined on the fibers of a jet bundle, into one of finding a function defined on a Cartesian product of vector spaces.More precisely, the formal covariant differentiation operator acts linearly on the fibers of T 1 2 M (to be even more precise, • ∇ is a vector bundle morphism covering the identity of M ) and thus its image is again a vector bundle; similarly, the images of further iterations of • ∇ are again vector bundles.That is, fixing an arbitrary point x ∈ M, and a chart around it, we obtain that the fibers where , are all finite dimensional real vector spaces, whereas the restriction of the Lagrangian density to these fibers becomes a mapping defined on a Cartesian product of vector spaces.This allows us to use the following result : Theorem 5 (Homogeneous Function Theorem, [11]).Let V i , i = 0, • • • , r be finite dimensional real vector spaces.If f : R is a smooth function with the property that there exist b ∈ R and a i > 0, i = 0, • • • , r such that: then, f must be a sum of polynomials of degree d i in v i , where d i ∈ N satisfy the relation If there are no non-negative integers d 0 , • • • , d r with the above property, then f is the zero function.
Let us apply the homogeneous function theorem to our situation.The requirement that λ = Ldx should be invariant under any coordinate changes naturally induced by local coordinate changes x µ = x µ x ν ′ on the base manifold implies, in particular, the invariance under homotheties (with constant factor k > 0) Under these transformations, the wedge product dx = dx 0 ∧ dx 1 ∧ dx 2 ∧ dx 3 changes as The invariance condition on λ = Ldx then implies where primes on L denote the components of L and of its covariant derivatives in the new coordinates x α ′ (and we have omitted the indices for simplicity).Moreover, we have that which then leads to: Now, fix an arbitrary point x ∈ M .The restriction of L to the fiber at x of our configuration space is a smooth mapping defined on a Cartesian product of vector spaces (54).Applying to it the homogeneous function theorem, with it follows that L must be a sum of r homogeneous polynomials in L, • ∇L etc., whose degrees d i ∈ N in the derivatives of order i in L satisfy In particular, we must have r ≤ 3. We have then proven : Proposition 6 Any smooth, generally covariant Lagrangian λ = Ldx depending only on the distortion tensor of an affine connection Γ and its derivatives is at order at most three.Moreover, the Lagrangian density L must be expressed as a sum of homogeneous polynomials of degrees d 0 , d 1 , d 2 and, respectively, d 3 in the variables L, • ∇L, • ∇ • ∇L and, respectively, ∇L satisfying : The next step is to realize that, under the hypothesis that λ cannot depend on the metric g, it cannot depend on either the coefficients • Γ α βγ or their derivatives; that is, • Γ α βγ and their derivatives must eventually cancel out in the expression of L, giving This leaves us with L as a sum of homogeneous polynomials in L, ∂L, ∂∂L and ∂∂∂L, of the same degrees as in (63).We thus obtain : Corollary 7 Any smooth, generally covariant Lagrangian λ = Ldx depending only on the distortion tensor of an affine connection Γ and its derivatives is at order at most three.Moreover, it must be a sum of homogeneous polynomials, of degrees d 0 , d 1 , d 2 and, respectively, d 3 in the variables L, ∂L, ∂∂L and, respectively, ∂∂∂L satisfying Remark.In the Homogeneous Function Theorem, the smoothness assumption on f on an entire Cartesian product of vector spaces V 0 ×• • •×V n (in particular, smoothness at its zero vector) is essential.As a consequence, the result cannot be applied to find Lagrangians depending on a metric tensor, since the condition det g = 0 forbids (g αβ ) from being all zero (otherwise stated, we cannot pick any of the fibers of Met (M ) as V 0 , since these fibers are not vector spaces).This allows for non-polynomial natural Lagrangian forms in the metric, such as |det g|dx.
Yet, in our case, our configuration space T 1 2 M is a vector bundle, therefore the Homogeneous Function Theorem can be safely applied, ensuring that λ must be polynomial, as in (65).Actually, as we will see in the next subsection, relation (65) can be further simplified.

B. Classification of pure distortion Lagrangians
To find all generally covariant (natural), pure distortion Lagrangians λ ∈ Ω 4,M J r T 1 2 M , we will use Corollary 7 above, together with several known results in the literature, which we briefly review below : 1. Any natural Lagrangian (which is an equivariant mapping, under the action of the differential group), must be obtained as the result of a natural operator, [10].
2. The only possible first order natural operators acting on a differential p-form on a manifold and returning a (p + 1)-form, are constant multiples of the exterior derivative d, [10], [11].Moreover, natural (generally covariant) differential operators on arbitrary tensor bundles are (see, e.g., [18], p4) compositions of exterior differentiation and invariant (natural) algebraic operators.Actually, when producing Lagrangians, which are horizontal differential forms, the appropriate operator is the total (or horizontal) exterior derivative d In particular, since d H • d H ≡ 0, there are no natural operators of order r > 1 on tensor bundles, involving the tensor variables and their derivatives alone.
3. Natural algebraic operators on tensor bundles are, [18], only finite iterations of : permutations of indices, tensor product with invariant tensors, trace with respect to one subscript and one superscript and linear combinations of these.
Using the above mentioned results, together with Corollary 7, we find Theorem 8 Assume dim(M ) = 4.Then, all natural metric-affine Lagrangians depending on the distortion of the connection alone are of order at most one and must be expressed as a sum whose terms fall into one of the following classes: 1. Purely algebraic terms: These must be expressed as homogeneous polynomials of degree 4 in the components L α βγ of the distortion tensor.
2. First order terms: These must be either quadratic in L and linear in ∂L, or quadratic in ∂L (and independent of L).In any of the two cases, these must be obtained via horizontal exterior differentiation and/or wedge product, from differential forms of rank at most three, depending algebraically on L.
Proof.Assume λ = Ldx is a natural Lagrangian of order r on T (66) In other words, λ is of order at most one.Moreover, equation (65) becomes : This leaves room for three possibilities : corresponding to the two situations in the statement of the theorem.The statement on the exterior derivative/wedge product structure for the latter two cases follows again from the results recalled in the beginning of this subsection.
A complete list of the possibilities of building such Lagrangians is given in Appendix B.

VI. CONCLUSION
In the present paper, we have shown that, in any physical theory involving more than one dynamical variable, having an educated guess (which can be based, e.g., on some physical principle) on the field equations with respect to one such variable, say y A , one can find, in a systematic way, the closest variational equations δL δy A = 0 to our original guess.Using this procedure, all the terms in the Lagrangian density L that involve, in a way or another, y A or their derivatives can be recovered.The obtained Lagrangian density then also determines the Euler-Lagrange equations for the other dynamical variables, say z I , up to terms that are completely independent from y A and their derivatives (and hence do not contribute to the y A equation).
As a first application, we studied the case of metric-affine theories.Assuming that one has a guess on the metric equations, one can recover the closest equations to these that are Euler-Lagrange equations for some Lagrangian.In that case, we also classified the terms in the Lagrangian that cannot be recovered by our technique (i.e.terms that are completely independent of the metric tensor).We found that these are given by polynomial expressions (of degree at most 4) in the distortion of the connection and its first order derivatives.
In a forthcoming paper, we will apply this technique to determine the metric-affine models of gravity that give the closest metric equations to the ΛCDM model of cosmology.This will then further allow us to constrain the evolution equations for the connection (i.e., for the distortion tensor).
Of course, the procedure outlined in this paper is fully general and can thus be applied to a variety of other contexts, e.g., to scalar-tensor theories, or scalar-vector-tensor theories.To further extend our procedure it might also be interesting to study in detail cases where the convergence of the Vainberg-Tonti Lagrangian, as defined in this paper, cannot be guaranteed.We leave these and other questions for future works.In this appendix, we present the explicit form of the Helmholtz expressions, encoding obstruction to variationality, and detail the computations underlying the first statment of Theorem 2. For simplicity, we here display everything in the case of a second order source form.Reasonings unfold similarly in the general case.

Helmholtz expressions
For a second order source form E = E A dy A ∧ dx, the local variationality conditions (Helmholtz conditions) read: 2. Complement to the proof of Theorem 2 Let us now discuss the computations underlying the first statment of Theorem 2. To that purpose, we assume the same setup as in the statment of the theorem; yet, here -for conciseness of the expressions -we restrict our presentation to the case of a second order source form : Assume that E (1) = E A dy A ∧ dx is locally variational with respect to the variables y A , that is, the corresponding Hemholtz expressions vanish.Denoting by λ 1 = L 1 dx the Vainberg-Tonti Lagrangian of E (1) with respect to the variables y A (33), we get (for r = 2; the proof for general r is completely similar): which, after integration by parts in the first term, leads to: Similar computations yield: Summing up, we immediately find : where H µν AB , H ν AB , H AB are the Helmholtz expressions (A1)-(A3).Since, by hypothesis, E (1) is locally variational with respect to the variables y A , we get that H AB = 0, H µ AB = 0, H µν AB = 0, which then implies : δL 1 δy B = E B , that is, λ 1 is a Lagrangian for E (1) , as claimed.

A preliminary step is to classify lower rank invariant
) which are algebraic in T τ βγ and Q τ βγ .These are, as mentioned above, polynomial in T and Q; moreover, invariance to arbitrary natural coordinate changes implies that the total degree of the polynomial must be precisely k.
a. 1-forms.For k = 1, we get two independent forms : (here we haven't used any dots next to T or Q in the left hand sides as there is no risk of confusion).
b. 2-forms.We easily find four independent such forms : c. Forms of rank 3.These must belong to one of the following classes : where A, B, C ∈ {Q, T } and σ ∈ S 3 .By direct inspection, we find 18 independent invariants: 6 wedge products : 2. Zeroth order (algebraic) Lagrangians in L These must be expressed as homogeneous polynomials of total degree 4 in T τ βγ and Q τ βγ .There are 65 such independent invariants, as follows : 33 wedge products of lower rank differential forms : and 32 indecomposable 4-forms, grouped as follows : 5 independent forms of type where A, B ∈ {T, Q} , found for σ = (1, 2, 3, 4) and σ = (1, 4, 2, 3) : 3 independent forms of type indecomposable such forms are generated by derangements σ ∈ S 4 (i.e.σ (i) = i, ∀i); all these permutations lead, up to a sign, to the same results :

First order Lagrangians
We will now discuss natural Lagrangians on J 1 T 1 2 M that are first order in L (i.e. that depend on ∂ σ L ρ µν ).These must be obtained from the lower rank algebraic invariants from section B 1 via (horizontal) exterior derivative and wedge products.
We then find 29 independent such terms : • 3 independent Lagrangians quadratic in ∂L : These are, yet, all total divergences as, e.g., d H α T ∧ d H α T = d H (α T ∧ d H α T ) .Thus, they produce trivial Euler-Lagrange equations.
• 14 Lagrangians linear in ∂L involving α and β terms : Of these, each pair (B43)-(B48) above is made by Lagrangians which differ by a total derivative8 , hence, they produce the same Euler-Lagrange equations.We obtain, thus, 8 possibilities of producing different Euler-Lagrange equations.These correspond e.g. to the wedge products of the two first order rank 2 terms in L (d H α T and d H α Q ) with the four algebraic rank 2 terms in L (i.e.α T ∧ α Q , β Q.T. , β T T.. and β QT.. ).
• 12 Lagrangians linear in ∂L of type d H γ ABC .These are all obtained by horizontal exterior differentiation; hence, their Euler-Lagrange expressions identically vanish.
To conclude, on 4-dimensional manifolds, one can build 65 algebraic invariants, but only 8 nontrivial first order, independent Lagrangians, using the distortion tensor alone.
Interesting remark : there are only one algebraic invariant Lagrangian α Q ∧ γ Q•Q•Q• and no first order, nontrivial Lagrangians which can be built from the symmetric part of L only.

1 2 M
. According to Corollary 7, we must have r ≤ 3 and the density L = L (L, ∂L, ∂∂L, ∂∂∂L) must be polynomial in all its variables, with the respective degrees d 0 , d 1 , d 2 , d 3 satisfying (65).The latter relation can obviously hold only for d 2 , d 3 ≤ 1 (where only one of the values d 2 , d 3 can be non-zero) -i.e., L is at most linear in one of the variables ∂∂L or ∂∂∂L; but, Result 2 above actually forbids this situation, meaning that we must actually have d 2 = d 3 = 0.