Morse families and Dirac systems

Dirac structures and Morse families are used to obtain a geometric formalism that unifies most of the scenarios in mechanics (constrained calculus, nonholonomic systems, optimal control theory, higher-order mechanics, etc.), as the examples in the paper show. This approach generalizes the previous results on Dirac structures associated with Lagrangian submanifolds. An integrability algorithm in the sense of Mendela, Marmo and Tulczyjew is described for the generalized Dirac dynamical systems under study to determine the set where the implicit differential equations have solutions.


Introduction
Dirac structures were introduced in [CW88, Cou90] as a unified approach to both symplectic and Poisson geometries. One of the motivations behind the definition was the study of constrained systems, including the celebrated case of the constrained bracket induced by a degenerate Lagrangian (which was first studied by Dirac [Dir50,Dir67], and after whom Dirac structures are named). The infinite-dimensional analog was introduced in [Dor87] in the context of integrable evolution equations.
Dirac structures were soon employed to describe many situations of interest in mechanics and mathematical physics. In particular the idea of using a Dirac structure D ⊂ T M ⊕ T * M, where M = T * Q and D is induced by the canonical symplectic structure, and a Hamiltonian function H : M → R which represents the energy E = H to write an implicit Hamiltonian system of the forṁ is already found in [vdSM95a,vdSM95b]. This has been the cornerstone of the development of a geometric theory of Port-Hamiltonian systems [DvdS99]; we refer the interested reader to [vdSJ14] for a survey and a comprehensive list of references. Building on the notion of implicit Hamiltonian system, the case of Lagrangian systems (possibly degenerate) was described in [YM06a,YM06b] using the so-called "Dirac differential" DL : T Q → T * T * Q of the Lagrangian L : T Q → R. In a nutshell, the Dirac differential combines Tulczyjew's diffeomorphisms and the differential of L to define a subset of T * T * Q. It is then proved that the implicit Lagrangian system where X : T Q ⊕ T * Q → T T * Q is a partial vector field and D ω Q ⊂ T T * Q ⊕ T * T * Q is the Dirac structure induced by the canonical symplectic form ω Q on T * Q, leads to the equations of the Lagrangian system written in an implicit form. One of the virtues of (2) is that one might modify the Dirac structure D ω Q to account for a nonholonomic distribution ∆ Q ⊂ T Q, and produce the standard nonholonomic equations (again, the equations are obtained in an implicit way). One can modify this approach to include more general situations such as vakonomic mechanics [JY15].
Dirac systems, i.e. system of the form (1), also include Lagrangian systems given by L : T Q → R. In this case, one enlarges the phase space and works on the Pontryagin bundle M = T Q ⊕ T * Q, endowed with a suitable Dirac structure, and the energy E : M → R given by E(q, v, p) = pv − L(q, v). Within this framework, there is no need for neither a Dirac differential operator nor the notion of a partial vector field as in [YM06a,YM06b]The reader can take a look at [CEF14] for the more elaborated examples of nonholonomic systems and LC-circuits.
Another unified approach to Dirac systems, but based on the more general notion of Dirac algebroids, is found in [GG11]. Using a somehow similar approach to that of [YM06a], the authors develop a formalism which includes, among others, mechanics on algebroids, non-autonomous systems and vakonomic and nonholonomic mechanics.
In this paper, we wish to take an alternative point of view and generalize Dirac systems in such a way that dynamics is defined by means of a Lagrangian submanifold of the phase space. We will use Morse families to generate those Lagrangian submanifolds, an approach that has already been applied in the realm of optimal control problems [BLIPMdD15]. With this notion of generalized Dirac system we are able to recover many examples in the literature in a unified intrinsic formalism, including nonholonomic and vakonomic mechanics, optimal control problems and constrained problems on linear almost Poisson manifolds.
The paper starts with a brief review of the relevant definitions in Dirac geometry (Section 2). In Section 3 the basic construction of Lagrangian submanifolds out of Morse families is explained (we follow closely the exposition in [LM87]), and we define the notion of generalized Dirac system that we will consider in this paper. Theorem 1 relates this approach with the standard notion of Dirac system. Section 4 is devoted to a number of examples and in Section 5 we discuss the application of the integrability algorithm in [MMT95] to the notion of generalized Dirac system and discuss the preservation of the presymplectic structure by the dynamics under the assumption of the integrability of the Dirac structure. The paper ends with a section devoted to future work. The final appendix contains details about the relation between the Dirac structures of interest to us and some natural maps in mechanics.
Acknowledgements. The authors acknowledge the financial support from the Spanish government through the network research grant MTM2015-69124-REDT. MB and DMdD acknowledge financial support from the Spanish Ministry of Economy and Competitiveness, through the research grants MTM2013-42870-P, MTM2016-76702-P and "Severo Ochoa Programme for Centers of Excellence" in R&D (SEV-2015-0554). HC and EGTA thank the CONICET for financial support. HC and EGTA also acknowledge funding from ANPCyT (BID PICT 2013 1302, Argentina) and from Universidad Nacional del Sur (PGI 24/L098). EGTA is grateful to the ICMAT (Madrid) for its hospitality during the visits which made this work possible.

Preliminaries on Dirac structures
Consider a finite dimensional vector space U, and let U * be its dual. We endow the vector space U ⊕ U * with the following symmetric non-degenerate pairing: where (u 1 , α 1 ), (u 1 , α 2 ) ∈ U ⊕ U * . A linear Dirac structure on U ⊕ U * is a Lagrangian subspace D ⊂ U ⊕U * or, in other words, D satisfies D = D ⊥ where the orthogonal is taken relative to the pairing ⟪·, ·⟫. It is easy to show that a Dirac structure is characterized by the following two conditions: ⟪(u 1 , α 1 ), (u 2 , α 2 )⟫ = 0 for all (u 1 , α 1 ), (u 2 , α 2 ) ∈ U ⊕ U * , and dim D = dim U.
We remark that we do not require any integrability condition in this definition (this is the convention in e.g. [DvdS99,YM06a]). The reader can find more details about the geometric meaning of the integrability condition on [Cou90]. Two basic examples of Dirac structures are the following: . Its graph defines a Dirac structure that we denote D ω : (ii) Let Λ be a Poisson bivector on M, and let us denote by ♯ Λ : T * M → T M the isomorphism given by β, ♯ Λ (α) = Λ(β, α), for each α, β ∈ T * M. The graph of ♯ Λ defines a Dirac structure: More general Dirac structures can be obtained restricting forms or bivectors to distributions or codistributions, respectively. We refer to [DvdS99,YM06a]) for more details and examples. We remark that, in general, Dirac structures are not given by graphs of forms or bivectors, see e.g. [Bur13].
Within the framework of Dirac manifolds (manifolds equipped with a Dirac structure), there are operations of "backward" and "forward" which extend the usual notions of pullback of a 2-form and push-forward of a bivector (see [BR03,Bur13]). We start with the construction in the case of vector spaces. Let ϕ : U → V be a linear map between the vector spaces U and V . The following holds: is a linear Dirac structure on U that we call backward of D U by ϕ.
2) If D U is a linear Dirac structure on U, then is a linear Dirac structure on V that we call forward of D U by ϕ.
These operations can be extended pointwise to the case of Dirac manifolds, although one needs some regularity condition to assure that the resulting distributions are smooth (and hence, define Dirac structures). In more detail, the construction of the backward and the forward for Dirac manifolds are as follows. Let f : M → N be a smooth map, then: by T m f in the sense of (3). This defines a Lagrangian distribution of T M ⊕T * M. When it is a subbundle (i.e. the distribution is regular), then it becomes a Dirac structure D M on M that we call the backward of D N by f , and denote it by with the forward F (Tmf ) as in (4). Then, similarly to the backward case, one can use the forward construction to define pointwise a Lagrangian distribution of T N ⊕ T * N. Whenever this distribution becomes smooth, it defines a Dirac structure on N that we call the forward of D M by f , and denote it by D N ≡ F f (D M ).
Some regularity conditions which guarantee that these constructions define Dirac structures can be found in [Bur13,CRY17]. The forward and the backward of a Dirac structure have the following functorial property: if f : M → N and g : N → Q are smooth maps, then

Morse families and generalized Dirac systems
The notion of a Morse family or phase function was introduced in [Hör71]. Here we just give some key definitions and essential results that we will need later. More details can be found in [AM78, dLR89, GS77, LM87, Wei71] and references therein. In particular, we will follow [LM87].
Morse families and Lagrangian submanifolds. A simple but important example of a Lagrangian submanifold of T * Q is provided by the image α(Q) of a closed 1-form α on Q. More general Lagrangian submanifolds of cotangent bundles can be represented as a certain quotient of images of 1-forms, as we will explain next following [LM87]. Recall that if π : M → N is a submersion the conormal bundle is Define the vector bundle morphism j π : (ker T π) • → T * N by for all η ∈ (ker T π) • and for all v ∈ T π(η) M. It is easy to check that this application is well defined and that the following diagram is commutative One can also show using the definition of j π (5) that the restriction of j π to each fiber is an isomorphism from that fiber to the corresponding fiber of T * N. The map j π can be locally described as follows. Let (q i , y a ) be fibered coordinates on M and (q i ) on N such that π(q i , y a ) = (q i ) which induce coordinates (q i , y a , p i , z a ) on T * M and (q i , p i ) on T * N. The subbundle (ker T π) • is locally described by coordinates (q i , y a , p i , z a = 0), and We write π * : T * π(η) N → T * η M for the pullback of π. Note that π * • j π = id (ker T π) • . Recall that by definition dE(M) and (ker T π) • are transverse in T * M, denoted by In coordinates adapted to the fibration, if the submersion π : M → N is expressed by π(q i , y a ) = (q i ), then the condition for E : M → R to be a Morse family is that the matrix has maximal rank for all (q i , y a ) satisfying ∂E ∂y a = 0.
Observe that as a consequence of Definition 2 the submanifold (ker T π) • ∩ dE(M) is isotropic in (T * M, ω M ), since it is contained in the Lagrangian submanifold dE(M). A computation shows that dim ((ker T π) • ∩ dE(M)) = dim N (see [LM87]). We remark that the restriction of the canonical symplectic form ω M to (ker T π) • is equal to π * ω N , locally dq i ∧dp i . From here we derive the following useful result (see also [LM87, Appendix 7, Proposition 1.12] or Chapter 4 in [GS77]).
Proposition 1. Let E : M → R be a Morse family. The restriction of the morphism j π : (ker T π) • → T * N to the isotropic submanifold (ker T π) • ∩ dE(M) is a Lagrangian immersion of (ker T π) • ∩ dE(M) in (T * N, ω N ). This Lagrangian immersion is said to be generated by the Morse family E.
We will denote by the immersed Lagrangian submanifold in the above proposition. Observe that in general S E is not horizontal, that is, it is not transverse to the fibers of the canonical cotangent projection π N , and consequently, it is not the image of the differential of a function on N.
Weak Morse families. We will now describe a certain extension of the basic results on Morse families discussed in the previous paragraphs. Namely we will study cases where we have the weaker condition that (ker T π) • ∩ dE(M) is a submanifold and for all α ∈ (ker T π) • ∩ dE(M) we have that That is, we are assuming that (ker T π) • and dE(M) are weakly transverse (this is sometimes called clean intersection). Under the condition of weak transversality we have that is of constant rank (a subimmersion). With this assumption, j π ((ker T π) • ∩ dE(M)) is an immersed Lagrangian submanifold of T * N which may include multiple points (see [LM87]).
The local criteria we will be using for weak transversality of dE(M) is the following. The submanifold (ker T π) • is described locally by z a = 0, a = 1, . . . , k (where k = dim M − dim N). Let z = (z 1 , . . . , z k ), which is a R k -valued function. We define the set Locally, M 0 coincides with the set (z • dE) −1 (0). The differential of the map z • dE is the matrix (6). Therefore, if its rank is constant, using the constant rank theorem the set (z • dE) −1 (0) defines an embedded submanifold whose tangent space is Im dE ∩ ker z. To sum up, if the matrix in (6) has constant rank (not necessarily maximum), dE(M 0 ) = (ker T π) • ∩ dE(M) is an embedded submanifold of T * M whose tangent space satisfies the clean intersection condition.
Definition 3. With the notation introduced above, E will be called a weak Morse family if (ker T π) • and dE(M) are weakly transverse.
Example 1. The following simple example of weak Morse family is of interest in this paper. Given the submersion π : M → N and a function f : Obviously E is not a Morse family (the rank of (6) is zero), but it is a weak Morse family and moreover which is a Lagrangian submanifold of (T * N, ω N ).
Dirac systems and Dirac systems over a weak Morse family. Assume that M is endowed with a Dirac structure D M , and let E : M → R be a given energy function. We consider the following implicit dynamical system: for a curve γ : I → M (where I ⊂ R is an interval), we say that γ is a solution of the Dirac system (D M , dE) iḟ (7) The system described by (7) is general enough to encompass a number of situations of interest in mathematical physics including of course classical Lagrangian and Hamiltonian systems, but also nonholomic mechanics or electric LC circuits [YM06a, YM06b, CEF14].
We will now extend the definition of Dirac system to include more general Lagrangian submanifolds defined in terms of weak Morse families. As the examples in the next section show, this broader definition permits to describe more general dynamical systems in terms of a Dirac structure and a Lagrangian submanifold. With the notations used in this section, let π : M → N be a surjective submersion, S E ⊂ T * N a Lagrangian submanifold induced by a weak Morse family E : M → R, and D N a Dirac structure on N. We look for curves n(t) in N which solve the following implicit dynamical systeṁ where µ n(t) ∈ (S E ) n(t) , i.e. µ n(t) ∈ S E and π N (µ n(t) ) = n(t) (recall that π N : T * N → N is the canonical projection of the cotangent bundle). We will say that the dynamical system (8) is a Dirac system over E. We will also refer to (8) as the (generalized) Dirac system (D N , S E ).
The solution curves of the Dirac system over a Morse family can be alternatively described as a projection of solution curves of the Dirac system Recall that the backward Dirac structure D M is well defined since π is a submersion (see [Bur13]). More precisely: then the curve n : I → N defined by n = π • m is a solution of the Dirac system determined by (D N , S E ), that is, for all t in I, ii) Conversely, if n : I → N is a solution of the Dirac system determined by (D N , S E ), then there exists a solution m(t) of the Dirac system (D M , dE) which projects onto n, i.e. n = π • m.
This means that n(t) solves the generalized Dirac system (D N , S E ).
The converse follows easily from the definitions.

Examples
The purpose of this section is to show how the notion of generalized Dirac system covers many examples of interest in mechanics and control theory.

Lagrangian and Hamiltonian Mechanics
We will describe this first example in some detail to clarify the notations and basic results of the previous sections.
Lagrangian mechanics. Let L : T Q → R be a Lagrangian, possibly degenerate, and consider the Dirac structure D ω Q on T * Q induced by the canonical symplectic 2-form ω Q on T * Q. The coordinate expression of D ω Q reads: Define the energy function E : It is clear that E is a Morse family for the projection pr 2 : T Q⊕T * Q → T * Q, and therefore it generates the Lagrangian submanifold S E of T * T * Q. Indeed, the local expressions for the projection and the energy are has maximal rank (I denotes de identity matrix of size equal to dim Q). We will also need the kernel of T pr 2 and its annihilator, The local expression of the map j π : (ker (T pr 2 )) • → T * T * Q is then and from here the expression of S E = j π dE(M) ∩ ker (T pr 2 ) • follows: To get dynamics, we consider the generalized Dirac system determined by the pair (D ω Q , S E ). Recall that a curve γ : I → T * Q is a solution of this implicit system if it satisfies: ( where µ γ(t) ∈ (S E ) γ(t) . In coordinates, γ(t) = (q i (t), p i (t)) and a solution satisfies Expressed in more familiar terms, which are the well-known Euler-Lagrange equations for L.
Remark 2. We can alternatively consider the canonical Dirac structure D M on M = T Q ⊕ T * Q defined by the pullback of the canonical symplectic form on N = T * Q by the canonical projection pr 2 : M → T * Q (see (12)). We take the usual energy on M, is a solution of the Dirac system (D M , dE) if it satisfies the implicit Euler-Lagrange equations obtained above.
Hamiltonian mechanics. Consider a Hamiltonian H : T * Q → R and the Dirac struc- leads to the classical Hamilton equationṡ Remark 3. More details about the Dirac structure D ω Q and its relation with the geometry of the spaces T T * Q, T * T * Q and T * T Q can be found in Appendix A.

Mechanics on linear almost Poisson structures
Let τ A : A → Q be a vector bundle of rank n over a manifold Q of dimension m, and let A * be the dual vector bundle of A, with corresponding vector bundle projection π A * : A * → Q. Recall that a linear almost Poisson structure on A * is a bracket such that: ii) {·, ·} A * satisfies the Leibniz rule, that is, iii) {·, ·} A * is linear, which by definition means that if ϕ and ψ are linear functions on A * then {ϕ, ψ} A * is also a linear function.
If, in addition, the bracket satisfies the Jacobi identity, then {·, ·} A * is called a linear Poisson structure on A * . We will denote by Λ A * (df, dg) = {f, g} A * the (almost) Poisson bivector associated to an (almost) Poisson linear structure. The associated Dirac structure will be denoted The local description of such a bracket is as follows. Let (q i ), 1 ≤ i ≤ n be local coordinates on an open subset U of Q and {e A }, 1 ≤ A ≤ rank A * be a local basis of sections of π A * : A * → Q. Any point α q ∈ A * is locally given by α q = p A e A (q) and, therefore, (q i , p A ) provide coordinates on A * . With respect to this system of coordinates on A * , the linear almost Poisson bracket has the following local expressions: Consequently, the linear almost Poisson bivector associated to the linear almost Poisson structure on A * has the following coordinate expression: We remark that this example generalizes the case A = T Q, where the Poisson bivector Λ T * Q is the canonical one associated to the canonical symplectic form. Note that both ω Q and Λ T * Q define the same Dirac structure on T * Q.
Equations of motion. We specify the dynamics giving a Lagrangian function L : A → R with associated energy function E : M → R, with M = A ⊕ A * , which is a Morse family over the submersion π (M,A * ) : M → A * . This Morse family generates the immersed Lagrangian submanifold S E of the symplectic manifold (T * A * , ω A * ). A curve γ : , and by a computation completely analogous to the one used to obtain (9), we find: Note that, in general, S E will not be the graph of the differential of a real function on A * (but it is an immersed Lagrangian submanifold, as shown in Section 3). If the Lagrangian is regular, then S E can be obtained as a differential.
The expression of D Λ A * ⊂ T A * ⊕ T * A * is obtained as the graph of the bivector Λ A * : The equations of motion will follow from the generalized Dirac system (D Λ A * , S E ). In coordinates, a curve solves the Dirac system (D A * , S E ) if, and only if, For the Hamiltonian description, the energy E is given by the Hamiltonian H(q, p), and the Dirac system (D A * , dE) leads to: which agree with those in the literature, see [dLMMdD10].
Remark 4. More details on the geometry of D Λ A * can be found in Appendix A.
Euler-Poincaré equations. A particular case of the previous construction is obtained when A * is the dual of a Lie algebra (as a vector bundle over a point). Let G be a Lie group, g its Lie algebra and g * its dual. On g * we have the ± Lie-Poisson bracket: where µ ∈ g * and δf δµ : g * → g stands for the functional derivative of f and where [·, ·] is the Lie algebra bracket on g. It is well known that both brackets are induced by reduction of the standard Lie bracket on T * G by right or left-reduction. Let us denote by g ± the Lie algebra g endowed with the (±)-Lie-Poisson bracket. The map ♯ g ± is simply ♯ g ± : T * g * ≡ g * × g −→ T g * ≡ g * × g * (µ, ξ) −→ (µ, ∓ad * ξ µ), and we have a Dirac structure defined on g * , D g ± ⊂ T g * ⊕ T * g * ≡ g * ⊕ g * ⊕ g. Given a Lagrangian L : g −→ R, frequently defined as a reduced Lagrangian from T G, we have the Morse family E : g ⊕ g * −→ R (ξ, µ) −→ µ, ξ − L(ξ), generating the Lagrangian submanifold S E of T * g * ≡ g * × g given by The solutions of the generalized Dirac system (D g ± , S E ) are curves µ : where (µ(t), ξ(t)) ∈ S E . Therefore, the equations are: which correspond to the Euler-Poincaré equations d dt We refer the reader to [Hol11,MR99] for more details.
Euler-Poincaré equations with advected parameters. Another important class of examples comes from actions of Lie algebras on manifolds. Given a homomorphism Φ from the Lie algebra g to the Lie algebra of vector fields on Q, X(Q), we can induce a linear Poisson bracket on the trivial bundle A * = Q × g * → Q as follows: Here d q f stands for the differential of f with respect to q ∈ Q, and the evaluation point (q, µ) has been suppressed. It is not difficult to check that where J : T * Q → g * is the associated cotangent momentum map J(α q ), ξ = α q , Φ(ξ) q .
For a Lagrangian L : A = Q × g → R we define the Morse family E : Q × g × g * −→ R given by E(q, ξ, µ) = µ, ξ −L(q, ξ) which generates the following Lagrangian submanifold The equations of motion are derived now using the generalized Dirac system (D A * , S E ) and the corresponding solutions are curves (q, µ) : where (q(t), µ(t), ξ(t)) ∈ S E . Therefore, the equations are: which corresponds to the following equations d dt As a particular case, suppose that G is a Lie group acting by left representation on a vector space V , and denote by v → gv the left representation of g ∈ G on v ∈ V . Then, G also acts on the left on its dual space V * . For each v ∈ V , denote by ρ v : g → V the linear map given by and denote by ρ * v : V * → g * the map ρ * v (a), ξ = a, ρ v (ξ) , a ∈ V * , ξ ∈ g.
We will use the common notation Particularizing the previous discussion to this case, we obtain that A = V * × g → V * where now the homomorphism Φ : g → End (V * ), is given by In this case A * = V * × g * → V * and the linear Poisson structure is given by . Given a Lagrangian L : V * ×g → R we obtain the Euler-Poincaré equations with advected parameters d dt We refer the reader to [HMR98] for many interesting applications of these equations. See also [CM87] and [CIM87] for a discussion of variational principles in this context.
Nonholonomic mechanics. Now we will show that the formalism of Dirac systems covers some interesting cases of nonholonomic mechanics (see [Blo15] and references therein). This particular type of constrained mechanical systems have a considerable practical interest since nonholonomic constraints are present in a great variety of engineering and robotic tools describing the dynamics of wheeled vehicles, manipulation gadgets and locomotion, etc. For simplicity and since most examples are in that category, we will only consider systems subjected to linear constraints. In this case, the dynamics is described by a C ∞ -distribution A on the configuration space Q, that is, by a linear vector subbundle τ A : A → R of T Q with canonical inclusion i A : A → T Q. We say that A is holonomic if A is integrable or involutive and nonholonomic otherwise, that is, a regular linear velocity constraint A is nonholonomic if it is not holonomic. Therefore, we will say that a curve γ : I ⊆ R → Q satisfies the constraints given by A iḟ Mathematically a mechanical nonholonomic system is given by the following data: 1) A Lagrangian L : T Q → R of the form: Here g denotes a Riemannian metric on the configuration space Q and V : Q → R is a potential function. Locally, the metric is determined by the non-degenerate symmetric matrix (g ij ) 1≤i,j≤dim Q such that g = g ij (q) dq i ⊗ dq j . Therefore 2) A vector subbundle τ A : A → Q.
Given this two data, the equations of motion in nonholonomic mechanics are completely determined by the Lagrange-d'Alembert principle. This principle states that a curve γ : I ⊆ R → Q is an admissible motion of the system if δ T 0 L(γ(t),γ(t)) dt = 0 for variations which satisfy δγ ∈ A γ(t) . Locally, if γ(t) = q i (t) then, from the Lagranged'Alembert principle, we arrive at the well-known nonholonomic equations To present the previous nonholonomic equations as a generalized Dirac system we proceed as follows (see [GdLMMndD09,dLMMdD10]). Using the Riemannian metric g we have the orthogonal decomposition T Q = A ⊕ A ⊥ and the corresponding orthogonal projectors

Now define the following linear almost Poisson bracket {·, ·}
where i A : A → T Q denotes the inclusion, {·, ·} T * Q is the standard Poisson bracket of the cotangent bundle and f, g ∈ C ∞ (A * ). Denote by Λ A * (df, dg) = {f, g} A * , and by D Λ A * the associated Dirac structure on this almost Poisson manifold (see [dLMMdD10], and also [vdSM94,CdLMndD99]). Defining E : the solutions of the nonholonomic equations are expressed as the solutions of the generalized Dirac system determined by (D Λ A * , dE).
Locally, consider a basis of vector fields {X a , X α } on Q, 1 ≤ a ≤ m and m+1 ≤ α ≤ n, such that A q = span {X a (q)} and A ⊥ q = span {X α (q)}. Using this decomposition it is easy to induce coordinates (x i , y a ) in A such that for any vector v q ∈ T q Q v q = y a X a (q) + y α X α (q).
These coordinates are known as quasi-velocities with respect to the frame {X a , X α }, and they turn out to be very useful in the context of nonholonomic mechanics (we refer the reader to [CM10] for more details; see also [BMZ09]). Observe that in these coordinates, if v q ∈ A q , then y α = 0 represents the nonholonomic constraints. Consequently, A is described by the coordinates (q i , y a ). In these adapted coordinates the nonholonomic equations are rewritten as: where X a = X i a (q) ∂ ∂q i , P[X a , X b ] = C c ab X c and l : A → R is the restriction of L to A, that is, L |A = l. The almost Poisson bracket satisfies: where the {p a } are implicitely defined by the relation p a = ∂l ∂y a .

Constrained variational calculus on linear almost Poisson manifolds
Let L : M → R be a constrained Lagrangian where M ⊂ T Q is a constraint submanifold.
A constrained variational problem [AKN88], [CdLMdDM02], [IMMdDS08] consists on finding critical points of an action functional t 1 t 0 L(q(t),q(t)) dt on the family of curves satisfying some fixed endpoints condition as, for instance, q(t 0 ) = q 0 , q(t 1 ) = q 1 and, besides, satisfying the constraints, that is, (q(t),q(t)) ∈ M q(t) , for all t ∈ (t 0 , t 1 ). The submanifold M is (2n − m)−dimensional and is locally determined by the vanishing of constraint functions, Φ a = 0, 1 ≤ a ≤ m, where Φ a : T Q → R.
We are implicitly assuming that the solution curves q(t) admit nontrivial variations in the space of curves satisfying the constraints; that is, we are dealing with normal solutions, in opposition to the abnormal ones, which are pathological curves that do not admit nontrivial variations.
In the case of normal solutions it is possible to characterize the solutions by using the standard procedure of Lagrange multipliers. The usual way to present the equations of motion of vakonomic mechanics is the following: where λ a are Lagrange multipliers to be determined andL : T Q → R is an arbitrary extension of L to T Q. The equations (10) can be seen as the Euler-Lagrange equations for the extended Lagrangian L =L + λ a Φ a . Note that if we consider the extended Lagrangian λ 0L + λ a Φ a , with λ 0 = 0 or 1, then we recover all the solutions, both the normal and the abnormal ones [AKN88].
We will see how our scheme is easily adapted to the case of constrained variational problems. Assume, for sake of simplicity, that the restriction (τ Q ) |M : M → Q is a surjective submersion. In this case, we can choose coordinates (q i ,q A ) on M and the constraints are rewritten Φ a (q i ,q i ) = ϕ a (q i ,q A ) −q a . In other words, M admits the local description: Given the Lagrangian L : M → R, define the function E : where v q ∈ M q and α q ∈ T * q Q. In adapted coordinates It is a simple computation to show that E is a Morse family for the projection pr 2 : M × Q T * Q → T * Q, and it generates the following immersed Lagrangian submanifold S E of T * T * Q: If we consider the Dirac structure D ω Q on T * Q, then a curve γ(t) = (q i (t), p i (t)) is a solution of the Dirac system (D ω Q , S E ) if In other terms, These equations are equivalent to the equations (10), where Ψ a (q i ,q i ) = ϕ a (q i ,q A ) −q a and λ a = ∂L ∂q a − p a .
The case of a general vector bundle. The same procedure works in the case of reduced constrained systems where we have a Dirac structure on a linear almost Poisson manifold A * , denoted D Λ A * , as discussed earlier in Section 4.2. Besides the vector bundle τ A : A → Q, we assume that we have a fiber bundle τ M : M → Q with M ⊂ A (which, in general, is not a vector subbundle) and a Lagrangian L : M → R .
With the notation used above, let pr 2 denote the projection and take as a Morse family where v q ∈ M q and α q ∈ A * q . The equations corresponding to the generalized Dirac system determined by the pair (D Λ A * , S E ) are: where µ γ(t) ∈ (S E ) γ(t) . In order to write locally the equations of motion, we will choose local fiber bundle coordinates (q i , y A , y a ) of A such that and we obtain Observe now that and the solutions γ(t) = (q i (t), p A (t), p a (t)) of the Dirac system (D Λ A * , S E ) verify the following systems of equations: These equations can be found in [IMMdDS08].
Higher-order mechanics. Our geometric approach also recovers the higher-order mechanics whose Lagrangian function is given by: L : T (k) Q → R and we have the Dirac structure D ω T * T (k−1) Q on T * T (k−1) Q defined by the natural symplectic structure on the cotangent bundle T * T (k−1) Q over T (k−1) Q. It is important to note that the manifold T (k) Q can be embedded into T T (k−1) Q fitting into the following commutative diagram: Hence, we can define the Morse family as follows where v ∈ T (k) Q and α ∈ T * T (k−1) Q. The reader can obtain as an exercise the equations of motion corresponding to the generalized Dirac system determined by (D ω T * T (k−1) Q , S E ) and check that they are precisely the equations for the higher-order mechanics in [dLR85]. We point out that in this case S E is a submanifold of T * T * T (k−1) Q.

Optimal control theory
We will adopt the notation of Section 4.2. We consider the optimal control problem of an autonomous system with fixed initial and final boundary conditions q 0 and q T , where [0, T ] ⊂ R is a fixed interval. The set of admissible controls are piecewise-continuous functions of time taking values on a set U ⊂ R m . The state or control equations and associated boundary conditions have the forṁ q = F (q, u) , q(0) = q 0 , q(T ) = q T , and the cost functional is: The optimal control problem consists of finding the minimum value of the cost functional over the control set and to determine the solution of the state equations for this optimal control. The standard way to single out the solution candidates is via Pontryagin's maximum principle [PBGM86], but we will show here how to characterize them using our framework.
Geometrically, an optimal control problem is determined by a control bundle τ C : C → Q (typically, C = Q × U), a fibered mapping F : C → T Q such that τ C = τ Q • F and a cost function L : C → R. Consider the bundle C τ C × π Q T * Q and the projection is not in general a Morse family over pr 2 . Locally, does not necessarily have maximum rank and thus it is not, in general, a Morse family. It may happen that S E is not a immersed submanifold of T * T * Q. In any case, we can consider the system determined by (D ω Q , S E ) and the solutions are now given by: Following the same procedure as in the previous sections we obtain the equations of motion for the system (D ω Q , S E )q which are the typical Pontryagin's equations for the Hamiltonian function E : The case of general bundles. An interesting generalization of the previous optimal control problem consists of replacing T Q by a vector bundle A over Q. That is the following data are given: a control bundle τ C : C → Q and the fibered mapping F : C → A (such that τ C = τ A • F ) , a cost function L : C → R and the Dirac structure D Λ A * defined in Section 4.2. Consider the bundle C τ C × π A * A * and the projection The function E : Locally From the Dirac system (D Λ A * , S E ) we obtain the equations of motioṅ These equations can be compared with the equations obtained for an optimal control problem defined on Lie algebroids in [Mar07]. When the function E is a Morse family, then everything falls into the description in [BLIPMdD15] where the integrability algorithm is used to find the solutions. In the next section the algorithm will be adapted to the family of generalized Dirac systems described in this paper.

Integrability algorithm and Dirac systems
We are going to adapt the integrability algorithm developed in [MMT95] to solve implicit differential equations to the case of Dirac systems defined by Morse families. We first review the integrability algorithm prior to adapt it to the unified framework described in this paper.
Integrability algorithm. When an implicit differential equation is given, the algorithm allows to find a subset, if it exists, where the solution curves are. The steps in the algorithm guarantee that the curves will not leave that final subset because of imposed tangency conditions.
Let S be an implicit differential equation on a manifold P , that is, a submanifold S of T P . In such a case, it is possible to construct an algorithm to extract the integrable part of S in P (see [MMT95]).
A curve γ : I ⊆ R → P is called a solution of the differential equation S ifγ(I) ⊂ S. The implicit differential equation S is said to be integrable at v ∈ S if there is a solution γ : I ⊆ R → P such thatγ(0) = v. The implicit differential equation S is said to be integrable if it is integrable at each point v ∈ S.
Proposition 2. [MMT95, Proposition 5] Let τ P : T P → P be the canonical tangent bundle projection. If N = τ P (S) is a submanifold of P and if the mapping is a surjective submersion, then the condition S ⊂ T N is sufficient for integrability of the implicit differential equation S.
In order to obtain the integrable part of an implicit differential equation we construct the following sequence of objects N 1 , τ 1 ), . . . , (S k , N k , τ k ), . . .
For each k, it is assumed that the sets N k are submanifolds and that the mappings τ k are surjective submersions. Since the dimension of P is finite, the sequence of implicit differential equations S 0 , S 1 , . . . , S k , . . . stabilizes at some index k, that is, S k = S k+1 . The integrable implicit differential equation S k ⊂ T P is the integrable part of S. We remark that S k is possibly empty.
Adaptation of the integrability algorithm for Dirac systems. As described in Section 3, a Dirac system over a Morse family E is an implicit dynamical system given by equation (8). This system is defined on the Whitney sum T N ⊕ T * N. We will apply the integrability algorithm in the part corresponding to the tangent bundle by defining the following submanifold of T N: A solution to the dynamical system (D N , S E ) is a curve n(t) in N such thatṅ(t) lies in S D N ,E . To obtain the integrable part of S D N ,E in N, we start by taking S 0 = S D N ,E , N 0 = τ N (S 0 ) and τ 0 = τ N .
The following steps of the algorithm are defined by If the algorithm stabilizes, there exists a final submanifold (possibly empty) satisfying S k f = T τ N (S k f ) ∩ S k f . The steps of the algorithm generate a sequence of submanifolds in N as follows As a consequence, for every In this way we have found the base submanifold where the original dynamical system has solution. Thus a solution to the dynamical system (D N , S E ) is a curve n(t) on N k f such that (ṅ(t), µ n(t) ) ∈ (D N ) n(t) , where µ n(t) ∈ (S E ) n(t) .
By the properties of Dirac structures reviewed in Section 2, and assuming some regularity condition 1 , the backward of D N by the map i 0f = i 0 • i 1 • · · · • i k f : N k f ֒→ N defines a Dirac structure D N k f = B i 0f (D N ) on N k f . This condition is not necessarily always true. Even though we can make some comments about the dynamics on D N k f if the Morse family is also pull-backed. A solution of (D N , S E ) is always a solution of (D N k f , i * 0f (S E )), but the converse does not hold in general, as is known for the case of singular Lagrangians studied in [Dir67,GN79,GNH78].
Remark 5. A comprehensive study of the constraint algorithm for standard Dirac systems can be found in [CEF14].
A preservation result. We will now prove that if the Dirac structure is integrable, any solution of the Dirac system in the final constraint manifold N k f preserves the presymplectic structure along the corresponding leaf. This result generalizes the case in which the Lagrangian submanifold is given by the graph of an energy function.
Proof. Using Cartan's formula and the definition of D Nz we have £ X ω f z = d(i X ω f z ) = dµ. As S E is a Lagrangian submanifold of T * N, for any Y 1 , Y 2 ∈ X(S E ) we have that 0 In particular, if ν is understood as a 1-form on N, the previous computation for Y 1 , Y 2 ∈ X(S E ) can be rewritten as follows: But this implies that for any Z 1 , Z 2 ∈ X ∈ (H f z ) obtained from the projections of vector fields on S E we have (£ X ω f z )(Z 1 , Z 2 ) = dµ(Z 1 , Z 2 ) = 0. It remains to prove that any vector field Z on H f z can be expressed as a projection of a vector field on S E . For any integral curve n(t) of Z in the leaf H f z , the integrability algorithm guarantees that there exists µ n(t) in (S E ) n(t) such that (ṅ(t), µ n(t) ) ∈ (D N ) n(t) . As µ n(t) = (iṅ (t) ω f z ) n(t) , the differentiability of µ guarantees that the result holds. Note that, as needed, T π N d dt µ n(t) =ṅ(t) = Z(n(t)) .

Future work
The unified formalism developed in this paper includes and extends recent results in the literature such as [JY15] where nonholonomic and vakonomic mechanics are described using Dirac structures. As the authors prove there, nonholonomic mechanics cannot be described by Lagrangian submanifolds. However, a Morse family also defines a Lagrangian submanifold that can be used to provide the Dirac structures with dynamics. This approach makes possible to describe nonholonomic mechanics as described in Section 4.2, as well as many other examples explained in Section 4.
The future research lines include: 1. The interconnection of simpler systems allows to describe complex systems as the theory of port-Hamiltonian systems shows [vdSJ14,vdSM95a]. Dirac structures have already been used in this context [CvdSB07,CvdSB03] (we also refer to [BLCGTAMdD18] for a recent geometric approach), but our formalism provides an intrinsic description to tackle the interconnection of Dirac systems by means of Lagrangian submanifolds and Morse families.
2. To solve the generalized Dirac systems is usually challenging. This paper reveals a unified geometric approach that opens the path to define geometric integrators for those Dirac systems [HLW10, LO11, MW01, PL17].

A Natural maps and commutative diagrams
There are some interesting relations between the Dirac structure D ω Q on T * Q, given by the graph of ω Q , and the spaces T T * Q, T * T * Q and T * T Q appearing in the Tulczyjew triple. Let us first recall that there are canonically defined isomorphisms whose local expressions are ♭ ω Q : T T * Q → T * T * Q , (q i , p i ,q i ,ṗ i ) → (q i , p i , −ṗ i ,q i ), α Q : T T * Q → T * T Q , (q i , p i ,q i ,ṗ i ) → (q i ,q i ,ṗ i , p i ).
The intrinsic definition of these maps, and the motivation behind them, can be found in [Tul76b,Tul76a]. With these maps in mind, and noting that D ω Q reads we will define diffeomorphisms Ψ 1 , Ψ 2 and Ψ 3 from D ω Q to the spaces T T * Q, T * T Q and T * T * Q, respectively. Namely, if we denote by pr 1 and pr 2 the projections of T T * Q ⊕ T * T * Q onto T T * Q and T * T * Q, and by i Dω Q : D ω Q ֒→ T T * Q ⊕ T * T * Q. Then we set: These maps and their coordinate expressions are shown in Diagram 1 (where ♯ ω Q is the inverse of ♭ ω Q ).
One might also relate D ω Q to the Dirac structure D M on M = T Q ⊕ T * Q, given by the graph of the pullback of ω Q to M. In coordinates There are natural maps where pr T * Q is the projection onto T * Q, and i M : M → T * T Q is the inclusion (it is a vector bundle inclusion, see [CEF14] for a definition). In coordinates, i M (q, v, p) = (q, v, p, 0). The basic observation is that the spaces T * Q and T * T Q both have canonical Dirac structures D ω Q and D ω T Q , and that D M can be obtained via the backward of these structures by either the projection or the inclusion, i.e. D M = B pr T * Q (D ω Q ) = B i M (D ω T Q ). We summarize the situation in an enlarged diagram (Diagram 2).
The map Φ : D M → D ω Q is a vector bundle morphism over the projection pr T * Q , in coordinates Φ(q i , v i , p i ,q i ,v i ,ṗ i , α i , γ i , β i ) = (q i , p i ,q i ,ṗ i , α i , β i ).
A coordinate-free definition is Φ = T pr T * Q ⊕ T * i T * Q , where i T * Q : T * Q → M = T Q ⊕ T * Q is the inclusion i T * Q (q, p) = (q, 0, p), and T * i T * Q is the cotangent map of i T * Q . In the case of a linear almost Poisson bracket discussed in Section 4.2, there is a similar commutative diagram for D A * (compare with Diagram 1): To define the maps involved, let us first recall the existence of a canonical isomorphism R : T * A * → T * A, in coordinates R(q i , p A , α i , β A ) = (q i , β A , −α i , p A ).
The map ε in the diagram is such that the following diagram is commutative (in particular, it depends on the Poisson structure chosen). In coordinates, we find . We refer the reader to [GUG06,GU99] for more details. We can now define the maps Ψ 1 , Ψ 2 and Ψ 3 . Denote by pr 1 and pr 2 the projections of T A * ⊕ T * A * onto T * A * and T A * , and i D Λ A * : D Λ A * → T A * ⊕ T * A * the inclusion. Then: Ψ 2 : D Λ A * → T * A * , Ψ 2 = pr 2 • i D Λ A * , The coordinate expressions are summarized in the following diagram: We also have an enlarged commutative diagram generalizing Diagram 2: where D M = B π (M,A * ) (D Λ A * ) and the map Φ is defined analogously to (13).