1 Introduction

Since the theory of general relativity (GR) is a classical field theory of gravitation, the choice of BCs is of great importance. The role of surface integrals in GR has been investigated first in Dewitt and Dirac’s papers [1, 2] and then was covered deeply in the works of York [3] and Regge and Teitelboim [4]. Trying to quantize GR in path integral formalism, Gibbons and Hawking [5] showed that, a boundary term should be added to the Einstein–Hilbert (EH) action, in order to have a well-defined variational principle with Dirichlet BC, i.e. \( \delta g_{ab}|_{\textit{ Boundary}}=0 \). Such terms, added to the EH action, or the action of generalized theories of gravity [6,7,8,9,10,11,12], are called GHY terms which are used for for finite volume spaces. For non-compact spaces like asymptotically Minkowski or Ads, the variational problem needs extra boundary terms in addition to the GHY term since it depends on the specific asymptotic form of the space-time [13].

The theory of GR is described by a degenerate Lagrangian, i.e. it can be written as the sum of a quadratic part in the first derivatives of metric and a total derivative term. There are two approaches to deal with GR. The first one is the well-known ADM formalism which uses the Gauss–Codazzi equation to get rid of the second derivative terms of the Lagrangian [5, 7, 8, 14]. The second one, which is more covariant, manifests the quadratic Lagrangian by subtracting a suitable boundary term which can be removed by adding a GHY term [15, 16].

For modified gravity models such as \(f( R )\)-gravity, which is non-degenerate, one needs to use the so-called Ostrogradsky approach [17], by introducing enough number of fields to the theory such that the whole Lagrangian includes at most the first derivatives of the fields. In this way one is able to go through a canonical approach and at the same time introduce consistent BCs. For \(f( R )\)-gravity without considering additional fields, one needs to consider the extrinsic curvature variation \(\delta K_{ij}\), as well as \(\delta g_{ij}\) to vanish on the boundary, which is inconsistent since extrinsic curvature \( K_{ij}\), includes derivatives of the metric. However, by adding the famous GHY term \( - 2\int _{\partial {\mathcal {M}}}d^{D-1}y\epsilon \sqrt{h} f'(R)\delta K \) [h and K are the trace of induced metric and the extrinsic curvature respectively, \( \epsilon =\pm 1 \) depending on the timelike or spacelike nature of the boundary \( \partial {\mathcal {M}} \) and \( f'(R)=\frac{\partial f}{\partial R} \)] to the action, the BCs reduce to vanish \(\delta R\) on the boundary simultaneously with the Dirichlet BC. But calculating \(\delta R\) (see Appendix C) shows that the main problem is not resolved since R is not an independent field and its variation includes again variations of the derivatives of the metric.

In this paper we try in Sect. 2 to change f(R) Lagrangian into a degenerate one by Ostrogradsky approach. To do so, we write the \( f( R ) \)-gravity in the Jordan frame of the Brans–Dicke action [18,19,20]. We find that the action of the theory is degenerate. Hence, by adding appropriate GHY terms, Dirichlet or other BCs can be achieved. Writing the boundary terms of the action in terms of fields and momentum fields, in a foliation independent approach, enables us to introduce the consistent GHY term for Dirichlet, Neumann and two types of mixed BCs in arbitrary dimensions. For one type of mixed BC, the GHY term vanishes. This may be interpreted that the \(f( R )\)-gravity is more consistent with this mixed type of BC in D dimension.

In this paper the Latin indices are used to show the space-time coordinates and the Greek ones are used to denote the space coordinates. The calculations are done in arbitrary dimensions of space-time and the signature of metric is (\(-,+,+,+\)).

2 \(f( R )\)-gravity

The action of GR is holographic [15, 16], i.e. there is a relation between the surface and bulk terms as following:

$$\begin{aligned} \sqrt{-g}R= & {} \sqrt{-g}{\mathcal {L}}_{\textit{ quad}}(\partial ,\partial g)\nonumber \\&+\frac{1}{D/2-1}\partial _i\left( -g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _ig_{ab})}\right) , \end{aligned}$$
(1)

where

$$\begin{aligned} {\mathcal {L}}_{\textit{ quad}}= & {} \frac{1}{4}{\mathcal {M}}^{abcdef}\partial _ag_{bc}\partial _dg_{ef} \nonumber \\ {\mathcal {M}}^{abcdef}\equiv & {} g^{ad}\left( g^{bc}g^{ef}-g^{be}g^{cf}\right) \nonumber \\&+2g^{af}\left( g^{be}g^{cd}-g^{bc}g^{ed}\right) \end{aligned}$$
(2)

As can be seen, it can be written as a quadratic Lagrangian plus a total derivative term [15, 16]. Unlike the GR Lagrangian, \( f( R ) \)-gravity given by

$$\begin{aligned} S =\int d^Dx \sqrt{-g} f( R ), \end{aligned}$$
(3)

seems to be non-degenerate.Footnote 1 Varying the above action and integrating by part, without implying any BC, we haveFootnote 2

$$\begin{aligned} \delta \int _{{\mathcal {M}}} d^Dx\sqrt{-g}f( R )&=\int _{{\mathcal {M}}} d^Dx\sqrt{-g} L^{ab}\delta g_{ab}\nonumber \\&\quad +\int _{\partial {\mathcal {M}}}d^{D-1}y \sqrt{h}\left\{ -\frac{ f ^{\prime }\Pi _{ij}}{\sqrt{h}}\right. \nonumber \\&\quad \left. +\epsilon \nabla _af'(h^a_jn_i-n^ah_{ij})\right\} \delta h^{ij}\nonumber \\&\quad +\int _{\partial {\mathcal {M}}}d^{D-1}y\epsilon f'\delta (2 K \sqrt{h}) \end{aligned}$$
(4)

where

$$\begin{aligned} L_{ab}\equiv -\frac{1}{2} f g_{ab}+ f ^{\prime } R _{ab}-\nabla _a\nabla _b f ^{\prime }+g_{ab}\square f ^{\prime }=0 \end{aligned}$$
(5)

is the equation of motion. \(\Pi _{ij}=\epsilon \sqrt{h}( K _{ij}- K h_{ij})\) is the momentum conjugate to \( h^{ij} \) in GR and \( n_i \) is the normal vector of the boundary. As can be seen, to obtain the equations of motion, imposing the Dirichlet BC,Footnote 3 we can get rid of the first surface integral in the above equation. To remove the second surface integral, the usual GHY boundary term can be added to the action (3) as follows

$$\begin{aligned} S _t= & {} S + S _{GHY}=\int _{{\mathcal {M}}} d^Dx \sqrt{-g} f( R )\nonumber \\&-2\int _{\partial {\mathcal {M}}}d^{D-1}y\epsilon \sqrt{h} f' K . \end{aligned}$$
(6)

Varying the above action gives

$$\begin{aligned} \delta S _t&=\int _{{\mathcal {M}}} d^Dx\sqrt{-g} L_{ab}\delta g^{ab} +\int _{\partial {\mathcal {M}}}d^{D-1}y\epsilon \sqrt{h}\nonumber \\&\quad \times \,\left\{ \frac{ f ^{\prime }\Pi _{ij}}{\sqrt{h}}+\nabla _af'(h^a_jn_i-n^ah_{ij}) \right\} \delta h^{ij}\nonumber \\&\quad -2\int _{\partial {\mathcal {M}}}d^{D-1}y\epsilon \sqrt{h} K f''\delta R. \end{aligned}$$
(7)

Hence, to get the equations of motion, we need to impose \(\delta R|_{\textit{ Boundary}}=0 \), in addition to \( \delta h^{ij}|_{\textit{ Boundary}}=0 \). In Appendix C, we have shown that \(\delta R\) is a combination of variations \( \delta h^{ij} , \delta K_{ij}, \delta n^i, \nabla _i \delta K \) and \( \delta (\nabla _a \nabla _i n^a ) \). Now we can ask if \( \delta R|_{\textit{ Boundary}}=0 \) is compatible with the Dirichlet BC?

To answer this question we need to define, in a consistent way, the momenta conjugate to the field variables in order to distinguish the Dirichlet and Neumann BCs where the momentum fields vanish on the boundary. However, this can be done only for degenerate theories, where the bulk term of Lagrangian contains at most the first order derivatives of the fields. Noting Ostrogradsky approach [17], we should change the \( f( R ) \) Lagrangian into a degenerate one as much as possible. To do so, using scalar-tensor formulation, by introducing an scalar field \( \phi \), we write \( f( R ) \) action as follows:

$$\begin{aligned} S =\int d^{D}x\sqrt{-g}(\phi R -V(\phi )), \end{aligned}$$
(8)

in which \( \phi =f'( R ) \), \( V(\phi )= R (\phi )\phi -f( R (\phi )) \) and we have assumed that \( f''(R)\ne 0 \). Now substituting the relation (1) in the above action, we have

$$\begin{aligned} S= & {} \int _{{\mathcal {M}}}d^Dx \sqrt{-g}\left( \phi {\mathcal {L}}_{\textit{ quad}}-V(\phi )\right) \nonumber \\&+\frac{1}{D/2-1} \int _{{\mathcal {M}}}d^Dx \phi \partial _i \left( -g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\right) \end{aligned}$$
(9)

The first integral contains only the metric, its first order derivatives and the scalar field \( \phi \). Integrating by parts, this is also the case for the second integral, and thus the above Lagrangian is degenerate. To see this, let us rewrite Eq. (9) as follows

$$\begin{aligned} S&=\int _{{\mathcal {M}}}d^Dx \sqrt{-g}\left( \phi {\mathcal {L}}_{\textit{ quad}}-V(\phi )\right) \nonumber \\&\quad +\frac{1}{D/2-1}\int _{{\mathcal {M}}}d^Dx \partial _i \phi g_{ab} M ^{iab}\nonumber \\&\quad -\frac{1}{D/2-1}\int _{t}d^{D-1}y \phi g_{ab} P ^{ab}. \end{aligned}$$
(10)

where

$$\begin{aligned} M ^{iab} \equiv \frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})} = \frac{\sqrt{-g}}{2} {\mathcal {M}}^{iabpqr} \partial _p g_{qr} \end{aligned}$$

and \( {\mathcal {M}}^{iabpqr} \) is defined in Eq. (2). Note that \( P ^{ab}\equiv \partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})/\partial (\partial _{0} g_{ab})\) is the canonical momentum of \( g_{ab} \) in GR. Hereafter we have also assumed that \( \partial {\mathcal {M}} \) contains two spacelike \((D-1)\)-dimensional surfaces at \( t=\text {constant} \) and one timelike surface on which the integral vanishes at large spatial distances. Now we are able to define the canonical momenta of \( \phi \) and \( g_{ab} \) as follows

$$\begin{aligned} {{\bar{P}}}^{ab}\equiv & {} \frac{\delta S }{\delta (\partial _0 g_{ab})}=\phi P ^{ab}\nonumber \\&+\frac{(D-1)\sqrt{-g}}{D-2}(g^{i0}g^{ab}-2g^{ib}g^{0a})\partial _i\phi \end{aligned}$$
(11)

and

$$\begin{aligned} {{\bar{P}}}_\phi \equiv \frac{\delta S }{\delta (\partial _0 \phi )}=\frac{1}{D/2-1} P \end{aligned}$$
(12)

where \( P = g_{ab} P ^{ab} \) and we have used the following relation

$$\begin{aligned} \partial _i \phi g_{ab} {\mathcal {M}}^{iab0qr} =(D-1)( g^{i0}g^{qr}-2g^{ir} g^{0q} ) \partial _i \phi . \end{aligned}$$
(13)

Considering the action (10), one can see that, regardless of the surface integral which is a GHY term, the Lagrangian contains fields and their first order derivatives. Therefore, we can be sure that the variational principle for this action is compatible with the Dirichlet BC. Before investigating in details the compatibility of the model, let us show explicitly the structure of the added GHY term in the ADM formalism. Consider the following relation

$$\begin{aligned} g _{ab}{P}^{ab}&=\frac{\sqrt{-g}}{4}g_{ab}g_{de,f}\left[ {\mathcal {M}}^{ab0def}+{\mathcal {M}}^{defab0}\right] \nonumber \\&=\sqrt{-g}\frac{D-2}{2}g_{de,f}\left( g^{de}g^{0f}-g^{df}g^{0e}\right) \nonumber \\&=\frac{D-2}{2}\frac{1}{\sqrt{-g}}\partial _a(gg^{0a})\nonumber \\&=\frac{D-2}{2}\sqrt{-g}\left[ -2 K n^0+\frac{\partial _{\alpha } N ^{\alpha }}{ N ^2}\right] \end{aligned}$$
(14)

where \(n^a=N^{-1}(1,-N^\alpha )\) and the lapse and shift functions are denoted by N and \( N^{\alpha }.\)Footnote 4 In the last equality we have used the following two identities

$$\begin{aligned}&2 K n^o=\frac{2}{N^2\sqrt{h}}\partial _a(N^2\sqrt{h}g^{0a})=\frac{2}{N^2}\partial _a(N^2g^{0a})\nonumber \\&\qquad \quad \, +\,2g^{0a}\partial _a\ln \sqrt{h} \end{aligned}$$
(15)
$$\begin{aligned}&\frac{1}{N^2}\partial _a(N^2g^{0a})=\frac{\partial _{\alpha }N^{\alpha }}{N^2} \end{aligned}$$
(16)

Substituting the expression (14) into (10) gives

$$\begin{aligned} S&=\int _{{\mathcal {M}}}d^Dx \sqrt{-g}\left( \phi {\mathcal {L}}_{\textit{ quad}}-V(\phi )\right) \nonumber \\&\quad +\frac{1}{D/2-1}\int _{{\mathcal {M}}}d^Dx \partial _i \phi g_{ab} M ^{iab}\nonumber \\&\quad -2\int _{t}d^{D-1}y\sqrt{h} \phi K +\int _{t}d^{D-1}y\sqrt{h}\phi \frac{\partial _{\alpha }N^{\alpha }}{N} \end{aligned}$$
(17)

where the first surface integral in (17), is the same as GHY term of Refs. [6,7,8]. However, the second surface term is often lost in the literatures. We will come back to this point in the next subsection.

Now let us consider the variations of the action (10). First, we rewrite it in terms of the momenta given in Eqs. (11) and (12). By adding (and subtracting) the following surface integral

$$\begin{aligned}&\frac{2(D-1)}{(D-2)^2}\int _t d^{D-1}y \sqrt{-g} g_{ab} (g^{i0}g^{ab}-2g^{ib}g^{0a})\partial _i\phi \nonumber \\&\quad =\frac{2(D-1)}{D-2}\int _t d^{D-1}y \sqrt{-g} \partial ^0\phi \end{aligned}$$
(18)

to (and from) the action (10), we get

$$\begin{aligned} S&=\int _{{\mathcal {M}}}d^Dx \sqrt{-g}\left( \phi {\mathcal {L}}_{\textit{ quad}}-V(\phi )\right) \nonumber \\&\quad +\frac{2}{D-2}\int _{{\mathcal {M}}}d^Dx \partial _i \phi g_{ab} M ^{iab}\nonumber \\&\quad -\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} {{\tilde{P}}}^{ab}\nonumber \\&\quad +\frac{2(D-1)}{D-2}\int _t d^{D-1}y \sqrt{-g} \partial ^0\phi \end{aligned}$$
(19)

Varying this action with respect to \( \phi \) and \( g_{ab} \) and using Eq. (13), after a little algebra, we obtain

$$\begin{aligned} \delta S = \delta _{\phi } S +\delta _{g} S \end{aligned}$$
(20)

where

$$\begin{aligned} \delta _{\phi } S= & {} \int _{{\mathcal {M}}}d^Dx \left\{ \sqrt{-g}\left( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\right) \right. \nonumber \\&\left. +\frac{1}{D/2-1} \partial _i \left( -g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\right) \right\} \delta \phi \end{aligned}$$
(21)

and

$$\begin{aligned} \delta _{g} S&=\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} + \frac{D-4}{D-2}\int _{t}d^{D-1}y {{\bar{P}}}^{ab} \delta g_{ab}\nonumber \\&\quad +\frac{D-1}{D-2}\int _{t}d^{D-1}y \sqrt{-g} \partial ^0 \phi g^{ab} \delta g_{ab}\nonumber \\&\quad -\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} \delta {{\bar{P}}}^{ab}\nonumber \\&\quad +\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} P ^{ab} \delta \phi \nonumber \\&\quad +\frac{2(D-1)}{D-2}\int _{t}d^{D-1}y \sqrt{-g} \delta (\partial ^0 \phi ) \end{aligned}$$
(22)

in which

$$\begin{aligned} L ^{ab}&=\phi \frac{ \partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial g_{ab}} - \partial _i\left( \phi M ^{iab}\right) -\frac{1}{2}\sqrt{-g} g^{ab} V(\phi )\nonumber \\&\quad +\frac{2}{D-2} \partial _i \phi M ^{iab} +\frac{2}{D-2}\partial _i \phi g_{kl} H ^{iabkl} \nonumber \\&\quad -\frac{1}{D-2} \partial _p (\sqrt{-g}\partial _i \phi g_{qr} {\mathcal {M}}^{iqrpab}) \end{aligned}$$
(23)

and \( H ^{iabkl} \equiv \partial M ^{iab}/\partial g_{kl} \). Substituting (21) and (22) in (20) gives

$$\begin{aligned} \delta S&= \int _{{\mathcal {M}}}d^Dx \bigg \{ \sqrt{-g}\left( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\right) \nonumber \\&\quad +\frac{1}{D/2-1} \partial _i \left( -g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\right) \bigg \}\delta \phi \nonumber \\&\quad +\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} + \frac{D-4}{D-2}\int _{t}d^{D-1}y {{\bar{P}}}^{ab} \delta g_{ab}\nonumber \\&\quad -\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} \delta {{\bar{P}}}^{ab}\nonumber \\&\quad +\frac{D-1}{D-2}\int _{t}d^{D-1}y \sqrt{-g} \partial ^0 \phi g^{ab} \delta g_{ab} +\int _{t}d^{D-1}y \bar{ P }_\phi \delta \phi \nonumber \\&\quad +\frac{2(D-1)}{D-2}\int _{t}d^{D-1}y \sqrt{-g} \delta (\partial ^0 \phi ) \end{aligned}$$
(24)

As expected, without the GHY term, the undesirable BCs: \( \delta g_{ab}|_{\textit{ Boundary}}=\delta {{\bar{P}}}_{ab}|_{\textit{ Boundary}}= \delta \phi |_{\textit{ Boundary}}=\delta (\partial ^0 \phi )|_{\textit{ Boundary}}=0\) should be assigned. In order to find the appropriate GHY term, let us discuss three different types of BCs leading to a consistent stationary action principle for \( f ( R )\)-gravity.

2.1 Dirichlet BC

Considering the surface terms in Eq. (39), in order to impose the Dirichlet BC: \( \delta g_{ab}|_{\textit{ Boundary}}=\delta \phi |_{\textit{ Boundary}}=0 \), we need to modify the action (19) by adding the following GHY term

$$\begin{aligned} S _{\textit{ D}}= & {} S + S _{\textit{ D}} ^{\textit{ GHY}}= S +\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} {{\bar{P}}}^{ab}\nonumber \\&-\frac{2(D-1)}{D-2}\int _t d^{D-1}y \sqrt{-g} \partial ^0 \phi \end{aligned}$$
(25)

To see that the above action is compatible with the Dirichlet BC, let us vary it as follows

$$\begin{aligned} \delta S _{\textit{ D}}= & {} \int _{{\mathcal {M}}}d^Dx \left\{ \sqrt{-g}\Bigg ( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\right) \nonumber \\&+\frac{1}{D/2-1} \partial _i \Bigg (-g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\Bigg )\Bigg \}\delta \phi \nonumber \\&+\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} + \int _{t}d^{D-1}y {{\bar{P}}}^{ab} \delta g_{ab}\nonumber \\&+\int _{t}d^{D-1}y {\bar{P}}_{\phi }\delta \phi \end{aligned}$$
(26)

which gives the equation of motion subjected the Dirichlet BC. Note that \( \phi =f'(R) \) gives \( \delta \phi |_{\textit{ Boundary}}=f''(R)\delta R|_{\textit{ Boundary}}=0\). Now we can surely say that \( \delta R|_{\textit{ Boundary}}=0 \) is compatible with the Dirichlet BC and is in fact part of it. This is a clear covariant verification of the result pointed in Ref. [7] in the framework of the ADM foliation. To be more concrete, we can determine the GHY term \(S_{\textit{ D}} ^{\textit{ GHY}}\) in terms of ADM variables. Using (14) and substituting \( \phi = f'(R) \), we have

$$\begin{aligned} S _{\textit{ D}} ^{\textit{ GHY}}=-2\int _{t}d^{D-1}y\sqrt{h} f'(R) K +\int _{t}d^{D-1}y\sqrt{h} f'(R) \frac{\partial _{\alpha }N^{\alpha }}{N} \end{aligned}$$
(27)

which are the same terms present in Eq. (17). According to the Dirichlet BC, \(\delta R|_{\textit{ Boundary}}=\delta h_{ab}|_{\textit{ Boundary}}= \delta N^\mu |_{\textit{ Boundary}}=\delta N|_{\textit{ Boundary}}=0 \), the last term of the above equation can be neglected and the first term suffices [6,7,8, 15]. However, note that this is correct only for the Dirichlet BC.

To complete our discussion, we can set \( \phi =1 \) and \( V(\phi )=0 \) in Eq. (24) to find the following result for the case of GR

$$\begin{aligned} \delta S_{\textit{ (EH)}}= & {} \int _{{\mathcal {M}}}d^Dx {{\bar{L}}}^{ab} \delta g_{ab} + \frac{D-4}{D-2}\int _{t}d^{D-1}y P ^{ab} \delta g_{ab}\nonumber \\&-\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} \delta P ^{ab} \end{aligned}$$
(28)

where

$$\begin{aligned} {{\bar{L}}}^{ab}= \frac{ \partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial g_{ab}} - \partial _i M ^{iab} \end{aligned}$$

Imposing the Dirichlet BC: \( \delta g_{ab}|_{\textit{ Boundary}}=0 \), the action should be modified by the following GHY term to get the equations of motion,

$$\begin{aligned} S _{\textit{ D(EH)}}= S _{\textit{ (EH)}}+ S _{\textit{ D(EH)}} ^{\textit{ GHY}}= S _{\textit{ (EH)}}+\frac{2}{D-2}\int _{t}d^{D-1}y g_{ab} P ^{ab} \nonumber \\ \end{aligned}$$
(29)

Moreover, using Eq. (14), we can rewrite \( S _{\textit{ D(EH)}} ^{\textit{ GHY}}\) in the familiar form

$$\begin{aligned} S _{\textit{ D(EH)}} ^{\textit{ GHY}}=-2\int _{t}d^{D-1}y \sqrt{h} K + \int _{t}d^{D-1}y \sqrt{h} \frac{\partial _{\alpha } N^{\alpha }}{N} \end{aligned}$$
(30)

where for the Dirichlet BC, the second term can be neglected [21].

2.2 Neumann BC

In order to obtain the GHY term related to the Neumann BC: \( \delta {\bar{P}}^{ab}|_{\textit{ Boundary}}=\delta {\bar{P}}_\phi |_{\textit{ Boundary}}=0 \), let us write (24) in a different form. From (11) and (12), we find that

$$\begin{aligned} {\bar{P}}^{ab}\delta g_{ab}= & {} -g_{ab}\delta {\bar{P}}^{ab}+\frac{D-2}{2}{\bar{P}}_\phi \delta \phi +\frac{D-2}{2} \phi \delta {\bar{P}}_\phi \nonumber \\&+ (D-1) \delta (\sqrt{-g}\partial ^0 \phi ) \end{aligned}$$
(31)

Inserting this into (24) gives

$$\begin{aligned} \delta S&= \int _{{\mathcal {M}}}d^Dx \bigg \{ \sqrt{-g}\left( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\right) \nonumber \\&\quad +\frac{1}{D/2-1} \partial _i \left( -g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\right) \bigg \}\delta \phi \nonumber \\&\quad +\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} - \int _{t}d^{D-1}y g_{ab} \delta {{\bar{P}}}^{ab} \nonumber \\&\quad +\frac{D-4}{2}\int _{t}d^{D-1}y \phi \delta {{\bar{P}}}_\phi +\frac{D-2}{2}\int _{t}d^{D-1}y {{\bar{P}}}_\phi \delta \phi \nonumber \\&\quad +\frac{D-1}{2}\int _{t}d^{D-1}y \sqrt{-g} \partial ^0 \phi g^{ab} \delta g_{ab} \nonumber \\&\quad +{(D-1)}\int _{t}d^{D-1}y \sqrt{-g} \delta (\partial ^0 \phi ) \end{aligned}$$
(32)

This shows that the action (19) is consistent with the Neumann BC if we propose the following GHY term

$$\begin{aligned} S _{\textit{ N}}= & {} S + S _{\textit{ N}} ^{\textit{ GHY}}= S -\frac{D-2}{2}\int _{t}d^{D-1}y {{\bar{P}}}_\phi \phi \nonumber \\&-(D-1)\int _t d^{D-1}y \sqrt{-g} \partial ^0 \phi \end{aligned}$$
(33)

Variation of (33) yields

$$\begin{aligned} \delta S _{\textit{ N}}&= \int _{{\mathcal {M}}}{d^D}x \Bigg \{ \sqrt{-g}\Bigg ( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\Bigg )\nonumber \\&\quad +\frac{1}{D/2-1} \partial _i \Bigg (-g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\Bigg )\Bigg \}\delta \phi \nonumber \\&\quad +\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} - \int _{t}d^{D-1}y g_{ab} \delta {{\bar{P}}}^{ab}\nonumber \\&\quad - \int _{t}d^{D-1}y \phi \delta {\bar{P}}_{\phi } \end{aligned}$$
(34)

which gives the equations of motion using Neumann BC.

Using (14) and inserting \( \phi =f'(R) \), we can write the GHY term in (33) in the ADM formalism as

$$\begin{aligned} S _{\textit{ N}} ^{\textit{ GHY}}&=(D-2)\int _{t}d^{D-1}y \sqrt{h} f'(R) K \nonumber \\&\quad -\frac{D-2}{2} \int _{t}d^{D-1}y \sqrt{h} f'(R) \frac{\partial _{\alpha } N^{\alpha }}{N}\nonumber \\&\quad -(D-1)\int _td^{D-1}y\sqrt{h}N\partial ^0 f'(R) \end{aligned}$$
(35)

It should be noted that unlike the case of Dirichlet BC, the second term in the above action can not be neglected unless for the coordinate system in which \( N^{\alpha }=0 \). It is worth to compare (35) with the GHY term (27) for Dirichlet BC. It is easily seen that

$$\begin{aligned} S _{\textit{ N}} ^{\textit{ GHY}}=-\frac{D-2}{2} S _{\textit{ D}} ^{\textit{ GHY}}-(D-1)\int _td^{D-1}y\sqrt{h}N\partial ^0 f'(R) \end{aligned}$$
(36)

2.3 Mixed BC

There are two types of mixed BCs for f(R)-gravity: \( \delta {\bar{P}}_{ab}|_{\textit{ Boundary}}=\delta \phi |_{\textit{ Boundary}}=0\) or \( \delta {\bar{P}}_\phi |_{\textit{ Boundary}}=\delta g_{ab}|_{\textit{ Boundary}}=0\). We begin with the first one. Using the variation of f(R)-gravity action, (24) or (32), the first type mixed BC would be consistent if we have added the following GHY term to the action

$$\begin{aligned} S ^{}_{\textit{ MI}}= & {} S + S _{\textit{ MI}} ^{\textit{ GHY}}= S -\frac{D-4}{2}\int _{t}d^{D-1}y \phi {{\bar{P}}}_\phi \nonumber \\&-(D-1)\int _{t}d^{D-1}y \sqrt{-g} \partial ^0 \phi \end{aligned}$$
(37)

Varying the above action gives

$$\begin{aligned} \delta S _{\textit{ MI}}&=\int _{{\mathcal {M}}}d^Dx \Bigg \{ \sqrt{-g}\Bigg ( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\Bigg ) \nonumber \\&\quad +\frac{1}{D/2-1} \partial _i \Bigg (-g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\Bigg )\Bigg \}\delta \phi \nonumber \\&\quad +\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} - \int _{t}d^{D-1}y g_{ab} \delta {{\bar{P}}}^{ab}\nonumber \\&\quad +\int _{t}d^{D-1}y {\bar{P}}_{\phi } \delta \phi \end{aligned}$$
(38)

As can be seen, the mixed BC: \( \delta {{\bar{P}}}_{ab}|_{\textit{ Boundary}}=\delta \phi |_{\textit{ Boundary}}=0 \) yields consistently the equations of motion. Now using Eq. (14) and \( \phi =f'(R) \), we can write the GHY term of Eq. (37) in terms of ADM variables as

$$\begin{aligned} S _{\textit{ MI}} ^{\textit{ GHY}}&=(D-4)\int _{t}d^{D-1}y \sqrt{h} f'(R) K \nonumber \\&\quad -\frac{D-4}{2} \int _{t}d^{D-1}y \sqrt{h} f'(R) \frac{\partial _{\alpha } N^{\alpha }}{N}\nonumber \\&\quad -(D-1)\int _td^{D-1}y\sqrt{h}N\partial ^0 f'(R) \end{aligned}$$
(39)

It is also worth noting here to find the relation between Dirichlet and the above mixed GHY boundary terms in f(R) -gravity. Comparing the above result with that obtained in Eq. (27), we see that

$$\begin{aligned} S _{\textit{ MI}} ^{\textit{ GHY}}=-\frac{D-4}{2} S _{\textit{ D}} ^{\textit{ GHY}}-(D-1)\int _td^{D-1}y\sqrt{h}N\partial ^0 f'(R) \end{aligned}$$
(40)

For GR, i.e. \( \phi =1 \) and \( V(\phi )=0 \), it is interesting that the newly defined action (37) is consistent with the Neumann BC

$$\begin{aligned} S _{\textit{ N(EH)}}= S _{\textit{ (EH)}}+ S _{\textit{ N(EH)}} ^{\textit{ GHY}}= S_{\textit{ (EH)}} -\frac{D-4}{D-2}\int _{t}d^{D-1}y P \end{aligned}$$
(41)

This shows that the pure Neumann BC may be used for GR in arbitrary dimensions. To clarify more, using Eq. (14), it is easy to see that the above GHY term with respect to the ADM variables takes the form

$$\begin{aligned} S _{\textit{ N(EH)}} ^{\textit{ GHY}}= & {} (D-4)\int _{t}d^{D-1}y \sqrt{h} K \nonumber \\&-\frac{D-4}{2} \int _{t}d^{D-1}y \sqrt{h} \frac{\partial _{\alpha } N^{\alpha }}{N}. \end{aligned}$$
(42)

where again the second term in the above action or in (39), can be ignored only for the special choice of coordinate system mentioned in the previous subsection. Also, it can be easily seen that, in GR, in contrast to the Dirichlet case, the required GHY term, compatible with the Neumann BC, depends on the dimension of space-time and for \( D=4 \), the coefficient of GHY term vanishes. Thus there is no need to any GHY term in order to have a consistent theory. This point, explained here covariantly is also shown recently in Ref. [14] in ADM approach. Another interesting feature is the relation between Dirichlet and Neumann GHY term in GR. Comparing Eqs. (30) and (42), one finds

$$\begin{aligned} S _{\textit{ N(EH)}}^{\textit{ GHY}}=-\frac{D-4}{2} S _{\textit{ D(EH)}}^{\textit{ GHY}} \end{aligned}$$
(43)

Now let us look at the second type of mixed BC: \( \delta {\bar{P}}_\phi |_{\textit{ Boundary}}=\delta g^{ab}|_{\textit{ Boundary}}=0 \). In order to discuss the consistency of \( f ( R )\)-gravity with this BC, first we use (31) to substitute for \(g_{ab}\delta {\bar{P}}^{ab} \) in (24). This leads to

$$\begin{aligned} \delta S _{\textit{ MII}}&=\int _{{\mathcal {M}}}d^Dx \Bigg \{ \sqrt{-g}\Bigg ( {\mathcal {L}}_{\textit{ quad}}-\partial _\phi V(\phi )\Bigg ) \nonumber \\&\quad +\frac{1}{D/2-1} \partial _i \Bigg (-g_{ab}\frac{\partial (\sqrt{-g}{\mathcal {L}}_{\textit{ quad}})}{\partial (\partial _{i} g_{ab})}\Bigg )\Bigg \}\delta \phi \nonumber \\&\quad +\int _{{\mathcal {M}}}d^Dx L ^{ab} \delta g_{ab} + \int _{t}d^{D-1}y {{\bar{P}}}^{ab}\delta g_{ab} \nonumber \\&\quad -\int _{t}d^{D-1}y \phi \delta {\bar{P}}_{\phi } \end{aligned}$$
(44)

Clearly by applying the BC: \( \delta {\bar{P}}_{\phi }|_{\textit{ Boundary}}=\delta g_{ab}|_{\textit{ Boundary}}=0 \), we can get the equations of motion without adding any GHY term to the above expression. This means that f(R)-gravity with the above type of mixed BC is self-consistent with no need to any GHY term in D dimension. To clarify this point better, let us return to the relation (4) in which the boundary terms are written in the ADM formalism. One can write these terms in term of the momenta conjugate to \( \phi \), \( h_{ij} \), N and \( N^\alpha \). These are derived in details in appendix D and are as follows

$$\begin{aligned} {\bar{\Pi }}_N= & {} {\bar{\Pi }}_{N^{\alpha }}=0\\ {\bar{\Pi }}_\phi= & {} -2\epsilon \sqrt{h} K \end{aligned}$$
$$\begin{aligned} {\bar{\Pi }}_{ij}=\epsilon \sqrt{h}\left\{ \phi ( K _{ij}- K h_{ij})+\frac{h_{ij}}{N}({\dot{\phi }}-N^{\alpha }\partial _\alpha \phi )\right\} \end{aligned}$$
(45)

Substituting this into (4) and inserting \( \phi =f'(R) \), we obtain

$$\begin{aligned} \delta \int _{{\mathcal {M}}} d^Dx\sqrt{-g}f( R )&=\int _{{\mathcal {M}}} d^Dx\sqrt{-g} L^{ab}\delta g_{ab}\nonumber \\&\quad -\int _{\partial {\mathcal {M}}}d^{D-1}y \sqrt{h}{\bar{\Pi }}_{ij}\delta h^{ij}\nonumber \\&\quad -\int _{\partial {\mathcal {M}}}d^{D-1}yf'\delta {\bar{\Pi }}_\phi \nonumber \\&\quad -\int _{\partial {\mathcal {M}}}d^{D-1}y\epsilon \sqrt{h} \nabla ^i\phi \delta n_i \end{aligned}$$
(46)

where \( h^{ij}\delta n_i =-n_i\delta h^{ij}\) is used. It can be seen that the above surface terms, which are written in the ADM formalism, are completely in agreement with what we have derived by the covariant approach in (44). Regarding the above relation and by applying the mixed BC: \( \delta {\bar{\Pi }}_\phi |_{\textit{ Boundary}}=\delta n_i|_{\textit{ Boundary}}=\delta h^{ij}|_{\textit{ Boundary}}=0 \), we can get the equations of motion in D dimension without any GHY term.

3 Conclusion

In this paper it is shown that unlike GR, the action of \( f( R ) \)-gravity is not holographic such as the action of Lanczos–Lovelock theory. Moreover, the Lagrangian of \( f( R ) \)-gravity can not be expressed as the sum of quadratic and total derivative terms. So \( f( R ) \) Lagrangian is not degenerate. Following the Ostrogradsky approach, since \( f( R ) \)-gravity is a theory with higher order derivatives of metric, it carries a single additional degree of freedom, which is the scalar field of equivalent Brans–Dicke action. Introducing this field, leads to a degenerate Lagrangian which is used to develop the problem of BC and the corresponding GHY terms in \( f( R ) \)-gravity [7, 8].

Here we have followed a foliation independent approach to find the GHY boundary terms in \( f( R ) \)-gravity, required to make the BC variation problem well-defined. We have shown that in addition to the Dirichlet BC, the Neumann BC and two types of the mixed BCs can be introduced for the \(f( R )\)-gravity. The remarkable point which is one of the main results of this paper is about the mixed BCs. We have shown that one of the mixed BC: \( \delta {\bar{P}}_{ab}|_{\textit{ Boundary}}=\delta \phi |_{\textit{ Boundary}}=0\) is reduced to the Neumann BC in the case of GR. This BC together the other mixed BC: \(\delta {\bar{P}}_\phi |_{\textit{ Boundary}}=\delta g^{ab}|_{\textit{ Boundary}}=0\) are self-consistent BCs, i.e. these do not need to any GHY term to be consistent with the theory, the first one for GR and the second one for \(f( R )\)-gravity, both in D dimension.