{'fraction_non_alphanumeric': 0.04846674041213835, 'fraction_numerical': 0.013764554277047291, 'mean_word_length': 3.5135886349598517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 83, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A polynomial bound on solutions of quadratic equations in free groups

We provide polynomial upper bounds on the size of a shortest solution for quadratic equations in a free group. A similar bound is given for parametric solutions in the description of solutions sets of quadratic equations in a free group.


Introduction
Let G be a group and X a countable set of variables. An equation in G is an element E of the free product G * F X where F X is the free group freely generated by X. Usually we write equations in the classical form E = 1 where E is a word over G ∪ X ±1 representing a reduced product in G * F X . Elements of G occurring in E are called coefficients of an equation E = 1. A solution of E = 1 in G is a homomorphism α : G * F X → G such that g α = g for every g ∈ G (so-called G-homomorphism) and E α = 1. Sometimes it is convenient to consider the quotient G E = G * F X /(E = 1) of G * F X modulo the normal subgroup generated by E, called the equation group of E = 1. In this case solutions of E = 1 in G are precisely G-homomorphisms G * F X → G. (Observe that if E = 1 has a solution then G embeds into G E .) In general, there are two natural problems concerning equations from a given class E. The first one is the famous Diophantine problem: does there exist an algorithm to check whether or not a given equation from E has a solution in a group G. The second problem is to get an effective description of the set of solutions of an equation in E.
A word E and an equation E = 1 are termed quadratic if every variable x ∈ X occurring in E (as x or x −1 ) occurs precisely twice. Quadratic equations form a very special class among equations of a general form in groups. However, they play an important role in several areas of mathematics. This is not very surprising since quadratic equations are naturally related to the topology of compact surfaces (see for example [7,24] and Section 2 below). Quadratic equations groups naturally appear in JSJ-decompositions of groups (via QH subgroups) and as group actions of dynamical systems (via interval exchange). Moreover, quadratic equations play a fundamental part in general theory of equations in groups and algebraic (Diophantine) geometry over groups [2,15,16,14,28]. It has been shown by Kharlampovich and Myasnikov [15,16] that every system of equations in a free group is rationally equivalent to finitely many systems in non-degenerate triangular quasiquadratic form (NTQ), which gives a precise analog of the elimination theory from the classical algebraic geometry, with proper extension theorems and nice algorithmic properties (for details see surveys [17,18]). NTQ systems are crucial in Implicit Function Theorems in free groups [14] and Tarski problems [19,28].
The theory of quadratic equations in a free group F goes back to the works of Lyndon [20] and Malcev [22], who described, correspondingly, all solutions of the equation x 2 y 2 z 2 = 1 and The first author has been supported by the Russian Foundation for Fundamental Research .
[x, y] = [a, b] (here x, y, z ∈ X are variables and a, b ∈ F are the generators of F ). Malcev anticipated several modern techniques, introducing automorphic equivalence of solutions and focusing on minimal solutions in each automorphic orbit. In [30] Wicks gave a decision algorithm for the Diophantine problem for equations of the type W = g (g ∈ F ). He showed that the problem of solving such an equation can be effectively reduced to solving finitely many particular equations in a free monoid with involution (via "Wicks forms").
In [5], Comerford and Edmunds proved that the Diophantine problem for arbitrary quadratic equations in a free group F is decidable. Later Comerford and Edmunds [6] and Grigorchuk and Kurchanov [11] completely described solution sets of quadratic equations in free groups (the result will be formulated below in this section).
In 1982, Makanin [23] proved that the Diophantine problem in free groups is solvable, and a few years later Razborov [25] gave a description of solutions of systems of equations in free groups. These two very influential papers shaped the modern theory of equations in groups. Note that the description of solutions sets of quadratic equations given in [6,11] is a very special case of Razborov's description for general equations.
Techniques for solving equations in free and related groups were instrumental in solution of some other decision problems in group theory: for example, the isomorphism problem in hyperbolic groups [27,9], limit groups [3], and toral relatively hyperbolic groups [8].
In view of applications, the principal question concerning equations in groups is the time complexity of decision algorithms. It has been shown by Bormotov, Gilman, and Myasnikov [1] that one-variable equations in a free group admit polynomial time decision algorithms. Ol'shaskniȋ [24] and Grigorchuk and Kurchanov [11] proved that if the number of variables is fixed then the Diophantine problem for quadratic equations in free groups has a decision algorithm polynomial in the sum of the lengths of the coefficients. However, this is as far as one can go in polynomial time. First, Diekert and Robson showed in [10] that the Diophantine problem for quadratic equations in free monoids (semigroups) is NP-hard. Then Kharlampovich, Lysenok, Myasnikov and Touikan proved that the Diophantine problem for quadratic equations in free groups is precisely NP-complete [13]. Nevertheless, a few important questions remained to be open, above all, the question whether decidable quadratic equations in free groups have solutions polynomially bounded in the size of the equation.
The affirmative answer to this question is given by the following theorem. Here a quadratic word Q is orientable if every variable x occurring in Q occurs in Q with two opposite exponents as x and x −1 and non-orientable otherwise, that is, if a variable occurs in Q twice with the same exponent +1 or −1.
Theorem 1.1. Let Q be a quadratic word. If the equation Q = 1 is solvable in a free group F A then there exists a solution α such that for any variable x, for some constant N. Here n(Q) denotes the total number of variables in Q and c(Q) the total length of coefficients occurring in Q. One can take N = 40 for orientable Q and N = 150 for non-orientable Q.
If Q is standard orientable or semi-standard non-orientable (see Definitions 2.2 and 3.4) then there exists α with a better bound with N = 8 and N = 36 respectively.
In a similar manner, we give a bound on the size of parametric solutions of quadratic equations which participate in the description of their solution sets. To state the result we need to define a concept of a parametric solution. Let T be an alphabet of parameters which is assumed to be disjoint from the alphabet of constants A and alphabet of variables X. A parametric solution of an equation E = 1 in F A is an F A -homomorphism η : F A∪Var(E) → F A∪T such that E η = 1 where Var(E) denotes the set of variables occurring in E. If η is a parametric solution of E = 1 then for any F A -homomorphism ψ : F A∪T → F A we get a solution ηψ of E = 1 in the usual sense, a specialization of η. Note that we use here a notion of a solution of an equation E = 1 in a free group F A which is slightly different from one introduced above. Instead of taking F A -homomorphisms of F A∪X we restrict them to the free group F A∪Var(E) involving only variables which occur in E. This provides a more convenient way for describing all possible solutions of a given equation E = 1.
Let Stab(E) denote the group of all F A -automorphisms φ of F A∪Var(E) such that E φ is conjugate to E. This group acts on the solution set of E = 1 by left multiplications. Hence any parametric solution η produces a whole bunch of solutions in the usual sense, the union of orbits of specializations of η: The above mentioned result of Comerford-Edmunds [6] and Grigorchuk-Kurchanov [11] asserts that for any quadratic equation E = 1 in F A there is (and can be effectively produced) a finite set {η i } of basic parametric solutions such that the set of all solution of E = 1 is the union ∪ i Sol(η i ).
Let η and θ be two parametric solutions of the same equation E = 1 in F A . Let us say that η is a generalization of θ if there are an automorphism φ ∈ Stab(E) and an endomorphism ω ∈ End F A (F A∪T ) such that θ = φηω. Clearly, in this case we have Sol(η) ⊇ Sol(θ). Theorem 1.2. Let Q = 1 be a quadratic equation in a free group F A . Then any parametric solution of Q = 1 has a generalization η such that for any variable x, the length of x η is bounded by the same function as in Theorem 1.1 with c(Q) replaced by c(Q) + 2n(Q).
In particular, there is a finite set of basic parametric solutions of Q = 1 satisfying this bound.
Note that a simple description of solution sets (in terms of basic parametric solutions) is known for coefficient-free quadratic equations. In this case, only one basic solution is enough. Moreover, if an equation is in the standard form then the value of each variable in the basic parametric solution is either a parameter letter or trivial, see [12,Section 5]. This basic parametric solution is a generalization of every other parametric solution, so the theorem does not give much in this case.
The proof of Theorems 1.1 and 1.2 has three main constituents. In Section 3 we produce various automorphisms that allow to transform quadratic words to a desired form. In particular, we re-prove a well known fact (closely related to the classification theorem for compact simplicial surfaces, see for example [26,Chapter VI]) that a quadratic word can be equivalently transformed to a word belonging to one of the four standard series, see Proposition 2.1. However, in our proof, we provide an "economical" transformation (Propositions 3.3, 3.5, 3.7, 3.9 and 3.10.) As a corollary we formulate a general result on the bound on the complexity of automorphisms which reduce a given quadratic word to the standard form over any group G.
Corollary 3.11. Let Q ∈ G * F X be quadratic word over an arbitrary group G. Then there are automorphisms φ, ψ ∈ Aut G (G * F X ) such that Q φ and Q ψ are conjugate to the standard quadratic words equivalent to Q and for any variable x, where c(Q) is the total length of coefficients of Q expressed in any left-invariant (e.g. word) metric on G.
Note that we provide here bounds for two different automorphisms: for the direct transfor- The reason is that a bound on a automorphism φ of a free group F does not imply a reasonable bound on its inverse φ −1 ; in particular, see Example 3.8 below.
As the next step of our argument we develop a version of the elimination process for quadratic equations in a free group. To do this, we define a certain set of transformations on pairs of the form (Q, α) where Q is a coefficient-free quadratic word and α is an evaluation of variables in Q, i.e. an F A -homomorphism F A∪Var(Q) → F A . Then we define a certain transformation sequence starting from a given pair (Q, α) whose primary goal is to eliminate cancellations in the formal word Q[α] obtained by substituting in Q of the value x α of each variable x. Our approach is essentially an improved version of similar approaches used in [5,6,11] for description of solution sets of quadratic equations in a free group. We start in Section 4 with a lighter version of it, with no care about transformation homomorphisms, and prove Proposition 4.6 sufficient for the proof of Theorem 1.1. Our full version of the eliminated process is elaborated in Section 6 for the proof of Theorem 1.2.
Note that there is an alternating (and essentially equivalent) approach to solutions of quadratic equations in free groups using Lyndon-van Kampen diagrams on surfaces, see for example [24]. Though this approach provides a clear geometric vision, an advantage of using elimination process is an easier control of transformation homomorphisms.
The final ingredient to the proof is a statement about Lyndon-van Kampen diagrams (Proposition 5.4) which says that a diagram can be unfolded in an economical way.

Quadratic words and surfaces
In this section, we recall some elementary concepts and formulate some known facts about quadratic words. The free group F A and a countable set X of variables will be fixed throughout the whole paper. The following fact is well known (see for example [12,Section 4]). Proposition 2.1. By an F A -automorphism of F A∪X , every quadratic word can be reduced to one of the following forms: , . Here x i , y i and z i are variables and c i ∈ F A , c i = 1, are coefficients. The proof of the proposition essentially repeats the proof of the classification theorem for compact surfaces, see for example a classical topology textbook [26,. In the next section we refine the proof and formulate a series of propositions that the reduction automorphism can be chosen economically in terms of its size.
The series of quadratic words in Proposition 2.1 represent the four series of compact surfaces: closed orientable surfaces of genus g, closed non-orientable surfaces of genus g, orientable surfaces of genus g with m boundary components and non-orientable surfaces of genus g with m boundary components, respectively.
The relation between quadratic words and surfaces relies upon the following simple observation. Let Q be a quadratic word. Take a 2-disk D with boundary ∂D divided into |Q| arcs. Choose an orientation of the boundary ∂D and label the arcs with letters of Q in the order they appear in Q (instead of x −1 we put x and direct the arc in the opposite to the orientation of ∂D). Then for each variable x occurring in Q, glue together the two arcs labelled by the two occurrences of x in Q, according to their orientation. We get a 2complex S Q representing a compact surface. The surface is closed if Q is coefficient-free and has a boundary otherwise. (See Fig. 1 where Q = x −1 ay −1 bxcyd and S Q is homeomorphic to a torus with a disk removed.) Directed edges of 2-complex S Q carry in a natural way labels in A ±1 ∪X ±1 . The edges in the interior of the surface are labelled by variables in Var(Q) and edges in the surface boundary labelled by letters in A ±1 which come from coefficients of Q. In case of orientable S Q we fix a positive direction of passing along each boundary component which agrees with the chosen orientation of the boundary of disk D. In this case, we view the label of the boundary component as an element of F A defined up to conjugacy. If S Q is non-orientable then labels of boundary components are viewed as elements of F A defined up to conjugacy and taking the inverse.
The topological type of S Q may be different from the topological type of S R where R is a standard form of Q from Proposition 2.1. It is not hard to see that if the label c of a boundary component of S Q represents the trivial element of F A then the corresponding boundary component disappears in S R . We introduce an extra reduction step for S Q : if c is trivial, attach a 2-disk along the corresponding boundary component of S Q . We denoteS Q the resulting surface. Definition 2.3. Let Q be a quadratic word. We call the unordered tuple of all nontrivial labels of boundary components of S Q , viewed as elements of F A , the standard coefficients of Q. As remarked above, the standard coefficients are defined up to conjugacy if S Q is orientable and up to conjugacy and taking inverses if S Q is non-orientable.
Definition 2.4. Two quadratic words Q and R are equivalent ifS Q andS R have the same topological type and their tuples (c 11 , . . . , c m1 ) and (c 12 , . . . , c m2 ) of standard coefficients are the same up the the natural equivalence: if S Q is orientable then up to enumeration, each c i1 is conjugate to the corresponding c i2 ; if S Q is non-orientable then up to enumeration, each c i1 is conjugate to either c i2 or c −1 i2 . With a slight abuse of the language, we call a quadratic word Q itself orientable if S Q is an orientable surface and non-orientable otherwise. It is immediate from the construction of S Q that Q is orientable if and only if each variable in Q has two occurrences with different exponents −1 and +1. By the genus of Q we mean the genus of S Q .
Thus, any quadratic word Q is defined up to equivalence by the following parameters: orientability (true/false), the genus g and the tuple of standard coefficients (c 1 , . . . , c m ). Proposition 2.1 asserts precisely that any quadratic word can be reduced by an F A -automorphism of F A∪X to an equivalent standard quadratic word.
The following fact may be attributed to folklore. (We don't make use of it in the paper and provide only a sketch of the proof.) Proposition 2.5. Let Q, R ∈ F A∪X be two quadratic words. Then the following statements are equivalent: Sketch of the proof: To prove implication (i)⇒(ii), we reduce two given equivalent quadratic words to equivalent standard forms by Proposition 2.1. It is then an easy exercise to show that two equivalent standard quadratic words are images of each other under an F Aautomorphisms of F A∪X (one can use also automorphisms from Lemmas 3.13 and 3.14 below). Implication (iii)⇒(i) follows easily from the following statement: If Q, R ∈ F A∪X are quadratic words and R is conjugate to Q φ for some φ ∈ Aut F A (F A∪X ) then φ may be represented as a product τ 1 τ 2 . . . τ k of elementary Nielsen F A -automorphisms τ i such that the cyclically reduced form of Q τ 1 ...τ i is a quadratic word for each i. To prove the statement, we use the Higgins-Lyndon approach to stabilizers in Aut(F ) as exposed in Lyndon and Schupp's book [21,Section I.4]. We apply a modified version of Proposition I.4.23 of [21] to one cyclic word u 1 = Q and the tuple of non-cyclic words u i , i ≥ 2, consisting of all letters a ∈ A. By this proposition, φ can be represented as a product φ = ρ 1 ρ 2 . . . ρ r of Whitehead automorphisms ρ i such that for some p and q, 0 ≤ p ≤ q ≤ r − 1, . . , r − 1 where, by definition, Q 0 = Q and Q i is the cyclically reduced form of Q ρ 1 ρ 2 ...ρ i . Then it is not hard to see that in each of the chains can be factored into a sequence of elementary Nielsen automorphisms which keep the property of a word being quadratic.

Transforming quadratic words
In this section, we describe several specific transformations of quadratic words to produce equivalent quadratic words of a desired form. By a transformation we mean application of an F A -automorphism of F A∪X (or an F C -automorphism of F C∪X where F C is the group of formal coefficients, see below).
By |W | we denote the length of an element of a free group written as a frely reduced word. The notation |W | x will be used for the total number of occurrences of a letter x in W . More generally, is S is a set of letters then |W | S will denote the total number of occurrences in W of letters from S. Sometimes we consider formal (not necessarily freely reduced) words W . In this case, |W | denotes the length of W .
For automorphisms of a free group F Y , we use a notation which means that φ maps generator x ε i i to W i and does not change other generators. We describe several types of elementary transformations φ applied to a quadratic word Q ∈ F A∪X and producing an equivalent quadratic word Q φ , or, in a weaker form, an equivalent quadratic word conjugate to the image Q φ of Q.
Permutations and exponent sign changes of variables: Permutations on the set of variables and automorphisms of the form (x → x −1 ). These automorphisms always carry quadratic words into equivalent ones. We will implicitly assume that automorphisms of this type are applied if needed. For example, to transform a word Q 1 to a given word Q 2 it is enough to find an automorphism φ ∈ Aut F A (F A∪X ) such that Q φ 1 is equal to Q 2 up to renaming variables and changing their exponent signs.
Multiplications by coefficients: Automorphisms of the form (x ε → x ε d), d ∈ F A . Any automorphism of this form carries any quadratic word to an equivalent one. We will use only the special case when x ε d −1 or dx −ε occurs in Q as a subword. We refer to these transformations as coefficient shifts. Geometrically, we shift the start of the edge labelled x ε along the boundary arc of S Q labelled d −1 from the start of this arc to its end (Fig. 2). This automorphism does not change S Q unless the corresponding boundary component is labelled by the trivial element and there are two occurrences of (x ε d −1 ) ±1 in Q (Fig. 3). In this case, this boundary component disappears (but the topological type of the reduced surfaceS Q is not changed).   Introductions of new variables: Nielsen automorphisms of the form (x ε → x ε y δ ) where a variable y does not occur in Q.
Related Nielsen automorphisms: Nielsen automorphisms (x ε → x ε y δ ) related to Q, that is, those for which (x ε y −δ ) ±1 occurs in Q. Geometrically, we shift the start of the edge labelled x ε along the edge labelled y δ , see Fig. 4. If (x ε y −δ ) ±1 occurs in Q ±1 twice then y is eliminated from Q. If we view Q as a cyclic word then for any Nielsen automorphism ρ related to Q, the image Q ρ is conjugate to a quadratic word equivalent to Q. It is sometimes convenient to view transformations of quadratic words from a slightly different angle-through formal coefficients. This means that we introduce a new alphabet C of formal coefficients and consider quadratic words in Q ∈ F C∪X with the property that each coefficient letter c ∈ C occurs in Q at most once. To get a quadratic word in the usual sense (as an element of F A∪X ) we have to provide it with a coefficient map F C → F A .
Thus we have two ways of representing quadratic words: as an element of F A∪X and as a pair (Q, γ) where Q is a quadratic word with formal coefficients and γ is a coefficient map. An advantage of the second way is that quadratic words can be viewed independently on the coefficient group which may be not necessarily free. We use this representation since it provides a more convenient accounting of lengths of coefficients occurring in transformations.
Note that all elementary transformations introduced above are applicable also to quadratic words with formal coefficients (just with F A replaced by the formal coefficient group F C ). If a pair (Q, γ) represents a quadratic word R ∈ F A∪X then transformations of Q induce corresponding transformations of R.
In the rest of the section we assume that quadratic words are ones with formal coefficients and belong to the group F C∪X .
We prove a series of statements asserting that a quadratic word can be reduced to a standard form using an automorphism of bounded complexity. Note that the notion of a standard quadratic word is essentially not changed when passing to words with formal coefficients. It is required only that any formal coefficient occurs in the coefficients c i of a standard quadratic word at most once in total.
Definition 3.1. We call automorphisms of the form (x ε → W x ε ) where x does not occur in W , elementary.
We say that an elementary automorphism (x ε → W x ε ) changes x and touches variables occurring in W .
A product ρ 1 ρ 2 . . . ρ k of elementary automorphisms ρ i is triangular if it satisfies the following condition: as soon as ρ i touches x, the variable x is not changed by all subsequent automorphisms ρ i+1 , . . . , ρ k .
The following observation is immediate: be a triangular product of elementary automorphisms of a free group F . For a generator x, let W i 1 , W i 2 , . . . , W ir be all words W i which participate in automorphisms (x i → W i x i ) with x i = x and ε i = 1, and W j 1 , W j 2 , . . . , W jt be all words W i which participate in In particular, for any generator y = x, the number of occurrences of y in x φ does not exceed the total number of occurrences of y in all W i k and W j k . Proposition 3.3. Let Q ∈ F C∪X be an orientable quadratic word. Then there exists an automorphism φ ∈ Aut F C (F C∪Var(Q) ) such that Q φ is conjugate to a standard quadratic word equivalent to Q and for any x, y ∈ Var(Q) and c ∈ C, we have |x φ | y ≤ 4 and |x φ | c ≤ 2.
In particular, |x φ | ≤ 2|Q| for any x ∈ Var(Q), Proof. We construct the required automorphism φ as a triangular product of elementary automorphisms. Starting from this point throughout the proof, we denote by Q the current quadratic word after application of a sequence of elementary automorphisms constructed so far. At the start, Q is any quadratic word from the hypothesis of the proposition. We view Q as a cyclic word and thus regard transformations up to conjugation. We assume that Q has at least one variable (otherwise the proposition is trivial). At any moment, there are locked variables in Q which have been touched by previous elementary automorphisms. They should not be changed by subsequent elementary automorphisms.
By Γ Q we denote the 1-skeleton of S Q , i.e. the graph embedded in the surface after the identification of arcs in the boundary of disk D as described in Section 2.
Step 1: Eliminating boundary superfluous vertices. If S Q is a closed surface then Step 1 is void and we jump to Step 2. Recall that S Q is closed if and only if Q is coefficient-free.
We call a vertex ν in the boundary of S Q essential if it is an endpoint of an interior edge of S Q (i.e. an endpoint of an edge labelled by a variable).
Let ℓ be a boundary component of S Q . Observe that ℓ has at least one essential vertex (since Q has at least one variable). We describe a sequence of elementary automorphisns which result in exactly one essential vertex in ℓ. Let ν 1 , . . . , ν k be all cyclically ordered essential vertices in ℓ. Let c ∈ F A be the label of the arc between ν 1 and ν 2 and x 1 , . . . , x r ∈ X ±1 be labels of edges starting at ν 2 so that cx 1 , Fig. 5). We apply to Q a sequence of elementary automorphisms eliminating essential vertex ν 2 . Then we proceed in the same way eliminating all other essential vertices ν 3 , . . . , ν k .
We repeat the procedure for all other boundary components of S Q . After that, each boundary component will have exactly one essential vertex. Their labels are the standard coefficients of Q. There are no locked variables after this step.
Step 2: Eliminating inner superfluous vertices. We choose a base vertex ν 1 of Γ Q as follows. If Q is coefficient-free we take any vertex of Γ Q . If Q has a coefficient then for the base vertex we take any essential vertex in the boundary of S Q .
Suppose that Γ Q has a vertex ν = ν 1 in the interior of S Q . Let e 1 , . . . , e k be all directed edges starting at ν, labelled by variables x 1 , . . . , x k ∈ X ±1 . Since ν and ν 1 are connected by a path in Γ Q , at least one of e i , say e 1 , ends in a vertex ν ′ distinct from ν. Then we apply a sequence of elementary automorphisms Observe that x 1 does not occur in the new word Q ψ , so the locked variable x 1 will not participate in the subsequent automorphisms.
We perform elimination of all vertices ν = ν 1 in the interior of S Q . After that, if Q is coefficient-free then Γ Q has only one vertex ν 1 . If Q has a coefficient then Γ Q has m vertices ν 1 , . . . , ν m , one in each boundary component of S Q .
Step 3: Collecting coefficient factors. We assume here that Q has at least one coefficient. If Q is coefficient-free, we jump to Step 4.
The step consists of a sequence of substeps 3 1 , 3 2 , . . . , 3 m−1 . Before step 3 i , Q has the form and c j ∈ F A and W has no locked variables. Recall that Q is viewed as a cyclic word, so at the start of step 3 we have Q = c 1 W for some W and coefficient c 1 .
If no coefficients occur in W then we stop. Suppose that a coefficient occurs in W . Since Γ Q is connected, there is an edge in Γ Q starting at ν 1 and ending in a boundary component of S Q distinct from ones labelled by c 1 , c 2 , . . . , c i . Let z i+1 ∈ X ±1 be such an edge (for convenience we identify edges with their labels) and ν i+1 its endpoint in a boundary component labelled c i+1 .
Step 3 i consists of the following. Using related Nielsen automorphisms and coefficient shifts, we first shift starting vertices of all interior edges of S Q at ν i+1 other than z −1 i+1 to a new position at ν 1 along the path labelled z −1 i+1 or the path labelled c i+1 z −1 i+1 (see Fig. 6). Next, if there are edges starting at ν 1 between z i and z i+1 , we shift them one by one along After that, Q gets the form W ′ and we iterate the procedure. Finally we come to a word of the form If R is empty we get the desired standard quadratic word. Otherwise we proceed to the next step 4.
Observe that all edges of Γ Q labelled by variables occuring in R start and end at the same vertex ν 1 . In this case, we define a star word R * as the sequence of labels of edges labelled by variables in R when moving around ν 1 in a small neighborhood of ν 1 . To fix the direction of the motion we agree that if x ε y δ occurs in R * then y −δ x ε occurs in R. If Q has a coefficient then R * is the word read off between the edges of Γ Q labelled the starting letter of c 1 and z m (see Fig. 7). If Q is coefficient-free then R = Q and we view R * as a cyclic word.
Observe that R * is an orientable quadratic word of the same length and with the same variables as R.
Step 4: Collecting commutators. We assume that Q has a coefficient; the coefficient-free case is similar with obvious minor changes. Figure 7.
At any stage of this step, we do not change the coefficient part of Q already collected, so Q has the above form where R is a coefficient-free quadratic word. We will apply only related Nielsen automorphisms involving variables of R. This implies that all edges of Γ Q labelled by variables in R start and end at the same vertex ν 1 . The whole step 4 is again an iterative sequence of smaller steps 4 1 , . . . , 4 g . Before sub- where T and T * are orientable quadratic words with Var(T ) = Var(T * ); in particular, |T | = |T * |.
We stop if T and T * are empty. Assume that T and T * are nonempty. Let x i be a variable occurring in T , so We claim that at least one variable y i occurs in V exactly once. Indeed, if V is a (possibly empty) quadratic word then a quadratic wordV lies between the two occurrences of In this case the edge of Γ Q labelled x i would wave distinct endpoints, a contradiction.
Hence, up to interchanging x i and y i and changing their exponent signs we have The following sequence of automorphisms collects the commutator [y i , x −1 i ] when applied to T * : It is straightforward to check that for any Nielsen automorphism ρ related to T * there is a dual Nielsen automorphism ρ * related to T whose action on T agrees with the action of ρ on T * , that is, ( We observe that if ρ changes x and touches y, then the role of these variables in ρ * is interchanged. This implies that there is a sequence ψ of related Nielsen automorphisms touching only x i and y i which transforms T to a word T ψ where as required. This finishes step 4 i . After completion of this procedure Q gets the standard form. We get an automorphism φ reducing to such a form an arbitrary quadratic word from the hypothesis of the proposition. Calculation of the bounds for φ. Fix a variable x ∈ Var(Q). Let W 1 , W 2 , . . . W k be the list of all words W in elementary automorphisms (x ε → W x ε ) which are the factors of φ. We claim that any variable y = x occurs in all W i in total at most 4 times. Indeed, at each individual step 2, 3 or 4, y occurs at most twice in the automorphisms of the form (x → W x) and at most twice in the automorphisms of the form (x −1 → W x −1 ). It remains to observe that if y participates (i.e. occurs in some W ) at step 2 or 3 then y does not participate in subsequent steps. By Lemma 3.2 we get From the construction it is easy see also that each constant c ∈ C occurs in |x φ | at most twice. This implies This finishes the proof of Proposition 3.3.
Definition 3.4. We call a non-orientable quadratic word Q semi-standard if Q has one of the following forms Proposition 3.5. Let Q ∈ F C∪X be a non-orientable quadratic word. Then there exists an automorphism φ ∈ Aut F C (F C∪Var(Q) ) such that Q φ is conjugate to a semi-standard quadratic word equivalent to Q and for any x, y ∈ Var(Q) and c ∈ C, we have |x φ | y ≤ 4 and |x φ | c ≤ 2.
Proof. The steps 1-3 are the same as in the case of orientable S Q . After performing these three steps we get The rest of reduction consists of the following step.
Step 4 n : Collecting squares and commutators. As in the orientable case, we will work with the star word R * . Unfortunately, the definition of R * given in the proof of Proposition 3.3 suits only for orientable R since it always produces an orientable R * . We modify the definition.
For any edge e of S Q , we fix its orientation which is a choice of the positive direction of crossing e inside S Q . When passing around the base vertex ν 1 , we read the label x of e with exponent +1 if we cross e in the positive direction and −1 otherwise (so the exponent signs of variables in R * are not related directly to the exponent signs of the corresponding occurrences in R). It is easy to check that application of a related Nielsen automorphism ρ = (x ε → y δ x ε ) to R * agrees with application of a dual Nielsen automorphism ρ * related to R that changes y and touches x.
Let e be an edge of Γ Q labelled by a variable x ∈ Var(R). If e reverses the orientation when viewed as a loop in S Q then we cross e twice in the same direction when passing around ν 1 . Hence the both occurrences of x in R * have the same exponent sign. Since there is at least one orientation-reversing e, R * is a non-orientable quadratic word. Thus, up to the exponent sign of x, R * has the form R * = Z 1 xZ 2 xZ 3 . We then collect the square of x: is non-orientable then we repeat the procedure collecting the square of a variable to the right. Otherwise we apply the procedure of collecting commutators described in Step 4 in the orientable case. Using a triangular sequence of elementary automorphisms we finally reduce Q to the form The bound on φ is obtained in the same way as in the orientable case.
To define θ k we proceed in a similar way by taking for γ another automorphism Proposition 3.7. Let Q ∈ F C∪X be a non-orientable quadratic word. Then there exists an automorphism φ ∈ Aut F C (F C∪Var(Q) ) such that Q φ is conjugate to a standard quadratic word equivalent to Q and for any Proof. Proposition 3.5 and Lemma 3.6 produce an automorphism φ ∈ Aut F C (F C∪Var(Q) ) such that Q φ is conjugate to a standard quadratic word equivalent to Q and where k is the number of commutators in the semi-standard form given by Proposition 3.5. It remains to notice that k ≤ 1 2 (genus(Q) − 1).
We turn now to bounds similar to Propositions 3.3, 3.5 and 3.7 where we estimate the size of the automorphism inverse to φ. Note that the sizes of an automorphism φ of a free group F and of its inverse φ −1 can be very different. We give an example where the ratio is exponential in the rank of F .
It is not hard to see that ||φ −1 || = 2 n . Proposition 3.9. Let Q ∈ F C∪X be any quadratic word. Then there exists an automorphism ψ ∈ Aut F C (F C∪Var(Q) ) such that Q ψ is conjugate to a quadratic word R equivalent to Q and the following assertions are true: (i) R is standard if Q is orientable and semi-standard if Q is non-orientable.
(ii) For any x, y ∈ Var(Q) and c ∈ C, we have |x ψ −1 | y ≤ 4 and |x ψ −1 | c ≤ 2. In particular, Proof. Similarly to the arguments used in the proof of Propositions 3.3 and 3.5, we view Q as a cyclic word and construct ψ so that the inverse automorphism ψ −1 will be a triangular product of elementary automorphisms. The condition that ψ −1 is triangular is equivalent to the condition that ψ is reverse triangular in the following sense: if a variable x is changed by some elementary automorphism in the product then x is not touched by subsequent elementary automorphisms. If fact, the proof will be simpler than the proof of Propositions 3.3 and 3.5 because there is no need to pass to the star word and we will operate on the quadratic word Q itself.
According to the change in the notion of a triangular product, we change the notion of a locked variable: a variable x is viewed as locked at a current transformation step if it was previously changed by an elementary automorphism. Subsequent elementary automorphisms should not touch locked variables. Similar to the proof of Propositions 3.3 and 3.5, we collect locked variables to a fixed part of Q. Thus, at any moment Q has the form LR where L is the locked part of Q and R has no locked variables. At the start, L is empty and since Q is viewed a cyclic word, we assume without loss of generality that R starts with a coefficient letter.
We proceed in two steps.
Step 1 i : Reducing the coefficient-free part.
If R is non-orientable then R = Z 1 xZ 2 xZ 3 for some variable x. Using a sequence of elementary automorphisms similar to one given in Step 4 n in the proof of Proposition 3.5 we collect x 2 to the left of R and add it to the locked part.
If R is orientable and there are variables x and y which "cross" in R, that is, R = Z 1 x −1 Z 2 y −1 Z 3 xZ 4 yZ 5 (up to exponent signs of x and y) then we collect the commutator [x, y] to the left of R as in Step 4 in the proof of Proposition 3.3.
Iterating the procedure, we reduce Q to the form where R is orientable and has no crossing variables.
Step 2 i : Collecting the coefficient part. If R has no variables then we are done. Let Var(R) = ∅. By the assumption that R has no crossing variables, there is a variable z with no variables between the two occurrences of z in R.
It remains to observe that at any transformation step, we preserve the property that R starts with a coefficient letter and so c 1 = 1.
From Proposition 3.9 and Lemma 3.14 we get a dual version of Proposition 3.7.
Proposition 3.10. Let Q ∈ F C∪X be a non-orientable quadratic word. Then there exists an automorphism ψ ∈ Aut F C (F C∪Var(Q) ) such that Q ψ is conjugate to a standard quadratic word equivalent to Q and for any x, y ∈ Var(Q) and c ∈ C, we have |x ψ −1 | y ≤ 8 genus(Q) and |x ψ −1 | c ≤ 4 genus(Q).
Passing from quadratic words with formal coefficients to quadratic words Q ∈ G * F X over a group G we can easily formulate a general result for an arbitrary coefficient group G.
Corollary 3.11. Let Q ∈ G * F X be quadratic word over an arbitrary group G. Then there are automorphisms φ, ψ ∈ Aut G (G * F X ) such that Q φ and Q ψ are conjugate to standard quadratic words equivalent to Q and for any variable x, is the total length of coefficients of Q expressed in any left-invariant (e.g. word) metric on G.
Proof. For orientable Q this follows from Propositions 3.3 and 3.9. If Q is non-orientable then we have to use Propositions 3.7 and 3.10 and inequality genus(Q) ≤ n(Q).
In the end of the section, we formulate several lemmas for later use. The first one was in fact proved in the proof of Proposition 3.9 (unlike the proposition, we do not make a passage to a conjugate element here).
Proof. Using the automorphism Lemma 3.14. Let . . , ε m = ±1, be two non-orientable quadratic words of the same genus g with the same set of coefficient letters {c 1 , . . . , c m }. Then there is an automorphism ψ of F {c 1 ,...,cm}∪Var(Q 1 ) such that c ψ i = c i for all i, with the following properties: Proof. We use the following set of automorphisms: We pick up x 2 q with q = min{k, r} and move it to the right of Q 1 so that the square/commutator part becomes the same as in Q 2 and each constant c i gets the exponent sign ε i as in Q 2 . The bounds in (ii) are straightforward.

An elimination process for quadratic words
There is a general approach to solutions of equations in free and similar groups which may be called elimination process. It usually deals with pairs (E, α) where E = 1 is an equation in a group F and α is its solution. On the set of such pairs, a certain set of transformations is defined. The idea is to reduce step-by-step the cancellation which appears after substituting α into E and then, starting from a given pair (E, α), to get a new pair (E 1 , α 1 ) of bounded complexity. In particular, solvability of equation E = 1 is reduced to existence of a solution of bounded complexity of finitely many such equations E 1 = 1 which can be algorithmically checked. To describe the solution set of E = 1 one needs in addition to track transformations homomorphisms. (There are several ways to define them; for example, in the case of a free group F = F A a transformation homomorphism from a pair (E, α) to a pair (E 1 , α 1 ) can be viewed as an endomorphism φ : F A∪X → F A∪X such that E φ = E 1 and α = φα 1 .) For free groups, an elimination process has been applied in its full strength by Razborov [25] to provide a description of solutions of an arbitrary system of equations in free groups. In the case of quadratic equations, there is a much simpler version in [5,6,11].
In this section, we apply a version of the elimination process to pairs of the form (Q, α) where Q ∈ F X is a coefficient-free quadratic word and α is an evaluation of variables of Q, i.e. a homomorphism F X → F A . We use the process to give a bound on the size of some solution of a related quadratic equation and thus do not need to track transformation homomorphisms. A more sophisticated version (with tracking transformation homomorphisms) will be used in Section 6 to obtain bounds on the size of parametric solutions.
Let (Q, α) be a pair where Q ∈ F X is a coefficient-free quadratic word and α : F X → F A is an evaluation of variables of Q. We define several types of elementary transformations which carry (Q, α) to a new pair (Q 1 , α 1 ). In all cases, there will be a transformation homomorphism φ ∈ End(F X ) such that Q 1 = Q φ (but we do not require that α = α 1 φ). As one of the main inductive parameters, we take the length of a formal word Q Degenerate transformation. Application condition: x α = 1 for some x ∈ Var(Q). We do not change α and apply the homomorphism φ = (x → 1) to Q, so Q 1 is obtained from Q by removing all occurrences of x and performing subsequent cancellation.
We introduce a natural notion related to this transformation. We say that a coefficient-free The following fact is an easy exercise. Proposition 4.1. Let Q 1 and Q 2 be coefficient-free quadratic words. Then Q 2 is a homomorphic image of Q 1 if and only if either Q 1 and Q 2 are of the same orientability and genus(Q 2 ) ≤ genus(Q 1 ) or Q 1 is non-orientable, Q 2 is orientable and genus(Q 2 ) < 1 2 genus(Q 1 ).
Cancellation reduction. Application condition: a non-trivial cancellation in Q[α] occurs between the values of two neighboring variables x ε and y δ (ε, δ = ±1). There are two cases.
Case 1: x = y. Then for some u, v and w = 1, where equality stands for graphical equality of words. We take a variable z / ∈ Var(Q) and define a transformation homomorphism φ by Case 2: x = y. Then x ε y δ becomes (x ε ) 2 and for some u and w = 1, In a similar manner, we take φ = (x ε → z −1 x ε z) and define α 1 by (x ε ) α 1 = u, z α 1 = w. After application of this transformation we get a pair (Q 1 , α 1 ) which satisfies the strict inequality Splitting a variable. Application condition: x is a variable in Q with x α = 1. We introduce a new variable y / ∈ Var(Q) and apply to Q the substitution φ = (x → xy). For α 1 , we take any homomorphism F X → F A such that x α 1 y α 1 = x α , the product x α 1 y α 1 is reduced and α 1 coincides with α on all variables other than x and y.
As an illustration, we prove a well known fact. 30]). Let w ∈ F A be a value of a coefficient-free quadratic word Q. Then there exists a homomorphic image R of Q and an evaluation β : F X → F A such that x β = 1 for all x ∈ Var(R), the word R[β] is freely reduced and equals to w.
Proof. Let w = Q α . We start with the pair (Q, α) and apply degenerate transformations and cancellation reductions until possible. For the resulting pair (R, β), R and β are as required.
is a value of a coefficient-free non-orientable quadratic word of genus g then w can be represented as a product u 2 Proof. Let Q be the quadratic word from the hypothesis and let w = v −1 w 1 v where w 1 is cyclically reduced. By Proposition 4.2 and Lemma 3.12, there is a standard orientable or semi-standard non-orientable quadratic word R and an evaluation β of variables in R such that R is a homomorphic image of Q, R β = w 1 and |x β | ≤ 2|w 1 | for every variable x ∈ Var(R). If needed by we add to R extra commutators or squares with new variables y with values y β = 1 so that R becomes equivalent to Q. The required u i 's and v i 's are obtained by conjugating the values x β with v.
In what follows, we apply an elimination process to a pair (Q, α) where α is a solution of a standard quadratic equation written in the form Our goal is to find a solution of this equation satisfying the bound from Theorem 1.1. To do this, using elimination process we find first a short (in a certain sense) solution of an equivalent quadratic equation of the same form, for given fixed elements c 1 , . . . , c m ∈ F A . Then, by using an "economical" automorphism from Section 3 we reduce the equation to the ininial form thus producing the required "short" solution of the original equation (1).
Instead of keeping fixed the element Q α during transformations as in the proof of Proposition 4.2 we will keep the property that Q α is a product of conjugates of fixed elements c 1 , . . . , c m ∈ F A (that is, w = u −1 1 c 1 u 1 . . . u −1 m c m u m for some u 1 , . . . , u m ), up to changing exponent signs of c i in the non-orientable case.  . . , c m ∈ F A be cyclically reduced elements of F A . We say that w is a unsigned product of conjugates of c 1 , . . . , c m if w is a product of conjugates of c ε 1 1 , . . . , c εm m for some ε 1 , . . . , ε m = ±1. We say that w is a short unsigned product of conjugates of c 1 , . . . , c m if w, viewed as a freely reduced cyclic word, does not have a form w = uhvh −1 where h is non-empty and the set {c i } can be properly partitioned into two subsets {c p i } and {c q i } so that u is a unsigned product of conjugates of c p i 's and v is a unsigned product of conjugates of c q i 's.
It is not hard to prove that if w is a short or short unsigned product of conjugates of c 1 , . . . , c m then then |w| ≤ |c i |. This is essentially a consequence of the van Kampen lemma, see Lemma 5.5 below.
Proposition 4.6. Let c 1 , c 2 , . . . , c m ∈ F A and Q be a coefficient-free (orientable or nonorientable) quadratic word of genus g. Suppose that the quadratic equation (i) If Q is orientable then a short product of conjugates of c 1 , . . . , c m is a product of at most g commutators in F A . (ii) If Q is non-orientable then a short unsigned product of conjugates of c 1 , . . . , c m is a product of at most g squares in F A .
Proof. We consider first the case of orientable Q. Let α be a solution of the equation from the hypothesis of the proposition. We describe a sequence of transformations starting with the pair (Q, α). Any moment we will have a coefficient-free quadratic word R and a homomorphism β : F X → F A such that R is a homomorphic image of Q and R β is a product of conjugates of c 1 , . . . , c m . For the inductive parameter that will be decreased during transformations, we take the pair (|R β |, |R[β]|) with lexicographic ordering. Recall that |R β | denotes the length of the freely reduced word representing R β and |R[β]| denotes the length of the formal word R[β].
If x β = 1 for some variable x ∈ Var(R) then we apply the degenerate transformation (x → 1) to (R, β) decreasing the number of variables in R. The element R β and the formal word R[β] are not changed.
If R[β] has a cancellation then we apply a cancellation reduction so that R β is not changed but the length of R[β] decreases.
If R[β] has a cyclic reduction then we change β by conjugating all the values x β with the same element of F A decreasing the length of R β . Observe also that using this operation we can change R β to its any cyclic shift not increasing parameter (|R β |, |R[β]|).
Thus we assume that R[β] is cyclically reduced (and hence is the cyclically reduced form of R β ) and all variables x in R have non-trivial values x β = 1.
Suppose that R β is not a short product of conjugates of c 1 , . . . , c m , that is, up to a cyclic shift we have R β = uhvh −1 where u, v and h = 1 are as in Definition 4.4. Splitting variables if needed we may assume that h and h −1 are values of single variables in R, that is, We replace β by a new evaluation β 1 such that the length of cyclically reduced form of R β decreases and R β 1 is still a product of conjugates of c 1 , . . . , c m . After that we go back to the start of our procedure replacing R β 1 by its cyclically reduced form. There are two cases.
Case 1: x 1 = x 2 . We define x β 1 = 1 and leave the values of all other variables unchanged. Then R β 1 = (UV ) β = uv and by the condition of Definition 4.4, R β 1 is a product of conjugates of c 1 , . . . , c m .
The description of the transformation sequence is finished. After finitely many steps we get a pair (R, β) such that R β is a short product of conjugates of c 1 , . . . , c m . Since R is a homomorphic image of Q, it is a product of at most g commutators in F X . This proves (i).
In the non-orientable case, the argument is similar with the difference that we keep R β being an unsigned product of conjugates of c 1 , . . . , c m . (In Case 2, if x 1 occurs in R twice with the same exponent ε then some exponent signs of c 1 , . . . , c m are changed after the transformation.)

Unfolding Lyndon-van Kampen diagrams
Using Proposition 4.6 and automorphisms from Section 3 it is not difficult to get a bound on the size of the shortest solution of a standard quadratic equation in F A . The bound is Nn(Q)c(Q) in the case of orientable Q and and Nn(Q) 2 c(Q) in the case of non-orientable Q. To improve this bound by factor n(Q) we prove an extra statement. Informally speaking, it says that a Lyndon-van Kampen diagram can be unfolded in an economical way.
We recall some definitions and facts about Lyndon-van Kampen diagrams (or simply diagrams from now on for brevity).
By a diagram we mean a finite 2-dimensional cell complex ∆ embedded in the plane R 2 and endowed with a labelling function λ over an alphabet Y . The latter means that for any directed edge e of ∆ the label λ(e) is fixed which is either a letter in Y ±1 or is empty. For any two mutually inverse directed edges e and e −1 , we have λ(e −1 ) = (λ(e)) −1 . The labelling function is naturally extended to paths (viewed as sequences of directed edges) in the 1-skeleton ∆ (1) of ∆. The label λ(p) of a path p is a word in Y ±1 which we will often identify with an element of F Y . We call the label of the boundary loop of a 2-cell D of ∆ the boundary label of ∆, defined up to a cyclic shift.
We assume that all diagrams are connected and simply connected. We assume also that a diagram ∆ is endowed with a fixed base vertex ν 0 in the boundary of ∆ and, moreover, a boundary loop of ∆ at ν 0 is fixed. (In general, the boundary loop starting at a given boundary vertex may be not unique). The label of the fixed boundary loop of ∆ is called the boundary label of ∆.
We admit that the boundary label of a 2-cell D of a diagram ∆ is the empty word or has the form yy −1 , y ∈ Y . In this case we call D a trivial 2-cell of vertex or edge type, respectively. Otherwise a 2-cell is called nontrivial. The boundary label of a nontrivial 2-cell is always assumed to be cyclically reduced.
If We need a precise description of the process of constructing a diagram from a representation of an element w as a product of conjugates of c 1 , . . . , c m . We start with describing several elementary operations applied to a given diagram ∆ which produce a new diagram ∆ 1 over the same set {c 1 , . . . , c m }.
(T1) Contracting a trivial edge. If e is an edge with distinct endpoints and λ(e) = 1 then we contract e into a vertex.
(T2) Contracting a trivial 2-cell. Let D be a trivial 2-cell of ∆. Assume that either D has vertex type and the boundary loop consists of one edge or D has edge type and the boundary loop of D consists of exactly 2 edges and is labelled yy −1 , y ∈ Y . Then we contract D to a vertex or to an edge labelled y, respectively.
We admit also inverse operations (T1) −1 and (T2) −1 , introducing a trivial edge and introducing a trivial 2-cell, respectively. We call operations (T1), (T2) and their inverses trivial transformations. We introduce another two types of elementary operations which we call elementary reductions.
(R1) Folding boundary edges. Assume that two distinct boundary directed edges e 1 and e 2 of ∆ have the same label, a common initial vertex ν and distinct terminal vertices. We assume furthermore that the path (e 1 e 2 ) ±1 occurs in the boundary loop of ∆. (This is not always true in the case when ν is the base vertex of ∆.) Then we perform folding of e 1 and e 2 into a single edge.
(R2) Removal of a leaf edge. Let e be an edge of ∆ with an endpoint ν of valence 1. We assume that ν is not the base vertex of ∆. Then we remove e and its endpoint ν from ∆. Note that e does not belong to the boundary of a nontrivial 2-cell of ∆ since boundary labels of nontrivial 2-cells are assumed to be cyclically reduced. Therefore, this operation either reduces cancellation in the boundary label of ∆ or changes a trivial 2-cell of edge type to a trivial 2-cell of vertex type.
By definition, for all the operations introduced, the base vertex and the boundary loop of ∆ 1 are inherited in the natural way from those of ∆.
Observe that (T1) and (T2) do not change the boundary label w of ∆, (R1) reduces a cancellation in w and (R2) either does not change w or reduces a cancellation in w.
It is easy to see that any cancellation in the boundary label of ∆ can be reduced by either (R1) or (R2) after a sequence of trivial transformations (T1) ±1 and (T2) ±1 .
Definition 5.1. We say that a diagram ∆ 2 is obtained by folding from a diagram ∆ 1 if it is the result of application of a sequence of trivial transformations and elementary reductions so that the boundary label of ∆ 2 is freely reduced. We say also that ∆ 1 is obtained by unfolding from ∆ 2 .
For technical convenience, we assume that after folding, diagram ∆ 2 always undergoes the following tightening procedure: First, contract any trivial 2-cell whenever it can be contracted by using (T2) and any sequence of operations (T1) ±1 . Second, contract all trivial edges whenever possible.
Below we use the following properties of tight diagrams as in Definition 5.1. The proof of the following lemma is an easy exercise and left to the reader. We can consider also an inverse process: given a diagram ∆ over a set {c 1 , . . . , c m } with boundary label w we can unfold ∆ to get a rose diagram ∆ 0 and its associated factorization of w in the free group F Y where σ is a permutation on the set {1, . . . , m} and c ′ i is a cyclic shift of c i . The following proposition describes the relationship between two factorizations obtained in this way. Proposition 5.3. Let ∆ be a diagram with labeling function over Y , with boundary label w. Let ∆ 1 and ∆ 2 be two rose diagrams obtained from ∆ by unfolding and let be the associated factorizations of w in F Y where σ is a permutation on the set {1, . . . , m} and c ′ i is a cyclic shift of c i . Then there is an F Y -automorphism φ of F Y ∪{z 1 ,...,zm} such that and the following diagram is commutative where α and β are the corresponding evaluations of variables z i : 1, . . . , m). Proof. Let ν 0 be the base vertex of ∆ 1 and ν 1 , . . . , ν m be vertices where disks with boundary labels c i are attached to the other part of ∆ 1 (shown in Fig. 8). Let z i be the simple path between ν i and ν 0 and d i the boundary loop of the corresponding 2-cell at ν i (which is labelled c i ). We keep similar notations ν ′ i , z ′ i and d ′ i for ∆ 2 . Unfolding transformations ∆ → ∆ i induce a homotopy equivalence ψ between 1-skeletons ∆ such that ψ(ν 0 ) = ψ(ν ′ 0 ). In particular, we have the induced isomorphism Moreover, from the construction of elementary operations it is easy to see that ψ satisfies the following conditions: (i) For any loop p at ν 0 , the image ψ(p) is a loop at ν ′ 0 labelled with a word representing the same element of F Y .
. We define formally a homomorphismψ : The definition implies that for any loop p at ν 0 , we have ψ(p) =ψ(p) up to homotopy rel ν ′ 0 . From this we conclude that all z ′−1 i d ′ i z ′ i belong to the image ofψ and henceψ is in fact an isomorphism. From (iii) we get Now we adjustψ to get the required φ. By (i) and (ii), we have ) It is easy to see that φ satisfies all the required conditions.
To formulate the main result of the section, we need two more definitions. Let e be a nontrivial edge of a diagram ∆. We call e a tree edge if both e and e −1 occur in the boundary loop of ∆ (or, in other words, ∆ splits into two disjoint subdiagrams after removal of e). We call e tubular if e and e −1 occur in the boundary loop of a trivial 2-cell of ∆.
Proposition 5.4. Let w, c 1 , c 2 , . . . , c m be cyclically reduced elements of a free group F Y . Let ∆ be a diagram with boundary label w over the set {c 1 , . . . , c m } and let N denote the total length of labels of tree and tubular edges of ∆. Assume that ∆ is tight as in Definition 5.1.
Then there is rose diagram obtained from ∆ by unfolding such that for the associated factorization σ is a permutation on the indices {1, . . . , m} and c ′ i is a cyclic shift of c i , the following is true: Proof. Suppose that e is an edge in the interior of ∆ such that at least one of the endpoints of e belongs to the boundary of ∆. Then we can apply to ∆ an unfolding operation (R1) −1 replacing e by two new boundary edges. Starting from ∆, we perform recursively unfoldings of all interior edges. Then we contract all trivial 2-cells using (T1) and (T2). The resulting diagram∆ has no interior edges and no trivial 2-cells. For convenience, we further introduce new trivial edges where needed, so that each vertex of∆ gets valence at most 3 (see Fig. 9) Figure 9.
We claim that∆ has exactly N tree edges. Indeed, since ∆ is tight, by Lemma 5.2(i) any nontrivial interior edge of ∆ either occurs in the boundary loop of a nontrivial 2-cell or is tubular. Then every tree edge of∆ comes either from a tree edge of ∆ (which is not changed in the transformation) or from a tubular edge e of ∆ (which becomes a tree edge after unfolding e and contracting the trivial 2-cell D with ∂D ⊃ e).
Let ν 1 be the base vertex of∆ and ℓ be the boundary loop of∆. We enumerate cells R 1 , . . . , R m of∆ in the order as their boundary edges meet first in ℓ. Let be a sequence of subdiagrams of∆ where each ∆ i is obtained from ∆ i−1 by attaching the topological closure of R i and a segment s i joining R i with ∆ i−1 . We view s i as a path from a vertex µ i in ∂R i to a vertex ξ i in ∂∆ i−1 . The boundary loop of R i at µ i is labelled with a cyclic shift c ′ σ(i) of c σ(i) where σ is a permutation on {1, . . . , m}. Let r i be the terminal segment of the boundary loop of ∆ i−1 starting at ξ i . Denote v i = λ(s i r i ). Then we have and from the construction we can easily see that the rose diagram associated with this factorization is obtained by unfolding from∆ successively along paths r m , r m−1 , . . . , r 1 each time slicing off one 2-cell D i .
Observe that s i r i passes through every tree edge of∆ at most twice and through every other edge of∆ at most once. This implies Let us prove (ii). Let 1 ≤ t 1 < t 2 < · · · < t k ≤ m be an increasing sequence of indices t i . Let h i be the component of the intersection ∂R i ∩ ℓ that meets first in ℓ. We consider a diagram ∆ ′ obtained by removal from∆ all 2-cells R i and all arcs h i with i = t j . It is easy to see that the boundary label of ∆ ′ is equal to For the proof of Theorem 1.1, we will use Proposition 5.4 in the special case when w is a short product of conjugates of elements c 1 , . . . , c m in the sense of Definition 4.4. We start with the following simple observation. Proof. If e is a tree edge of ∆ then the boundary loop of ∆, up to a cyclic shift, has the form peqe −1 where p and q are loops which bound two subdiagrams ∆ 1 and ∆ 2 of ∆. Since w is cyclically reduced, the labels of p and q are nontrivial elements of F Y and hence both ∆ 1 and ∆ 2 have nontrivial 2-cells. We get a factorization of w as in Definition 4.4 which contradicts the assumption that w is short.
To prove the second statement, we take a tight diagram ∆ over {c 1 , . . . , c m } with boundary label w. By the first statement and Lemma 5.2(i), any boundary edge of ∆ belongs to the boundary of a nontrivial 2-cell. The total length of their boundary labels is i |c i |. Proof. Take any diagram ∆ over {c 1 , . . . , c m } with boundary label w. Assume that e is a tubular edge of ∆. Let D be the trivial 2-cell of ∆ with boundary loop peqe −1 where λ(p) = λ(q) = 1. One of the loops p or q bounds a subdiagram ∆ 1 of ∆. Then we can remove the annulus D ∪ e from ∆ replacing the subdiagram ∆ 1 ∪ D ∪ e by ∆ 1 .
Continuing this process we may assume that ∆ has no tubular edges. It remains to apply Lemma 5.5 and Proposition 5.4.
Proof of Theorem 1.1. Assume that a quadratic equation Q = 1 is solvable in F A . Let ψ ∈ Aut F A (F A∪X ) be an automorphism given by Proposition 3.3 or Proposition 3.5 such that Q φ is conjugate to a standard orientable or semi-standard non-orientable quadratic word R. If α is a solution of R = 1 then ψα is a solution of Q = 1 and for any x ∈ Var(Q), We have n(R) ≤ n(Q) and c(R) ≤ c(Q) and we can always assume that x α = 1 for every x ∈ Var(Q) \ Var(R). This implies that the statement of the theorem for Q follows from the statement for R. Therefore, it is sufficient to prove the theorem in the case of a standard or semi-standard Q. Let We can further assume that all c i are cyclically reduced. Indeed, in case of general c i 's we consider the equationQ = 1 where each c i is replaced with its cyclically reduced form c i = u −1 i c i u i . A solution of Q = 1 can be obtained from a solution ofQ = 1 by the substitution It is easy to see that the statement of the theorem for Q = 1 follows from the statement for Q = 1. Now consider two cases.
. This implies by Lemma 3.13 that there are elements v 1 , . . . , v m of length |v i | ≤ 3c(Q) such that By Corollary 4.3, w can be represented as a product of g commutators of elements of length at most 2c(Q). Hence we get a solution γ of the equation To get a solution of the original equation Q = 1, we eliminate z 1 by applying to the left-hand side of (2) the automorphism ψ ∈ Aut(F A∪X ) defined by Case 2: Q is semi-standard non-orientable, i.e.
Similarly to Case 1, for some ε 1 , . . . , ε m ∈ {−1, 1} we find a solution γ of another semistandard equation and |z γ i | ≤ 3c(Q) for all i. By Lemma 3.14, there is an automorphism φ ∈ Aut(F A∪X ) carrying its left-hand side, up to conjugation, to a word Finally, we eliminate z 1 as in the orientable case which at most triples the bound, and observe that 8g + 12m + 2 ≤ 12n(Q).

Bounding parametric solutions
In this section we prove Theorem 1.2. As defined in Section 1, by a parametric solution of an equation E = 1 in a free group F A we mean an F A -homomorphism η : F A∪Var(E) → F A∪T such that E η = 1 where T is a set of parameters. Here instead of the "big" group F A∪X we consider the group F A∪Var(E) involving only variables occurring in Q. It will be convenient to change this point of view by introducing formal sets of variables for equations. We assume that an equation E = 1 is endowed with a formal finite set of variables V ⊂ X such that V ⊇ Var(E) (in other words, we admit now fictitious variables x ∈ V not occurring in E). A parametric solution of such an equation (E = 1, V ) is then an F A -homomorphism β : F A∪V → F A∪T such that E β = 1. If V = Var(E) then we get equations and their parametric solutions in the initial sense.
Transformations of equations are no longer F A -automorphisms (or F A -endomorphisms if degenerate transformations are allowed) of the big free group F A∪X but homomorphisms φ : F A∪V → F A∪V 1 where V, V 1 ⊂ X are finite sets of variables. Since we want φ to be "potentially invertible" we require that φ be a monomorphism. Moreover, we will require that the condition given by the following definition should be satisfied. Definition 6.1. We call an F A -monomorphism φ : F A∪V → F A∪V 1 primitive if the image of φ is a free factor of F A∪V 1 .
The main ingredient to the proof of Theorem 1.2 is the following proposition which may be viewed as an advanced form of Proposition 4.6. Proposition 6.2. Let {c 1 , . . . , c m } be a finite set of cyclically reduced elements of F A . Suppose that η : F A∪Var(Q)∪Z → F A∪T is a parametric solution of a quadratic equation in F A of the form Then there is a coefficient-free quadratic word R equivalent to Q, a finite set of variables V ⊇ Var(R) and a parametric solution θ : F A∪V ∪Z → F A∪T of an equation if Q is non-orientable and σ is a permutation on {1, 2, . . . , m}, such that the following assertions are true: z σ(m) and the following diagram is commutative: such that any tree or tubular edge of ∆ is labelled by a sigle parameter letter and the total number of tree and tubular edges is less than m.
Proof. We consider first the case of orientable Q (so all ε i are 1). We describe a certain transformation process. At any moment, we will have the following data: • A quadratic word R * of the form where R is a coefficient-free quadratic word equivalent to Q; • A finite set V of variables such that V ⊇ Var(R).
• A parametric solution θ : F A∪V ∪Z → F A∪T of the equation R * = 1.
• A primitive F A -monomorphism φ : F A∪Var(Q)∪Z → F A∪V ∪Z and an endomorphism ω ∈ End F A (F A∪T ) satisfying (i).
We start with R * 0 = Q −1 z −1 1 c 1 z 1 . . . z −1 m c m z m , V 0 = Var(Q) and θ 0 = η given by the hypothesis of the proposition. For φ and ω, we take the identity maps.
A principal distinction from the proof of Proposition 4.6 is that we cannot use degenerate transformations now. We can have variables x with x θ = 1 which we call degenerate. Instead of |R[θ]| as one of the inductive parameters, we use |R[θ]| whereR is obtained by removal of all degenerate variables from R and performing subsequent cancellations. Variables x ∈ Var(R) \ Var(R) which are not degenerate are called cancelled.
Our inductive parameter now is the pair (|R θ |, |R[θ]|) with lexicographic ordering. The whole transformation process consists of steps 1-5 described below.
We start with describing several elementary transformations of triples (R * , V, θ) of the described form. There will be two types of them.
A substitution is given by a new set of variables V 1 ⊇ V , an F A -monomorphism ψ : F A∪V ∪Z → F A∪V 1 ∪Z and a homomorphism θ 1 : F A∪V 1 ∪Z → F A∪T such that θ = ψθ 1 . The new quadratic word R * 1 is defined as the cyclically reduced form of (R * ) ψ . In most cases when substitutions are defined, we change only R and do not change the coefficient part . A generalization is given by an endomorphism τ ∈ End F A (F A∪T ) and a new parametric solution θ 1 of R * = 1 such that θ = θ 1 τ . In this case we get a new triple (R Note that in both cases existence of φ and ω satisfying (i) for a triple (R * , V, θ) automatically implies one for the new triple (R * 1 , V 1 , θ 1 ). So we will not care about condition (i). Transferring cancelled subwords. Application condition: a word of the form x ε D occurs in R where x ∈ Var(R) and D disappears inR. We apply the substitution ψ = (x ε → x ε D −1 ) to R and do not change V and θ. The transformation transfers D to another location in R.
(Observe that x ε Dx −ε cannot occur in R since x would be cancelled otherwise.) Cancellation reduction. Application condition: a non-trivial cancellation inR[θ] occurs between the values of two neighboring variables x ε and y δ (ε, δ = ±1) and x ε y δ occurs also in R. If x = y then for some u, v and w = 1, We introduce a new variable z / ∈ V , take V 1 = V ∪ {z} and define ψ and θ 1 by and (x ε ) θ 1 = u, (y δ ) θ 1 = v, z θ 1 = w and h θ 1 = h θ for h = x, y, z.
The case x = y is treated in a similar way (see the proof of Proposition 4.6).
Observe that both operations do not change R θ , transferring cancelled subwords does not change alsoR[θ] and cancellation reduction decreases the length ofR[θ] by 2|w| where w is the cancellable part.
Step 1. Assume thatR[θ] has a cancellation between the values of two neighboring variables x ε and y δ . Then a word of the form x ε Dy δ occurs in R where D disappears inR. We transfer D to another location so that x ε and y δ become neighbors in R and then apply cancellation reduction decreasing |R[θ]|. We repeat the procedure untilR[θ] becomes freely reduced.
To makeR[θ] cyclically reduced, we use one more transformation.
Conjugation. Take a new variable y / ∈ V , take V 1 = V ∪ {y} and define ψ : To define θ 1 , we take any element u ∈ F A∪T for the value y θ 1 of y and set according to equality θ = ψθ 1 : x θ 1 = ux θ u −1 for x ∈ Var(R) and z θ 1 i = z θ i u, i = 1, . . . , m. For this transformation, we have R θ 1 1 = u −1 R θ u.
Step 2. If R θ is not cyclically reduced then using conjugation we replace it with its cyclically reduced form. Then jump back to Step 1.
We can assume now that R and θ satisfy condition (ii). In the rest of the proof, we show how to achieve (iii). We observe for the future that using conjugation we can replaceR[θ] with any its cyclic shift not increasing the inductive parameter (|R θ |, |R[θ]|). We introduce yet another transformation.
Splitting a variable. Let x ∈ Var(R). By the definition ofR we have x θ = 1. Take a new variable y / ∈ V , take V 1 = V ∪ {y} and apply to R the substitution ψ = (x → xy). To define θ 1 , we take any values x θ 1 and y θ 1 such that the product x θ 1 y θ 1 is reduced and equals x θ . The values of all other variables are unchanged.
Starting from now we fix any diagram ∆ with boundary labelR[θ] over the set {c 1 , . . . , c m } folded from the rose diagram associated with factorization (3). Transformations below will include also change of ∆.
We introduce a transformation which changes the coefficient part.
Rearranging coefficients. Let ∆ 0 be a rose diagram obtained from ∆ by unfolding, and let be the associated factorization ofR[θ] into a product of conjugates of c i 's. (Note that we can always assume that a cyclic shift of c i coincides with c i in this factorization, by performing extra unfolding operations on the rose diagram.) By Lemma 5.3, there is an automorphism ψ ∈ Aut(F A∪V ∪Z ) changing only variables in Z such that We apply the substitution ψ to get a new triple (R * , V, θ 1 ) where the solution θ and the coefficient part in R * are only changed.
Step 3. Let e be a tree edge of ∆ and let h = λ(e) = 1. The edge e divides ∆ into the union ∆ = ∆ 1 ∪ e ∪ ∆ 2 of e and two subdiagrams ∆ 1 and ∆ 2 . Passing to a cyclic shift of R[θ] if needed (which can be performed using conjugation) we assume that where occurrences of h and h −1 are the labels of e and e −1 , respectively. Splitting variables if necessary we may assume that h and h −1 are values of single variables, that is, Note that U and V are labels of boundary loops of subdiagrams ∆ 1 and ∆ 2 . The set of 2-cells of ∆ is partitioned into the set of 2-cells in ∆ 1 and in ∆ 2 . Let . . , i m } be factorizations obtained from unfoldings of ∆ 1 and ∆ 2 . Then . is a factorization associated to an unfolding of ∆. We apply first rearrangement of coefficients so that equation R * = 1 gets the form

Consider two cases.
Case 1: We apply a generalization transformation which replaces h with a new parameter t. The new parametric solution θ 1 is defined by . . , i m y → y for y ∈ Var(R) \ {x 1 } and y = z i 1 , . . . , z i k In ∆, we change the label of e to t. Note that we do not change the inductive parameter (|R θ |, |R[θ]|) since h is the label of a single edge e and hence |h| = 1.
After performing the transformation we start a new iteration of Step 3 checking for another tree edge of ∆. In general, after splittings of variables new tree edges may appear in ∆. However, the total length of labels of tree edges is not changed. Therefore, after finitely many iteration steps we either process all tree edges of ∆ or come to Case 2 where the inductive parameter decreases.
Case 2: x 1 = x 2 . Then x 1 occurs either in U or in V . Without loss of generality we assume that x 1 occurs in U (if x 1 occurs in V then we can pass to a cyclic shift ofR[θ] by conjugation and then come to a symmetric situation). Let U = U 1 x −1 1 U 2 . First we apply the substitution We get Next we apply another substitution After application of ψ 1 and ψ 2 we get a new triple (R * 1 , V, θ 1 ) with We jump next to Step 1.
Step 3 is finished.
At this point, we produce a triple (R * , V, θ) satisfying (ii) and a diagram ∆ with boundary labelR[θ] over the set {c 1 , . . . , c m } folded from the rose diagram associated with (3). The diagram ∆ has the property that the label of any its tree edge e is a single parameter letter t. Moreover, there are exactly two occurrences of t inR[θ] and both are the values of one variable x ∈ Var(R).
Step 4. Let e be a tubular edge of ∆. Let D be the trivial 2-cell with boundary loop epe −1 q where p and q are loops with empty labels and p bounds a subdiagram ∆ 1 of ∆. Without loss of generality we assume that there are no tubular edges in ∆ 1 . We choose any non self-intersecting path s joining the base vertex ν 0 with the start of e and unfold ∆ along the path sepe −1 s −1 as shown in Fig. 10 (note that D is contracted into an edge after this procedure). Then we perform folding of the resulting diagram reducing cancellation in the newly appeared copies s 1 e 1 p 1 e −1 1 s −1 1 and s 2 e 2 p 2 e −1 3 s −1 3 of sepe −1 s −1 (Fig. 10). The resulting diagram ∆ ′ is the union of two subdiagrams Θ and ∆ 2 with Θ ∩ ∆ 2 = {ν 0 }. The subdiagram Θ is obtained from the union of ∆ 1 and s 1 e 1 by adding trivial 2-cells so that the complement Θ − ∆ consists of annuli formed by the trivial 2-cells and tubular edges that become all edges of the path s 1 e 1 . The subdiagram ∆ 2 is obtained from the complement ∆ − ∆ 1 by contracting the path q into a vertex (to do the contraction, we introduce trivial edges where needed to remove self-intersections in q).
Observe that the boundary label of Θ is empty and the boundary label of ∆ ′ is equal to the boundary label of ∆. Since both ∆ and ∆ ′ can be unfolded form a common rose diagram ∆ 0 we can perform rearranging coefficients so that factorization (3) is replaced by the factorization associated to ∆ 0 . We replace also ∆ with ∆ ′ . Similar to Step 3 we further replace occurrences of the label of s 1 e 1 in the values x β of variables x by a new parameter letter (only values of variables z i are changed for which the corresponding coefficient c i is the boundary label of a 2-cell in ∆ 1 ).
We perform the described procedure for all tubular edges of ∆. After this, ∆ becomes the union of subdiagrams∆ and Θ 1 , . . . , Θ r with a common vertex ν 0 and having no other intersections. Each subdiagram Θ i has empty label and a single tubular edge labelled by a parameter letter. It is not hard to see that after the whole procedure no tree edges appear in ∆.
Step 5. The final procedure is elimination of tree vertices of ∆, that is, vertices that do not belong to the boundary of any 2-cell of ∆.  Figure 10.
Let ν be a tree vertex of ∆. SinceR[θ] is cyclically reduced, the valence of ν is at least 2. We assume without loss of generality that ν is distinct from the base vertex ν 0 of ∆ (otherwise using conjugation we can move ν 0 to any non-tree boundary vertex of ∆).
Let e 1 , . . . , e d be all directed edges starting at ν, and let x 1 , . . . , x d be the corresponding variables, so x θ i = t i is a parameter letter which is the label of e i . Since ν = ν 0 , all occurrences of variables x i inR are of the form . . .
We first apply to R the substitution This eliminates x 2 fromR (it either disappears in R or becomes cancelled inR). For the new solution θ 1 we get x θ 1 i = t 1 t i for i = 2, . . . , d. All occurrences of parameter letters t i in the values of other variables (which can be only z j 's) are of the form . . . t −1 i t i+1 . . . (i mod d). Hence we can perform a generalization replacing each t 1 t i with a single parameter t i .
After performing this operation, the length ofR[θ] is decreased. We get also a new diagram ∆ 1 which is obtained from ∆ by contracting the edge e 1 into a vertex.
We repeat the procedure until we get rid off all tree vertices of ∆. The description of the transformation process is finished. Let ∆ be a diagram obtained after all steps 1-5. To prove the proposition, we have only to estimate the total number of tree and tubular edges of ∆.
Let e 1 , . . . , e k be all tree edges of ∆ and let r be the number of subdiagrams Θ i with empty label produced at Step 4. Each of the subdiagrams Θ i has at least one non-trivial 2-cell since otherwise it should be contracted to a vertex. The same is true for all connected components of the complement ∆ − ∪ i e i . This implies that the number of these connected components is at most m − r. On the other hand, this number is precisely k + 1 since each e i joins two components of ∆ − ∪ i e i and ∆ is simply connected. Hence k + r < m.
The proof of Proposition 6.2 is completed in the case when Q is orientable. In the case of non-orientable Q the only difference in the argument is that we admit inerses of coefficient factors. (In Case 2 at Step 3, it may happen that x 1 occurs in R twice with the same exponent +1 or −1. Then the corresponding transformation inverses E which occurs in the coefficient part.) Proof of Theorem 1.2. We start with the case when Q is a standard orientable quadratic word.
We assume that Q has at least one coefficient. If Q is coefficient-free then there exists a parametric solution η 0 ∈ Hom(F Var(Q) , F T ) of the equation Q = 1 such that the value of each variable is either a parameter letter or trivial and any ordinary solution α of Q = 1 in any coefficient group F A may be represented as φαω where φ ∈ Stab(Q) and ω ∈ Hom(F T , F A ) (see Theorem 4 in Section 5 of a survey [12]). This implies that η 0 is a generalization of any other parametric parametric solution η of Q = 1 (since η is an ordinary solution in F A∪T ). In this case, the statement of Theorem 1.2 holds with bound |x η 0 | ≤ 1.
Let η be a parametric solution of a standard quadratic equation Q = 1 where , a finite set of variables V ⊇ Var(R) and a parametric solution θ : F A∪V ∪Z → F A∪T which satisfy conditions (i)-(iii) of that proposition.
Let a primitive F A -monomorphism φ : F A∪Var(Q 0 )∪Z → F A∪V ∪Z and ω ∈ End F A (F A∪T ) be as in (i), that is, up to conjugation we have (1) . . . z σ(m) c σ(m) z σ(m) and the following diagram is commutative: Our strategy is to further transform the equation R = z −1 σ(1) c σ(1) z σ(1) . . . z −1 σ(m) c σ(m) z σ(m) and its parametric solution θ so that we come back to the initial equation Q = 1. After that, with a slight adjustment, θ will give a desired generalization of η. We will find an "ecomonic" transformation which, together with conditions (ii) and (iii) of Proposition 6.2, will provide the required bound on the size of the resulting generalization of η.
• A primitive F A -monomorphism φ : F A∪Var(Q)∪Z → F A∪V ∪Z and an endomorphism ω ∈ End F A (F A∪T ) with (4) and (5). Note that we do not include the set V of formal variables here since we do not need to introduce new variables and V will not change.
In a similar way, we will use two types of elementary transformations: substitutions and generalizations. During the transformation process, condition (i) of Proposition 6.2 will be automatically held by construction.
We start now with the pair (R * , θ) obtained after application of Proposition 6.2. Observe that conditions (ii) and (iii) imply the following bound on the total length of values x θ of variables in x ∈ Var(R): Step 1: Transforming the coefficient part. Let ∆ be the diagram satisfying condition (iii) of Proposition 6.2. We unfold ∆ using Proposition 5.4 and in a similar way as in the proof of Theorem 1.1 we change the coefficient part of equation R * = 1 and the parametric solution θ using Proposition 5.3 so that the equation gets the form R = z −1 1 c 1 z 1 . . . z −1 m c m z m and we have |z θ i | ≤ 3c(Q) + 4m for all i = 1, 2, . . . , m.
Step 2: TransformingR to the standard form. We apply the procedure described in the proof of Proposition 3.9 to makeR a product of commutators. Since our transformation should apply to R we mimic application of related Nielsen automorphisms toR as application of automorphisms to R in the following way.
Assume that x ε y δ occurs inR an we want to apply toR a related Nielsen automorphism ρ = (x ε → x ε y −δ ). There is a subword x ε W y δ of R where W is deleted inR. In particular, W θ = 1. Then application of an automorphism (x ε → x ε y −δ W −1 ) to R produces a new word R 1 such thatR 1 =R ρ .
At this step, we change the values of parametric solution θ on variables of x ∈ Var(R) only (and will not change them until the final Step 4). According to Lemma 3.12 we get |x θ | ≤ 2c(Q) + 4m for all x ∈ Var(R).
Step 3: Transforming the deleted part to the standard form. Recall that variables in Var(R) \ Var(R) are divided into two types: degenerate variables x with x θ = 1 and cancelled ones which cancel in R after removal of degenerate variables. Let . . x ε k k and W i are deleted inR. Using substitutions ( i+1 ) we can move W i 's not changingR. SinceR is a product of commutators, it is easy to see that we can collect all W i 's together at any location between x ε i i and x ε i+1 i+1 . We reduce R to the form R = WR. Let x, y ∈ Var(W ) and σ = (x ε → x ε y δ ) ∈ Aut(F A∪V ∪Z ) be a Nielsen automorphism related to R (i.e. (x ε y −δ ) ±1 occurs in W ). Application of σ does not changeR whenever x is cancelled or both x and y are degenerate. Observing that two cancelled variables cannot "cross" in W and using Nielsen automorphisms of the above form we transform W to a product of commutators [y 1 , y 2 ] . . . [y 2r−1 , y 2r ] where at least one variable y j or y j+1 is degenerate in each commutator [y i , y i+1 ].
Finally, we apply a generalization to θ by assigning a single parameter letter to each cancelled variable x. After the transformation, all of R is written as a product of commutators and we get |x θ | ≤ 1 for all x ∈ Var(R) \ Var(R) Step 4: Eliminating z 1 . We do this in the same way as in the proof of Theorem 1.1. The resulting bound increases by 6c(Q) + 8m for |x θ | when x ∈ Var(R) and by 3c(Q) + 4m for |z θ i |.
We have "almost" produced the desired generalization θ of the initial parametric solution η, with the only difference that θ is formally defined on a larger set of variables V . This issue is solved by the following observation. Lemma 6.3. Let Q ∈ F A∪X be a standard quadratic word with at least one coefficient. If φ : F A∪Var(Q) → F A∪V is a primitive F A -monomorphism and Q φ is conjugate to Q then Im φ = F A∪Var(Q) .
Proof. It follows from Definition 6.1 that a primitive F A -monomorphism φ : F A∪Var(Q) → F A∪V can be extended to an F A -automorphism of F A∪V . Assume that φ ∈ Aut F A (F A∪V ) and Q φ is conjugate to Q. We apply a slightly modified version of Proposition I.4.24 in [21] to one cyclic word u 1 = Q and the tuple of non-cyclic words u i , i ≥ 2, consisting of all letters of A. Observe that there is no elementary Whitehead automorphism ρ ∈ Aut(F A∪V ) which does not increase the length of all u i and strictly decreases it for at least one i. Then φ can be represented as a product ρ 1 ρ 2 . . . ρ r of elementary Whitehead automorphisms ρ i which do not change the length of each u i . We can eliminate permutations and exponent sign changes of generators, so each ρ i can be assumed to be an elementary Whitehead F A -automorphism of F A∪V . An easy inductive argument shows that then for each i, the image Q ρ 1 ...ρ i (viewed as a cyclic word) is a quadratic word equivalent to Q and (F A∪Var(Q) ) ρ i = F A∪Var(Q) . This implies that (F A∪Var(Q) ) φ = F A∪Var(Q) .
The lemma shows that as long as we have a commutative diagram (5) where φ ∈ Stab(Q) then then we can restrict it to F A∪Var(Q) : This means precisely thatθ is a generalization of η. The proof of Theorem 1.2 is finished in the case of a standard orientable quadratic equation Q = 1. The case when Q is semi-standard non-orientable is treated in a similar way with the following changes: • The word R * under transformation has the form R * = R −1 z −1 σ(1) c ε 1 σ(1) z σ(1) . . . z −1 σ(m) c εm σ(m) z σ(m) . • After Step 1, the equation gets the form R = z −1 1 c ε 1 1 z 1 . . . z −1 m c εm m z m for some ε 1 , . . . , ε m = ±1. • In Step 2, we reduce R to a semi-standard form.
• In Step 3, we reduce W to a semi-standard form y 2 1 . . . y 2 k [y k+1 , y k+2 ] . . . [y r−1 , y r ] where each y i in y 2 i is degenerate and either y i or y i+1 is degenerate in each commutator [y i , y i+1 ]. After the reduction, we move W to the right of the last square factor inR so that the whole word R would be written in a semi-standard form.
• Before Step 4, we apply Lemma 3.14 to get R * = Q. We prove the theorem in the general case. Let Q = 1 be any quadratic equation in F A . Let φ ∈ Aut F A (F A∪Var(Q) ) be an automorphism given by Propositions 3.3 or 3.5 such that Q φ is conjugate to a standard or semi-standard quadratic word R equivalent to Q. Then φ defines a one-two-one correspondence η → φη between parametric solutions η of the equation (R = 1, Var(Q)) with formal set of variables Var(Q) and parametric solutions φη of the equation Q = 1.
Recall that a parametric solution η 1 : F A∪Var(E) → F A∪T of E = 1 is a generalization of another parametric solution η 2 of the same equation E = 1 if there are an automorphism ψ ∈ Stab(E) and an endomorphism ω ∈ End F A (F A∪T ) such that η 2 = ψη 1 ω. We extend this definition to parametric solutions of equations (E = 1, V ) with formal set of variables by taking instead of Stab(E) the group Clearly, the correspondence η → φη preserves the relation "η 1 is a generalization of η 2 " in the new extended version.
For a parametric solution θ of R = 1, letθ denote the parametric solution of (R = 1, Var(Q) defined by extending θ in the following natural way: for each variable x ∈ Var(Q) \ Var(R) we choose a parameter letter t (which does not occur in parametric words y θ for y ∈ Var(R)) and set xθ = t. Clearly, any parametric solution of (R = 1, Var(Q)) has a generalization of the formθ for some θ. It is also obvious that the correspondence θ →θ preserves the relation "θ 1 is a generalization of θ 2 ". Now let η be an arbitrary parametric solution of Q = 1. To find the required generalization η 1 of η, we pass on to the parametric solution ψ −1 ξ of (R = 1, Var(Q)) and take its generalization of the formθ for some θ. By the statement of the theorem for the equation R = 1, there is a generalization θ 1 of θ such that for any x ∈ Var(R) |x θ 1 | ≤ 8(c(R) + 2n(R)) if Q is orientable, 36n(R)(c(R) + 2n(R)) if Q is non-orientable.