1 Introduction

Points in general position in the plane are basic objects in classical geometry as well as in computational geometry. The concept naturally extends to arbitrary metric spaces and asking for the maximum number of points in general position appears as a natural problem. The problem to find the maximum number of points that can be placed in the \(n \times n\) grid so that no three points lie on a line is known as the no-three-in-line problem and was posed back in 1917 by Dudeney [5]. After a century the problem remains open, cf. [12, 15, 20]. Closely related problems are investigated in discrete geometry, see [3, 19].

Recently, the general position problem has been studied for metric spaces generated by graphs. The problem was independently introduced in [13, 25], the present terminology and formalism are from [13]. If \(G = (V(G), E(G))\) is a graph, then \(S\subseteq V(G)\) is a general position set if \(d_G(u,v) \ne d_G(u,w) + d_G(w,v)\) holds for every \(\{u,v,w\}\in \left( {\begin{array}{c}S\\ 3\end{array}}\right) \), where \(d_G(x,y)\) denotes the shortest-path distance in G, and \(\left( {\begin{array}{c}S\\ 3\end{array}}\right) \) the set of all 3-subsets of S. Equivalently, no three vertices lie on a common geodesic. We also say that the vertices from S lie in general position. The general position problem is to find a largest general position set of G, the order of such a set is the general position number \(\mathrm{gp}(G)\) of G. A general position set of G of order \(\mathrm{gp}(G)\) will be called a gp-set.

Following the seminal papers, the general position problem has been investigated in a sequence of papers [1, 6, 10, 14, 16, 18, 22, 26]. As it happens, in the special case of hypercubes, the general position problem was studied back in 1995 by Körner [11] related to some coding theory problems. In this paper, asymptotic lower and upper bounds were proved on the gp-number of hypercubes, and several closely related problems (cf. Sect. 5) were considered. The lower bound from [11] was improved in [17].

The results from [14] on the general position problem in interconnection networks with the emphasis on grid graphs were a starting motivation for the present study. One of the main results of [14] asserts that if \(P_\infty \) denotes the two-way infinite path, then \(\mathrm{gp}(P_\infty \,\square \,P_\infty ) = 4\), and consequently \(\mathrm{gp}(P_r\,\square \,P_s) = 4\) for \(r,s\ge 3\). The non-trivial part of this result (that \(\mathrm{gp}(P_r\,\square \,P_s) \le 4\) holds) was proved using the so-called Monotone Geodesic Lemma which was in turn derived from the celebrated Erdös-Szekeres theorem, cf. [2, Theorem 1.1]. The result \(\mathrm{gp}(P_\infty \,\square \,P_\infty ) = 4\) was recently generalized in two directions. In [9], it is proved that \(\mathrm{gp}(P_\infty ^{\,\square \,, k}) = 2^{2^{k-1}}\), while in [24], it is demonstrated that if \(T_1\) and \(T_2\) are arbitrary trees, then \(\mathrm{gp}(T_1\,\square \,T_2) = \mathrm{gp}(T_1) + \mathrm{gp}(T_2)\). The general position number of several other Cartesian product graphs is studied in [23].

In the rest of this section we prepare material needed later on. In the next section we have a closer look at the structure of gp-sets in grid graphs. We need to do it for the proof of the subsequent theorem on cylinder graphs (Theorem 3.2). As a side result we determine the number of gp-sets in \(P_r\,\square \,P_s\) for every \(r,s\ge 2\), a result that could be of independent interest. In Sect. 3 we then determine \(\mathrm{gp}(P_r\,\square \,C_s)\) for every \(r\ge 2\) and \(s\ge 3\). In the subsequent section we prove that if \(3\le s\le r\), \(4 \ne s\), and \(r\ge 6\), then \(\mathrm{gp}(C_r\,\square \,C_s) \in \{6,7\}\). We also discuss exact values and in particular prove that \(\mathrm{gp}(C_3\,\square \,C_s) = 6\) holds for \(s\ge 6\). Motivated by the results of [11], we consider in Sect. 5 how to apply the probabilistic method to obtain asymptotic lower bounds on the gp-number of Cartesian powers of graphs.

1.1 Preliminaries

For a positive integer k we will use the notation \([k] = \{1,\ldots , k\}\) and \([k]_0 = \{0,\ldots k-1\}\). The Cartesian product \(G\,\square \,H\) of graphs G and H has the vertex set \(V(G\,\square \,H) = V(G)\times V(H)\), vertices (gh) and \((g',h')\) are adjacent if either \(gg'\in E(G)\) and \(h=h'\), or \(g=g'\) and \(hh'\in E(H)\). Given a vertex \(h\in V(H)\), the subgraph of \(G\,\square \,H\) induced by the set \(\{(g,h):\ g\in V(G)\}\), is a G-layer and is denoted by \(G^h\). H-layers \(^gH\) are defined analogously. Each G-layer and H-layer is isomorphic to G and H, respectively. If \(X\subseteq V(G\,\square \,H)\), then the projection \(p_G(X)\) of X to G is the set \(\{g\in V(G):\ (g,h)\in X\ \mathrm{for\ some}\ h\in V(H)\}\). The projection \(p_H(X)\) of X to H is defined analogously. The k-tuple Cartesian product of a graph G by itself, alias Cartesian power of G, is denoted by \(G^{\,\square \,, k}\). This is well-defined since the Cartesian product operation is associative. For more on the Cartesian product see [7]. As stated above, the following result was the primary motivation for the present paper.

Theorem 1.1

[14]. If \(r\ge 3\) and \(s\ge 3\), then \(\mathrm{gp}(P_r\,\square \,P_s) = 4\).

A subgraph H of a graph G is isometric if \(d_H(u,v) = d_G(u,v)\) holds for all \(u,v\in V(H)\). A set of subgraphs \(\{H_1,\ldots , H_k\}\) of a graph G is an isometric cover of G if each \(H_i\), \(i\in [k]\), is isometric in G and \(\bigcup _{i=1}^k V(H_i) = V(G)\).

Theorem 1.2

[13, Theorem 3.1]. If \(\{H_1,\ldots , H_k\}\) is an isometric cover of G, then

$$\begin{aligned} \mathrm{gp}(G) \le \sum _{i=1}^k \mathrm{gp}(H_i)\,. \end{aligned}$$

If G is a connected graph, \(S\subseteq V(G)\), and \({{\mathcal {P}}} = \{S_1, \ldots , S_p\}\) is a partition of S, then \({{\mathcal {P}}}\) is distance-constant (alias “distance-regular” [8, p. 331]) if for any \(i,j\in [p]\), \(i\ne j\), the distance \(d_G(u,v)\), where \(u\in S_i\) and \(v\in S_j\), is independent of the selection of u and v. This distance is then the distance \(d_G(S_i,S_j)\) between the parts \(S_i\) and \(S_j\). A distance-constant partition \({{\mathcal {P}}}\) is intransitive if \(d_G(S_i, S_k) \ne d_G(S_i, S_j) + d_G(S_j,S_k)\) holds for distinct indices \(i,j,k\in [p]\).

Theorem 1.3

[1, Theorem 3.1]. Let G be a connected graph. Then \(S\subseteq V(G)\) is a general position set if and only if the components of the subgraph induced by S are complete subgraphs, the vertices of which form an intransitive, distance-constant partition of S.

Suppose that G is a connected bipartite graph and a general position set S contains two adjacent vertices x and y. Then Theorem 1.3 implies that \(|S| = 2\), because no other vertex of G can be at the same distance to x and y. We state this observation for later use.

Corollary 1.4

If G is a bipartite graph with \(\mathrm{gp}(G) \ge 3\), then every gp-set of G is an independent set.

2 Enumeration of gp-Sets in Grids

In this section we take a closer look at the structure of gp-sets in grids. We have two reasons to do it, the first is that this insight will be used in the proof of Theorem 3.2, the second is that we are able to enumerate the gp-sets in grids as follows.

Theorem 2.1

If \(2\le r\le s\), then

$$\begin{aligned} \#\mathrm{gp}(P_r\,\square \,P_s) = \left\{ \begin{array}{ll} 6; &{} r = s = 2\,, \\ \displaystyle {\frac{s(s-1)(s-2)}{3}}; &{} r = 2, s\ge 3\,, \\ \displaystyle {\frac{rs(r - 1)(r - 2)(s - 1)(s - 2)(r(s - 3) - s + 7)}{144}}; &{} r, s\ge 3\,. \end{array} \right. \end{aligned}$$

Proof

Set \(V(P_n) = [n]\). If \(r = s = 2\), then the assertion is clear since \(P_2\,\square \,P_2 = C_4\). Let next \(r=2\) and \(s\ge 3\). It is straightforward to see that \(\mathrm{gp}(P_2\,\square \,P_s) = 3\). Moreover, if X is a gp-set of \(P_2\,\square \,P_s\), then X has one vertex in one of the two \(P_s\)-layers and two vertices in the other \(P_s\)-layer, say \(X = \{(1,i), (2,j), (2,k)\}\), where \(j<k\). Since X is a gp-set we infer that \(j< i < k\). Hence, for a given vertex (1, i), there are \(i-1\) possibilities to select the vertex (2, j), and \(s-i\) possibilities for the vertex (2, k). The same holds if X has two vertices in \(^1P_s\) and one vertex in \(^2P_s\). From this it follows that

$$\begin{aligned} \#\mathrm{gp}(P_2\,\square \,P_s) = 2\cdot \sum _{i=1}^s (i-1)(s-i) = \frac{s(s-1)(s-2)}{3}\,. \end{aligned}$$

Suppose in the rest that \(r,s\ge 3\), so that \(\mathrm{gp}(P_r\,\square \,P_s) = 4\) by Theorem 1.1. Hence by Corollary 1.4, every gp-set is an independent set (of cardinality 4). Let X be an arbitrary such set and assume first that \(|p_{_{P_s}}(X)| = 2\). Then, clearly, X has two vertices in one \(P_r\)-layer and two vertices in another \(P_r\)-layer. Let \((i,j)\in X\) be a vertex that has the smallest first coordinate among the vertices of X. Then (ij) and the two vertices of X from the \(P_r\)-layer not containing (ij) lie on a common geodesic. Analogously, X cannot be a general position set if \(|p_{_{P_r}}(X)| = 2\). Since also \(|p_{_{P_r}}(X)| = 1\) or \(|p_{_{P_s}}(X)| = 1\) are not possible, we only need to distinguish the following two cases.

Case 1: \(|p_{_{P_r}}(X)| = 4\) and \(|p_{_{P_s}}(X)| = 4\).

Let \(p_{_{P_r}}(X) = \{a, b, c, d\}\), where \(a< b< c < d\), and let \(p_{_{P_s}}(X) = \{a', b', c', d'\}\), where \(a'< b'< c' < d'\). Then in the set \(p_{_{P_r}}(X) \times p_{_{P_s}}(X)\) there are 4! different 4-sets of vertices that project onto both \(p_{_{P_r}}(X)\) and \(p_{_{P_s}}(X)\). They can be described with permutations \(\pi \) of \(p_{_{P_s}}(X)\). That is, if \(\pi : p_{_{P_s}}(X) \rightarrow p_{_{P_s}}(X)\) is a bijection, then the corresponding gp-set of vertices of \(P_r\,\square \,P_s\) is \(S_\pi = \{(a, \pi (a')), (b, \pi (b')), (c, \pi (c')), (d, \pi (d'))\}\). Now, by the metric structure of \(P_r\,\square \,P_s\) (cf. [14]), \(S_\pi \) is a general position set if and only if the sequence \((\pi (a'), \pi (b'), \pi (c'), \pi (d'))\) contains no monotone subsequence of length 3. By a direct inspection we find that if \(\pi (a') = a'\) or if \(\pi (a') = d'\), then we get no general position sets. If \(\pi (a') = b'\), then exactly the sequences \((b', a', d', c')\) and \((b', d', a', c')\) yield general position sets. Symmetrically, if \(\pi (a') = c'\), then exactly the sequences \((c', a', d', b')\) and \((c', d', a', b')\) yield general position sets. Hence, if \(|p_{_{P_r}}(X)| = 4\) and \(|p_{_{P_s}}(X)| = 4\), then there are exactly \(4\left( {\begin{array}{c}r\\ 4\end{array}}\right) \left( {\begin{array}{c}s\\ 4\end{array}}\right) \) gp-sets.

Case 2: \(|p_{_{P_r}}(X)| = 3\) (and \(|p_{_{P_s}}(X)| = 3\) or \(|p_{_{P_s}}(X)| = 4\)).

Let \(p_{_{P_r}}(X) = \{a, b, c\}\), where two vertices from X project to a, say \((a,a'), (a,b')\in X\), where \(a' < b'\). Let \((x,x')\) be a vertex of \(P_r\,\square \,P_s\), where \(x'\le a'\) and \((x,x')\ne (a,a')\). Then \(d((x,x'), (a,b')) = d((x,x'), (a,a')) + d((a,a'), (a,b'))\), which means that \((x,x')\notin X\). Similarly, if \((x,x')\) is a vertex of \(P_r\,\square \,P_s\) with \(x'\ge b'\) and \((x,x')\ne (a,b')\), then also \((x,x')\notin X\). We have thus shown that

$$\begin{aligned} X\cap ([r] \times \{1,\ldots , a'\}) = \{(a,a')\}\ \mathrm{and}\ X\cap ([r] \times \{b',\ldots , s\}) = \{(a,b')\}\,. \end{aligned}$$

Let \(X = \{(a,a'), (a,b'), (x,x'), (y,y')\}\), where \(x\ne y\). By a similar argument as above we see that, without loss of generality,

$$\begin{aligned} (x,x')&\in \{1,\ldots , a-1\}\times \{a'+1,\ldots , b'-1\}\ \mathrm{and}\\ (y,y')&\in \{a+1,\ldots , r\}\times \{a'+1,\ldots , b'-1\}\,. \end{aligned}$$

Since the vertices \((x,x')\) and \((y,y')\) are arbitrary vertices from \(\{1,\ldots , a-1\}\times \{a'+1,\ldots , b'-1\}\) and \(\{a+1,\ldots , r\}\times \{a'+1,\ldots , b'-1\}\), respectively, for fixed \(a, a', b'\) we obtain precisely

$$\begin{aligned}{}[(b'-a'-1)(a-1)]\cdot [(b'-a'-1)(r-a)] = (b'-a'-1)^2(a-1)(r-a) \end{aligned}$$

gp-sets. To obtain the number of all gp-sets in this case, we need to sum up over all coordinates a of the factor \(P_r\), onto which two vertices from X project. Consequently, the number of gp-sets in Case 2 is

$$\begin{aligned} \sum _{a=1}^r \sum _{a'=1}^s \sum _{b'=a'+1}^s [(b'-a'-1)^2(a-1)(r-a)] = \frac{rs(r^2 - 3r + 2)(s^3-4s^2 + 5s - 2)}{72}\,. \end{aligned}$$

By the above two cases, if \(r, s\ge 3\), then

$$\begin{aligned} \#\mathrm{gp}(P_r\,\square \,P_s)&= 4\left( {\begin{array}{c}r\\ 4\end{array}}\right) \left( {\begin{array}{c}s\\ 4\end{array}}\right) + \frac{rs(r^2 - 3r + 2)(s^3-4s^2 + 5s - 2)}{72} \\&= \frac{rs(r - 1)(r - 2)(s - 1)(s - 2)(r(s - 3) - s + 7)}{144}\,, \end{aligned}$$

which is the claimed expression. \(\square \)

If \(r=3\) and \(s\ge 3\), then Theorem 2.1 yields

$$\begin{aligned} \#\mathrm{gp}(P_3\,\square \,P_s) = \frac{s(s - 2)(s - 1)^2}{12}\,, \end{aligned}$$

which, after substituting s with \(s+1\) gives the sequence A002415 from OEIS [21]. In addition, the case \(r=2\) and \(s\ge 3\) yields the sequence A007290.

3 Cylinders

In this section we determine the general position number of cylinders. For this task, the following function will be useful. If G is a connected graph and \(X\subseteq V(G)\) is a general position set, then

$$\begin{aligned} F(X) = \{u\in V(G)-X:\ X\cup \{u\}\ \mathrm{is\ not\ a\ general\ position\ set}\}\,. \end{aligned}$$

If \(X=\{x,y\}\), we will simplify the notation \(F(\{x,y\})\) to F(xy).

Set \(V(P_r)=[r]_0\) and \(V(C_s)=[s]_0\). From now on, operations with the integers in \(V(C_s)\) are done modulo s.

Lemma 3.1

Let \(r\ge 2\), \(s\ge 3\), and let S be a general position set of the cylinder graph \(P_r\,\square \,C_s\). Then the following assertions hold.

  1. (i)

    If \(|S|\ge 5\), then S is an independent set.

  2. (ii)

    If \(|S| \ge 4\), then \(|S\cap V(^iC_s)|\le 2\) for every \(i\in [r]_0\).

  3. (iii)

    If \(|S\cap V(^iC_s)| = 2\) for some \(i\in [r]_0\), then \(|S|\le 4\).

  4. (iv)

    If \(r\ge 6\), \(|S| = 5\), and \(|S\cap V(^iC_s)| \le 1\) for every \(i\in [r]_0\), then \(\mathrm{gp}(P_5\,\square \,C_s) \ge 5\).

Proof

(i) Suppose \(|S|\ge 5\) and S is not independent. If \((i,k), (i+1,k)\in S\), then we observe that \(F((i,k), (i+1,k))=V(P_r\,\square \,C_s)-\{(i,k), (i+1,k)\}\), which means that \(S = \{(i,k), (i+1,k)\}\), a contradiction. On the other hand, if \((i,k), (i,k+1)\in S\), then either \(F((i,k), (i,k+1))=V(P_r\,\square \,C_s)-\{(i,k), (i,k+1)\}\) (when s is even), or \(F((i,k), (i,k+1))=V(P_r\,\square \,C_s)-(\{(i,k), (i,k+1)\}\cup (V(P_r)\times \{j\}))\) (when s is odd), where j is the vertex which is on \(C_s\) opposite to k and \(k+1\). The first possibility directly leads to a contradiction. For the second one, since every \(P_r\)-layer, being an isometric subgraph, contributes at most two vertices to a general position set of \(P_r\,\square \,C_s\), it follows that \(|S|\le 4\), which is again a contradiction. Consequently S must be an independent set.

(ii) The result follows directly from the following fact. If \(\{(i,k_1),(i,k_2),(i,k_3)\} \subseteq S\), then (since \(k_1\), \(k_2\), and \(k_3\) are distinct) \(F(\{(i,k_1),(i,k_2),(i,k_3)\})=V(P_r\,\square \,C_s)-\{(i,k_1),(i,k_2),(i,k_3)\}\), which means that \(|S| = 3\).

(iii) Let \(i\in [r]_0\) be such that \(|S\cap V(^iC_s)| = 2\). We may assume without loss of generality that \(S\cap V(^iC_s) = \{(i,0), (i,j)\}\), where \(j\le \lfloor s/2 \rfloor \). Then

$$\begin{aligned} F((i,0), (i,j))= & {} [r]_0 \times (\{j-\lfloor s/2\rfloor ,\dots , 0\}\cup \{j,\dots , \lfloor s/2\rfloor \})\\ {}&\cup&(\{i\}\times I)-\{(i, 0), (i, j)\}, \end{aligned}$$

where \(I=[s]_0\) if s is even and \(j=s/2\); or \(I=\{0,\dots , j\}\) otherwise.

If \(j=1\), then F((i, 0), (ij)) equals \(V(P_r\,\square \,C_s) - \{(i, 0), (i, j)\}\) when s is even, or F((i, 0), (ij)) equals \(V(P_r\,\square \,C_s)-(([r]_0\times \{\lceil s/2\rceil \}) \cup \{(i, 0), (i, j)\})\) when s is odd. In the first situation we clearly have \(|S|\le 2\). In the latter one, the set of vertices \([r]_0\times \{\lceil s/2\rceil \}\) could contain at most two vertices of S, since it induces an isometric path in \(P_r\,\square \,C_s\), and so \(|S|\le 4\). We may assume in the rest that \(j\ge 2\). Note that \(V(P_r\,\square \,C_s)-(F((i,0), (i,j))\cup \{(i,0), (i,j)\})=Y_1\cup Y_2\cup Y_3\cup Y_4\), where

$$\begin{aligned} Y_1= & {} \,[i]_0 \times \{1,\dots , j-1\} \\ Y_2= & {} \,[i]_0 \times \{\lfloor s/2\rfloor +1,\dots , j-\lfloor s/2\rfloor -1\} \\ Y_3= & {} \,([r]_0-[i+1]_0) \times \{1,\dots , j-1\} \\ Y_4= & {} \,([r]_0-[i+1]_0) \times \{\lfloor s/2\rfloor +1,\dots , j-\lfloor s/2\rfloor -1\}. \end{aligned}$$

Consider two vertices \((i',j'),(i'', j'')\in S-\{(i,0), (i,j)\}\). (If there are no two such vertices, then clearly \(|S|\le 3\).) If either \((i',j'),(i'', j'')\in Y_1\); or \((i',j'),(i'', j'')\in Y_2\); or \((i',j'),(i'', j'')\in Y_3\); or \((i',j'),(i'', j'')\in Y_4\), then it happens that \((i,0)\in F((i',j'), (i'',j''))\) or \((i,j)\in F((i',j'), (i'',j''))\), which is not possible. As a consequence, each of the sets \(Y_1\), \(Y_2\), \(Y_3\), and \(Y_4\) must contain at most one vertex of S.

Assume now there is a vertex \((i',j')\in Y_1\cap S\). Then the set \(F((i',j'), (i,0))\cup F((i',j'), (i,j))\) contains the whole set \(Y_4\). By symmetry, if there is a vertex \((i',j')\in Y_4\cap S\), then \(Y_1\cap S = \emptyset \). Hence, \(|(Y_1\cup Y_4) \cap S| \le 1\). Similarly we obtain that \(|(Y_2\cup Y_3) \cap S| \le 1\). Therefore, the sets \(Y_1\), \(Y_2\), \(Y_3\), and \(Y_4\) can contain at most two vertices of S, which gives \(|S|\le 4\).

(iv) Let \(S = \{(i_k, j_k):\ k\in [5]_0\}\). Since \(|S\cap V(^iC_s)| \le 1\), the coordinates \(i_k\) are pairwise different, hence we may assume without loss of generality that \(i_0< i_1< i_2< i_3 < i_4\). Set \(S' = \{(k,j_k):\ k\in [5]_0\}\). We claim that \(S'\) is a general position set of \(G_5 = P_5\,\square \,C_s\). Assume on the contrary that

$$\begin{aligned} d_{G_5}((p,j_p), (r,j_{r})) = d_{G_5}((p,j_p), (q,j_{q})) + d_{G_5}((q,j_q), (r,j_{r}))\, \end{aligned}$$

for some \(p,q,r\in [5]_0\), \(p< q < r\). Since the distance function in Cartesian products is additive, we get that

$$\begin{aligned} d_{P_5}(p,r) + d_{C_s}(j_p,j_{r}) = d_{P_5}(p,q) + d_{C_s}(j_p,j_{q}) + d_{P_5}(q,r) + d_{C_s}(j_q,j_{r})\,. \end{aligned}$$

Since \(d_{P_5}(p,r) = d_{P_5}(p,q) + d_{P_5}(q,r) \), we thus have

$$\begin{aligned} d_{C_s}(j_p,j_{r}) = d_{C_s}(j_p,j_{q}) + d_{C_s}(j_q,j_{r})\,. \end{aligned}$$

From this we get that in \(G_r = P_r\,\square \,C_s\),

$$\begin{aligned} d_{G_r}((i_p,j_p), (i_r,j_{r}))&= d_{P_r}(i_p,i_r) + d_{C_s}(j_p, j_{r}) \\&= [d_{P_r}(i_p,i_q) + d_{P_r}(i_q,i_r)] + [d_{C_s}(j_p,j_{q}) + d_{C_s}(j_q,j_{r})] \\&= [d_{P_r}(i_p,i_q) + d_{C_s}(j_p,j_{q})] + [d_{P_r}(i_q,i_r) + d_{C_s}(j_q,j_{r})] \\&= d_{G_r}((i_p,j_p), (i_q,j_{q})) + d_{G_r}((i_q,j_q), (i_r,j_{r}))\,. \end{aligned}$$

This contradiction proves that \(S'\) is a general position set of \(P_5\,\square \,C_s\). We conclude that \(\mathrm{gp}(P_5\,\square \,C_s) \ge 5\). \(\square \)

Note that Lemma 3.1(iv) allows us to map a general position set of cardinality 5 in long cylinders to a general position set of the same cardinality in cylinders over \(P_5\).

Theorem 3.2

If \(r\ge 2\) and \(s\ge 3\), then

$$\begin{aligned} \mathrm{gp}(P_r\,\square \,C_s) = \left\{ \begin{array}{ll} 3; &{} r = 2, s = 3\,, \\ 5; &{} r \ge 5,\ \mathrm{and}\ s=7\ \mathrm{or}\ s\ge 9\,, \\ 4; &{} \mathrm{otherwise}\,. \end{array} \right. \end{aligned}$$

Proof

First, it is easy to verify that \(\mathrm{gp}(P_2\,\square \,C_3) = 3\).

Assume next that \(r\le 4\) and suppose that there exists a general position set S with \(|S|\ge 5\). If \(r=2\), this is not possible by Lemma 3.1(ii). Let next \(r\in \{3,4\}\). Then there exists a \(C_s\)-layer \(^iC_s\) with \(|V(^iC_s)\cap S| \ge 2\). The case \(|V(^iC_s)\cap S| > 2\) is not possible by Lemma 3.1(ii), while the case \(|V(^iC_s)\cap S| = 2\) is excluded by Lemma 3.1(iii). Hence \(\mathrm{gp}(P_r\,\square \,C_s) \le 4\) for \(r\in \{2,3,4\}\). It is straightforward to see that the set \(\{(0,0), (1,1), (0, \lfloor s/2\rfloor ), (1, \lfloor s/2\rfloor +1)\}\) is a general position set of \(P_r\,\square \,C_s\) for \(r\ge 2\) and \(s\ge 4\). Moreover, if \(s=3\), then the set \(\{(0,1), (1,0), (1,2), (2,1)\}\) is a general position set of \(P_r\,\square \,C_3\) for \(r\ge 3\). Hence \(\mathrm{gp}(P_r\,\square \,C_s) \ge 4\) for \(r\in \{2,3,4\}\) and so \(\mathrm{gp}(P_r\,\square \,C_s) = 4\) for \(r\in \{2,3,4\}\).

The general position set \(\{(0,0), (1,2), (2,4), (3,6), (4,1)\}\) of \(P_5\,\square \,C_7\) demonstrates that \(\mathrm{gp}(P_5\,\square \,C_7) \ge 5\).

Suppose next that for some \(r\ge 6\) the cylinder \(P_r\,\square \,C_8\) contains a general position set S with \(|S| = 5\). From Lemma 3.1(iii) it follows that \(|S\cap V(^iC_8)| \le 1\) for every \(i\in [r]_0\). Hence the assumptions of Lemma 3.1(iv) are fulfilled, and we can map the general position set S of cardinality 5 in the cylinder \(P_r\,\square \,C_8\), \(r\ge 6\), to a general position set of the same cardinality (5) in the cylinder over \(P_5\,\square \,C_8\), which indeed implies that \(\mathrm{gp}(P_5\,\square \,C_8) \ge 5\). However, we have checked by computer that \(\mathrm{gp}(P_5\,\square \,C_8) = 4\). Thus, we have obtained a contradiction. Therefore, \(\mathrm{gp}(P_r\,\square \,C_8) \le 4\) for \(r\ge 5\) (the case \(r=5\) was computationally made). Since clearly \(\mathrm{gp}(P_r\,\square \,C_8) \ge 4\), we conclude that \(\mathrm{gp}(P_r\,\square \,C_8) = 4\) for \(r\ge 5\).

Suppose now that \(r = 5\), \(s\ge 9\), and consider the set

$$\begin{aligned} S = \{u_0=(0,1), u_1=(1,4), u_2=(2, \lfloor s/2\rfloor +2), u_3=(3,0), u_4=(4, 3)\}\,. \end{aligned}$$

We claim that S is a general position set. Note first that the vertices \(u_0, u_1, u_3, u_4\) lie in a general position. Further,

$$\begin{aligned} d(u_2,u_0)&= (s - \lfloor s/2\rfloor - 1) + 2 = s - \lfloor s/2\rfloor + 1,\\ d(u_2,u_1)&= \lfloor s/2\rfloor - 1, \\ d(u_2,u_3)&= s - \lfloor s/2\rfloor - 1, \\ d(u_2,u_4)&= \lfloor s/2\rfloor + 1. \end{aligned}$$

Then \(d(u_0,u_2) = s - \lfloor s/2\rfloor + 1 < \lfloor s/2\rfloor + 3 = d(u_0,u_1) + d(u_1,u_2)\). Similarly we see that \(u_2\) is not on a geodesic containing three vertices of S. Hence, S is a general position set and thus \(\mathrm{gp}(P_5\,\square \,C_s) \ge 5\) for \(s\ge 9\).

Note finally that the general position set for \(P_5\,\square \,C_7\) and the general position set for \(P_5\,\square \,C_s\), \(s\ge 9\), are also general position sets for \(P_r\,\square \,C_7\), \(r\ge 6\), and for \(P_r\,\square \,C_s\), \(r\ge 6\), respectively. We conclude that \(\mathrm{gp}(P_r\,\square \,C_s) \ge 5\) for \(r\ge 5\) and \(s\ge 7\), \(s\ne 8\).

It remains to prove that the above constructed general position sets of cardinality 5 are gp-sets. Hence let S be a gp-set of \(P_r\,\square \,C_s\), where \(|S| \ge 5\). Note that S is an independent set, by Lemma 3.1(i). Then make a partition of \(V(P_r\,\square \,C_s)\) into two sets \(A_1\) and \(A_2\) inducing two grids that are isometric subgraphs of \(P_r\,\square \,C_s\). Without loss of generality, we may assume \(A_1=V(P_r)\times [\lceil s/2\rceil ]_0\) and \(A_2=V(P_r)\times ([s]_0-[\lceil s/2\rceil ]_0)\). Now, let \(S_1=S\cap A_1\) and \(S_2=S\cap A_2\). Since \(\mathrm{gp}(P_r\,\square \,C_s)\ge 5\), it follows \(|S_1|\ge 3\) or \(|S_2|\ge 3\). Moreover, since \(A_1\) and \(A_2\) induce isometric grid graphs, Theorem 1.1 implies that \(|S_1|\le 4\) and \(|S_2|\le 4\). To simplify the notation, we write \(s_d=\lfloor s/2\rfloor \) Note that here we do not need to change floor to ceil. We consider the following cases.

Case 1: \(|S_1|=4\).

Let \(S_1=\{(a',a), (b',b), (c',c), (d',d)\}\). Note that \(S_1\) is then a gp-set of the grid induced by \(A_1\). Since the structure of every gp-set of a grid graph is known from the proof of Theorem 2.1, we can assume without loss of generality the following facts: \(a< b < d\), \(a< c < d\), and either (\(c'< a' < b'\) and \(c'< d' < b'\)) or (\(b'< a' < c'\) and \(b'< d' < c'\)). Note that there is neither relationship between ab nor between \(a',b'\), namely, it can happen \(a\le b\) or \(b\le a\) and \(a'\le b'\) or \(b'\le a'\). Examples of such sets are shown in Fig. 1. For presentation purposes, in this and the subsequent figures an orientation is selected such that \(C_s\)-layers are drawn horizontally and \(P_r\)-layers vertically.

Fig. 1
figure 1

Two possible configurations of the set \(S_1\) (edges of the grid have not been drawn)

We now consider the set \(F(S_1)\) in \(V(P_r\,\square \,C_s)\). Figure 2 shows an example of the forbidden area generated by only two vertices of \(S_1\) (\((c',c)\) and \((d',d)\) in this case). Since it is not necessary for our purposes, we do not look at the whole set \(S_1\), only a significant part.

Fig. 2
figure 2

The forbidden area \(F((c',c),(d',d))\) appears surrounded by the dashed rectangles. Vertices \(b_1\) and \(b_2\) of \(C_s\) are diametral with b while \(c_1\) and \(c_2\) are diametral with c. Here \(b_1 = b+s_d\), \(b_2 = b-s_d\), \(c_1 = c+s_d\), and \(c_2 = c-s_d\). Similar convention will be used in the subsequent figures. Notice that if the cycle would have an even order, then \(b_1=b_2\) and \(c_1=c_2\)

We detail now the case \(a< b \le c < d\) and \(c'< a' \le d' < b'\), see Fig. 3. Observe that:

$$\begin{aligned} \{a',\dots ,r-1\}\times \{a,a-1,\dots ,c-s_d\}&\subset F((c',c),(a',a)), \\ \{0,\dots ,a'\}\times \{a,a-1,\dots ,b-s_d\}&\subset F((b',b),(a',a)), \\ \{d',\dots ,r-1\}\times \{d,d+1,\dots ,c+s_d\}&\subset F((c',c),(d',d)), \\ \{0,\dots ,d'\}\times \{d,d+1,\dots ,b+s_d\}&\subset F((b',b),(d',d)). \end{aligned}$$

Let us define a subset A of \(A_2\) by \(A=A_2-F(S_1)\). Observe that A is empty if and only if one of the following situations occur: \(a'=d'\), or \(a'=d'-1\), or \(b=c\), or (\(b=c-1\) and s is even). More precisely, \(A=\{a'+1,\dots ,d'-1\}\times \{b_2,\dots ,c_1\}\). Figure 3 shows an example of this where the set A is not empty.

Fig. 3
figure 3

Part of the forbidden area of the bolded set of vertices appears in dashed rectangles. The two gray vertices of the thick rectangle (denoted by A) do not belong to the forbidden area of the bolded vertices

As a consequence, it must happen that \(S_2\subseteq A\), since otherwise we get a contradiction with S being a gp-set. If \(|S_2|\ge 2\), then let \((x',x),(y',y)\in S_2\). It is then not difficult to observe that \((c',c),(x',x),(y',y)\) or \((d',d),(x',x),(y',y)\) lie in a geodesic of \(P_r\,\square \,C_s\), as well as \((a',a),(x',x),(y',y)\) or \((b',b),(x',x),(y',y)\), which is not possible. Thus \(|S_2|\le 1\).

By using a similar reasoning, we deduce the same conclusion for any other relationship of abcd and \(a',b',c',d'\) (from those ones that allow to obtain a gp-set of the grid induced by \(A_1\), according to the proof of Theorem 2.1). As a consequence of the whole deduction of this case, we obtain that \(\mathrm{gp}(P_r\,\square \,C_s)=|S|=|S_1|+|S_2|\le 5\).

Case 2: \(|S_2|=4\).

The situation is similar to Case 1, although if s is odd, then the set \(A_2\) is smaller than \(A_1\) by a difference of one \(P_r\)-layer. Notwithstanding, this fact does not influence the arguments considered in Case 1.

Case 3: \(|S_1|=3\) or \(|S_2|=3\).

Assume first that \(|S_1|=3\), and let \(S_1=\{(a',a),(b',b),(c',c)\}\). Clearly, the three elements of \(S_1\) cannot lie simultaneously in the same \(^iC_s\)-layer, or in the same \(P_r\,^j\)-layer. Moreover, it cannot happen that \(a'\le b'\le c'\) and \(a\le b\le c\) at the same time, or any other similar double monotone sequence. This means that, for instance, if \(a'\le b'\le c'\), then either (\(b < a\) and \(b < c\)) or (\(b > a\) and \(b > c\)).

We may assume now that \(a'\le b'\le c'\), \(b < a\) and \(b < c\). Figure 4 shows an example of this.

Fig. 4
figure 4

An example of a configuration for the set \(S_1\)

We now consider the set \(F(S_1)\) in \(V(P_r\,\square \,C_s)\), and observe the following. Recalling that \(s_d=\left\lfloor s/2\right\rfloor \) we have:

$$\begin{aligned} \{c',\dots ,r-1\}\times \{c,c+1,\dots ,a+s_d\}&\subset F((c',c),(a',a)), \\ \{0,\dots ,a'\}\times \{a,a-1,\dots ,c-s_d\}&\subset F((c',c),(a',a)),\\ \{b',\dots ,r-1\}\times \{b,b-1,\dots ,a-s_d\}&\subset F((b',b),(a',a)), \\ \{0,\dots ,a'\}\times \{a,a+1,\dots ,b+s_d\}&\subset F((b',b),(a',a)), \\ \{c',\dots ,r-1\}\times \{c,c+1,\dots ,b+s_d\}&\subset F((c',c),(b',b)), \\ \{0,\dots ,b'\}\times \{b,b-1,\dots ,c-s_d\}&\subset F((c',c),(b',b)). \end{aligned}$$

See Fig. 5 for an example of the situations above.

Fig. 5
figure 5

A significant part of the set \(F(S_1)\) appears surrounded by dashed rectangles. For \(x\in \{a,b,c\}\), the vertices \(x_1\) and \(x_2\) from \(C_s\) (\(x_1=x+s_d\) and \(x_2=x-s_d\)) are diametral vertices with x. Note that if \(C_s\) is an even cycle, then \(x_1 = x_2\)

Observe now that there are four sets, say \(B_1\), \(B_2\), \(B_3\), and \(B_4\), such that \(B_1\cup B_2\cup B_3\cup B_4=A_2-F(S_1)\), and satisfying the following. If \(B_1\), \(B_2\), \(B_3\), and \(B_4\) are not empty, then

$$\begin{aligned} B_1&= \{a'+1,\dots ,c'-1\}\times \{s_d+1,\dots ,b+s_d\}, \\ B_2&= \{a'+1,\dots ,c'-1\}\times \{b+s_d+1,\dots ,a+s_d\}, \\ B_3&= \{0,\dots ,a'\}\times \{b+s_d+1,\dots ,a+s_d\}, \\ B_4&= \{0,\dots ,a'\}\times \{a+s_d+1,\dots ,c+s_d\}. \end{aligned}$$

Note that some of these sets could be empty, or could have non-empty intersection, depending on the parity of s and on the structure of the set \(S_1\).

If \(|S_2\cap B_i|\ge 2\) for some \(i\in [4]\), then we shall find an isometric subgraph of \(P_r\,\square \,C_s\) isomorphic to a grid graph such that it contains four vertices of the set S. Hence, we can change the partition given by \(A_1\) and \(A_2\) from the beginning, to a new one, and proceed as in Case 1, to prove that \(\mathrm{gp}(P_r\,\square \,C_s)\le 5\). That is, if \(|S_2\cap B_i|\ge 2\) for some \(i\in [3]\), then we can use the partition \(A'_1=[r]_0\times \{a,a+1,\dots ,a+s_d\}\) and \(A'_2=V(P_r\,\square \,C_s)-A'_1\), and if \(|S_2\cap B_4|\ge 2\), then we can use the partition \(A'_1=[r]_0\times \{a+s_d+1,a+s_d+2,\dots ,a\}\) (note that \(a+s_d+1=a-s_d\)) and \(A'_2=V(P_r\,\square \,C_s)-A'_1\). In concordance, we may assume that \(|S_2\cap B_i|\le 1\) for every \(i\in [4]\).

We consider now the three sets \(B_1\), \(B_2\) and \(B_3\). If at least two of them contain one element from \(S_2\), then, as above, we can find a different partition of \(V(P_r\,\square \,C_s)\) and proceed like in Case 1. Thus, \(|(B_1\cup B_2\cup B_3)\cap S_1|\le 1\).

Finally, we deduce that \(\mathrm{gp}(P_r\,\square \,C_s)=|S|=|S_1|+|S_2|= |S_1|+ |(B_1\cup B_2\cup B_3)\cap S_1|+|B_4\cap S_1|\le 5\). By using similar arguments, we can again obtain a similar conclusion for any other possible relationship between abc and \(a',b',c'\).

Now, if \(|S_2|=3\) and s is even, then an identical procedure as above leads to the same conclusion. Finally, if \(|S_2|=3\) and s is odd, then the arguments above do not apply since \(A_2\) has only \(\lfloor s/2\rfloor \) \(P_r\)-layers. However, it must happen \(|S_1|\le 2\), since otherwise, we proceed as in the previous situation (when \(|S_1|=3\)). Consequently, we have that \(\mathrm{gp}(P_r\,\square \,C_s)=|S|=|S_1|+|S_2|\le 5\). This completes the proof of this case, and therefore, of the whole theorem. \(\square \)

4 Torus Graphs

Knowing \(\mathrm{gp}(P_r\,\square \,P_s)\) and \(\mathrm{gp}(P_r\,\square \,C_s)\), the next task is to consider the torus graphs \(C_r\,\square \,C_s\), \(r, s\ge 3\), where we keep the convention that \(V(C_n) = [n]_0\). In contrast to the former two cases, for the torus graphs we are not able to give an exact result, but we will prove a theorem which reduces the general position number of the torus graphs to only two cases. The following lemma and short remarks will be useful for our proof.

Lemma 4.1

If S is a general position set in \(P_r \,\square \,P_s\) and there exists \(x \in S\), with \(\mathrm{deg}(x)=2\), then \(|S|\le 3.\)

Proof

Suppose on the contrary that \(|S|=4\). Assume without loss of generality that \((0,0)\in S.\) Let \((i,i'),(j,j'),(k,k')\) be the other three vertices of S where \(i\le j \le k\). If \(i'\le j'\), then \((0,0),(i,i'),(j,j')\) lie on a common geodesic. So \(i'>j'.\) Similarly, \(j'>k'.\) But now \((i,i'),(j,j'),(k,k')\) lie on a common geodesic. \(\square \)

Remark 4.2

If \(S = \{(0,0),(i,i'),(j,j')\}\) is a general position set of \(P_r \,\square \,P_s\), then \(i\ne j\) and \(i' \ne j'\).

Remark 4.3

The graph \(P_r\) is an isometric subgraph of \(C_s\) if \(r \le \lfloor \frac{s}{2}\rfloor +1.\)

We now bound \(\mathrm{gp}(C_r\,\square \,C_s)\) from the above as follows.

Theorem 4.4

If \(r\ge 3\) and \(s\ge 3\), then \(\mathrm{gp}(C_r\,\square \,C_s)\le 7\).

Proof

Let \(S\subseteq V(C_r \,\square \,C_s)\) be a general position set and let \(w\in S\). Since \(C_r \,\square \,C_s\) is a vertex-transitive graph (meaning that for each pair of vertices of \(C_r \,\square \,C_s\) there is an automorphism which maps the first vertex into the second), we can without loss of generality set \(w = (\lfloor \frac{r}{2} \rfloor , \lfloor \frac{s}{2}\rfloor )\). Consider the following four subgraphs of \(C_r \,\square \,C_s\) (where addition is done modulo r or s):

  • \(X_1 = \{(u_i,v_j): u_i \in [\lfloor \frac{r}{2}\rfloor +1]_0, v_j \in [\lfloor \frac{s}{2}\rfloor +1]_0\},\)

  • \(X_2 = \{(u_i,v_j): u_i \in \{\lfloor \frac{r}{2}\rfloor ,\lfloor \frac{r}{2}\rfloor +1,\ldots ,\lfloor \frac{r}{2}\rfloor +\lfloor \frac{r}{2}\rfloor \}, v_j \in [\lfloor \frac{s}{2}\rfloor +1]_0\},\)

  • \(X_3 = \{(u_i,v_j): u_i \in \{\lfloor \frac{r}{2}\rfloor ,\lfloor \frac{r}{2}\rfloor +1,\ldots ,\lfloor \frac{r}{2}\rfloor +\lfloor \frac{r}{2}\rfloor \}, v_j \in \{\lfloor \frac{s}{2}\rfloor ,\lfloor \frac{s}{2}\rfloor +1,\ldots ,\lfloor \frac{s}{2}\rfloor +\lfloor \frac{s}{2}\rfloor \},\)

  • \(X_4 = \{(u_i,v_j): u_i \in [\lfloor \frac{r}{2}\rfloor +1]_0, v_j \in \{\lfloor \frac{s}{2}\rfloor ,\lfloor \frac{s}{2}\rfloor +1,\ldots ,\lfloor \frac{s}{2}\rfloor +\lfloor \frac{s}{2}\rfloor \}.\)

For each \(i \in [4]\), the graph \(X_i\) is isomorphic to \(P_{\lfloor \frac{r}{2}\rfloor +1} \,\square \,P_{\lfloor \frac{s}{2}\rfloor +1}\). Hence, by Remark 4.3, every \(X_i\) is an isometric subgraph of \(C_r \,\square \,C_s.\) Since \(w \in X_i\), \(i \in [4]\), it is clear that \(\mathrm{gp}(C_r \,\square \,C_s) \le 9\) (by Lemma 4.1). This bound can be further improved using the following:

Claim: If \(|(X_1 \cup X_3) \cap S| = 5\), then \(|(X_2 \cup X_4) \cap S| \le 2\).

Clearly, if the claim is proved, then by symmetry we also infer that if \(|(X_2 \cup X_4) \cap S| = 5\), then \(|(X_1 \cup X_3) \cap S| \le 2\). From these two facts the assertion of the theorem will follow. It thus remains to prove the claim.

Let \(u_1 = (x_1,y_1)\), \(u_2 = (x_2,y_2)\), \(u_3 = (x_3,y_3)\), and \(u_4 = (x_4,y_4)\) be vertices such that \(X_1 \cap S = \{u_1,u_2,w\}\) and \(X_3 \cap S =\{u_3,u_4,w\}\). Suppose that there are vertices \(u_5 = (x_5,y_5)\) and \(u_6 = (x_6,y_6)\) such that \(\{u_5,u_6\} \subseteq X_2 \cap S\). As S is a general position, Remark 4.2 implies that we may without loss of generality assume that \(x_1<x_2<x_3<x_4\) and \(y_2<y_1<y_4<y_3\). Further, we may also assume that \(x_5<x_6\) and \(y_5<y_6\).

If \(x_3 - x_1 \le \frac{r}{2}\), then either w lies on a \(u_1,u_3\)-geodesic (if \(y_3-y_1 \le \frac{s}{2}\)) or \(u_2\) lies on such a geodesic (when \(y_3 - y_1 \ge \frac{s}{2}\)). It follows that \(x_3 - x_1 > \frac{r}{2}\). With a similar reasoning we also get that \(y_3 - y_1 > \frac{s}{2}\), since otherwise \(u_4\) is on a \(u_1,u_3\)-geodesic.

Applying the same reasoning the following is obtained: \(x_4 - x_2 > \frac{r}{2}\) and \(y_4 - y_2 > \frac{s}{2}\). We now distinguish the following cases.

Case 1: (\(y_3 - y_6 \ge \frac{s}{2}\)).

Subcase 1a: \(x_3 < x_6\).

First, \(x_3>x_5\), since otherwise \(u_5\) lies on a \(u_3,u_6\)-geodesic. If \(y_4-y_5 \ge \frac{s}{2}\), then \(u_3\) lies on a \(u_4,u_5\)-geodesic. So, \(y_4 - y_5 < \frac{s}{2}.\) If \(x_4 > x_6\), then \(u_6\) is on a \(u_4,u_5\)-geodesic, so \(x_6>x_4\). If \(y_1 \le y_6\), then \(u_6\) is on a \(u_1,u_4\)-geodesic, so \(y_1>y_6\). But if \(y_1> y_6\), then \(u_6\) is on a \(u_1,u_3\)-geodesic.

Subcase 1b: \(x_3 > x_6\).

If \(y_4 - y_6 \ge \frac{s}{2}\), then \(u_3\) is on a \(u_4,u_6\)-geodesic. So, \(y_4-y_6 < \frac{s}{2}\). But now \(u_6\) is on a \(u_4,u_5\)-geodesic.

Case 2: (\(y_3 - y_6 < \frac{s}{2}\)).

Subcase 2a: \(x_3 < x_6\).

If \(x_6>x_4\), then \(u_4\) is on a \(u_3,u_6\)-geodesic. So, \(x_4>x_6\). Also, \(y_4-y_5 > \frac{s}{2}\), since otherwise \(u_6\) is on a \(u_4,u_5\)-geodesic. If \(x_3>x_5\), then \(u_3\) is on a \(u_4,u_5\)-geodesic, so \(x_3<x_5\).

We observe that \(y_1 < y_6\), for otherwise \(u_6\) is on a \(u_1,u_5\)-geodesic. If \(x_6-x_2 > \frac{r}{2}\), then \(u_1\) is on a \(u_2,u_6\)-geodesic. Therefore, \(x_6-x_2 < \frac{r}{2}.\) This implies that \(y_2>y_5\), for otherwise \(u_5\) lies on a \(u_2,u_6\)-geodesic. But now, \(u_5\) lies on a \(u_1,u_3\)-geodesic.

Subcase 2b (\(x_3 > x_6\)).

If \(y_4-y_5 \ge \frac{s}{2}\), then \(u_3\) is on a \(u_4,u_5\)-geodesic, and if \(y_4-y_5 < \frac{s}{2}\), then \(u_6\) is on a \(u_4,u_5\)-geodesic. \(\square \)

A general position set S of \(C_7 \,\square \,C_7\) with \(|S| = 7\) is shown on Fig. 6. It can be easily checked that the minimum distance between the pairs of vertices from S is 3, and that the maximal distance is 5. Therefore, S is indeed a general position set.

Fig. 6
figure 6

General position set with seven vertices

The construction from Fig. 6 cannot be extended to arbitrary \(r,s \ge 7\). We have checked by computer that \(\mathrm{gp}(C_8\,\square \,C_7)\le 6\). In fact, 6 is also the exact lower bound in this case as follows from the following, main result of this section.

Theorem 4.5

If \(r\ge s \ge 3\), \(s\ne 4\), and \(r\ge 6\), then \(\mathrm{gp}(C_r\,\square \,C_s) \in \{6, 7\}\).

Proof

From Theorem 4.4 we know that \(\mathrm{gp}(C_r\,\square \,C_s)\le 7\). It thus remains to prove that \(\mathrm{gp}(C_r\,\square \,C_s)\ge 6\).

The condition \(s\ne 4\) assures that \(S_s = \{0,\lfloor \frac{s}{3}\rfloor ,\lfloor \frac{2s}{3}\rfloor \}\) is a gp-set of \(C_s\). The condition that \(r\ge 6\) assures that \(\lfloor r/6\rfloor \ge 1\). Consider now the set

$$\begin{aligned} S = \{&(0,0), (\left\lfloor r/2\right\rfloor ,0), (\left\lfloor r/6 \right\rfloor , \left\lfloor s/3 \right\rfloor ), (\left\lfloor r/6 \right\rfloor + \left\lfloor r/2\right\rfloor , \left\lfloor s/3 \right\rfloor ), \\&(\left\lfloor (2r)/6 \right\rfloor , \left\lfloor (2s)/3 \right\rfloor ), (\left\lfloor (2r)/6 \right\rfloor + \left\lfloor r/2\right\rfloor , \left\lfloor (2s)/3 \right\rfloor )\}\,. \end{aligned}$$

In Fig. 7 the set S is shown for the case \(C_6\,\square \,C_3\).

Fig. 7
figure 7

The set S in \(C_6\,\square \,C_3\) appears in bold

We claim that S is a general position set. Since \(C_p\)-layers are isometric subgraphs, no other vertex is on a geodesic between the pair of vertices with the same second coordinate. Hence we only need to consider the triples of vertices from S with pairwise different second coordinates. We do this for the vertices \(x_1 = (0,0)\), \(x_2 = (\left\lfloor r/6 \right\rfloor , \left\lfloor s/3 \right\rfloor )\), and \(x_3 = (\left\lfloor (2r)/6 \right\rfloor , \left\lfloor (2s)/3 \right\rfloor )\), the other cases are treated similarly. Since \(x_1, x_2, x_3\) lie in a subgraph of \(C_r\,\square \,C_s\) isomorphic to \(P_{\lfloor r/3 \rfloor + 1} \,\square \,C_s\) which is an isometric subgraph, it suffices to show that \(d(x_1,x_3) < d(x_1,x_2) + d(x_2,x_3)\). This can be verified using the facts \(d(x_1,x_3) = \lfloor r/3 \rfloor + (s - \lfloor (2s)/3 \rfloor )\), \(d(x_1,x_2) = \lfloor r/6 \rfloor + \lfloor s/3 \rfloor \), and \(d(x_2,x_3) \ge \lfloor r/6 \rfloor + \lfloor s/3 \rfloor \). \(\square \)

Theorems 4.4 and 4.5 yield the following problem, for which we believe that if \(\mathrm{min}\{r,s\} \le 6\), then \(\mathrm{gp}(C_r \,\square \,C_s) = 6\).

Problem 4.6

Determine for \(r\ge 3, r\ne 4, s\ge 6\), whether \(\mathrm{gp}(C_r\,\square \,C_s) = 6\) or whether \(\mathrm{gp}(C_r\,\square \,C_s) = 6\).

5 Cartesian Powers

In this section, we consider the general position number of Cartesian powers and obtain asymptotically exponential lower bounds using a probabilistic approach.

The n-dimensional hypercube \(Q_n\) is defined as \(K_2^{\,\square \,, n}\). In particular, \(Q_1 = K_2\), \(Q_2 = C_4\), and \(Q_3\) is the graph of the 3-D cube. Cartesian products of complete graphs, known as Hamming graphs, form a natural generalization of hypercubes. In [6], it was proved that if \(k\ge 2\) and \(n_1, \ldots , n_k\ge 2\), then

$$\begin{aligned} \mathrm{gp}(K_{n_1}\,\square \,\cdots \,\square \,K_{n_k}) \ge n_1 + \cdots + n_k - k\,. \end{aligned}$$
(1)

Moreover, this lower bound is sharp on products of two complete graphs, that is, \(\mathrm{gp}(K_{n_1}\,\square \,K_{n_2}) = n_1 + n_2 - 2\).

The situation above changes dramatically as k grows. Körner [11] obtained a probabilistic construction of general position sets in \(Q_n\) of size \(\frac{1}{2}\frac{2^n}{\sqrt{3^n}}\). He also pointed out that the problem of finding the size of the largest point set in general position in \(Q_n\) is equivalent to finding the largest size of what is called a (2, 1)-separating system in coding theory. (For more on separating systems, see [4].) Körner was interested in

$$\begin{aligned} \alpha =\limsup _{n\rightarrow \infty }\frac{\log _2\mathrm{gp}(Q_n)}{n}\,. \end{aligned}$$

His probabilistic lower bound gives \(\alpha \ge 1-\frac{1}{2}\log _23\) and he also proved \(\alpha \le 1/2\). Later, Randriambololona [17] improved the lower bound to \(\alpha \ge \frac{3}{50}\log _211\) with an explicit construction.

The first moment method can be applied in a general setting to obtain large general position sets. For any graph G, let p(G) denote the probability that if one picks a triple \((x,y,z)\in V(G)^3\) uniformly at random, then \(d_G(y,z)=d_G(y,x)+d_G(x,z)\) holds. Let us call such triples bad. Note that this is never the case if \(x\ne y\) and \(y=z\), so \(p(G)\le 1-\frac{|V(G)|-1}{|V(G)|^2}<1\). Let \(H=H_1\,\square \,\cdots \,\square \,H_k\). Observe that the triple \({\mathbf {x}}=(x_1,\dots ,x_k),{\mathbf {y}}=(y_1,\dots ,y_k),{\mathbf {z}}=(z_1,\dots ,z_k)\in V(H)\) is bad in H if and only if the triples \(x_i,y_i,z_i\) are bad in \(H_i\) for all \(i \in [k]\). So if we pick M vertices uniformly at random with repetition from V(H), then the expected value \({\mathbb {E}}(X)\) of the number \(X=X(M)\) of unordered triples on a geodesic will be \(3\left( {\begin{array}{c}M\\ 3\end{array}}\right) \prod _{i=1}^kp(H_i)\). If \(X\le M/2\), then removing one vertex from every bad triple will leave us a general position set of size at least M/2. As there is always an instance for which \(X\le {\mathbb {E}}(X)\) holds, we obtain a general position set of size M/2 provided \(3\left( {\begin{array}{c}M\\ 3\end{array}}\right) \prod _{i=1}^kp(H_i)\le M/2\) holds. Therefore, it seems to be interesting to examine

$$\begin{aligned} \mathrm{gp}_{\,\square \,}(G):=\limsup _{n\rightarrow \infty }\frac{\log _{|V(G)|} \mathrm{gp}(G^{\,\square \,, n})}{n}\,. \end{aligned}$$

Clearly, we have \(\mathrm{gp}_{\,\square \,}(G)\le 1\) and the above reasoning yields the following theorem.

For a graph G one can consider its Cartesian power \(G^{\,\square \,, n}\). Then the required inequality is \(3\left( {\begin{array}{c}M\\ 3\end{array}}\right) p(G)^n\le M/2\) which is equivalent to \((M-1)(M-2)\le p(G)^{-n}\). Thus there exists a general position set in \(G^{\,\square \,, n}\) of size \(\frac{1}{2}p(G)^{-n/2}\). This and the inequality \(p(G)\le 1-\frac{|V(G)|-1}{|V(G)|^2}\) yields the following statement.

Theorem 5.1

If G is a graph, then

$$\begin{aligned} \mathrm{gp}_{\,\square \,} (G)\ge \log _{|V(G)|}p(G)^{-1/2}\ge 1-\log _{|V(G)|}(|V(G)|^2-|V(G)|+1)\,. \end{aligned}$$

Let us calculate p(G) for some graphs. First of all, \(p(K_n)=\frac{2n-1}{n^2}\) as in \(K_n\) the equality \(d(y,z)=d(y,x)+d(x,z)\) holds if and only if \(x=y\) or \(x=z\). (The case \(p(K_2)=\frac{3}{4}\) in Theorem  5.1 is just Körner’s result.) For even cycles we have \(p(C_{2k})=\frac{k(k+3)-1}{4k^2}\). If the vertices are \(\{-(k-1),-(k-2),\dots ,0,,\dots ,k-1,k\}\) in this cyclic order, then by symmetry we can assume \(x=0\). There are \(4k-1\) triples with \(x=y\) or \(x=z\) that form bad triples. If \(y=k\) or \(z=k\), then there are no other bad triples, otherwise for any y, there are \(k-|y|\) ways to choose z to obtain a bad triple. Similarly, one can verify \(p(C_{2k+1})=\frac{k(k+3)+1}{(2k+1)^2}\). Finally, consider the star \(S_k\) with k leaves. Then conditioning on whether x is the center or not one obtains \(p(S_k)=\frac{1}{k+1}+\frac{k}{k+1}\frac{2k+1}{(k+1)^2}\). Observe that if one picks uniformly at random only among the leaves of \(S_k\), then the probability of picking a bad triple is \(p'(S_k)=\frac{2k-1}{k^2}\) which for large enough ks is roughly 2/3 of \(p(S_k)\), so in this way one obtains the better bound \(\mathrm{gp}_{\,\square \,}(S_k)\ge \log _2p'(S_k)^{-1/2}\).

Concerning \(\mathrm{gp}_{\,\square \,}(G)\) we wonder whether one can write limit instead of limit superior in the definition of \(\mathrm{gp}_{\,\square \,}(G)\). Moreover, by the above we have \(\lim _{k\rightarrow \infty }p(C_k)=\frac{1}{4}\). We also pose:

Problem 5.2

Decide whether \(\liminf _{k\rightarrow \infty }\frac{\mathrm{gp}_{\,\square \,}(C_k)}{\log _k2}>1\) holds.