Solution (source code)

= Solution

Choose free <group generators> $a_1,\ldots,a_n$. Construct the <Schreier coset graph> $\Gamma$ with vertices the right <cosets> $Hg$ and a positively oriented edge labelled $a_k$ from $Hg$ to $Hga_k$. This is well defined and connected. Its inverse edge carries $a_k^{-1}$. A word in the <group generators> determines a unique path from the base vertex $H$; that path closes exactly when the word represents an element of $H$.

Deleting a consecutive edge followed by its inverse corresponds exactly to free cancellation in the word. Since reduced words are unique in a <free group>, the resulting map from based loops modulo these cancellations to $H$ is injective as well as surjective, and respects concatenation. Thus $H$ is the <fundamental group> of $\Gamma$. More explicitly, choose a <spanning tree> $T$ and, for each unoriented edge outside $T$, choose one orientation. The tree path from the base vertex to that edge, followed by the edge and the returning tree path, defines an element of $H$. Every loop is a product of these elements and their inverses: insert the appropriate tree paths between successive edges, and tree edges contribute trivial factors. Collapsing the tree leaves one loop for each remaining edge. A product of the chosen basis loops maps to the corresponding word in these loop labels. If the original path could cancel to the constant path, its image could do so as well, since collapsing tree edges preserves every backtracking cancellation. A nonempty reduced word in the remaining labels cannot cancel to the empty word, proving that there are no further relations. These elements therefore form a free basis. This proves that \b[$H$ is a <free group>] without assuming the <subgroup> theorem.

If $i=[F_n:H]$ is finite, the graph has $i$ vertices and $ni$ unoriented edges, counted by their positive labels; loops and parallel edges count separately. A spanning tree has $i-1$ edges. The <Nielsen–Schreier formula> follows:
$$
\boxed{\operatorname{rank}(H)=ni-(i-1)=1+i(n-1).}
$$
For a sequence of finite indices $i_j\to\infty$, this gives the <rank-to-index limit for subgroups of a free group>
$$
\boxed{\frac{\operatorname{rank}(H_j)}{i_j}=n-1+\frac1{i_j}\longrightarrow n-1.}
$$

Finally, let $\theta:F_n\to F_n$ be an <endomorphism>, and put $L=\theta(F_n)$. It is generated by the $n$ images $\theta(a_k)$. If its index $d$ is finite, it is free of rank $r=1+d(n-1)$. A rank-$r$ <free group> needs at least $r$ <group generators>: its <abelianization> is $\mathbb Z^r$, and reduction modulo $2$ gives the $r$-dimensional vector space $(\mathbb Z/2\mathbb Z)^r$, which cannot be generated by fewer than $r$ vectors. Therefore
$$
1+d(n-1)\leq n.
$$
Since $n\geq2$, this forces $d\leq1$, hence $L=F_n$. This proves that a <finite-index image of a free-group endomorphism is surjective>:
$$
\boxed{\theta\text{ is surjective, or }[F_n:\theta(F_n)]=\infty.}
$$