The Word and Geodesic Problems in Free Solvable Groups

We study the computational complexity of the Word Problem (WP) in free solvable groups $S_{r,d}$, where $r \geq 2$ is the rank and $d \geq 2$ is the solvability class of the group. It is known that the Magnus embedding of $S_{r,d}$ into matrices provides a polynomial time decision algorithm for WP in a fixed group $S_{r,d}$. Unfortunately, the degree of the polynomial grows together with $d$, so the uniform algorithm is not polynomial in $d$. In this paper we show that WP has time complexity $O(r n \log_2 n)$ in $S_{r,2}$, and $O(n^3 r d)$ in $S_{r,d}$ for $d \geq 3$. However, it turns out, that a seemingly close problem of computing the geodesic length of elements in $S_{r,2}$ is $NP$-complete. We prove also that one can compute Fox derivatives of elements from $S_{r,d}$ in time $O(n^3 r d)$, in particular one can use efficiently the Magnus embedding in computations with free solvable groups. Our approach is based on such classical tools as the Magnus embedding and Fox calculus, as well as, on a relatively new geometric ideas, in particular, we establish a direct link between Fox derivatives and geometric flows on Cayley graphs.


Introduction
In this paper we study the computational complexity of several algorithmic problems related to the Word Problem (WP) in free solvable groups. Let S r,d be a free solvable group of rank r ≥ 2 and the solvability class d ≥ 2. We present here a uniform decision algorithm that solves WP in time O(rn log 2 n) in the free metabelian group S r,2 (also denoted by M r ), and O(n 3 rd) in the free solvable group S r,d for d ≥ 3, where n is the length of the input word. In particular, this algorithm is at most cubic in n and linear in r and d for all free solvable groups S r,d . Notice, that in all previously known polynomial time decision algorithms for WP in S r,d the degree of the polynomial grows together with d. In fact, we prove more, we show that one can compute Fox derivatives of elements from S r,d in time O(n 3 rd). This allows one to use efficiently the Magnus embedding in computations with free solvable groups. On the other hand, we describe geodesics in S r,d and show that a seemingly close problem of finding the geodesic length of a given element from S r,2 is surprisingly hardit is NP-complete. Our approach is based on such classical tools as the Magnus embedding and Fox calculus, as well as, on a relatively new (in group theory) geometric ideas from [12] and [53]. In particular, we establish a direct link between Fox derivatives and geometric flows on Cayley graphs. The study of algorithmic problems in free solvable groups can be traced to the the work [36] of Magnus, who in 1939 introduced an embedding (now called the Magnus embedding) of an arbitrary group of the type F/N ′ into a matrix group of a particular type with coefficients in the group ring of F/N (see section 2.2 below). Since WP in free abelian groups is decidable in polynomial time, by induction, this embedding immediately gives a polynomial time decision algorithm for a fixed free solvable group S r,d . However the degree of the polynomial here grows together with d.
In 1950's R. Fox introduced his free differential calculus and made the Magnus embedding much more transparent [20,21,22,23] (see also Section 2.3). Namely, besides other things, he showed that an element w ∈ F belongs to N ′ = [N, N ] if and only if all partial derivatives of w is equal to 0 in the integer group ring of F/N . This reduces WP in F/N ′ directly to the word problem in F/N . In particular, it solves, by induction, WP in S r,d . Again, the decision algorithm is polynomial in a fixed group S r,d , but the degree of the polynomial grows with d -not a surprise since the partial derivatives of w describe precisely the image of w under the Magnus embedding.
A few years later P. Hall proved the finiteness of all subdirect indecomposable finitely generated abelian-by-nilpotent groups. This implies that all finitely generated abelian-by-nilpotent, in particular, metabelian, groups are residually finite. About the same time Gruenberg extended this result to arbitrary free solvable groups [27]. Now one can solve WP in S r,d in the following way. Given w ∈ S r,d , as a word in the fixed set of generators, one can start two processes in parallel. The first one enumerates effectively all consequences of the defining relations of S r,d in F r (which is possible since the group is recursively presented) until the word w occurs, and the second one enumerates all homomorphisms from S r,d into all finite symmetric groups S n (checking if a given r-tuple of elements in S n generates a solvable group of class d) until it finds one where the image of w is non-trivial. However, computer experiments show that the algorithm described above is extremely inefficient (though its complexity is unknown).
Another shot at WP in metabelian groups comes from their linear representations. V. Remeslennikov proved in [45] that a finitely generated metabelian group (under some restrictions) is embeddable into GL(n, R) for a suitable n and a suitable ring R = K 1 × . . . × K n which is a finite direct product of fields K i . In [54], see also [55], B. Wehrfritz generalized this result to arbitrary finitely generated metabelian groups G. It follows that G is embeddable into a finite direct product of linear groups. Since WP in linear groups is polynomial time decidable this implies that WP in G is polynomial time decidable. Notice, that it is unclear if there is a uniform polynomial time decision algorithm for WP in arbitrary finitely generated metabelian groups.
In comparison, observe, that there are finitely presented solvable groups of class 3 with undecidable WP. In [34] O. Kharlampovich constructed the first example of such a group by simulating a universal Minski machine in WP of the group. There are several results which clarify the boundary between decidability and undecidability of the word problems in solvable groups, we refer to a survey [35] for details.
Our approach to WP in free solvable groups is based on the Fox Theorem mentioned above. Using binary tree search techniques and associative arrays we were able to compute Fox's derivatives of elements w of a free solvable group S d,r in time O(n 3 d), where n = |w|. Significance of this result goes beyond WP for these groups -it gives a fast algorithm to compute images of elements under the Magnus embedding. This opens up an opportunity to solve effectively other algorithmic problems in groups S r,d using the classical techniques developed for wreath products of groups.
In the second half of the paper, Section 4, we study algorithmic problems on geodesics in free metabelian groups. Let G be a group with a finite set of generators X = {x 1 , . . . , x r } and µ : F (X) → G the canonical epimorphism. For a word w in the alphabet X ±1 by |w| we denote the length of w. The geodesic length l X (g) of an element g ∈ G relative to X is defined by We write, sometimes, l X (w) instead of l X (w µ ). A word w ∈ F (X) is called geodesic in G relative to X, if |w| = l X (w). We are interested here in the following two algorithmic search problems in G.
The Geodesic Problem (GP): Given a word w ∈ F (X) find a word u ∈ F (X) which is geodesic in G such that w µ = u µ .
The Geodesic Length Problem (GLP): Given a word w ∈ F (X) find l X (w).
Though GLP seems easier than GP, in practice, to solve GLP one usually solves GP first, and only then computes the geodesic length. It is an interesting question if there exists a group G and a finite set X of generators for G relative to which GP is strictly harder than GLP.
As customary in complexity theory one can modify the search problem GLP to get the corresponding bounded decision problem (that requires only answers "yes" or "no"): The Bounded Geodesic Length Problem (BGLP): Let G be a group with a finite generating set X. Given a word w ∈ F (X) and a natural number k determine if l X (w) ≤ k.
In Section 4.1 we compare in detail the algorithmic "hardness" of the problems WP, BGLP, GLP, and GP in a given group G. Here we would like only to mention that in the list of the problems above each one is Turing reducible in polynomial time to the next one in the list, and GP is Turing reducible to WP in exponential time (see definitions in Section 4.1).
Among general facts on computational complexity of geodesics notice that if G has a polynomial growth, i.e., there is a polynomial p(n) such that for each n ∈ N cardinality of the ball B n of radius n in the Cayley graph Γ(G, X) is at most p(n), then one can easily construct this ball B n in polynomial time with an oracle for WP in G. If, in addition, such a group G has WP decidable in polynomial time then all the problems above have polynomial time complexity with respect to any finite generating set of G (since the growth and WP stay polynomial for any finite set of generators). Now, by Gromov's theorem [25], groups of polynomial growth are virtually nilpotent, hence linear, so they have WP decidable in polynomial time. It follows that all Geodesic Problems are polynomial time decidable in groups of polynomial growth (finitely generated virtually nilpotent groups). On the other hand, there are many groups of exponential growth where GP is decidable in polynomial time, for example, hyperbolic groups [15] or metabelian Baumslag-Solitar group BS(1, n) = a, t | t −1 at = a n , n ≥ 2 (see [14] and Section 4.1 for comments).
In general, if WP in G is decidable in polynomial time then BGLP is in the class NP, i.e., it is decidable in polynomial time by a non-deterministic Turing machine. It might happen though, that BGLP in a group G is as hard as any in the class NP, i.e., it is NP-complete. The simplest example of this type is due to Perry, who showed in [44] that BGLP is NP-complete in the metabelian group Z 2 wr(Z × Z) (the wreath product of Z 2 and Z × Z). Correspondingly, the search problems GP and GLP are NP-hard, which means, precisely, that some (any) NP-complete problem is Turing reducible to them in polynomial time.
Our view-point on geodesics in free solvable groups is based on geometric ideas from the following two papers. In 1993 Droms, Lewin, and Servatius introduced a new geometric approach to study WP and GLP in groups of the type F/N ′ via paths in the Cayley graph of F/N [12]. In 2004 Vershik and Dobrynin studied algebraic structure of solvable groups, using homology of related Cayley graphs [53]. This approach was outlined earlier in the papers [51,52], where possible applications to random walks on metabelian groups have been discussed. In the papers [51,52] (see also [53]) a new robust presentation of a free metabelian group S r,2 was introduced as an extension of Z r by the integer first homology group of the lattice Z r (viewed as a one-dimensional complex) with a distinguished 2-cocycle. Similar presentations of other metabelian and solvable groups laid out foundations of a new approach to algorithmic problems in solvable groups.
It seems these ideas are still underdeveloped in group-theoretic context, despite their obvious potential. Meanwhile, in semigroup theory similar geometric techniques have been widely used to deal with free objects in semidirect products of varieties. One can find an explicit exposition of these techniques in the papers due to Almeida [1] and Almeida and Weil [2], while in [48, ?, 4, 3] Auinger, Rhodes and Steinberg use similar machinery on a regular basis. Earlier, similar methods, though sometimes implicitly, were used in inverse semigroups theory, we refer here to papers [42,37,38,8].
In group theory most of the results in this area relied on various forms of the Magnus embedding and Fox derivatives. The role that the Magnus embeddings play in varieties of groups was clarified by Shmelkin [49]. In [39] Matthews proved that the conjugacy problem (CP) in free metabelian groups is decidable, and Kargapolov and Remeslennikov generalized this to free solvable groups S r,d [32]. A few years later Remeslennikov and Sokolov described precisely the image of F/N ′ under the Magnus embedding and showed that CP is residually finite in S r,d [47]. We refer to a survey [46] on algorithmic problems in solvable groups.
In Sections 2.4 and 2.5 we study elements of groups of the type F/N ′ via flows on the Cayley graph Γ of F/N . It turns out the flow generated by a word w ∈ F on the graph Γ directly corresponds to the Fox derivatives of w in the group ring ZF/N . This simple observation links together the techniques developed in group theory for the Magnus embeddings with the extensive geometric and the graph-theoretic machinery for flows. Indeed, the set of geometric circulations (flows where the Kirchhoff law holds for all vertices, including the source and the sink) form a group which is naturally isomorphic to the first homology group H 1 (Γ, Z) of Γ. In this content the geometric circulations on Γ represent precisely the 1-cycles of Γ (viewed as 1-complex). The classical result in homology theory describes H 1 (Γ, Z) as the abelianization of the fundamental group π 1 (Γ), which, in this case, is isomorphic to the free group N . Putting all these together one has another geometric proof of the Fox theorem, as well as the description of the kernel of the Magnus embedding.
In Section 2.7 we describe geodesics in groups F/N ′ as Euler tours in some finite subgraphs of Γ generated by the supports of the flows of the elements of F/N ′ on Γ. The description is geometric, explicit, and it gives a natural way to compute the geodesic length of elements. In this part geometric ideas seem unavoidable. However, this simplicity becomes treacherous when one concerns the efficiency of computations.
We prove that BGLP (relative to the standard basis) is NP-complete even in S r,2 . Consequently, the problems GP and GLP are NP-hard in S r,2 . To show this we construct a polynomial-time reduction of the Rectilinear Steiner Tree Problem (RSTP), which is NP-complete, to BGLP in S r,2 . The necessary information on RSTP is outlined in Section 4.3 and the proof of the main theorem is in Section 4.4. Notice, that in [12] GLP was claimed to be polynomial time decidable in arbitrary finitely generated free solvable groups, but the argument turned out to be fallacious.
In the second half of the 20th century free solvable groups, as well as, solvable wreath products of groups and finitely generated metabelian groups, were intensely studied, but mostly from the view-point of combinatorial groups theory. Now they stand at the heart of research in various areas of algebra. On the one hand, the rejuvenated interest to these groups stems from random walks on groups and, cohomology theory. For example, wreath products of abelian groups give exciting examples and counterexamples to several conjectures on the numerical characteristics of random walks. It seems, the main reasons that facilitate research here come from some paradoxical properties of the groups itself: all these groups are amenable (as solvable group), but they have exponential growth and may have nontrivial Poisson boundary [31], etc. These groups, contrary to, say, free nilpotent groups, may have irreducible unitary representations with nontrivial cohomology. Some numerical characteristics of these groups are very intriguing, giving new exciting examples in the quantitative group theory. For example, metabelian "lamplighter" groups have intermediate growth of the drift, positive entropy, etc. These groups were intensively studied recently (see papers [31,16] and the bibliography in the latter).
On the other hand, metabelian groups are currently at the focus of a very active research in geometric groups theory. In 1983 Gromov proposed a program for studying finitely generated groups as geometric objects [26]. One of the principal directions of this program is the classification of finitely generated groups up to quasi-isometry. It follows from Gromov's result on groups with polynomial growth [25] that a group quasi-isometric to a nilpotent group is virtually nilpotent. In the case of solvable groups the situation is much less known. Erschler shown in [13] that a group quasi-isometric to a solvable group may be not virtually solvable. Thus, the class of virtually solvable groups is not closed under quasi-isometry. On the other hand there are interesting classes of solvable non-polycyclic groups that are quasi-isometrically rigid, for example, solvable Baumslag-Solitar groups (Farb and Mosher [18,19]). We refer to the papers [41] and [17] for some recent results in this area.
It seems timely to try extend the results of this paper to the classes of solvable groups mentioned above. There are many interesting open questions concerning computational complexity of algorithmic problems in these classes of solvable groups, we discuss some of them in Section 5.
All polynomial time algorithms presented in this work are implemented and available at [10].

Acknowledgement
We would like to thank M.Sapir and B.Steinberg who brought to our attention some relevant geometric ideas from semigroup theory.

The Word Problem
Let F = F r = F (X) be a free group with a basis X = {x 1 , . . . , x r }. A subset R ⊆ F defines a presentation P = X | R of a group G = F/N where N = ncl(R) is the normal closure of R in F . If R is finite (recursively enumerable) then the presentation is called finite (recursively enumerable).
The Word Problem W P for P is termed decidable if the normal closure N is a decidable subset of F (X), i.e., there exists an algorithm A to decide whether a given word w ∈ F (X) belongs to N or not. The time function T A : F (X) → N of the algorithm A is defined as the number of steps required for A to halt on an input w ∈ F (X). We say that the Word Problem for P is decidable in polynomial time if there exists a decision algorithm A, as above, and constants c, k ∈ N such that T A (w) ≤ c|w| k for every w ∈ F (X) (here |w| is the length of the word w). In this case we say that the time complexity of WP for P is O(n k ).

Free solvable groups and the Magnus embedding
For a free group F = F (X) of rank r denote by is a free metabelian group of rank r, and S r, is a free solvable group of rank r and class d. In the sequel we usually identify the set X with its canonical images in A r , M r and S r,d .
One of the most powerful approaches to study free solvable groups is via the, so-called, Magnus embedding. To explain we need to introduce some notation. Let G = F/N and ZG the group ring of G with integer coefficients. By µ : F → G we denote the canonical factorization epimorphism, as well its linear extension to µ : ZF → ZG. Let T be a free (left) ZG-module of rank r with a basis {t 1 , . . . , t r }. Then the set of matrices forms a group with respect to the matrix multiplication. It is easy to see that the group M (G) is a discrete wreath product M (G) = A r wrG of the free abelian group A r and G.
In [36] Magnus showed that the homomorphism φ : F → M (G) defined by which is now called the Magnus embedding. The Magnus embedding allows one to solve WP in the group F/N ′ if WP in G = F/N is decidable. Indeed, given a word w ∈ F (X) one can compute its image φ(w) in M (G) (multiplying the images of the letters in w) and then, using a decision algorithm for WP in G, check if the resulting matrix φ(w) is the identity matrix or not. To estimate the complexity of such an algorithm notice first, that the coefficients from ZG that occur in the upper-right corner of the matrix φ(w) have O(|w|) summands. Secondly, to check whether or not This gives an estimate for the time function T ′ of WP in F/N ′ via the time function T for WP in F/N : where n = |w|. Since WP in A r can be decided in linear time the estimate above shows that the complexity of WP in M r is O(rn 3 ). Moreover, induction on the solvability class d gives a polynomial estimate O(r d−1 n 2d−1 ) for WP in the free solvable group S r,d . Thus, the Magnus embedding gives a straightforward polynomial time (in r and n) decision algorithm for W P in S r,d , but the degree of the polynomial grows with d. In particular, this algorithm is not polynomial as a uniform algorithm on the whole class of free solvable groups.

Free Fox derivatives
Let F = F r (X) be a free group of rank r with a basis X = {x 1 , ..., x r }. The trivial group homomorphism F → 1 extends to a ring homomorphism ε : ZF → Z. The kernel of ε is called the fundamental ideal ∆ F of ZF , it is a free (left) ZF -module freely generated by elements In [20,21,22,23] R. Fox introduced and gave a thorough account of the free differential calculus in the group ring ZF . Here we recall some notions and results referring to books [9,5,28] for details.
A map D : ZF → ZF is called a derivation if it satisfies the following conditions: where ε is the ring homomorphism defined above.
For every x i ∈ X there is a unique derivation, the so-called, a free partial derivative ∂/∂x i , such that ∂x j /∂x i = δ ij , where δ ij is the Kronecker's delta. It turned out that for every u ∈ ZF Since ∆ F is a free ZF -module the equality (1) gives another definition of the partial derivatives. Condition (D2) implies the following useful formulas, that allow one to compute easily partial derivatives of elements of ZF and, hence, for a word w = The following result is one of the principle technical tools in this area, it follows easily from the Magnus embedding theorem, but in the current form it is due to Fox [20,21,22,23].
Theorem [Fox] Let N be a normal subgroup of F and µ : F → F/N the canonical epimorphism. Then for every u ∈ F the following equivalence holds: gives rise to a ring homomorphism µ : ZF → ZS d such that Composition of ∂/∂x i with µ gives an induced partial derivative ∂ µ /∂x i : ZF → ZS d , which we often denote again by ∂/∂x i omitting µ (when it is clear from the context). Partial derivatives ∂ µ /∂x i are useful when computing images under the Magnus embedding. Indeed, by induction on the length of w ∈ F it is easy to show that the image of w, under the Magnus embedding φ : F/N ′ → M (F/N ), can be written as follows This shows that the faithfulness of the Magnus embedding is, in fact, equivalent to the Fox Theorem above.

Flows on F/N
In this section we relate flow networks on the Cayley graph of F/N to the elements of F/N ′ .
designates an edge with the origin v 1 (also denoted by o(e)), the terminus v 2 (also denoted by t(e)), labeled by x. If for e ∈ E we have o(e) = t(e) then we say that e is a loop. The graph Γ can be finite or infinite.
Given an X-digraph Γ, we can make Γ into a directed graph labeled by the alphabet The new graph, endowed with this additional structure, is denoted byΓ. In fact in many instances we abuse notation by disregarding the difference between Γ andΓ.
The edges ofΓ inherited from Γ are called positively oriented or positive. The formal inverses of positive edges inΓ are called negatively oriented or negative. The edge set ofΓ splits in a disjoint union E(Γ) = E + (Γ) ⊔ E − (Γ) of the sets of positive and negative edges.
The use ofΓ allows us to define the notion of a path in Γ. Namely, a path p in Γ is a sequence of edges p = e 1 , . . . , e k where each e i is an edge ofΓ and the origin of each e i (for i > 1) is the terminus of e i−1 . In this situation we say that the origin o(p) of p is o(e 1 ) and the terminus t(p) is t(e k ). The length |p| of this path is set to be k. Also, such a path p has a naturally defined label ν(p) = ν(e 1 ) . . . ν(e k ). Thus ν(p) is a word in the alphabet Σ = X ∪ X −1 . Note that it is possible that ν(p) contains subwords of the form aa −1 or a −1 a for some a ∈ X. If v is a vertex of Γ, we will consider the sequence p = v to be a path with o(p) = t(p) = v, |p| = 0 and ν(p) = 1 (the empty word).
In general, one can consider labels in an arbitrary inverse semigroups, the construction above applies to this case as well. In particular, we will consider directed graphs with labels in Z. We consider also digraphs with no labels at all (to unify terminology, we view them sometimes, as labeled in the trivial semigroup {1}), the construction above still applies.
Let Γ = (V, E) be an X-digraph with two distinguished vertices s (called source) and t (called sink) from V . Recall that a flow (more precisely Z-flow) on Γ is a function f : E → Z such that The condition (F) is often referred to as the Kirchhoff law (see, for example, [6,11]) or a conservation law [7].
For the digraphΓ the definition above can be formulated in the following equivalent way, which is the standard one in flow networks: Here the net flow at v is equal to Usually a flow network comes equipped with a capacity function c : E → N, in which case a flow f has to satisfy the capacity restriction In the sequel we do not make much use of the capacity function (it occurs in an obvious way), so in most cases we consider flows on graphs Γ satisfying the Kirchhoff law (F) (or, equivalently, on graphsΓ satisfying (F1) and (F2)).
A flow f is called a circulation if (F) holds for all vertices from V (including s and t).
The constant function f : E(Γ) → {1} defines a circulation on Γ, since for every vertex g ∈ V (Γ) and every label x ∈ X there is precisely one edge (gx −1 , g) with label x incoming into g and precisely one edge (g, gx) with the label x leaving g.
An important class of flows on Γ = Γ(G, X) comes from paths in Γ. A path p in Γ defines an integer-valued function π p : E(Γ) → Z, such that for an edge e π(e) is the algebraic sum (with respect to the orientation) of the number of times the path p traverses e, i.e., each traversal of e in the positive direction adds +1, and in the negative direction adds −1. It is obvious that π P is a flow on Γ with the source o(p) (the initial vertex of p) and the sink t(p) (the terminal vertex of p). Notice that π p satisfies also the following conditions: (F5) π p has finite support, i.e, the set supp(π) = {e ∈ E | π(e) = 0} is finite.
We say that a flow π on Γ is geometric if it satisfies conditions (F4) and (F5).
It is easy to see that the set C(Γ) of all circulations on Γ forms an abelian group with respect to the operations (here f, g ∈ C(Γ)): Meanwhile, the set GC(Γ) of all geometric circulations is a subgroup of C(Γ). On the other hand, the sum f + g of two geometric flows gives a geometric flow only if the sink of f is equal to the source of g, or either f or g (or both) is a circulation. In fact, the set GF(Γ) of all geometric flows is a groupoid.
Let Π(Γ) be the fundamental groupoid of paths in Γ. Then the map σ : Π(Γ) → GF(Γ) defined for p ∈ Π(Γ) by σ(p) = π p is a morphism in the category of groupoids, i.e., the following holds (here p, q ∈ Π(Γ)): Now we will show that every geometric flow π on Γ can be realized as a path flow π p for a suitable path p.
Lemma 2.4. Let π be a geometric flow on Γ. Then there exists a path p in Γ such that π = π p .
Proof. Let π be a geometric flow on Γ with the source s and the sink t. Denote by Γ π the subgraph of Γ generated by supp(π) ∪ {s, t}. Suppose Q is a subgraph of Γ such that ∆ = Γ π ∪Q is a connected graph (every two vertices are connected by a path inΓ). Clearly, π induces a flow on ∆. Now we construct another Xdigraph ∆ * by adding new edges to ∆ in the following manner. Case 1). Suppose π is a circulation. Then every vertex in ∆ * has even directed degree. Therefore, the digraph ∆ * has an Euler tour p * , i.e., a closed path at s that traverses every edge in ∆ * precisely once. Let φ : ∆ * →∆ be the morphism of X-digraphs that maps all the new edges e (1) , . . . , e |π(e)|−1 to their original edge e. Clearly, the image p = φ(p * ) is a path in∆ such that π p = π.
Case 2). Suppose π is not a circulation. Let q be a path in ∆ * from s to t. Then π ′ = π − π q is a circulation. Hence by Case 1) there exists a path p in Γ such that π ′ = π p . Therefore, π pq = π p + π q = π ′ + π q = π, as required.

Geometric interpretation of Fox derivatives
In this section we give a geometric interpretation of Fox derivatives.
Let G = F/N , µ : F → F/N the canonical epimorphism, and Γ = Γ(G, X) the Cayley graph of G with respect to the generating set X. A word w ∈ F (X) determines a unique path p w in Γ labeled by w which starts at 1 (the vertex corresponding to the identity of G). As we mentioned in Section 2.4 the path p w defines a geometric flow π pw on Γ which we denote by π w . Lemma 2.5. Let w ∈ F = F (X). Then for any g ∈ F/N and x ∈ X the value of π w on the edge e = (g, gx) is equal to the coefficient in front of g in the Fox derivative (∂w/∂x) µ ∈ ZG, i.e., Proof. Follows by induction on the length of w from formulas (3).
The following theorem has been proven in [12,53] using a homological argument similar to the one in Proposition 2.8. Here we give a short independent proof based on the Fox theorem.
Theorem 2.6. [12,53] Let N be a normal subgroup of F and ∼ N an equivalence relation on F defined by Then uv −1 ∈ N ′ hence by Fox theorem ∂ µ (uv −1 )/∂x = 0 for every x ∈ X (here by ∂ µ /∂x we denote the canonical image of ∂/∂x in the group ring Z(F/N )). Observe that so, by Lemma 2.5 π u = π v , as claimed.
To show the converse, notice first that π u = π v implies that u = v in F/N . Indeed, it can be seen from the definition of π but also follows from (1) and Lemma 2.5 since in this case and, hence, by Fox theorem uv −1 ∈ N ′ .
Remark 2.7. Theorem 2.6 relates the algebraic and geometric points of view on derivatives. One can prove this theorem (see Section 2.6) using a pure topological argument, then the Fox theorem, as well as, the Magnus embedding, come along as easy corollaries.

Geometric circulations and the first homology group of Γ
We describe here geometric circulations on Γ = Γ(G, X) in a pure topological manner. For all required notions and results on homology of simplicial complexes we refer to [30] or [50].
In this section we view Γ as an infinite 1-complex.
Proof. It was mentioned already in Section 2.4 that the map p → π p is a morphism from the fundamental groupoid Π(Γ) of paths in Γ into the groupoid of geometric flows GF(Γ). Hence, the restriction of this map onto the fundamental group π 1 (Γ) of Γ gives a homomorphism of groups. We have seen in Lemma 2.4 that σ is onto. This proves the first statement. To see 2) observe first that a geometric circulation f : E(Γ) → Z, viewed as a formal sum e∈E(Γ) f (e)e, gives precisely a 1-chain in Γ (see, for example, [30]). Moreover,by definition, the net flow f * (v) at the vertex v ∈ V (Γ) is the coefficient in front of v in the boundary ∂f of f . Therefore, ∂f = 0, so f is a 1-cycle.
3) follows easily from the 2). Indeed, Γ is an 1-complex, so there are no non-trivial 1-boundaries in Γ. In this event H 1 (Γ, Z) is isomorphic to the group GC(Γ) of 1-cycles, as claimed.
4) It is a classical result that the kernel of σ : π 1 (Γ) → H 1 (Γ, Z) is equal to the derived subgroup of π 1 (Γ) (see [30]). To prove 4) it suffices to notice that π 1 (Γ) ≃ N , which is easy. Remark 2.9. Proposition 2.8 gives a simple geometric proof of Theorem 2.6, that relates the algebraic and geometric points of view on derivatives. Now one can derive the Fox theorem from the geometric argument above and then obtain the description of the kernel of the Magnus embedding, as an easy corollary.

Geodesics in F/N ′
Let G = F/N and µ : F (X) → G the canonical epimorphism. In this section we describe geodesics of elements of the group H = F/N ′ relative to the set of generators X µ .
It is convenient to view the free group F = F (X) as the set of all freely reduced words in the alphabet X ±1 = X ∪ X −1 with the obvious multiplication.
To describe geodesics in H (relative to X) of a given word w ∈ F we need a construction from Lemma 2.4. Recall that p w is the path in the Cayley graph Γ = Γ(G, X) from 1 to w µ with the label w and π w the induced geometric flow on Γ with the source 1 and the sink w µ . By Γ w we denote the subgraph of Γ generated by supp(π w ) ∪ {1, w µ }. Suppose Q is a finite subgraph of Γ such that ∆ = Γ w ∪ Q is a connected graph and Q has the least number of edges among all such subgraphs. It follows from minimality of Q that every connected component of Q is a tree. Moreover, if in the graph ∆ = Γ w ∪ Q one collapses every connected component Γ w to a point, then the resulting graph is a tree. We refer to Q as a minimal forest for w. In general, there could be several minimal forests for w.
Similarly as in the proof of Lemma 2.4, we construct a finite X-digraph ∆ * by replicating every edge e ∈ E(∆) with ||π w (e)| − 1| new edges in such a way that every vertex in V (∆ * )−{1, w µ } has even directed degree and the map, that sends every replica of an edge e back to e (or e −1 depending on the orientation) is a morphism of X-labeled digraphs φ : ∆ * →∆. There are two cases.
• Case I. Suppose that p w is a closed path in Γ, i.e., w ∈ N . In this case every vertex in ∆ * has even degree, so ∆ * has a Euler tour, say p * Q at 1. Denote by p Q the image φ(p * Q ) of p * Q under φ. It follows from the construction (see Lemma 2.4) that p Q is a closed path at 1 in Γ such that π w = π pQ . Therefore, if w pQ ∈ F is the label of p Q then by Theorem 2.6 w = w pQ in H. Moreover, since p Q is a Euler tour in ∆ * its length, hence the length of w pQ is equal to • Case II. Suppose that p w is a not a closed path in Γ, i.e., w ∈ N . By induction on |w| it is easy to show that the vertices 1 and w µ belong to the same connected component of Γ w . Again, there exists an Euler's tour p * Q in the graph ∆ * which starts at the source and ends at the sink. Clearly, π pQ satisfies the equality (6). If u is the label of the path π pQ then π u = π pQ = π w and u is a geodesic word for w. Now, with the construction in place, we are ready to characterize geodesics in H of elements from N . • if Q is a minimal forest for w then w pQ is a geodesic for w and l X (w) = e∈supp(pw ) π w (e) + 2|E(Q)|.
• every geodesic word for w is equal (in F ) to a word w pQ for a suitable minimal forest Q and an Euler path p * Q . Proof. Let u ∈ F be a geodesic word for w µ in H. Observe, that ∆ = supp(π u )∪ p u is a connected subgraph of Γ and Now, by Theorem 2.6 the equality u = w in H implies π u = π w . In particular, supp(π u ) = supp(π w ). Hence |p u | ≥ e∈supp(pw ) π w (e) + 2|E(∆ − supp(π w ))|.
Since u is geodesic for w the number |∆ − supp(π w )| is minimal possible, so Q = ∆ − supp(π w ) is a minimal forest for w. In fact, the equation 7 shows that the converse is also true. This proves the theorem.
The discussion above shows that GP is easy in F/N ′ provided one can solve the following problem efficiently.
Minimal Forest Problem (MFP) Given a finite set of connected finite subgraphs Γ 1 , . . . , Γ s in Γ find a finite subgraph Q of Γ such that Γ 1 ∪ . . . ∪ Γ s ∪ Q is connected and Q has a minimal possible number of edges. Proposition 2.11. GP in F/N ′ (relative to X) is linear time reducible to MFP for Γ(F/N, X).
Proof. Follows from the discussion above. Indeed, given a word w ∈ F one can in linear time compute the flow π w and find the connected components Γ 1 , . . . , Γ s of supp(π w ) ∪ {o(p w ), t(p w )} in Γ = Γ(F/N, X). Then, solving MFP for these components, one gets the subgraph Q which makes the graph Γ 1 ∪ . . . ∪ Γ s ∪ Q connected. Obviously, it takes linear time to find a Euler path in the graph ∆, hence to find a geodesic for w.

The Word Problem in free solvable groups
In this section we present fast algorithms to compute Fox derivatives of elements of a free group F in the group ring ZS r,d of a free solvable group S r,d . As an immediate application, we obtain a decision algorithm for WP in a free metabelian group M r with time complexity O(rn log 2 n) and a decision algorithm for WP in S r,d , d ≥ 3, with time complexity O(rdn 3 ). These are significant improvements in comparison with the known decision algorithms discussed in Introduction and Section 2.2. As another application we get a fast algorithm to compute images of elements from S r,d under the Magnus embedding, which opens up an opportunity to use efficiently the classical techniques developed for wreath products.

The Word Problem in free metabelian groups
In this section we compute Fox derivatives of elements of F in the group ring Z(F/F ′ ). Then we apply this to WP in free metabelian groups.
Let On each step k we either extend the domain Dom(S k ) of S k or change the value of S k on some element from Dom(S k ). To do this we need a data structure which allows one to do the following operations efficiently: • for a given (a, i) determine if (a, i) ∈ Dom(S k ) or not; • add (a, i) to Dom(S k ) if (a, i) ∈ Dom(S k ) and define S k (a, i) = q for some q ∈ Z; • change the value of S k on (a, i) if (a, i) ∈ Dom(S k ).
Every element a ∈ A can be written uniquely in the form a = x  (δ 1 (a), . . . , δ r (a)) to represents a. It follows from the formula (3) for partial derivatives that for every (a, i) ∈ Dom(S w ) the components δ j (a) of δ(a) satisfy the inequality |δ j (a)| ≤ |w|, as well as the values of S w and, hence, |S w (a, i)| ≤ |w|. Therefore, it takes ⌈log 2 (|w| + 1)⌉ bits to encode one coordinate δ j (a) (one extra bit to encode the sign + or −), r⌈log 2 (|w| + 1)⌉ bits to encode δ(a), and at most r⌈log 2 (|w| + 1)⌉ + ⌈log 2 r⌉ bits to encode (a, i). We denote the binary word encoding (a, i) by (a, i) * .
Thus every function S k can be uniquely represented by a directed {0, 1}labeled binary tree T k with the root ε and with leaves labeled by integers such that (a, i) ∈ Dom(S k ) if and only if there exists a path in T k from the root ε to a leaf labeled by the code of (a, i) and such that the leaf of this path is labeled precisely by the integer S k (a, i). Notice, that the height of T k is equal to r⌈log 2 (|w| + 1)⌉ + ⌈log 2 r⌉. Such a tree is visualized schematically in Figure  2. Remark 3.1. It is clear that one can perform every operation mentioned above on this data structure in at most r⌈log 2 (|w| + 1)⌉ + ⌈log 2 r⌉ elementary steps.
We use this data structure to design the following algorithm for computing S w . (1) if ε j = 1 then * check if there is a path (from the root to a leaf) labeled by (δ(a), i j ) * in S; * if such a path does not exist in S then create it, add it to S, and put 1 as the corresponding value at the new leaf; * if such a path exists in S then add 1 to the value at its leaf.
(2) if ε j = −1 then * add ε j to the i j th coordinate of δ(a); * check if there is a path (from the root to a leaf) labeled by (δ(a), i j ) * in S; * if such a path does not exist in S then create it, add it to S, and put −1 at the corresponding leaf; * if such a path exists in S then subtract 1 from the value at its leaf.
C. Output S n . Proof. Using the formula (3)   Computations.
• Apply Algorithm 3.2 to compute S w .
• Check, looking at the values assigned to leaves of S w , if all Fox derivatives ∂w/∂x i , i = 1, . . . , r are equal to 0 or not.
• If all the derivatives are 0 then output T rue. If there is a non-zero derivative then output F alse.

The Word problem in free solvable groups
In this section we present an algorithm to compute all Fox derivatives of a word w ∈ F in the group ring ZS r,d−1 , d ≥ In Section 3.1 we used a unique representation of elements a ∈ A r by their coordinate vectors δ(a) to compute Fox derivatives in nearly linear time. Now we do not have such normal forms of elements of S r,d , d ≥ 2, so our computations are slightly different, however, the general strategy is quite similar. To speed up computations we use some data structures based on efficient partitioning techniques.
In general, let G be a group generated by X and D a finite subset of F (X). A G-partition of D is a partition of D into a union of disjoint non-empty subsets D i such that for any u, v ∈ D, u = v in G if and only if they belong to some subset D i . Clearly, the G-partition of D is unique. Observe that if a group H is a quotient of G then the G-partition of D is the same or finer than the H-partition of D.
If the set D is ordered, say D = {w 0 , . . . , w n } then the G-partition of D can be represented by a function P : {0, . . . , n} → {0, . . . , n} where P (j) = i if and only if w i = w j in G and i is the smallest with such property. Given the G-partition P of D one can arrange his data in such a way that it takes linear time (in the size of j) to compute P (j). In particular, given i, j one can check in linear time if w i = w j in G. Also, for a given word w ∈ D one can find in linear time an index i such that w = w i . These are the main two subroutines concerning partitions of D. Let We order the set D w as follows w 0 = ε, . . . , w n = w. Now, to check whether or not the derivative ∂w/∂x i is trivial in ZS r,d−1 one has to determine which pairs (w i , w j ) of elements from D w represent the same element in S r,d−1 and then cancel out w i with w j in ∂w/∂x i if they have the opposite signs. The goal of Algorithm 3.10 below is to compute S r,d -partition for D w . This is performed in a sequence of iterations. The algorithm starts out by computing the A r -partition of D w . On the second iteration the algorithm computes the M r -partition of D w . On the third step it computes the S r,3 -partition of D w . It continues this way until it computes the S r,d -partition of D w .
To explain how the algorithm works assume that the S r,d−1 -partition of D w is given by the partition function P d−1 described above. Notice, that the S r,dpartition of D w is the same or finer than the S r,d−1 -partition of D w , since S r,d−1 is a quotient of S r,d . This shows that to construct S r,d -partition P d of D w one has only to compare elements from D w which are equal in S r,d−1 . Suppose that w s , w t ∈ D w , s < t and w s = w t in S r,d−1 . To check if w s = w t in S r,d we compare all their Fox derivatives in ZS r,d−1 , so for every k = 1, . . . , r we compute the following differences: Clearly, given w and s, as above one can compute the formal expression (9) in time O(|w|). To check if (9), viewed as an element in ZS r,d−1 , is equal to 0 it suffices to represent it in the standard group ring form g∈S r,d−1 mg (where m ∈ Z) and verify if all coefficients in this representation are zeros. Now we describe a particular procedure, termed Collecting Similar Terms Algorithm, which gives the standard group ring form for (9). Given (9) one can compute in time O(|w|) the following sum Observe now, that two summands w p and w q in (10) are equal in S r,d−1 if and only if p = q. It is easy to see that it takes time O(|w|) to collect similar terms in (10), i.e., to compute the coefficients in the standard group ring presentation of (10). It follows that ∂w s /∂x k = ∂w t /∂x k in ZS r,d−1 if and only if all the coefficients in the standard group ring form of (10) are equal to 0. The argument above shows that one can check whether or not ∂w s /∂x k = ∂w t /∂x k in ZS r,d−1 in time O(|w|). Since we need to compare all partial derivatives ∂/∂x k , k = 1, . . . , r, of the elements w s and w t it takes altogether O(r|w|) time to verify if w s = w t in S r,d−1 .
The routine above allows one to construct effectively the S r,d -partition P d of D w when given the S r,d−1 -partition P d−1 . A more formal description of the algorithm is given below. Algorithm 3.6. (Computing the S r,d -partition of D w ) Input. Positive integers r ≥ 2, d ≥ 2, and a word w ∈ F (X). Output. The S r,d -partition function P d for the set D w . Initialization. Compute the set D w and form the initial (trivial) F -partition P 0 of D w , so P 0 (i) = i for every i ∈ {0, . . . , n}.

Computations.
A. Compute A-partition P 1 of D w .
B. For c = 2, . . . , d do: 1) For each 0 ≤ s < t ≤ n such that w s = w t in S r,c−1 check whether or not w s = w t in S r,c .
2) Form the S r,c -partition P d of D w .
C. Output P d .
Lemma 3.7. Given integers r, d ≥ 2 and w ∈ F Algorithm 3.6 computes the Proof. Algorithm 3.6 makes precisely d iterations c = 1, . . . , d by consequently computing the S r,c -partitions of D w . After the S r,c−1 -partition of D w is computed, the algorithm computes the S r,c -partition of D w by comparing elements w s , w t ∈ D w in S r,c . It requires at most |w|(|w| + 1)/2 such checks, and, as was explained above, every such check can be done in time O(r|w|). Altogether one needs O(r|w| 3 ) steps to construct the function P c on the iteration c. Since the algorithm makes altogether d iterations it takes it O(dr|w| 3 ) time to produce P d , as claimed.
Now we are in a position to show two applications of Algorithm 3.6. The first one concerns with computing Fox derivatives in ZS r,d . Proof. Follows from Lemma 3.7.
The second application of Algorithm 3.6 is to WP in S r,d . Output. T rue if w = 1 in S r,d and F alse otherwise.

Computations.
A. Compute the set D w .
B. Using Algorithm 3.6 compute S r,d -partition P d of D w .
C. If P d (0) = P d (n), i.e., 1 = w in S r,d , then output T rue. Otherwise output F alse. Proof. Follows immediately from Lemma 3.7.

Geodesics in free metabelian groups
In this section we discuss the computational hardness of different variations of Geodesic problems and prove the main result about NP-completeness of BGLP in free metabelian groups.

Algorithmic problems with geodesics in groups
Let G be a group with a finite set of generators X = {x 1 , . . . , x r } and µ : F (X) → G the canonical epimorphism. In this section we view the free group F (X) as the set of all freely reduced words in the alphabet X ±1 = X ∪ X −1 with the obvious multiplication. For a word w in the alphabet X ±1 by |w| we denote the length of w. The geodesic length of an element g ∈ G relative to X, denoted by l X (g), is the length of a shortest word w ∈ F (X) representing g, i.e., l X (g) = min{|w| | w ∈ F (X), w µ = g}.
To simplify notation we write, sometimes, l X (w) instead of l X (w µ ). A word w ∈ F (X) is called geodesic in G relative to X, if |w| = l X (w).
We are interested here in the following algorithmic search problem in a given group G described as above.
The Geodesic Problem (GP): Given a word w ∈ F (X) find a geodesic (in G) wordw ∈ F (X) such that w µ =w µ .
One can consider the following variation of GP.

The Geodesic Length Problem (GLP):
Given a word w ∈ F (X) find l X (w).
Though GLP seems easier than GP (since a solution to GP gives, in linear time, a solution to GLP), in practice, to solve GP one usually solves GP first, and only then computes the geodesic length.
As customary in complexity theory one can modify the search problem GLP to get the corresponding bounded decision problem: The Bounded Geodesic Length Problem (BGLP): Let G be a group with a finite generating set X. Given a word w ∈ F (X) and a natural number k determine if l X (w) ≤ k.
It is instructive to compare the algorithmic "hardness" of the problems above and the Word Problem (WP). Clearly, if one of them is decidable then all of them are decidable. To see the difference we need to recall a few definitions. Let A and B be algorithmic problems with inputs sets I A and I B . Then A is termed Turing reducible to B in polynomial time, if there exists an algorithm A with an oracle for B (which can be viewed as a "subroutine" of A that for a given input e ∈ I B in one step returns the answer for B on e) that solves A in polynomial time. Similarly, one can define Turing reducibility in exponential time. In these cases we write A T,p B or, correspondingly, A T,exp B.
Again, it is not hard to see W P T,p BGLP T,p GLP T,p GP . Moreover, since (by brute force algorithm) GP T,exp W P it follows that all these problems are Turing reducible to each other in exponential time. Moreover, if G has polynomial growth, i.e., there is a polynomial p(n) such that for each nN cardinality of the ball B n of radius n in the Cayley graph Γ(G, X) is at most p(n), then one can easily construct this ball B n in polynomial time with an oracle for the WP in G (see, for example, [12] for details). It follows that if a group with polynomial growth has WP decidable in polynomial time then all the problems above have polynomial time complexity with respect to any finite generating set (since the growth and WP stay polynomial for any finite set of generators). Observe now, that by Gromov's theorem [25] finitely generated groups of polynomial growth are virtually nilpotent. It is also known that the latter have WP decidable in polynomial time (nilpotent finitely generated groups are linear). These two facts together imply that the Geodesic Problem is polynomial time decidable in finitely generated virtually nilpotent groups.
On the other hand, there are many groups of exponential growth where GP is decidable in polynomial time, for example, hyperbolic groups [15]. Among metabelian groups the Baumslag-Solitar group BS(1, 2) = a, t | t −1 at = a 2 has exponential growth (it is solvable but not polycyclic -and the claim follows from the Milnor theorem [40]) and GP in BS(1, 2) is decidable in polynomial time (see [14]).
In general, if WP in G is polynomially decidable then BGLP is in the class NP, i.e., it is decidable in polynomial time by a non-deterministic Turing machine. Indeed, if l X (w) ≤ k then there is a word u ∈ F (X) of length at most k which is equal to w in G -this u is a "witness" of polynomial size which allows one to verify in polynomial time that l X (w) ≤ k (just checking that u = w in G). In this case GLP is Turing reducible in polynomial time to an NP problem, but we cannot claim the same for GP. Observe, that BGLP is in NP for any finitely generated metabelian group, since they have WP decidable in polynomial time (see Introduction).
It might happen though, that WP in a group G is polynomial time decidable, but BGLP in G is as hard as any problem in the class NP, i.e., it is NP-complete. Recall (in the notation above) that a decision problem B is NP-complete if it is in NP and for any decision problem A from NP there is a computable in polynomial time function f : I A → I B (Karp reduction, or a polynomial reduction), such that A is true on x ∈ I A if and only if B is true on f (x). The simplest example of this type is due to Perry, who showed in [44] that BGLP is NP-complete in the metabelian group Z 2 wr(Z × Z) (the wreath product of Z 2 and Z × Z). In this event, the search problems GP and GLP are called NP-hard, this means precisely that some (any) NP-complete problem is a Turing reducible to them in polynomial time.
It would be very interesting to classify finitely generated metabelian groups with respect to computational hardness of their GP or GLP problems. In the next section we clarify the situation with free metabelian groups. Some remaining open problems are discussed in Section 5.
It was claimed in [12] that in free solvable groups of finite rank GLP is decidable in polynomial time. Unfortunately, in this particular case their argument is fallacious. Our main result of this section is the following theorem. Proof. The proof of this result consists of two parts. Firstly, in Section 4.2 (Corollary 4.5) we show that it suffices to prove that BGLP is NP-complete in M 2 . Secondly, in Section 4.4 (Theorem 4.11) we give a proof that BGLP is, indeed, NP-complete in M 2 .
This immediately implies the following results. To prove the Main Theorem we reduce the problem to the case r = 2 and then show that BGLP in M 2 is NP-complete. To see the latter we construct a polynomial reduction of the Rectilinear Steiner Tree Problem to BGLP in M r .

Reduction to M 2
Let V be a variety of groups. For groups A, B ∈ V we denote by A * V B the free product of A and B relative to V. In particular, if A = X | R , and As usual, A * V B satisfies the canonical universal property: any two homomorphism A → C, B → C into a group C ∈ V extends to a unique homomorphism A * V B → C (we refer to [43] for details). It follows The following lemma claims that free V-factors of a group G are isometrically embedded into G. Lemma 4.3. Let A, B ∈ V with finite generating sets X and Y . Then in the group A * V B no geodesic word (relative to X ∪Y ) for an element from A contains a letter from Y . In particular, for any word w ∈ F (X) its geodesic length in A (relative to X) is equal to the geodesic length in A * V B (relative to X ∪ Y ).
Proof. Let w ∈ F (X) be a geodesic word in A relative to X. Suppose that u ∈ F (X ∪ Y ) is a geodesic word in G = A * V B (relative to X ∪ Y ) that defines the same element as w. The identical map A → A and the trivial map B → 1 give rise to a homomorphism φ : G → A. This φ, when applied to u, just "erases" all letters from Y . It follows that if u contains a letter from Y then |u φ | < |u| ≤ |w| -contradiction with the assumption that w is geodesic in A relative to X (since w = u φ in A).
Corollary 4.4. In the notation above, each of the problems GP, GLP, BGLP in A (relative to X) is polynomial time reducible to the problem of the same type in A * V B (relative to X ∪ Y ).
Notice, that M n+m = M n * A2 M m , where A 2 is the variety of all metabelian groups. Since WP is in P for groups from M Corollary implies the following result.
Corollary 4.5. If BGLP is NP-complete in M 2 then it is NP-complete in M r , r ≥ 2, relative to the standard bases.
Remark 4.6. Corollary 4.5 easily generalizes to free groups in an arbitrary variety, provided they have WP decidable in polynomial time.

Rectilinear Steiner Tree Problem
The Steiner Tree Problem (STP), which was originally introduced by Gauss, is one of the initial twenty one NP-complete problems that appeared in the Karp's list [33]. We need the following rectilinear variation of STP.
Let R 2 be the Euclidean plane and Γ the integer grid canonically embedded into R 2 (all vertices from Z 2 together with all the horizontal and vertical lines connecting them). If A is a finite subset of Z 2 then a rectilinear Steiner tree (RST) for A is a subgraph T of Γ such that A ∪ T is connected in Γ. By s(T ) (size of T ) we denote the number of edges in T . An RST for A is optimal if it has a smallest possible size among all RST for A, we denote such RST by T A . Observe, that a given A may have several different optimal RST, but their size is the same, we denote it by s(A).
Notice that, in general, T A for A is not a spanning tree for A in Γ, it may contain some vertices from Z 2 which are not in A (so-called, Steiner points). The Rectilinear Steiner Tree Problem (RSTP) asks for a given finite A ⊆ Z 2 and k ∈ N decide if there exists some T A for A with s(T A ) < k. It is known that RSTP is NP-complete [24].

NP-completeness of BGLP in M 2
Now we construct a polynomial reduction of RSTP to GLDP in M 2 relative to the standard basis X = {x, y}.
With each point (s, t) ∈ Z 2 we associate a word y). Similarly, with a set of points A = {(s 1 , t 1 ), . . . , (s n , t n )} ⊂ Z 2 , ordered in an arbitrary way, we associate a word w si,ti .
Observe, that the word w s,t , as well as w A , belongs to F ′ = [F, F ], so in M 2 they define elements from M ′ 2 . In particular, the path p wA is a closed path in the grid Γ = Z 2 , which is viewed as the Cayley graph of the abelianization F/F ′ .
To prove the second statement, notice first that s(mA) ≤ ms(A). Indeed, stretching T A by the factor of m along all horizontal and vertical lines gives some RST for mA, hence the claim.
On the other hand, s(A) < s(mA)/m. To see this, observe that by Theorem 4.7 there exists R = T mA which lies inside the grid mZ × mZ. Since the coordinates of all vertices in R are multiples of k one can shrink R by the factor of m, in such a way that the image of R becomes an RST for A. Clearly, the size of the image is equal to s(T mA )/m, hence the result. Proposition 4.9. Let A be a finite subset of Z 2 , (b, c) ∈ A, and n = |A|. Put A * = 10n (A − (b, c)). Then l X (w A * ) ∈ [20ns(A), 20ns(A) + 4n].
Proof. Let u be a geodesic word for w A * relative to the basis X. Since w A * ∈ F ′ the paths p u and p w A * are closed paths in Γ = Z 2 (viewed as the Cayley graph of M 2 /M ′ 2 ). Hence u and w A * determine the same circulations π u = π A w * on Γ. As described in Section 2.7, the flow π u is associated with the subgraph Γ u generated in Γ by supp(π u ) ∪ {(0, 0)}. It follows from the construction of the word w A * that the connected components of Γ u are precisely the 1 × 1-squares in Γ, whose lower-left corners are located at the points from A * . Notice that (0, 0) ∈ A − (b, c) hence (0, 0) ∈ A * . Now, if Q is a minimal forest for u (a subgraph of Γ of minimal size that makes the graph Γ u ∪ Q connected in Γ) then by Theorem 2.10 |u| = l X (w A * ) = e∈supp(pu) π u (e) + 2|E(Q)| = 4n + 2|E(Q)|. (11) Observe, that an optimal RST T A * for A * also makes the graph Γ u ∪Q connected in Γ, hence |E(Q)| ≤ s(A * ). Therefore, l X (w A * ) ≤ 20ns(A) + 4n.
On the other hand assume that |u| = l X (w A * ) < 20ns(A). Hence, from (11), there exists a minimal forest Q for A * such that 2|E(Q)| < 20ns(A) − 4n. Since every connected component has precisely 4 edges and there are n such components, it follows that there is an RST for A * of size strictly less than 10ns(A) -contradiction with Corollary 4.8. This proves the proposition. Corollary 4.10. Let A be a finite subset of Z 2 and k ∈ N. In the notation above, s(A) < k ⇐⇒ l X (w A * ) < 20nk + 4n.
In particular, this gives a polynomial reduction of RSTP to BGLP in M 2 relative to X.
Theorem 4.11. GLDP in a free metabelian group M 2 is NP-complete.
Proof. Corollary 4.10 gives a polynomial reduction of RSTP in Z 2 to BGLP in M 2 . Therefore BGLP in M 2 is NP-hard. Meanwhile, as was mentioned above BGLP for M 2 is in NP, since WP in M 2 is polynomial.

Open Problems
Denote by M the class of all finitely generated metabelian groups.
Problem 5.1. Describe groups in M with GP in P. In particular, the following partial questions are of interest here: • Are there any groups in M with GP not in P?
• Do polycyclic groups from M have GP in P?
• Describe wreath products of two f.g. abelian groups have GP in P?
Notice, since WP is in P for groups from M, it follows that GLP is at most in NP (Turing reducible in P time to BGLP which is in NP). This makes the following problem very interesting.
Problem 5.2. Classify groups in M with NP-complete BGLP. In particular, the following partial questions are of interest: • Do polycyclic groups from M have GLP in P?
• Is it true that a wreath product of finitely generated abelian groups AwrB has NP-complete BGLP if A = 1 and the torsion-free rank of B is at least 2?
Clearly, GLP is polynomial time reducible to GP. On the other hand, it is not clear if there are finitely presented (or finitely generated) groups where GP is not polynomial time reducible to GLP. It would be interesting to clarify the situation in the class M. To this end we post the following