Straight-line complexity

Definition
Note that the actual definition of straight-line complexity as a numerical value varies a lot with the convention. What's more important is the ballpark of the definition.

Definition for a word computation problem
Consider a word $$w$$ in the letters $$x_1,x_2,\dots,x_n$$. The straight-line complexity of the problem of computing $$w$$ in terms of $$x_1,x_2,\dots,x_n$$ is defined as 0 if $$w$$ is the trivial word or $$w = x_i$$ for some $$i$$. Otherwise, it is the smallest positive integer $$m$$ such that we can construct the following:


 * A sequence $$w_1,w_2,\dots,w_m$$ of words in $$x_1,x_2,\dots,x_n$$ such that $$w_m = w$$
 * An expression for each $$w_i$$ as either of these:
 * the inverse of an element $$u$$ where $$u$$ is in $$\{x_1,x_2,\dots,x_n,w_1,\dots,w_{m-1} \}$$
 * the product of two elements $$uv$$ where both $$u$$ and $$v$$ are in $$\{x_1,x_2,\dots,x_n,w_1,\dots,w_{m-1} \}$$

The above definition of straight line complexity treats each multiplication and inversion operation as costing one line of complexity. We can define a more general straight-line complexity that associates different weights to multiplication and inversion, and then seeks to minimize the appropriately weighted combination of the multiplication and inversion steps.

For words in one letter, i.e., powers
Consider the word $$w = x^n$$ in one letter $$x$$ where $$n$$ is a positive integer. The straight-line complexity of this word is at most $$\lfloor \log_2n \rfloor + b(n) - 1$$ where $$b(n)$$ is the number of ones that appear in the binary expansion of $$n$$. In fact, that is the best we can achieve if we are forbidden from using inverses. The algorithm is as follows: write the binary expansion of $$n$$. By repeated squaring, compute $$x^{2^k}$$ for all relevant powers, and then multiply them.

If we are allowed to use inverses, the expression becomes a little more complicated. The smallest $$n$$ for which using inverses allows for a concrete saving is $$n = 31$$ (not using inverses would require 8 steps, whereas using inverses, we can compute $$x^{32}$$, $$x^{-1}$$, and then multiply, using 7 steps).

The general formula seems to be:

$$\min \{ \lfloor \log_2n \rfloor + b(n) - 1, 2\lfloor \log_2n \rfloor + 4 - b(n) \}$$

For negative numbers $$n$$, the formula seems to be:

$$\min \{ \lfloor \log_2n \rfloor + b(n), 2\lfloor \log_2n \rfloor + 4 - b(n) \}$$

Relation with word length
The straight-line complexity of a word in $$n$$ letters is related to its word length in two obvious ways. Let $$m$$ be the straight-line complexity and $$\ell$$ be the word length. Then:


 * $$\ell \le 2^m$$: This is because each step of the program can at most double the length of the longest word constructed so far.
 * $$m \le \min \{n,\ell \} + \ell - 1$$: Note that if the word does not involve inverses, $$m \le \ell - 1$$ for the obvious reason that we can multiply two at a time. If the word involves inverses, then we may need to perform inversion operations. We need to perform at most $$\min \{n, \ell \}$$ inversion operations.

Facts

 * Babai-Szemeredi reachability lemma says that for any element in a finite group $$G$$ and any generating set for the finite group, there is a word for the element in terms of the generating set that has straight line complexity $$(1 + \log_2|G|)^2$$.