Fundamental group of the total space of an oriented $S^1$ fiber bundle over $T^2$
Solution 1:
Here's a geometric view point which computes (a presentation of) $\pi_1(M)$. As a byproduct, we establish
The group $\pi_1(M)$ is nilpotent of at most $2$-steps. That is, $[\pi_1(M),\pi_1(M)]$ need not be trivial, but $[\pi_1(M), [\pi_1(M),\pi_1(M)]]$ is trivial.
(If $M$ is the trivial bundle, then $\pi_1(M)\cong \mathbb{Z}^3$ is abelian, i.e., one-step nilpotent. We will see below that if $M$ is non-trivial, then $\pi_1(M)$ is non-abelian.)
Because $Diff(S^1)$ deformation retracts to $O(2)$, a circle bundle is orientable iff it's principal. For a reasonable space $X$, principal circle bundles are classified by $H^2(X)$.
Now, decompose $T^2$ as a union of a small ball $B$ and the complement $C$ (enlarged slightly so there is overlap between $B$ and $C$) of the small ball. Note that $B\cap C$ deformation retracts to a circle.
Proposition 1: Every principal circle bundle $M$ over $T^2$ is obtained by gluing a trivial bundle $B\times S^1$ to a trivial bundle $C\times S^1$ via a map of their boundaries $f:S^1\times S^1\rightarrow S^1\times S^1$. Such an $f$ must have the form $f(\theta, \phi) = (\theta, g(\theta) + \phi)$ for some smooth map $g:S^1\rightarrow S^1$.
Proof:
Now, it's well known that $C$ deformation retracts to $S^1\vee S^1$, so $H^2(C) = 0$. Since $B$ is contractible, $H^2(B) = 0$ as well.
This means that any principal $S^1$ bundle over $T^2$ restricts to the trivial bundle on both $B$ and $C$. It follows that any principal $S^1$ bundle on $T^2$ is obtained as follows:
Glue $C\times S^1$ to $B\times S^1$ along their common boundary $S^1\times S^1$. The gluing map $f:S^1\times S^1\rightarrow S^1\times S^1$ must have the form $f(\theta,\phi) = (\theta, g(\theta)+\phi)$, where $g:S^1\rightarrow S^1$ is some smooth function. The form on the first factor is because the projection maps on $C\times S^1$ and $B\times S^1$ just project to the first factor, and these must match. The form on the second factor is because the bundle is $S^1$-principal. $\square$
Different choices of $g$ can lead to different bundles, but as is usual for bundles, homotopic $g$s lead to isomorphic bundles. So, we may as well focus on homotopy classes of $g$s, and there are precisely $\pi_1(S^1)\cong \mathbb{Z}$ of them. Representatives are given by $g_k(\theta) = k\theta$ for $k\in \mathbb{Z}$. For each such $k$, call the resulting total space $M = E_k$.
Now that we're armed with a geometric picture of $M$, we can use Seifert-van Kampen to compute the fundamental group of $E_k$. Let's set up some notation.
First, $\pi_1(C\times S^1)\cong F^2\times \mathbb{Z}$ with $F^2$ a free group on two generators (say, $a$ and $b$). Let $c$ denote a generator of the $\mathbb{Z}$ factor.
Second, $\pi_1(B\times S^1)\cong \mathbb{Z}$, say generated by $d$.
Lastly, $\pi_1((C\cap B)\times S^1)\cong \mathbb{Z}\times \mathbb{Z}$, say generated by $x$ and $y$.
Because $C$ is more complicated than $B$, we'll view the $(B\cap C)\times S^1$ as living in $C$, which is then attached to $B\times S^1$ via $f$.
Proposition 2: The group $\pi_1(E_k) \cong \langle a,b,c\, |[a,c], [b,c], [a,b]c^{-k}\rangle.$
From the usual van Kampen argument for computing $\pi_1$ of a genus 2 surface, the inclusion $(B\cap C)\times S^1\rightarrow C\times S^1$ maps $x$ to the commutator $[a,b]$, and it maps $y$ to c.
But what is $f_\ast:\pi_1((B\cap C)\times S^1)\rightarrow \pi_1(B\times S^1)$? Well, it's enough to figure out the induces map to $\partial (B\times S^1)\cong S^1\times S^1$, because the inclusion $\partial(B\times S^1)\rightarrow B\times S^1$ obviously kills the first factor and is the identity on the second.
Well, factor the map $(\theta,\phi)\mapsto (\theta, k\theta + \phi)$ via the composition $T^2\rightarrow T^3\rightarrow T^3\rightarrow T^2$ where $$(\theta,\phi)\mapsto (\theta,\theta,\phi)\mapsto (\theta,k\theta,\phi)\mapsto (\theta,k\theta + \phi).$$ Then it's not too hard to see that $x$ maps to $x + ky$ in $\partial(B\times S^1)$, where the $x$ then maps to $0$, but $ky$ maps to $kd$. That is, $x\in \pi_1((B\cap C)\times S^1)$ maps to $kd\in \pi_1(B\times S^1)$. Similarly, $y$ maps to $y$.
Applying Seifert-van Kampen, we find a presentation for $\pi_1(E_k)$ is $$\langle a,b,c,d| [a,c],[b,c], [a,b]d^{-k}, cd^{-1}\rangle $$ which simplifies to $$\langle a,b,c| [a,c],[b,c], [a,b]c^{-k}\rangle,$$ (where the relations $[a,c], [b,c]$ come from $\pi_1(C)$ and the other relations come from Seifert-van Kampen). $\square$
As a quick check, when $k=0$ (so we get the trivial bundle), this is $\pi_1(T^3)\cong \mathbb{Z}^3$, as it should be.
Lastly, we claim this is nilpotent for any $k$.
Proposition 3: For $k\neq 0$, the presentation $\langle a,b,c\,| [a,c], [b,c], [a,b]c^{-k}\rangle$ defines a 2-step nilpotent group for every $k$.
Proof: First, $[a,b] = c^k\neq 0$, so this presentation is not 1-step nilpotent.
Since $c$ is central, the relation $[a,b]c^{-k}$ can be rewritten as $abc^{-k} = ba$. Multiplying on the right and left by $a^{-1}$ gives $ba^{-1}c^{-k} = a^{-1}b$, so $ba^{-1} = c^k a^{-1} b$. Similar relations exist with $b^{-1} a$ and $b^{-1} a^{-1}$. The point is that any word in $a$, $b$, and $c$ is equivalent to a word which is alphabetical: it is of the form $a^s b^t c^u$ for integers $s,t,u$.
Consider the obvious map $\rho:\langle a,b,c\,|[a,c],[b,c], [a,b]c^{-k}\rangle \rightarrow \langle a,b,\,|[a,b]\rangle \cong \mathbb{Z}^2$, obtained by setting $c= e$. We claim that $\ker \rho = \langle c\rangle$. It is obvious that $c\in \ker \rho$, so let's establish the other direction. Suppose $w = a^s b^t c^u$ is an alphabetical word in $a,b,c$ and that $w\in \ker \rho$. Then $\rho(a^s b^t) = 0$ which implies that $s=t=0$.
Given any commutator $[w_1,w_2]$ in words $w_1$ and $w_2$, we see that $\rho([w_1,w_2]) = [\rho(w_1), \rho(w_2)] = 0$ because $\mathbb{Z}^2$ is abelian. Thus, the first derived subgroup of this presentation is a subgroup of $\ker \rho = \langle c\rangle$. Since $c$ is central, the second derived subgroup is trivial. $\square$
Solution 2:
Let me use $T$ to denote the torus. Oriented circle bundles over $T$ (indeed over any closed, connected surface) are classified up to orientation preserving bundle isomorphism by an integer known as the Euler number. To define this number, choose a standard cell decomposition of $T$ with a single vertex, two edges, and a single 2-cell. Let $T^{(i)}$ denote the $i$-skeleton and let $E^{(i)}$ denote the bundle restricted to $T^{(i)}$. Labelling the 1-cells of $T^{(1)}$ as $a,b$ so that the 2-cell is attached along the curve $\gamma : S^1 \to T$ which is expressed as a concatenation of edges of the form $aba^{-1}b^{-1}$.
Here's an obstruction theory description of the Euler number. Roughly speaking the pullback bundle $\gamma^* E$ is a trivial circle bundle over $S^1$, but the structure of the bundle $E \mapsto T$ gives two trivializations of $\gamma^* E$. Comparing those two trivializations produces the Euler number: any two trivializations of the same circle bundle over $S^1$ differ by a Dehn twist around any one of the circle fibers, and the Dehn twist exponent is the Euler number.
First, $E^{(1)}$ is a trivial circle bundle over $T^{(1)}$, and so we may pick a bundle isomorphism $$E^{(1)} \approx T^{(1)} \times S^1 $$ Pulling this back under the map $\gamma : S^1 \to T^{(1)}$ gives the first trivialization of $\gamma^* E$.
Second, consider an orientation preserving characteristic map $\chi : D^2 \to T$ for the 2-cell, whose restriction to the boundary circle $S^1$ is the curve $aba^{1}b^{-1}$. The pullback bundle $\chi^* E$ is a trivial bundle over $D^2$ (because $D^2$ is contractible), and so we may choose a bundle isomorphism $$\chi^* E \approx D^2 \times S^1 $$ Since $\gamma$ is defined on $\partial D^2 = S^1$, one may pullback this trivialization of $\chi^* E$ to give the second trivialization of $\gamma^* E$.
From this description, if the Euler number is equal to $X$ then one can use Van Kampen's theorem to obtain the presentation $$\pi_1(E) = \langle a, b, f \mid a b a^{-1} b^{-1} = f^X, \,\, a f a^{-1} f^{-1} = b f b^{-1} f^{-1} = \text{Id} \rangle $$ and from this the nilpotency of $\pi_1(E)$ clearly follows.
There's a nontrivial theorem going on here: one must prove that the Euler number is well-defined independent of choice (the main choice being the trivialization of $E^{(1)}$), and that two oriented circle bundles over $T$ are isomorphic as oriented bundles if and only if they have the same Euler number. Those proofs are where the true "obstruction theory" arguments take place.
Solution 3:
Orientable circle bundles over $X$ are classified by $H^2(X; \mathbb{Z})$ via the first Chern class (or Euler class). In particular, orientable circle bundles over $T^2$ are classified by $H^2(T^2; \mathbb{Z}) \cong \mathbb{Z}$. Let $M_r$ denote the total space of the orientable circle bundle over $T^2$ with first Chern class $r$; this is what is referred to as the Euler number in Lee Mosher's answer. For $r \neq 0$, the manifolds $M_r$ and $M_{-r}$ are diffeomorphic, but have opposite orientations. Below we give a construction of the manifolds $M_r$. This is more than you ask for, but it provides a different point of view than the other answers.
For $r = 0$, we have $M_0 = T^3$ and $\pi_1(T^3) \cong \mathbb{Z}^3$ which is abelian and hence nilpotent.
For $r \neq 0$, consider the quotient $H(3, \mathbb{R})/\Gamma_r$ where
$$H(3, \mathbb{R}) = \left\{\begin{bmatrix} 1 & x & z\\ 0 & 1 & y\\ 0 & 0 & 1\end{bmatrix} : x, y, z \in \mathbb{R}\right\}$$
is the three dimensional Heisenberg group, and
$$\Gamma_r = \left\{\begin{bmatrix} 1 & a & \frac{c}{r}\\ 0 & 1 & b\\ 0 & 0 & 1\end{bmatrix} : a, b, c \in \mathbb{Z}\right\}$$
is a discrete subgroup. Note that $H(3, \mathbb{R})$ is diffeomorphic to $\mathbb{R}^3$, but they are not isomorphic as Lie groups because $H(3, \mathbb{R})$ is not abelian while $\mathbb{R}^3$ is. For $r = 1$, the subgroup $\Gamma_1$ is precisely the three-dimensional integral Heisenberg group $H(3, \mathbb{Z})$ and the quotient $H(3, \mathbb{R})/H(3, \mathbb{Z})$ is known as the three-dimensional Heisenberg manifold.
For each $r \neq 0$, the quotient $H(3, \mathbb{R})/\Gamma_r$ is orientable as the nowhere-zero three-form $dx\wedge dy\wedge dz$ on $H(3, \mathbb{R})$ is invariant under the action of $\Gamma_r$. Moreover, there is compact fundamental domain for the action of $\Gamma_r$ (see here for the $r = 1$ case), and hence $H(3, \mathbb{R})/\Gamma_r$ is compact. One can show that the map $H(3, \mathbb{R})/\Gamma_r \to \mathbb{R}^2/\mathbb{Z}^2$ given by $A + \Gamma_r \mapsto (x, y) + \mathbb{Z}^2$ is a submersion, so it follows from Ehresmann's theorem that $H(3, \mathbb{R})/\Gamma_r$ is the total space of an orientable circle-bundle over $T^2$.
Note that $\pi_1(H(3, \mathbb{R})/\Gamma_r) \cong \Gamma_r$. As
$$\begin{bmatrix} 1 & a_1 & \frac{c_1}{r}\\ 0 & 1 & b_1\\ 0 & 0 & 1\end{bmatrix}\begin{bmatrix} 1 & a_2 & \frac{c_2}{r}\\ 0 & 1 & b_2\\ 0 & 0 & 1\end{bmatrix} = \begin{bmatrix} 1 & a_1 + a_2 & \frac{c_1}{r} + a_1b_2 + \frac{c_2}{r}\\ 0 & 1 & b_1 + b_2\\ 0 & 0 & 1\end{bmatrix},$$
we see that
$$[\Gamma_r, \Gamma_r] = \left\{\begin{bmatrix} 1 & 0 & c\\ 0 & 1 & 0\\ 0 & 0 & 1\end{bmatrix} : c \in \mathbb{Z}\right\}$$
and hence $[[\Gamma_r, \Gamma_r], \Gamma_r]$ is trivial, i.e. $\Gamma_r$ is two-step nilpotent.
Is $H(3, \mathbb{R})/\Gamma_r \to T^2$ the Chern class $r$ orientable circle bundle (as notation might suggest)? In order to answer this, note that it follows from the Gysin sequence applied to the circle bundle $M_r \to T^2$ that $H_1(M_r; \mathbb{Z}) \cong \mathbb{Z}\oplus\mathbb{Z}\oplus\mathbb{Z}/r\mathbb{Z}$. On the other hand
$$H_1(H(3, \mathbb{R})/\Gamma_r; \mathbb{Z}) \cong \pi_1(H(3, \mathbb{R})/\Gamma_r)^{\text{ab}} \cong \Gamma_r^{\text{ab}} \cong \mathbb{Z}\oplus\mathbb{Z}\oplus\mathbb{Z}/r\mathbb{Z}$$
where the last isomorphism follows from the description of $[\Gamma_r, \Gamma_r]$ above. Therefore, up to a choice of orientation, we see that $H(3, \mathbb{R})/\Gamma_r \to T^2$ is the Chern class $r$ orientable circle-bundle and hence $M_r$ is diffeomorphic to $H(3, \mathbb{R})/\Gamma_r$. Hence $\pi_1(M_r) \cong \pi_1(H(3,\mathbb{R}/\Gamma_r) \cong \Gamma_r$ is two-step nilpotent.
To see that the description of $\pi_1(M_r)$ is consistent with the ones given by Jason DeVito and Lee Mosher, note that there is an isomorphism $\Gamma_r \cong \langle a, b, c \mid [a, c] = [b, c] = 1, [a, b] = c^r\rangle$ given by
$$\begin{bmatrix} 1 & 1 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\end{bmatrix} \mapsto a,\quad \begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 1\\ 0 & 0 & 1\end{bmatrix} \mapsto b,\quad \begin{bmatrix} 1 & 0 & \frac{1}{r}\\ 0 & 1 & 0\\ 0 & 0 & 1\end{bmatrix} \mapsto c.$$
It follows from this presentation that
$$\Gamma_r^{\text{ab}} \cong \langle a, b, c \mid [a, b] = [a, c] = [b, c] = c^r = 1\rangle \cong \langle a\rangle\oplus\langle b\rangle\oplus\langle c \mid c^r = 1\rangle \cong \mathbb{Z}\oplus\mathbb{Z}\oplus\mathbb{Z}/r\mathbb{Z}$$
which agrees with the calculation above.
In general, manifolds which arise this way always have nilpotent fundamental group. More precisely, for every $r$, the manifold $M_r$ is of the form $N/\Gamma$ where $N$ is a simply connected nilpotent Lie group and $\Gamma < N$ is a discrete subgroup; that is, $M_r$ is a nilmanifold (every compact nilmanifold can be realised as such a quotient). As $\pi_1(N/\Gamma) \cong \Gamma < N$ and $N$ is nilpotent, it follows that the fundamental group of a compact nilmanifold is always nilpotent. The non-trivial part of this answer was to show that orientable circle bundles over $T^2$ are indeed nilmanifolds.