1 Introduction

Resolving sets can be used to distinguish the vertices of a graph G comparing distances to fixed vertices. Fault-tolerant resolving sets were defined to distinguish the vertices of G even though one of the vertices of the set fails. Here we consider a more general case, concretely, resolving sets that distinguish the vertices of a graph when any k vertices of the set fail, where k is a fixed integer.

The notion of resolving sets in graphs was defined independently by Harary and Melter [13] and Slater [25] and have since received a lot of attention due to their applications in several areas, such as network discovery and verification [3], robot navigation [17], chemistry [5] or games [7]. Fault-tolerant resolving sets were introduced in [14] and have been studied in [2, 6, 15, 19, 21, 23, 24, 27]. For more applications and properties on metric dimension and its variants, the reader is addressed to the surveys [20, 26] and the references herein.

Let G be a simple finite connected graph. For two vertices \(u,v \in V(G)\), let d(uv) denote the length of a shortest path from u to v. A vertex u of G resolves two vertices x and y if \(d(u,x)\not = d(u,y)\). A set of vertices \(S\subseteq V(G)\) is a resolving set for G if for every pair of different vertices x and y of G there is a vertex u in S that resolves x and y. The metric dimension of G, denoted by \(\dim (G)\), is the minimum cardinality of a resolving set, and a metric basis is a resolving set of cardinality \(\dim (G)\). If \(S=\{ u_1,\dots ,u_k \}\subseteq V(G)\), we denote by r(x|S) the vector of distances from x to the vertices of S, that is, \(r(x|S)=(d(x,u_1),\dots ,d(x,u_k))\). Thus, S is a resolving set if and only if \(r(x|S)\not = r(y|S)\) for every pair of distinct vertices \(x,y\in V(G)\). The elements of r(x|S) are the metric coordinates of x with respect to S. A resolving set \(S\subseteq V(G)\) is fault-tolerant if \(S-\{ u\}\) is a resolving set, for every \(u\in S\).

Resolving sets can be used to locate nodes in a network modeled as a graph, and fault-tolerant resolving sets can be used to locate nodes even though one of the nodes of the resolving set fails. Here we consider the possibility of more than one failure. Note that the set obtained after the removal of any k vertices of a resolving set S remains resolving if and only if every pair of vertices of the graph is resolved by at least \(k+1\) distinct vertices of S. This last concept was introduced in [9], concretely, a set S of vertices of a graph is a k-resolving set if for every pair of vertices x and y, the vectors r(x|S) and r(y|S) have at least k different coordinates. Hence, a set S remains resolving even though k vertices fail if and only if S is a \((k+1)\)-resolving set. The k-metric dimension and k-resolving sets of a graph and, concretely, of some product graphs have been studied in [2, 9,10,11,12, 18, 22, 28]. In the survey [20], an extensive summary of known results and applications of the k-metric dimension is given.

It is worth mentioning that, in contrast to resolving sets or fault-tolerant resolving sets, k-resolving sets do not always exist for \(k\ge 3\) [9]. Whenever a graph G has at least one k-resolving set, a k-resolving set of minimum cardinality is a k-metric basis, and its cardinality is the k-metric dimension of G, denoted by \(\dim _k(G)\) [9]. With this terminology, 1-resolving sets correspond to resolving sets and 2-resolving sets correspond to fault-tolerant resolving sets.

Here we are interested in finding resolving sets tolerant to k failures, that is, \((k+1)\)-resolving sets and, more precisely, \((k+1)\)-metric bases and the \((k+1)\)-metric dimension of three-dimensional grids. Grid graphs have been proven to be very useful in diverse areas such as robotics, video games and telecommunications [1, 8, 19]. The value of the k-metric dimension of two-dimensional grids is determined in [2].

Since a superset of a resolving set is also a resolving set, the following result is obvious and provides a necessary and sufficient condition for the existence of a k-resolving set.

Remark 1

A graph G has a k-resolving set if and only if V(G) is a k-resolving set.

Next result gives a lower bound on the k-metric dimension of a graph, whenever it is defined.

Proposition 2

[9]. If a graph G has a k-resolving set, then \(\dim _{k} (G)\ge \dim (G)+k-1\).

The paper is organised as follows. In Sect. 2, some properties concerning resolving sets for three-dimensional grids are given. Concretely, we prove that the metric dimension of a three-dimensional grid is exactly 3 and establish lower bounds on the number of vertices resolving a fixed pair of vertices. These bounds will be very useful in Sect. 3, devoted to the study of resolving sets tolerant to k failures in three-dimensional grids. Concretely, we determine the \((k+1)\)-metric dimension and describe \((k+1)\)-metric bases of these grids in almost all cases.

2 Resolving Sets in Three-Dimensional Grids

In this section we calculate the metric dimension of three-dimensional grids and prove some new results concerning resolving sets in these grids. We also point out sets of vertices resolving a fixed pair of vertices, that will be very useful in Sect. 3.

Formally, an r-dimensional grid, or rD grid for short, is any graph obtained as the cartesian product of r non-trivial paths, that is, \(P_{n_1}\Box \cdots \Box P_{n_r}\), with \(n_1,\dots , n_r\ge 2\). We can assume that the set of vertices of \(P_{n_1}\Box \cdots \Box P_{n_r}\) is:

$$\begin{aligned} V(P_{n_1}\Box \cdots \Box P_{n_r})=\{ (x_1,\dots ,x_r) : 0\le x_i \le n_i-1 \hbox { for every }i\in \{1,\dots ,r\} \} \end{aligned}$$

and two vertices \((x_1,\dots ,x_r)\) and \((y_1,\dots ,y_r)\) of \(V(P_{n_1}\Box \cdots \Box P_{n_r})\) are adjacent if and only if \(y_i\in \{x_i-1,x_i+1\}\), for some \(i\in \{ 1,\dots , r\}\), and \(x_j=y_j\), whenever \(j\not = i\). Hence, the degrees of the vertices of an rD grid are \(r, r+1,\dots ,2r\), and the distance between two vertices \((x_1,\dots ,x_r)\) and \((y_1,\dots ,y_r)\) in \(P_{n_1}\Box \cdots \Box P_{n_r}\) is:

$$\begin{aligned} d( (x_1,\dots ,x_r), (y_1,\dots ,y_r))=\sum _{i=1}^r |y_i-x_i|. \end{aligned}$$

There are some vertices that play an important role in resolving pairs of vertices of a 3D grid, concretely, vertices with degree different from the maximum degree, 6. The vertices of degree 3 are called corners. A vertex of degree 6 is an interior vertex. With the specified labeling of the vertices, the set of corners of a 3D grid is \(\{ (x_1,x_2,x_3): x_i\in \{ 0, n_i-1\} \hbox { for }i\in \{1,2,3 \} \}\). A face of a 3D grid is a set of vertices with a constant coordinate \(x_{i_0}\) equal to either 0 or to \(n_{i_0}-1\), for some \(i_0\in \{1,2,3\}\). Let \(F(n_1,n_2,n_3)\) denote the set of vertices belonging to any face, that is, \(F(n_1,n_2,n_3)=\{(x_1,x_2,x_3): \, x_i\in \{ 0, n_i-1\} \,\,\hbox { for some }i\in \{1,2,3\} \,\}\). We write simply F if the values \(n_1\), \(n_2\) and \(n_3\) are clear from context. Note that F consists of all non-interior vertices and \( |F(n_1,n_2,n_3)|=n_1n_2n_3-(n_1-2)(n_2-2)(n_3-2)=2(n_1n_2+n_2n_3+n_1n_3)-4(n_1+n_2+n_3)+8.\)

It is known that the metric dimension of an rD grid is at most r [17]. Also in this paper, it is said that it is exactly r and the proof is left to the reader. However, in general this is not in true. For example, it is known that the metric dimension of the hypercube, that can be viewed as a rD grid with \(n_1=\dots =n_r=2\), is less than r for \(r\ge 5\) [4]. It remains an open problem to determine the exact value of the metric dimension for general grids. A discussion on asymptotic values of the metric dimension of a grid is included in [16]. Next, we prove that the result stated in [17] holds for 3D grids.

Theorem 3

If \(n_1,n_2, n_3\ge 2\), then \(\dim (P_{n_1}\Box P_{n_2}\Box P_{n_3})=3\). Moreover, a set formed by three corners of a face is a metric basis.

Proof

We begin by proving that \(\dim (P_{n_1}\Box P_{n_2}\Box P_{n_3})\ge 3\). Paths are the only graphs with metric dimension 1 [5], thus, it is enough to prove that the metric dimension of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) is different from 2.

Suppose to the contrary that \(\dim (P_{n_1}\Box P_{n_2}\Box P_{n_3})=2\) and \(S=\{ u,v \}\) is a resolving set for G. Then, the degree of u and v is at most 3 [17]. Hence, u and v must be corners in \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). We can assume without loss of generality that \(u=(0,0,0)\) and \(v\in \{ (n_1-1,0,0), (n_1-1,n_2-1,0), (n_1-1,n_2-1,n_3-1) \}\).

But, if \(v=(n_1-1,0,0)\), then \(r((0,1,0)|S)=r((0,0,1)|S)=(1,n_1)\);

if \(v= (n_1-1,n_2-1,0)\), then \(r((0,1,0)|S)=r((1,0,0)|S)=(1,n_1+n_2-3)\); and

if \(v= (n_1-1,n_2-1,n_3-1)\), then \(r((0,1,0)|S)=r((1,0,0)|S)=(1,n_1+n_2+n_3-4)\), which is a contradiction.

In [17], the authors prove that the set \(\{ (0,0,0), (n_1-1,0,0), (0,n_2-1,0) \}\) is a resolving set for \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Hence, \(\dim (P_{n_1}\Box P_{n_2}\Box P_{n_3})= 3\). By symmetry, we have that every set formed by three corners of a face is a metric basis. \(\square \)

The following lemma describes some resolving sets of cardinality 4 for a 3D grid. Notice that similar resolving sets can be given by interchanging the role of the three coordinates.

Lemma 4

If \(h,h'\in \{ 0,\dots , n_3-1 \}\), with \(h\not =h'\), \(i\in \{ 0, \dots ,n_1-1 \} \) and \(j\in \{ 0, \dots ,n_2-1 \} \), then \(S=\{(0,0,h), (n_1-1,0,h), (0,n_2-1,h), (i,j,h')\}\) is a resolving set for \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\).

Proof

Let \(G=P_{n_1}\Box P_{n_2}\Box P_{n_3}\). By Theorem 3, the set \(S'=\{(0,0,h), (n_1-1,0,h), (0,n_2-1,h)\}\) is a metric basis for the 3D grid formed by the vertices \(\{ (x_1,x_2,x_3)\in V(G): x_3\le h\}\) and for the 3D grid formed by the vertices \(\{ (x_1,x_2,x_3)\in V(G): x_3\ge h\}\). Hence, if \(h\in \{0,n_3-1\}\), then S is a resolving set for G. Otherwise, by symmetry, two different vertices u and v of G have the same coordinates with respect to S if and only if \(u=(a,b,c_1)\) and \(v=(a,b,c_2)\), with \(c_1\not =c_2\) and \(c_1+c_2=2h\), for some integers \(a,b,c_1,c_2\). We claim that u and v are resolved by \((i,j,h')\). Indeed, suppose to the contrary that \((i,j,h')\) does not resolve u and v. In such a case, since \(d(u,(i,j,h'))=|i-a|+|j-b|+|h'-c_1|\) and \(d(v,(i,j,h'))=|i-a|+|j-b|+|h'-c_2|\), we have \(|h'-c_1|=|h'-c_2|\). But this equality is true if and only if \(c_1=c_2\) or \(c_1+c_2=2h'\). Hence, \(h=h'\), a contradiction. \(\square \)

Now, we give a sufficient condition for a set not to be resolving in a 3D grid. First we need some terminology. For every \(a_1\in \{1,\dots ,n_1-1\}\) and \(a_2\in \{1,\dots ,n_2-1\}\), we define the sets of vertices in \(P_{n_1}\Box P_{n_2}\):

$$\begin{aligned} R_{--}(a_1,a_2)&=\{ (x_1,x_2): 0\le x_1< a_1, 0\le x_2< a_2 \},\\ R_{++}(a_1,a_2)&=\{ (x_1,x_2): a_1\le x_1<n_1, a_2\le x_2<n_2 \},\\ R_{-+}(a_1,a_2)&=\{ (x_1,x_2): 0\le x_1< a_1, a_2\le x_2<n_2 \},\\ R_{+-}(a_1,a_2)&=\{ (x_1,x_2): a_1\le x_1<n_1, 0\le x_2< a_2 \}. \end{aligned}$$

Notice that these sets form a partition of the set of vertices of the 2D grid \(P_{n_1}\Box P_{n_2}\) (see Fig. 1).

Fig. 1
figure 1

The sets \(R_{--}(a_1,a_2)\), \(R_{++}(a_1,a_2)\), \(R_{-+}(a_1,a_2)\) and \(R_{+-}(a_1,a_2)\)

Let \(\text {pr}_3(S)\) be the projection of S onto \(P_{n_1}\Box P_{n_2}\), that is, \(\text {pr}_3(S)\) contains all the vertices of the 2D grid \(P_{n_1}\Box P_{n_2}\) obtained by deleting the third coordinate from the vertices of S. Analogously, the projection \(\text {pr}_{i}(S)\), \(i\in \{ 1,2 \}\), contains all the vertices of the 2D grid obtained by deleting the i-th coordinate from the vertices of S.

Lemma 5

If there exist \(a_1\in \{1,\dots ,n_1-1\}\) and \(a_2\in \{1,\dots ,n_2-1\}\) such that \(\text {pr}_3(S)\subseteq R_{--}(a_1,a_2)\cup R_{++}(a_1,a_2)\) or \(\text {pr}_3(S)\subseteq R_{-+}(a_1,a_2)\cup R_{+-}(a_1,a_2)\), then S is not a resolving set for \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\).

Proof

If \(\text {pr}_3(S)\subseteq R_{--}(a_1,a_2)\cup R_{++}(a_1,a_2)\), then the vertices \((a_1-1,a_2,0)\) and \((a_1, a_2-1,0)\) are not resolved by S. Analogously, if \(\text {pr}_3(S)\subseteq R_{-+}(a_1,a_2)\cup R_{+-}(a_1,a_2)\), then the vertices \((a_1-1,a_2-1,0)\) and \((a_1, a_2,0)\) are not resolved by S (see Fig. 2). \(\square \)

Note that, by symmetry, the preceding result can also be stated for \(\text {pr}_{1}(S)\) and \(\text {pr}_{2}(S)\).

Fig. 2
figure 2

If \(\text {pr}_3(S)\subseteq R_{--}(a_1,a_2)\cup R_{++}(a_1,a_2)\), then S is included in the white region and circled vertices are not resolved by any vertex of S. Analogously, if \(\text {pr}_3(S)\subseteq R_{-+}(a_1,a_2)\cup R_{+-}(a_1,a_2)\), then S is included in the gray region and squared vertices are not resolved by any vertex of S

Now, we prove some properties for general graphs that provide vertices resolving a fixed pair of vertices under certain conditions.

Lemma 6

Let u and v be vertices of a graph G. If d(uv) is odd, then every vertex of a shortest path between u and v resolves u and v. If d(uv) is even, then all but one of the vertices of a shortest path between u and v resolve u and v.

Proof

For every vertex x belonging to a shortest path from u to v, the equality \(d(u,x)+d(x,v)=d(u,v)\) holds. If d(uv) is odd, then there is no vertex x in the shortest path satisfying \(d(u,x)=d(v,x)\). If d(uv) is even, then there is exactly one vertex x in the shortest path satisfying \(d(u,x)=d(v,x)=d(u,v)/2\). \(\square \)

Lemma 7

Let u and v be vertices of a bipartite graph G.

If d(uv) is odd, then every vertex of G resolves u and v.

Proof

The distance between two vertices of the same partite set of G is even, and the distance between vertices of different partite sets is odd. If d(uv) is odd, then u and v belong to different partite sets of G, and for every vertex \(x\in V(G)\), the distances d(xu) and d(xv) have different parity. Hence, x resolves u and v. \(\square \)

Next results establish a lower bound on the number of vertices in F resolving a pair of fixed vertices u and v, taking into account the number of different coordinates of u and v.

Since grids are bipartite graphs, by Lemma 7, all the vertices of a grid resolve a pair of vertices u and v, if d(uv) is odd. Thus, we focus on the case d(uv) even. For \(n_1,n_2,n_3\ge 2\), we define

$$\begin{aligned} \alpha _M(n_1,n_2,n_3)&=\min \{ n_1(n_2+n_3-2),n_2(n_1+n_3-2) ,n_3(n_1+n_2-2) \}. \end{aligned}$$

It is easy to check that \(\alpha _M(n_1,n_2,n_3)=n_i(n_1+n_2+n_3-n_i-2)\), for \(n_i=\min \{ n_1,n_2,n_3 \}\).

Lemma 8

Let \(u=(x_1,x_2,x_3)\) and \(v=(y_1,y_2,y_3)\) be two different vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) with \(x_i\not =y_i\) for exactly one value \(i\in \{1,2,3\}\). Then, there are at least \(\alpha _M(n_1,n_2,n_3)\) vertices in \(F(n_1,n_2,n_3)\) resolving u and v.

Proof

Assume without loss of generality that \(x_1=y_1\), \(x_2=y_2\) and \(x_3\not =y_3\). A vertex \(z=(z_1,z_2,z_3)\) does not resolve u and v if and only \(d(z,u)=|x_1-z_1|+|x_2-z_2|+|x_3-z_3|=|x_1-z_1|+|x_2-z_2|+|y_3-z_3|=d(z,v)\), that is, if and only if \(|x_3-z_3|=|y_3-z_3|\). Hence, the set of vertices not resolving u and v is \(\{ (a,b,(x_3+y_3)/2) : 0\le a\le n_1-1, 0\le b\le n_2-1\}\) (note that this set is empty when \(x_3\) and \(y_3\) have different parity). In any case, there are at least \(|F|- (2n_1+2n_2-4)\) vertices in F resolving u and v. But

$$\begin{aligned}&|F|- (2n_1+2n_2-4)-n_3(n_1+n_2-2)\\&\quad = 2(n_1-2)(n_2-2)+(n_2-2)(n_3-2)+(n_1-2)(n_3-2)+2(n_3-2)\ge 0. \end{aligned}$$

Hence, \(|F|- (2n_1+2n_2-4)\ge n_3(n_1+n_2-2)\ge \alpha _M\). \(\square \)

Lemma 6 shows when a vertex of a shortest path between two fixed vertices u and v resolves the pair u and v. Next, we analyze which vertices not belonging to the shortest path resolve u and v. We denote by S(uv) the set of vertices belonging to a shortest path between u and v in a 3D grid. Concretely, for every pair \(u=(x_1,x_2,x_3)\) and \(v=(y_1,y_2,y_3)\) of distinct vertices of the grid \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\), S(uv) is the set of vertices:

$$\begin{aligned}{}[\min \{x_1,y_1\}, \max \{x_1,y_1\}]\times [\min \{x_2,y_2\}, \max \{x_2,y_2\}]\times [\min \{x_3,y_3\}, \max \{x_3,y_3\}]. \end{aligned}$$

Hence, S(uv) induces a 3D grid such that u and v are corners, if the three coordinates of u and v are different; a 2D grid, if u and v have exactly 2 different coordinates; and a path, if u and v differ by exactly one coordinate.

Next, we associate a vertex not in S(uv) with a vertex of the subgrid S(uv) (belonging to one of its faces, whenever S(uv) is a 3D grid) so that either both vertices resolve u and v or neither of them resolves u and v. The result is stated for the first coordinate, but it holds similarly for the second and third coordinates.

Lemma 9

Let \(u=(x_1,x_2,x_3)\) and \(v=(y_1,y_2,y_3)\) be two distinct vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Let \(z=(z_1,z_2,z_3)\).

  1. (i)

    If \(z_1\le \min \{x_1,y_1\}\), then z resolves u and v if and only if vertex \((\min \{x_1,y_1\},z_2,z_3)\) resolves u and v.

  2. (ii)

    If \(z_1\ge \max \{x_1,y_1\}\), then z resolves u and v if and only if vertex \((\max \{x_1,y_1\},z_2,z_3)\) resolves u and v.

Proof

We prove only the first item, because the second one is derived analogously. Assume without loss of generality that \(x_1\le y_1\). Let \(z=(z_1,z_2,z_3)\) be such that \(z_1\le x_1\) and let \(z'=(x_1,z_2,z_3)\). Then, \(d(z,u)=|x_1-z_1|+|x_2-z_2|+|x_3-z_3|=d(z,z')+d(z',u)\). Similarly, we have that \(d(z,v)=|y_1-z_1|+|y_2-z_2|+|y_3-z_3|=|y_1-x_1|+|x_1-z_1|+|y_2-z_2|+|y_3-z_3| =|x_1-z_1|+(|y_1-x_1|+|y_2-z_2|+|y_3-z_3|)=d(z,z')+d(z',v)\). Hence, z resolves u and v if and only if \(z'\) resolves u and v. \(\square \)

Note that the preceding lemma implies that a vertex z not in S(uv) resolves u and v if and only if the vertex in S(uv) closest to z resolves u and v.

Lemma 10

Let \(u=(x_1,x_2,x_3)\) and \(v=(y_1,y_2,y_3)\) be two different vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) with \(x_i=y_i\) for exactly one value of \(\{1,2,3\}\). Then, there are at least \(\alpha _M(n_1,n_2,n_3)\) vertices of \(F(n_1,n_2,n_3)\) resolving u and v.

Proof

We may assume without loss of generality that \(x_1<y_1\), \(x_2<y_2\) and \(x_3=y_3\). Then, \(d(u,v)=y_1-x_1+y_2-x_2\). If d(uv) is odd, then all the vertices in F resolve u and v by Lemma 7. Now suppose that \(d(u,v)=y_1-x_1+y_2-x_2\) is even. If \(y_1-x_1=y_2-x_2\), then, using Lemma 9 we derive that the vertices in F belonging to the set

$$\begin{aligned}&\{ (0,b,c) : 0\le b<y_2, 0\le c\le n_3-1\}\\&\cup \{ (n_1-1,b,c) : x_2< b<n_2-1, 0\le c\le n_3-1\}\\&\cup \{ (a,0,c) : 0\le a<y_1, 0\le c\le n_3-1\}\\&\cup \{ (a,n_2-1,c) : x_1< a<n_1-1, 0\le c\le n_3-1\} \end{aligned}$$

resolve u and v, and the number of vertices of this set is \((y_2+(n_2-1-x_2)+y_1+(n_1-1-x_1)-2)n_3=(y_2-x_2+y_1-x_1+n_1+n_2-4)n_3\ge (n_1+n_2-2)n_3\) (see Fig. 3, left).

Fig. 3
figure 3

Vertices (abc), with \(c=x_3\), of the 3D grid are represented. Left, case \(y_1-x_1=y_2-x_2\) and right, \(y_1-x_1\not = y_2-x_2\). Vertices in the striped region do not resolve u and v. In both cases, there are at least \(n_1+n_2-2\) vertices in the boundary resolving u and v (gray region)

If \(y_1-x_1\not = y_2-x_2\), we may assume \(y_1-x_1 < y_2-x_2\). Let \(r=(y_1-x_1+y_2-x_2)/2\). Then, the following vertices in F resolve u and v:

$$\begin{aligned}&\{ (0,b,c) : b\not = x_2+r, 0\le c\le n_3-1\}\\&\quad \cup \{ (n_1-1,b,c) : b\not = y_2-r, 0\le c\le n_3-1\}\\&\quad \cup \{ (a,0,c) : 0\le a\le n_1-1, 0\le c\le n_3-1\}\\&\quad \cup \{ (a,n_2-1,c) : 0\le a\le n_1-1, 0\le c\le n_3-1\}. \end{aligned}$$

and this set has at least \((2n_1+2n_2-4)n_3\) vertices. Hence, there are at least \((n_1+n_2-2)n_3\ge \alpha _M\) vertices in F resolving u and v (see Fig. 3, right). \(\square \)

Lemma 11

Let \(u=(x_1,x_2,0)\) and \(v=(y_1,y_2,n_3-1)\) be two vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Then, there are at least \(n_3(n_1+n_2-2)\) vertices in \(F(n_1,n_2,n_3)\) resolving u and v.

Proof

We claim that for every pair a and b, such that \(a\in \{ 0,n_1-1\}\) or \(b\in \{ 0, n_2-1\}\), there is at most one vertex in the set \(T_{a,b}=\{ (a,b,c): 0\le c\le n_3-1 \}\) not resolving u and v. Indeed, if there were at most two vertices not resolving them, then by Lemma 9 there would be two vertices z and \(z'\) belonging to some set \(T'_{a',b'}=\{ (a',b',c): 0\le c\le n_3-1 \}\) not resolving u and v, where \(x_1\le a'\le y_1\), \(x_2\le b'\le y_2\) and either \(a'\in \{ x_1,y_1\}\) or \(b'\in \{x_2,y_2\}\). But this is a contradiction by Lemma 6, because there is a shortest path between u and v that goes through both z and \(z'\). Notice that there are \(2n_1+2n_2-4\) sets of type \(T_{a,b}\), with \(a\in \{ 0,n_1-1\}\) or \(b\in \{ 0, n_2-1\}\). Hence, there are at least \((2n_1+2n_2-4)(n_3-1)\) vertices in \(F(n_1,n_2,n_3)\) resolving u and v, and \((2n_1+2n_2-4)(n_3-1)\ge (n_1+n_2-2)(2n_3-2)\ge (n_1+n_2-2)n_3\), where the last inequality holds because \(n_3\ge 2\). \(\square \)

Lemma 12

Let \(u=(x_1,x_2,x_3)\) and \(v=(y_1,y_2,y_3)\) be two different vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) with \(x_i\not =y_i\), for every \(i\in \{ 1,2,3 \}\). Then, there are at least \(n_1+n_2-2\) vertices \((z_1,z_2,z_3)\) resolving u and v with \(z_3=n_3-1\), and either \(z_1\in \{0,n_1-1\}\) or \(z_2\in \{0,n_2-1\}\).

Proof

Assume without loss of generality that \(x_i<y_i\) for all \(i\in \{1,2,3\}\). Let \(C=\{(z_1,z_2,n_3-1): z_1\in \{0,n_1-1\}\hbox { or }z_2\in \{0,n_2-1\}\}\) and let \(C'=\{(z_1,z_2,y_3): z_1\in \{0,n_1-1\}\hbox { or }z_2\in \{0,n_2-1\}\}\). Note that \(|C|=|C'|=2n_1+2n_2-4\). By Lemma 9, a vertex \(z=(z_1,z_2,n_3-1)\in C\) resolves u and v if and only if \((z_1,z_2,y_3)\in C'\) resolves u and v. Therefore, it is enough to show that there are at least \(n_1+n_2-2\) vertices in \(C'\) resolving u and v.

Consider the sets \(S_1=\{ (x_1,b, y_3): x_2\le b\le y_2 \}\cup \{ (a,y_2, y_3): x_1< a\le y_1 \}\), \(S_2=\{ (a,x_2, y_3): x_1\le a\le y_1 \}\cup \{ (y_1,b, y_3): x_2< b\le y_2 \}\) and \(S_3=\{ (x_1,x_2,c): x_3\le c < y_3\}\). The vertices of \(S_1\cup S_3\) form a shortest path between u and v as well as the vertices of \(S_2\cup S_3\). Hence, there is at most one vertex in \(S_1\) and at most one vertex in \(S_2\) not resolving u and v. Let S be the set of vertices in \(S_1\cup S_2\) not resolving u and v. Thus, \(|S|\in \{ 0,1,2\}\).

Note that for \(w=(z_1,z_2,y_3)\in S\), we have \(d(w,v)=d(w,u)= d(w, (x_1,x_2,y_3))+(y_3-x_3)>d(w, (x_1,x_2,y_3))\)

If \(|S|=0\), then all the vertices of \(C'\) resolve u and v by Lemma 9, and \(|C'|=2n_1+2n_2-4> n_1+n_2-2\).

If \(|S|=1\), then, since \(|S_1|=|S_2|\), the vertex in S must be \((x_1,x_2,y_3)\). By Lemma 9, there are \(2n_1+2n_2-4-(x_1+x_2+1)\) vertices in \(C'\) resolving u and v. But \(2n_1+2n_2-4-(x_1+x_2+1)\ge n_1+n_2-2\), because \(x_i<y_i\le n_i-1\), for \(i=1,2\) (see Fig. 4a).

Fig. 4
figure 4

Vertices (abc), with \(c=y_3\), of the 3D grid are depicted. Vertices in the striped region do not resolve u and v. The vertices of \(C'\) resolving u and v are in the gray region. a \(|S|=1\). bd \(|S|=2\)

If \(|S|=2\), then \((x_1,x_2,y_3)\notin S\), one vertex of S is in \(S_1{\setminus } S_2\), the other one belongs to \(S_2{\setminus } S_1\), and both are at the same distance from \((x_1,x_2,y_3)\).

Moreover, there is at most one vertex belonging to S in \(\{(x_1,y_2,y_3), (y_1,x_2,y_3)\}\). Indeed, if \(S=\{(x_1,y_2,y_3), (y_1,x_2,y_3)\}\), then \(y_1-x_1=y_2-x_2+y_3-x_3\) and \(y_2-x_2=y_1-x_1+y_3-x_3\), because the vertices of S are at the same distance from u and v, and this is not possible because \(y_3-x_3>0\). If \(S\cap \{(x_1,y_2,y_3), (y_1,x_2,y_3)\}=\emptyset \), then by Lemma 9 there are at least \(2n_1+2n_2-4-2\) vertices in \(C'\) resolving u and v, and \(2n_1+2n_2-4-2\ge n_1+n_2-2\) because \(n_1,n_2\ge 2\) (see Fig. 4b, c).

If \(|S\cap \{(x_1,y_2,y_3), (y_1,x_2,y_3)\}|=1\), we may assume without loss of generality that \(y_2-x_2<y_1-x_1\) so that \(S\cap \{(x_1,y_2,y_3), (y_1,x_2,y_3)\}=(x_1,y_2,y_3)\). By Lemma 9 there are at least \(2n_1+2n_2-4-1-(x_1+n_2-y_2)\) vertices in \(C'\) resolving u and v, \(2n_1+2n_2-4-1-(x_1+n_2-y_2)\ge n_1+n_2-2\) because \(x_1<y_1\le n_1-1\) and \(0\le x_2< y_2\) (see Fig. 4d).

In any case, there are at least \(n_1+n_2-2\) vertices in \(C'\) resolving u and v, and so in C, as we wanted to prove. \(\square \)

We finish this section with a lower bound on the number of vertices belonging to the faces of a 3D grid resolving any fixed pair of vertices.

Proposition 13

Let \(u,v\in V(P_{n_1}\Box P_{n_2}\Box P_{n_3})\). Then, there are at least \(\alpha _M(n_1,n_2,n_3)\) vertices in \(F(n_1,n_2,n_3)\) resolving u and v.

Proof

We proceed by induction on \(h=n_1+n_2+n_3\ge 6\).

If \(h=6\), then \(n_1=n_2=n_3=2\) and \(\alpha _M(n_1,n_2,n_3)=4\). Besides, all the vertices of the grid are in F(2, 2, 2) and it is easy to check that, for every pair of vertices u and v, there are at least 4 vertices resolving them.

Now we prove that the statement of the lemma holds whenever \(n_1+n_2+n_3=h\), assuming that it is true for grids \(P_{n_1'}\Box P_{n_2'}\Box P_{n_3'}\) such that \(n_1'+n_2'+n_3'\le h-1\). Let u and v be two different vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) and let \(R_{n_1,n_2,n_3}(u,v)\) denote the set of vertices of \(F(n_1,n_2,n_3)\) resolving u and v. If u and v have at least one equal coordinate, then \(|R_{n_1,n_2,n_3}(u,v)|\ge \alpha _M(n_1,n_2,n_3)\) by Lemmas 8 and  10. Now suppose that the three coordinates of u and v are distinct. We may assume \(n_1\le n_2\le n_3\). Suppose first that \(n_1<n_3\). In such a case, \(n_1+n_2+n_3-1=h-1\). If uv are in \(P_{n_1}\Box P_{n_2}\Box P_{n_3-1}\), then by induction hypothesis and using Lemmas 9 and 12,

$$\begin{aligned} |R_{n_1,n_2,n_3}(u,v)|&\ge |R_{n_1,n_2,n_3-1}(u,v)| + (n_1+n_2-2)\\ {}&\ge \alpha _M(n_1,n_2,n_3-1) +(n_1+n_2-2)\\ {}&=(n_2+(n_3-1)-2)n_1+(n_1+n_2-2)\\ {}&=(n_2+n_3-2)n_1+n_2-2\\ {}&\ge (n_2+n_3-2)n_1=\alpha _M(n_1,n_2,n_3). \end{aligned}$$

If no both vertices u and v are included in a grid \(P_{n_1}\Box P_{n_2}\Box P_{n_3-1}\), by symmetry it is enough to consider the case \(u=(x_1,x_2,0)\) and \(v=(y_1,y_2,n_3-1)\). By Lemma 11, \(|R_{n_1,n_2,n_3}(u,v)|\ge n_3(n_1+n_2-2)\ge \alpha _M(n_1,n_2,n_3)\).

Now suppose \(n_1=n_3\), that is, \(n_1=n_2=n_3=n\). Arguing as in the preceding case, if uv belong to \(P_{n}\Box P_{n}\Box P_{n-1}\), then

$$\begin{aligned} |R_{n,n,n}(u,v)|&\ge |R_{n,n,n-1}(u,v)| + (2n-2)\\ {}&\ge \alpha _M(n,n,n-1) +(2n-2)\\ {}&=(2n-2)(n-1)+(2n-2)\\ {}&=(2n-2)n=\alpha _M(n,n,n) \end{aligned}$$

Otherwise, assume that \(u=(x_1,x_2,0)\) and \(v=(y_1,y_2,n-1)\), and by Lemma 11, \(|R_{n,n,n}(u,v)|\ge n(2n-2)= \alpha _M(n,n,n)\). \(\square \)

3 Resolving sets tolerant to \(k\) failures in 3D Grids

Recall that a resolving set S of a graph remains resolving after the deletion of any k vertices if and only if S is a \((k+1)\)-resolving set of G, and the minimum cardinality of such a set is the \((k+1)\)-metric dimension of G. In this section we provide exact values and bounds on the \((k+1)\)-metric dimension of 3D grids. Moreover, in almost all cases, a \((k+1)\)-metric basis, that is, a \((k+1)\)-resolving set of minimum cardinality, is constructed.

Let \(\alpha _m(n_1,n_2,n_3)\) be defined as follows:

$$\begin{aligned} \alpha _m(n_1,n_2,n_3)&=2(n_1+n_2+n_3)-8, \end{aligned}$$

and recall the definition of \(\alpha _M(n_1,n_2,n_3)\) given in the preceding section:

$$\begin{aligned} \alpha _M(n_1,n_2,n_3)&=\min \{ n_1(n_2+n_3-2),n_2(n_1+n_3-2) ,n_3(n_1+n_2-2) \}. \end{aligned}$$

From now on, we assume \(n_1,n_2,n_3\ge 2\) and \(k\ge 2\). Note that \(\alpha _m\) and \(\alpha _M\) are half the number of vertices lying on an “edge” of the grid and half the number of vertices lying on the four smallest faces of the grid, respectively (see Fig. 5).

Fig. 5
figure 5

Left, \(\alpha _m\) is the number of vertices lying on the thicker edges of the grid. Right, \(\alpha _M\) is the number of vertices lying on the gray faces of the grid

Proposition 14

If \(k\ge \alpha _M(n_1,n_2,n_3)\), then \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) has no \((k+1)\)-resolving set.

Proof

Assume without loss of generality that \(\alpha _M =(n_1+n_2-2)n_3\). Suppose to the contrary that \(S\subseteq V=V(P_{n_1}\Box P_{n_2}\Box P_{n_3})\) is a \((k+1)\)-resolving set. Consider the partition \(\{ V_1,V_2 \}\) of V, where \(V_1=\{ u\in V: \text {pr}_3(u)\in R_{--}(1,1)\cup R_{++}(1,1) \}\) and \(V_2=\{ u\in V: \text {pr}_3(u)\in R_{-+}(1,1)\cup R_{+-}(1,1) \}\). Then, \(|V_2|=(n_1+n_2-2)n_3=\alpha _M(n_1,n_2,n_3) \le k\). Hence, by removing from S the at most k vertices belonging to \(V_2\) we have a set of vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) that is not resolving by Lemma 5, which is a contradiction. \(\square \)

Proposition 15

If \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) has a \((k+1)\)-resolving set, then

$$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3})\ge 2k+2. \end{aligned}$$

Proof

We prove that there is no \((k+1)\)-resolving set of cardinality at most \(2k+1\). Let \(a_1=\lfloor n_1/2 \rfloor \), \(a_2=\lfloor n_2/2 \rfloor \) and suppose that \(S\subseteq V(P_{n_1}\Box P_{n_2}\Box P_{n_3})\) is a \((k+1)\)-resolving set of cardinality at most \(2k+1\). Consider the partition \(\{ V_1,V_2 \}\) of the set \(V=V(P_{n_1}\Box P_{n_2}\Box P_{n_3})\) such that \(V_1=\{ (i,j,h)\in V : (i,j)\in R_{--}(a_1,a_2)\cup R_{++}(a_1,a_2) \}\) and \(V_2=\{ (i,j,h) \in V: (i,j)\in R_{-+}(a_1,a_2)\cup R_{+-}(a_1,a_2)\}\). By the Pigeonhole Principle, at least one of the sets \(V_1\) or \(V_2\) has at most k vertices of S. Hence, by removing these vertices from S we have a set of vertices of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) that is not resolving by Lemma 5, which leads to a contradiction. \(\square \)

Proposition 16

If \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) has a \((k+1)\)-resolving set and k is even, then

$$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3})\ge 2k+3. \end{aligned}$$

Proof

Let \(V=V(P_{n_1}\Box P_{n_2}\Box P_{n_3})\) and let \(a_1=\lfloor n_1/2 \rfloor \), \(a_2=\lfloor n_2/2 \rfloor \), and \(a_3=\lfloor n_3/2 \rfloor \). Suppose that \(S\subseteq V\) is a \((k+1)\)-resolving set of cardinality at most \(2k+2\). Consider the sets of V:

$$\begin{aligned} R_{---}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): 0\le x_1< a_1, 0\le x_2< a_2 , 0\le x_3<a_3\};\\ R_{--+}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): 0\le x_1< a_1, 0\le x_2< a_2 , a_3\le x_3<n_3\};\\ R_{+--}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): a_1\le x_1<n_1, 0\le x_2< a_2 , 0\le x_3<a_3\};\\ R_{+-+}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): a_1\le x_1<n_1, 0\le x_2< a_2 ,a_3\le x_3<n_3\};\\ R_{-+-}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): 0\le x_1< a_1, a_2\le x_2<n_2 , 0\le x_3<a_3\};\\ R_{-++}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): 0\le x_1< a_1, a_2\le x_2<n_2,a_3\le x_3<n_3 \};\\ R_{++-}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): a_1\le x_1<n_1, a_2\le x_2<n_2 , 0\le x_3<a_3 \};\\ R_{+++}(a_1,a_2,a_3)&=\{ (x_1,x_2,x_3): a_1\le x_1<n_1, a_2\le x_2<n_2 , a_3\le x_3<n_3 \}. \end{aligned}$$

Notice that, by definition, these sets form a partition of V. Moreover, if we consider the vertices of the grid as points of the 3D space, these sets are included in the eight regions defined by the semispaces \(x_1<a_1\), \(x_1\ge a_1\); \(x_2<a_2\), \(x_2\ge a_2\); and \(x_3< a_3\), \(x_3\ge a_3\). Consider the following partition of S (see Fig. 6):

$$\begin{aligned}&A_1=S\cap R_{---}(a_1,a_2,a_3),&A_2=S\cap R_{--+}(a_1,a_2,a_3),\\&B_1=S\cap R_{+--}(a_1,a_2,a_3),&B_2=S\cap R_{+-+}(a_1,a_2,a_3),\\&C_1=S\cap R_{-+-}(a_1,a_2,a_3),&C_2=S\cap R_{-++}(a_1,a_2,a_3),\\&D_1=S\cap R_{++-}(a_1,a_2,a_3),&D_2=S\cap R_{+++}(a_1,a_2,a_3).\\ \end{aligned}$$
Fig. 6
figure 6

The sets \(A_1,A_2,B_1,B_2,C_1,C_2,D_1,D_2\) are the vertices of S included in the regions obtained when partitioning the vertices of V into the eight octants determined by the chosen values of \(a_1\), \(a_2\) and \(a_3\)

If \(|A_1|+|A_2|+|D_1|+|D_2|\le k\) or \(|B_1|+|B_2|+|C_1|+|C_2|\le k\), then S is not a \((k+1)\)-resolving set because, by Lemma 5, the removal of the at most k vertices of S in \(A_1\cup A_2\cup D_1\cup D_2\) or in \(B_1\cup B_2\cup C_1\cup C_2\) produces a non-resolving set, which leads to a contradiction. Hence,

$$\begin{aligned} |A_1|+|A_2|+|D_1|+|D_2|\ge k+1\hbox { and }|B_1|+|B_2|+|C_1|+|C_2|\ge k+1. \end{aligned}$$

But, since

$$\begin{aligned} |A_1|+|A_2|+|D_1|+|D_2|+|B_1|+|B_2|+|C_1|+|C_2|=|S|\le 2k+2, \end{aligned}$$

we derive \(|S|=2k+2\), and

$$\begin{aligned} |A_1|+|A_2|+|D_1|+|D_2| =|B_1|+|B_2|+|C_1|+|C_2| = k+1. \end{aligned}$$

By symmetry, we derive

$$\begin{aligned} |A_1|+|B_1|+|C_2|+|D_2| =|A_2|+|B_2|+|C_1|+|D_1| = k+1,\\ |A_1|+|C_1|+|B_2|+|D_2| =|A_2|+|C_2|+|B_1|+|D_1| = k+1. \end{aligned}$$

Hence,

$$\begin{aligned}&|A_1|+|A_2|+|D_1|+|D_2| = k+1 \end{aligned}$$
(1)
$$\begin{aligned}&|A_1|+|B_1|+|C_2|+|D_2| =k+1 \end{aligned}$$
(2)
$$\begin{aligned}&|A_1|+|C_1|+|B_2|+|D_2|=k+1 \end{aligned}$$
(3)
$$\begin{aligned}&|A_2|+|B_2|+|C_1|+|D_1| = k+1 \end{aligned}$$
(4)

By subtracting Eq. (2) from Eq. (1), Eq. (3) from Eq. (1) and Eq. (4) from Eq. (3), we get

$$\begin{aligned} |D_1|+|A_2|= |B_1|+|C_2|=|C_1|+|B_2|=|A_1|+|D_2|=q, \end{aligned}$$

for some \(q\in {\mathbb {Z}}\) and, consequently,

$$\begin{aligned} |S|= |A_1|+|A_2|+|B_1|+|B_2|+|C_1|+|C_2|+|D_1|+|D_2|= 4q. \end{aligned}$$

Hence, \(|S|=2k+2=4q\), which implies that \(k+1\) is even, a contradiction.

\(\square \)

Note that the preceding lemma provides an alternative way of proving that the metric dimension of a 3D grid is at least 3 (see Theorem 3).

Next, we describe a \((k+1)\)-resolving set of minimum cardinality for some 3D grids. Bearing this in mind, we define the following \(n_1+n_2+n_3-4\) disjoint sets of four vertices:

$$\begin{aligned} S_{1,i}&=\{ (i,0,0),(i,n_2-1,0),(i,0,n_3-1),(i,n_2-1,n_3-1)\},\hbox { for }0\le i\le n_1-1,\\ S_{2,j}&=\{ (0,j,0),(n_1-1,j,0), (0,j,n_3-1), (n_1-1,j,n_3-1)\}, \hbox { for }1\le j\le n_2-2,\\ S_{3,h}&=\{ (0,0,h),(n_1-1,0,h), (0,n_2-1,h),(n_1-1,n_2-1,h)\}, \hbox { for }1\le h\le n_3-2. \end{aligned}$$

Proposition 17

If k is an odd integer and \(k< \alpha _m (n_1,n_2,n_3)\), then

$$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3}) = 2k+2. \end{aligned}$$

Proof

By Proposition 15, it is enough to construct a \((k+1)\)-resolving set of cardinality \(2k+2\). Let \(\alpha =\tfrac{k+1}{2}\). Note that by hypothesis \(\alpha =\tfrac{k+1}{2}\le n_1+n_2+n_3-4 \), so we can consider the following set S formed by \(\alpha \) of the previously defined sets of vertices (see an example in Fig. 7, left):

$$\begin{aligned} S&=\bigcup _{i=0}^{\alpha -1} S_{1,i}, \hbox { if }\alpha \le n_1,\\ S&=\bigg (\bigcup _{i=0}^{n_1-1} S_{1,i}\bigg )\cup \bigg (\bigcup _{j=1}^{\alpha -n_1} S_{2,j}\bigg ),\hbox { if }n_1< \alpha \le n_1+n_2-2,\\ S&=\bigg (\bigcup _{i=0}^{n_1-1} S_{1,i}\bigg )\cup \bigg (\bigcup _{j=1}^{n_2-2} S_{2,j}\bigg )\cup \bigg (\bigcup _{h=1}^{\alpha -n_1-n_2+2} S_{3,h}\bigg ),\hbox { if }n_1+n_2-2<\alpha .\end{aligned}$$
Fig. 7
figure 7

A 18-resolving set (left) and a 17-resolving set (right) of the grid \(P_{3}\Box P_{6}\Box P_{7}\) consists of squared, circled and crossed vertices. Squared vertices belong to some set \(S_{1,i}\), circled vertices to some \(S_{2,j}\), and crossed vertices to some \(S_{3,h}\)

Obviously, \(|S|=4\, \alpha =2k+2\). We claim that S is a \((k+1)\)-resolving set of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Indeed, any subset \(S'\) obtained after the removal of k vertices from S, contains at least three vertices of either one of the sets \(S_{1,i_0}\) for some \(0\le i_0\le n_1-1\), or \(S_{2,j_0}\) for some \(1\le j_0\le n_2-2\), or \(S_{3,h_0}\), for some \(1\le h_0\le n_3-2\), since otherwise we have to remove at least \(2\alpha =k+1\) vertices. By Lemma 4, there exists a vertex such that together with these three vertices form a resolving set for \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Hence, S is a \((k+1)\)-resolving set. \(\square \)

Proposition 18

If k is an even integer and \(k< \alpha _m(n_1,n_2,n_3)\), then

$$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3}) = 2k+3. \end{aligned}$$

Proof

By Proposition 16, it is enough to construct a \((k+1)\)-resolving set of cardinality \(2k+3\). Let \(\alpha =\tfrac{k}{2} +1\). Observe that, by hypothesis, \(\alpha \le n_1+n_2+n_3-4\). Thus, we can consider the following set \(S=S^*-\{ (0,0,0) \}\), where \(S^*\) is formed by the union of \(\alpha \) of the previously defined sets of vertices (see an example in Fig. 7, right):

$$\begin{aligned} S^*&=\bigcup _{i=0}^{\alpha -1} S_{1,i}, \hbox { if }\alpha \le n_1,\\ S^*&=\bigg (\bigcup _{i=0}^{n_1-1} S_{1,i}\bigg )\cup \bigg (\bigcup _{j=1}^{\alpha -n_1} S_{2,j}\bigg ),\hbox { if }n_1< \alpha \le n_1+n_2-2,\\ S^*&=\bigg (\bigcup _{i=0}^{n_1-1} S_{1,i}\bigg )\cup \bigg (\bigcup _{j=1}^{n_2-2} S_{2,j}\bigg )\cup \bigg (\bigcup _{h=1}^{\alpha -n_1-n_2+2} S_{3,h}\bigg ),\hbox { if }n_1+n_2-2<\alpha .\end{aligned}$$

Obviously, \(|S|=4\, \alpha -1=2k+3\). We claim that S is a \((k+1)\)-resolving set of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Indeed, any subset \(S'\) obtained after the removal of k vertices from S, contains at least three vertices of either one of the sets \(S_{1,i_0}\) for some \(0\le i_0\le n_1-1\), or \(S_{2,j_0}\) for some \(1\le j_0\le n_2-2\), or \(S_{3,h_0}\), for some \(1\le h_0\le n_3-2\), since otherwise we have to remove at least \(2(\alpha -1)+1 =k+1\) vertices. By Lemma 4, there exists a vertex such that together with these three vertices form a resolving set for \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\). Hence, S is a \((k+1)\)-resolving set. \(\square \)

Hence, the exact value of the \((k+1)\)-metric dimension has been determined whenever \(k< \alpha _m(n_1,n_2,n_3)\). In the remaining cases this parameter is defined, Proposition 13 provides us an upper bound on the \((k+1)\)-metric dimension.

Corollary 19

If \(k< \alpha _M(n_1,n_2,n_3) \), then \(F(n_1,n_2,n_3)\) is a \((k+1)\)-resolving set of \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) and, hence,

$$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3}) \le n_1n_2n_3- (n_1-2)(n_2-2)(n_3-2). \end{aligned}$$

We can summarize the previous results as follows.

Theorem 20

Let \(k,n_1,n_2,n_3\ge 2\).

  1. 1.

    If \(2\le k< \alpha _m(n_1,n_2,n_3)\), then

    $$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3})={\left\{ \begin{array}{ll} 2k+2, \hbox { if }k \hbox { is odd;}\\ 2k+3, \hbox { if }k \hbox { is even.} \end{array}\right. } \end{aligned}$$
  2. 2.

    If \(\alpha _m(n_1,n_2,n_3)\le k< \alpha _M(n_1,n_2,n_3)\), then

    $$\begin{aligned} \dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3}) \le n_1n_2n_3-(n_1-2)(n_2-2)(n_3-2) \end{aligned}$$
  3. 3.

    If \( \alpha _M(n_1,n_2,n_3)\le k\), then \(P_{n_1}\Box P_{n_2}\Box P_{n_3}\) has no \((k+1)\)-resolving set.

Observe that \(\alpha _m=\alpha _M\), whenever \(\min \{n_1,n_2,n_3\}=2\). Hence, the value of the \((k+1)\)-metric dimension is completely determined for these cases.

We finish by posing a conjecture about the exact value of the \((k+1)\)-metric dimension of 3D grids whenever \(\alpha _m\le k< \alpha _M\), based on the ideas used to construct \((k+1)\)-resolving sets for \(k<\alpha _m\).

Conjecture 21

If \(\alpha _m(n_1,n_2,n_3)\le k< \alpha _M(n_1,n_2,n_3)\), then

$$\begin{aligned}&\dim _{k+1}(P_{n_1}\Box P_{n_2}\Box P_{n_3})\\&\quad =\min \{ 4k-2\alpha _m(n_1,n_2,n_3)+4,n_1n_2n_3-(n_1-2)(n_2-2)(n_3-2) \}. \end{aligned}$$