theorem exercise_4_4 (p : polynomial ℂ) :
  p.degree = @card (root_set p ℂ) (polynomial.root_set_fintype p ℂ) ↔
  disjoint
  (@card (root_set p.derivative ℂ) (polynomial.root_set_fintype p.derivative ℂ))
  (@card (root_set p ℂ) (polynomial.root_set_fintype p ℂ)) :=

Suppose $p \in \mathcal{P}(\mathbf{C})$ has degree $m$. Prove that $p$ has $m$ distinct roots if and only if $p$ and its derivative $p^{\prime}$ have no roots in common.

\begin{proof}

    First, let $p$ have $m$ distinct roots. Since $p$ has the degree of $m$, then this could imply that $p$ can be actually written in the form of $p(z)=c\left(z-\lambda_1\right) \ldots\left(z-\lambda_m\right)$, which you have $\lambda_1, \ldots, \lambda_m$ being distinct.

To prove that both $p$ and $p^{\prime}$ have no roots in commons, we must now show that $p^{\prime}\left(\lambda_j\right) \neq 0$ for every $j$. So, to do so, just fix $j$. The previous expression for $p$ shows that we can now write $p$ in the form of $p(z)=\left(z-\lambda_j\right) q(z)$, which $q$ is a polynomial such that $q\left(\lambda_j\right) \neq 0$.

When you differentiate both sides of the previous equation, then you would then have $p^{\prime}(z)=(z-$ $\left.\lambda_j\right) q^{\prime}(z)+q(z)$

Therefore: $\left.=p^{\prime}\left(\lambda_j\right)=q \lambda_j\right)$

Equals: $p^{\prime}\left(\lambda_j\right) \neq 0$

Now, to prove the other direction, we would now prove the contrapositive, which means that we will be proving that if $p$ has actually less than $m$ distinct roots, then both $p$ and $p^{\prime}$ have at least one root in common.

Now, for some root of $\lambda$ of $p$, we can write $p$ is in the form of $\left.p(z)=(z-\lambda)^n q(z)\right)$, which is where both $n \geq 2$ and $q$ is a polynomial. When differentiating both sides of the previous equations, we would then have $p^{\prime}(z)=(z-\lambda)^n q^{\prime}(z)+n(z-\lambda)^{n-1} q(z)$.

Therefore, $p^{\prime}(\lambda)=0$, which would make $\lambda$ is a common root of both $p$ and $p^{\prime}$.

\end{proof}


theorem exercise_5_4 {F V : Type*} [add_comm_group V] [field F]
  [module F V] (S T : V →ₗ[F] V) (hST : S ∘ T = T ∘ S) (c : F):
  map S (T - c • id).ker = (T - c • id).ker :=

import .common

open set fintype complex polynomial submodule linear_map finite_dimensional
open module module.End inner_product_space

open_locale big_operators

Suppose that $S, T \in \mathcal{L}(V)$ are such that $S T=T S$. Prove that $\operatorname{null} (T-\lambda I)$ is invariant under $S$ for every $\lambda \in \mathbf{F}$.

\begin{proof}

    First off, fix $\lambda \in F$. Secondly, let $v \in \operatorname{null}(T-\lambda I)$. If so, then $(T-\lambda I)(S v)=T S v-\lambda S v=$ $S T v-\lambda S v=S(T v-\lambda v)=0$. Therefore, $S v \in \operatorname{null}(T-\lambda I)$ since $n u l l(T-\lambda I)$ is actually invariant under $S$.

\end{proof}


theorem exercise_5_12 {F V : Type*} [add_comm_group V] [field F]
  [module F V] {S : End F V}
  (hS : ∀ v : V, ∃ c : F, v ∈ eigenspace S c) :
  ∃ c : F, S = c • id :=

Suppose $T \in \mathcal{L}(V)$ is such that every vector in $V$ is an eigenvector of $T$. Prove that $T$ is a scalar multiple of the identity operator.

\begin{proof}

    For every single $v \in V$, there does exist $a_v \in F$ such that $T v=a_v v$. Since $T 0=0$, then we have to make $a_0$ be the any number in F. However, for every single $v \in V\{0\}$, then the value of $a_V$ is uniquely determined by the previous equation of $T v=a_v v$.

Now, to show that $T$ is a scalar multiple of the identity, then me must show that $a_v$ is independent of $v$ for $v \in V\{0\}$. We would now want to show that $a_v=a_w$.

First, just make the case of where $(v, w)$ is linearly dependent. Then, there does exist $b \in F$ such that $w=b v$. Now, you would have the following: $a_W w=T w=T(b v)=b T v=b\left(a_v v\right)=a_v w$. This is showing that $a_v=a_w$.

Finally, make the consideration to make $(v, w)$ be linearly independent. Now, we would have the following: $\left.a_{(} v+w\right)(v+w)=T(v+w)=T v+T w=a_v v+a_w w$.

That previous equation implies the following: $\left.\left.\left(a_{(} v+w\right)-a_v\right) v+\left(a_{(} v+w\right)-a_w\right) w=0$. Since $(v, w)$ is linearly independent, this would imply that both $\left.a_{(} v+w\right)=a_v$ and $\left.a_{(} v+w\right)=a_w$. Therefore, $a_v=a_w$.

\end{proof}


theorem exercise_5_20 {F V : Type*} [add_comm_group V] [field F]
  [module F V] [finite_dimensional F V] {S T : End F V}
  (h1 : @card T.eigenvalues (eigenvalues.fintype T) = finrank F V)
  (h2 : ∀ v : V, ∃ c : F, v ∈ eigenspace S c ↔ ∃ c : F, v ∈ eigenspace T c) :
  S * T = T * S :=

Suppose that $T \in \mathcal{L}(V)$ has $\operatorname{dim} V$ distinct eigenvalues and that $S \in \mathcal{L}(V)$ has the same eigenvectors as $T$ (not necessarily with the same eigenvalues). Prove that $S T=T S$.

\begin{proof}

    First off, let $n=\operatorname{dim} V$. so, there is a basis of $\left(v_1, \ldots, v_j\right)$ of $V$ that consist of eigenvectors of $T$. Now, let $\lambda_1, \ldots, \lambda_n$ be the corresponding eigenvalues, then we would have $T v_j=\lambda_1 v_j$ for every single $j$.

Now, for every $v_j$ is also an eigenvector of S, so $S v_j=a_j v_j$ for some $a_j \in F$. For each $j$, we would then have $(S T) v_j=S\left(T v_j\right)=\lambda_j S v_j=a_j \lambda_j v_j$ and $(T S) v_j=T\left(S v_j\right)=a_j T v_j=a_j \lambda_j v_j$. Since both operators, which are $S T$ and $T S$, agree on a basis, then both are equal.

\end{proof}


theorem exercise_6_2 {V : Type*} [add_comm_group V] [module ℂ V]
  [inner_product_space ℂ V] (u v : V) :
  ⟪u, v⟫_ℂ = 0 ↔ ∀ (a : ℂ), ∥u∥ ≤ ∥u + a • v∥ :=

Suppose $u, v \in V$. Prove that $\langle u, v\rangle=0$ if and only if $\|u\| \leq\|u+a v\|$ for all $a \in \mathbf{F}$.

\begin{proof}

    First off, let us suppose that $(u, v)=0$.

Now, let $a \in \mathbb{F}$. Next, $u, a v$ are orthogonal.

The Pythagorean theorem thus implies that

$$

\begin{aligned}

\|u+a v\|^2 & =\|u\|^2+\|a v\|^2 \\

& \geq\|u\|^2

\end{aligned}

$$

So, by taking the square roots, this will now give us $\|u\| \leq\|u+a v\|$.

Now, to prove the implication in the other direction, we must now let $\|u\| \leq$ $\|u+a v\|$ for all $a \in \mathbb{F}$. Squaring this inequality, we get both:

$$

\begin{gathered}

\|u\|^2 a n d \leq\|u+a v\|^2 \\

=(u+a v, u+a v) \\

=(u, u)+(u, a v)+(a v, u)+(a v, a v) \\

=\|u\|^2+\bar{a}(u, v)+a \overline{(u, v)}+|a|^2\|v\|^2 \\

\|u\|^2+2 \Re \bar{a}(u, v)+|a|^2\|v\|^2

\end{gathered}

$$

for all $a \in \mathbb{F}$.

Therefore,

$$

-2 \Re \bar{a}(u, v) \leq|a|^2\|v\|^2

$$

for all $a \in \mathbb{F}$. In particular, we can let $a$ equal $-t(u, v)$ for $t>0$. Substituting this value for $a$ into the inequality above gives

$$

2 t|(u, v)|^2 \leq t^2|(u, v)|^2\|v\|^2

$$

for all $t>0$.

Step 4

4 of 4

Divide both sides of the inequality above by $t$, getting

$$

2|(u, v)|^2 \leq t \mid(u, v)^2\|v\|^2

$$

for all $t>0$. If $v=0$, then $(u, v)=0$, as desired. If $v \neq 0$, set $t$ equal to $1 /\|v\|^2$ in the inequality above, getting

$$

2|(u, v)|^2 \leq|(u, v)|^2,

$$

which implies that $(u, v)=0$.

\end{proof}


theorem exercise_6_7 {V : Type*} [inner_product_space ℂ V] (u v : V) :
  ⟪u, v⟫_ℂ = (∥u + v∥^2 - ∥u - v∥^2 + I*∥u + I•v∥^2 - I*∥u-I•v∥^2) / 4 :=

Prove that if $V$ is a complex inner-product space, then $\langle u, v\rangle=\frac{\|u+v\|^{2}-\|u-v\|^{2}+\|u+i v\|^{2} i-\|u-i v\|^{2} i}{4}$ for all $u, v \in V$.

\begin{proof}

Let $V$ be an inner-product space and $u, v\in V$. Then

$$

\begin{aligned}

\|u+v\|^2 & =\langle u+v, v+v\rangle \\

& =\|u\|^2+\langle u, v\rangle+\langle v, u\rangle+\|v\|^2 \\

-\|u-v\|^2 & =-\langle u-v, u-v\rangle \\

& =-\|u\|^2+\langle u, v\rangle+\langle v, u\rangle-\|v\|^2 \\

i\|u+i v\|^2 & =i\langle u+i v, u+i v\rangle \\

& =i\|u\|^2+\langle u, v\rangle-\langle v, u\rangle+i\|v\|^2 \\

-i\|u-i v\|^2 & =-i\langle u-i v, u-i v\rangle \\

& =-i\|u\|^2+\langle u, v\rangle-\langle v, u\rangle-i\|v\|^2 .

\end{aligned}

$$

Thus $\left(\|u+v\|^2\right)-\|u-v\|^2+\left(i\|u+i v\|^2\right)-i\|u-i v\|^2=4\langle u, v\rangle.$

\end{proof}


theorem exercise_6_16 {K V : Type*} [is_R_or_C K] [inner_product_space K V]
  {U : submodule K V} :
  U.orthogonal = ⊥  ↔ U = ⊤ :=

Suppose $U$ is a subspace of $V$. Prove that $U^{\perp}=\{0\}$ if and only if $U=V$

\begin{proof}

    $V=U \bigoplus U^{\perp}$, therefore $U^\perp = \{0\}$ iff $U=V$.

\end{proof}


theorem exercise_7_6 {V : Type*} [inner_product_space ℂ V]
  [finite_dimensional ℂ V] (T : End ℂ V)
  (hT : T * T.adjoint = T.adjoint * T) :
  T.range = T.adjoint.range :=

Prove that if $T \in \mathcal{L}(V)$ is normal, then $\operatorname{range} T=\operatorname{range} T^{*}.$

\begin{proof}

    Let $T \in \mathcal{L}(V)$ to be a normal operator.

Suppose $u \in \operatorname{null} T$. Then, by $7.20$,

$$

0=\|T u\|=\left\|T^* u\right\|,

$$

which implies that $u \in \operatorname{null} T^*$.

Hence

$$

\operatorname{null} T=\operatorname{null} T^*

$$

because $\left(T^*\right)^*=T$ and the same argument can be repeated.

Now we have

$$

\begin{aligned}

\text { range } T & =\left(\text { null } T^*\right)^{\perp} \\

& =(\text { null } T)^{\perp} \\

& =\operatorname{range} T^*,

\end{aligned}

$$

where the first and last equality follow from items (d) and (b) of 7.7.

Hence, range $T=$ range $T^*$.

\end{proof}


theorem exercise_7_10 {V : Type*} [inner_product_space ℂ V]
  [finite_dimensional ℂ V] (T : End ℂ V)
  (hT : T * T.adjoint = T.adjoint * T) (hT1 : T^9 = T^8) :
  is_self_adjoint T ∧ T^2 = T :=

Suppose $V$ is a complex inner-product space and $T \in \mathcal{L}(V)$ is a normal operator such that $T^{9}=T^{8}$. Prove that $T$ is self-adjoint and $T^{2}=T$.

\begin{proof}

    Based on the complex spectral theorem, there is an orthonormal basis of $\left(e_1, \ldots, e_n\right)$ of $V$ consisting of eigenvectors of $T$. Now, let $\lambda_1, \ldots, \lambda_n$ be the corresponding eigenvalues. Therefore,

$$

T e_1=\lambda_j e_j

$$

for $j=1 \ldots n$.

Next, by applying $T$ repeatedly to both sides of the equation above, we get $T^9 e_j=\left(\lambda_j\right)^9 e_j$ and rei =8ej. Thus $T^8 e_j=\left(\lambda_j\right)^8 e_j$, which implies that $\lambda_j$ equals 0 or 1 . In particular, all the eigenvalues of $T$ are real. This would then imply that $T$ is self-adjoint.

Now, by applying $T$ to both sides of the equation above, we get

$$

\begin{aligned}

T^2 e_j & =\left(\lambda_j\right)^2 e_j \\

& =\lambda_j e_j \\

& =T e_j

\end{aligned}

$$

which is where the second equality holds because $\lambda_j$ equals 0 or 1 . Because $T^2$ and $T$ agree on a basis, they must be equal.

\end{proof}


theorem exercise_7_14 {𝕜 V : Type*} [is_R_or_C 𝕜]
  [inner_product_space 𝕜 V] [finite_dimensional 𝕜 V]
  {T : End 𝕜 V} (hT : is_self_adjoint T)
  {l : 𝕜} {ε : ℝ} (he : ε > 0) : ∃ v : V, ‖v‖= 1 ∧ (‖T v - l • v‖ < ε →
  (∃ l' : T.eigenvalues, ‖l - l'‖ < ε)) :=

Suppose $T \in \mathcal{L}(V)$ is self-adjoint, $\lambda \in \mathbf{F}$, and $\epsilon>0$. Prove that if there exists $v \in V$ such that $\|v\|=1$ and $\|T v-\lambda v\|<\epsilon,$ then $T$ has an eigenvalue $\lambda^{\prime}$ such that $\left|\lambda-\lambda^{\prime}\right|<\epsilon$.

\begin{proof}

    Let $T \in \mathcal{L}(V)$ be a self-adjoint, and let $\lambda \in \mathbf{F}$ and $\epsilon>0$.

By the Spectral Theorem, there is $e_1, \ldots, e_n$ an orthonormal basis of $V$ consisting of eigenvectors of $T$ and let $\lambda_1, \ldots, \lambda_n$ denote their corresponding eigenvalues.

Choose an eigenvalue $\lambda^{\prime}$ of $T$ such that $\left|\lambda^{\prime}-\lambda\right|^2$ is minimized.

There are $a_1, \ldots, a_n \in \mathbb{F}$ such that

$$

v=a_1 e_1+\cdots+a_n e_n .

$$

Thus, we have

$$

\begin{aligned}

\epsilon^2 & >|| T v-\left.\lambda v\right|^2 \\

& =\left|\left\langle T v-\lambda v, e_1\right\rangle\right|^2+\cdots+\left|\left\langle T v-\lambda v, e_n\right\rangle\right|^2 \\

& =\left|\lambda_1 a_1-\lambda a_1\right|^2+\cdots+\left|\lambda_n a_n-\lambda a_n\right|^2 \\

& =\left|a_1\right|^2\left|\lambda_1-\lambda\right|^2+\cdots+\left|a_n\right|^2\left|\lambda_n-\lambda\right|^2 \\

& \geq\left|a_1\right|^2\left|\lambda^{\prime}-\lambda\right|^2+\cdots+\left|a_n\right|^2\left|\lambda^{\prime}-\lambda\right|^2 \\

& =\left|\lambda^{\prime}-\lambda\right|^2

\end{aligned}

$$

where the second and fifth lines follow from $6.30$ (the fifth because $\|v\|=1$ ). Now, we taking the square root.

Hence, $T$ has an eigenvalue $\lambda^{\prime}$ such that $\left|\lambda^{\prime}-\lambda\right|<\epsilon$

\end{proof}


theorem exercise_1_1_3 (n : ℤ) :
  ∀ (a b c : ℤ), (a+b)+c ≡ a+(b+c) [ZMOD n] :=

import .common

open set function nat int fintype real polynomial mv_polynomial
open subgroup ideal submodule zsqrtd gaussian_int char_p mul_aut matrix

open_locale pointwise
open_locale big_operators
noncomputable theory

Prove that the addition of residue classes $\mathbb{Z}/n\mathbb{Z}$ is associative.

\begin{proof}

    We have

$$

\begin{aligned}

(\bar{a}+\bar{b})+\bar{c} &=\overline{a+b}+\bar{c} \\

&=\overline{(a+b)+c} \\

&=\overline{a+(b+c)} \\

&=\bar{a}+\overline{b+c} \\

&=\bar{a}+(\bar{b}+\bar{c})

\end{aligned}

$$

since integer addition is associative.

\end{proof}


theorem exercise_1_1_5 (n : ℕ) (hn : 1 < n) :
  is_empty (group (zmod n)) :=

Prove that for all $n>1$ that $\mathbb{Z}/n\mathbb{Z}$ is not a group under multiplication of residue classes.

\begin{proof}

    Note that since $n>1, \overline{1} \neq \overline{0}$. Now suppose $\mathbb{Z} /(n)$ contains a multiplicative identity element $\bar{e}$. Then in particular,

$$

\bar{e} \cdot \overline{1}=\overline{1}

$$

so that $\bar{e}=\overline{1}$. Note, however, that

$$

\overline{0} \cdot \bar{k}=\overline{0}

$$

for all k, so that $\overline{0}$ does not have a multiplicative inverse. Hence $\mathbb{Z} /(n)$ is not a group under multiplication.

\end{proof}


theorem exercise_1_1_16 {G : Type*} [group G]
  (x : G) (hx : x ^ 2 = 1) :
  order_of x = 1 ∨ order_of x = 2 :=

Let $x$ be an element of $G$. Prove that $x^2=1$ if and only if $|x|$ is either $1$ or $2$.

\begin{proof}

    $(\Rightarrow)$ Suppose $x^2=1$. Then we have $0<|x| \leq 2$, i.e., $|x|$ is either 1 or 2 .

( $\Leftarrow$ ) If $|x|=1$, then we have $x=1$ so that $x^2=1$. If $|x|=2$ then $x^2=1$ by definition. So if $|x|$ is 1 or 2 , we have $x^2=1$.

\end{proof}


theorem exercise_1_1_18 {G : Type*} [group G]
  (x y : G) : x * y = y * x ↔ y⁻¹ * x * y = x ↔ x⁻¹ * y⁻¹ * x * y = 1 :=

Let $x$ and $y$ be elements of $G$. Prove that $xy=yx$ if and only if $y^{-1}xy=x$ if and only if $x^{-1}y^{-1}xy=1$.

\begin{proof}

If $x y=y x$, then $y^{-1} x y=y^{-1} y x=1 x=x$. Multiplying by $x^{-1}$ then gives $x^{-1} y^{-1} x y=1$.

On the other hand, if $x^{-1} y^{-1} x y=1$, then we may multiply on the left by $x$ to get $y^{-1} x y=x$. Then multiplying on the left by $y$ gives $x y=y x$ as desired.

\end{proof}


theorem exercise_1_1_22a {G : Type*} [group G] (x g : G) :
  order_of x = order_of (g⁻¹ * x * g) :=

If $x$ and $g$ are elements of the group $G$, prove that $|x|=\left|g^{-1} x g\right|$.

\begin{proof}

    First we prove a technical lemma:

    {\bf Lemma.} For all $a, b \in G$ and $n \in \mathbb{Z},\left(b^{-1} a b\right)^n=b^{-1} a^n b$.

The statement is clear for $n=0$. We prove the case $n>0$ by induction; the base case $n=1$ is clear. Now suppose $\left(b^{-1} a b\right)^n=b^{-1} a^n b$ for some $n \geq 1$; then

$$

\left(b^{-1} a b\right)^{n+1}=\left(b^{-1} a b\right)\left(b^{-1} a b\right)^n=b^{-1} a b b^{-1} a^n b=b^{-1} a^{n+1} b .

$$

By induction the statement holds for all positive $n$.

Now suppose $n<0$; we have

$$

\left(b^{-1} a b\right)^n=\left(\left(b^{-1} a b\right)^{-n}\right)^{-1}=\left(b^{-1} a^{-n} b\right)^{-1}=b^{-1} a^n b .

$$

Hence, the statement holds for all integers $n$.

Now to the main result. Suppose first that $|x|$ is infinity and that $\left|g^{-1} x g\right|=n$ for some positive integer $n$. Then we have

$$

\left(g^{-1} x g\right)^n=g^{-1} x^n g=1,

$$

and multiplying on the left by $g$ and on the right by $g^{-1}$ gives us that $x^n=1$, a contradiction. Thus if $|x|$ is infinity, so is $\left|g^{-1} x g\right|$. Similarly, if $\left|g^{-1} x g\right|$ is infinite and $|x|=n$, we have

$$

\left(g^{-1} x g\right)^n=g^{-1} x^n g=g^{-1} g=1,

$$

a contradiction. Hence if $\left|g^{-1} x g\right|$ is infinite, so is $|x|$.

Suppose now that $|x|=n$ and $\left|g^{-1} x g\right|=m$ for some positive integers $n$ and $m$. We have

$$

\left(g^{-1} x g\right)^n=g^{-1} x^n g=g^{-1} g=1,

$$

So that $m \leq n$, and

$$

\left(g^{-1} x g\right)^m=g^{-1} x^m g=1,

$$

so that $x^m=1$ and $n \leq m$. Thus $n=m$.

\end{proof}


theorem exercise_1_1_25 {G : Type*} [group G]
  (h : ∀ x : G, x ^ 2 = 1) : ∀ a b : G, a*b = b*a :=

Prove that if $x^{2}=1$ for all $x \in G$ then $G$ is abelian.

\begin{proof}

    Solution: Note that since $x^2=1$ for all $x \in G$, we have $x^{-1}=x$. Now let $a, b \in G$. We have

$$

a b=(a b)^{-1}=b^{-1} a^{-1}=b a .

$$

Thus $G$ is abelian.

\end{proof}


theorem exercise_1_1_34 {G : Type*} [group G] {x : G}
  (hx_inf : order_of x = 0) (n m : ℤ) :
  x ^ n ≠ x ^ m :=

If $x$ is an element of infinite order in $G$, prove that the elements $x^{n}, n \in \mathbb{Z}$ are all distinct.

\begin{proof}

    Solution: Suppose to the contrary that $x^a=x^b$ for some $0 \leq a<b \leq n-1$. Then we have $x^{b-a}=1$, with $1 \leq b-a<n$. However, recall that $n$ is by definition the least integer $k$ such that $x^k=1$, so we have a contradiction. Thus all the $x^i$, $0 \leq i \leq n-1$, are distinct. In particular, we have

$$

\left\{x^i \mid 0 \leq i \leq n-1\right\} \subseteq G,

$$

so that $|x|=n \leq|G|$

\end{proof}


theorem exercise_1_6_4 :
  is_empty (multiplicative ℝ ≃* multiplicative ℂ) :=

Prove that the multiplicative groups $\mathbb{R}-\{0\}$ and $\mathbb{C}-\{0\}$ are not isomorphic.

\begin{proof}

    Isomorphic groups necessarily have the same number of elements of order $n$ for all finite $n$.

Now let $x \in \mathbb{R}^{\times}$. If $x=1$ then $|x|=1$, and if $x=-1$ then $|x|=2$. If (with bars denoting absolute value) $|x|<1$, then we have

$$

1>|x|>\left|x^2\right|>\cdots,

$$

and in particular, $1>\left|x^n\right|$ for all $n$. So $x$ has infinite order in $\mathbb{R}^{\times}$.

Similarly, if $|x|>1$ (absolute value) then $x$ has infinite order in $\mathbb{R}^{\times}$. So $\mathbb{R}^{\times}$has 1 element of order 1,1 element of order 2 , and all other elements have infinite order.

In $\mathbb{C}^{\times}$, on the other hand, $i$ has order 4 . Thus $\mathbb{R}^{\times}$and $\mathbb{C}^{\times}$are not isomorphic.

\end{proof}


theorem exercise_1_6_17 {G : Type*} [group G] (f : G → G)
  (hf : f = λ g, g⁻¹) :
  ∀ x y : G, f x * f y = f (x*y) ↔ ∀ x y : G, x*y = y*x :=

Let $G$ be any group. Prove that the map from $G$ to itself defined by $g \mapsto g^{-1}$ is a homomorphism if and only if $G$ is abelian.

\begin{proof}

    $(\Rightarrow)$ Suppose $G$ is abelian. Then

$$

\varphi(a b)=(a b)^{-1}=b^{-1} a^{-1}=a^{-1} b^{-1}=\varphi(a) \varphi(b),

$$

so that $\varphi$ is a homomorphism.

$(\Leftarrow)$ Suppose $\varphi$ is a homomorphism, and let $a, b \in G$. Then

$$

a b=\left(b^{-1} a^{-1}\right)^{-1}=\varphi\left(b^{-1} a^{-1}\right)=\varphi\left(b^{-1}\right) \varphi\left(a^{-1}\right)=\left(b^{-1}\right)^{-1}\left(a^{-1}\right)^{-1}=b a,

$$

so that $G$ is abelian.

\end{proof}


theorem exercise_2_1_5 {G : Type*} [group G] [fintype G]
  (hG : card G > 2) (H : subgroup G) [fintype H] :
  card H ≠ card G - 1 :=

Prove that $G$ cannot have a subgroup $H$ with $|H|=n-1$, where $n=|G|>2$.

\begin{proof}

    Solution: Under these conditions, there exists a nonidentity element $x \in H$ and an element $y \notin H$. Consider the product $x y$. If $x y \in H$, then since $x^{-1} \in H$ and $H$ is a subgroup, $y \in H$, a contradiction. If $x y \notin H$, then we have $x y=y$. Thus $x=1$, a contradiction. Thus no such subgroup exists.

\end{proof}


theorem exercise_2_4_4 {G : Type*} [group G] (H : subgroup G) :
  subgroup.closure ((H : set G) \ {1}) = ⊤ :=

Prove that if $H$ is a subgroup of $G$ then $H$ is generated by the set $H-\{1\}$.

\begin{proof}

    If $H=\{1\}$ then $H-\{1\}$ is the empty set which indeed generates the trivial subgroup $H$. So suppose $|H|>1$ and pick a nonidentity element $h \in H$. Since $1=h h^{-1} \in\langle H-\{1\}\rangle$ (Proposition 9), we see that $H \leq\langle H-\{1\}\rangle$. By minimality of $\langle H-\{1\}\rangle$, the reverse inclusion also holds so that $\langle H-\{1\}\rangle=$ $H$.

\end{proof}


theorem exercise_2_4_16b {n : ℕ} {hn : n ≠ 0}
  {R : subgroup (dihedral_group n)}
  (hR : R = subgroup.closure {dihedral_group.r 1}) :
  R ≠ ⊤ ∧
  ∀ K : subgroup (dihedral_group n), R ≤ K → K = R ∨ K = ⊤ :=

Show that the subgroup of all rotations in a dihedral group is a maximal subgroup.

\begin{proof}

    Fix a positive integer $n>1$ and let $H \leq D_{2 n}$ consist of the rotations of $D_{2 n}$. That is, $H=\langle r\rangle$. Now, this subgroup is proper since it does not contain $s$. If $H$ is not maximal, then by the previous proof we know there is a maximal subset $K$ containing $H$. Then $K$ must contain a reflection $s r^k$ for $k \in\{0,1, \ldots, n-1\}$. Then since $s r^k \in K$ and $r^{n-k} \in K$, it follows by closure that

$$

s=\left(s r^k\right)\left(r^{n-k}\right) \in K .

$$

But $D_{2 n}=\langle r, s\rangle$, so this shows that $K=D_{2 n}$, which is a contradiction. Therefore $H$ must be maximal.

\end{proof}


theorem exercise_3_1_3a {A : Type*} [comm_group A] (B : subgroup A) :
  ∀ a b : A ⧸ B, a*b = b*a :=

Let $A$ be an abelian group and let $B$ be a subgroup of $A$. Prove that $A / B$ is abelian.

\begin{proof}

    Lemma: Let $G$ be a group. If $|G|=2$, then $G \cong Z_2$.

Proof: Since $G=\{e a\}$ has an identity element, say $e$, we know that $e e=e, e a=a$, and $a e=a$. If $a^2=a$, we have $a=e$, a contradiction. Thus $a^2=e$. We can easily see that $G \cong Z_2$.

If $A$ is abelian, every subgroup of $A$ is normal; in particular, $B$ is normal, so $A / B$ is a group. Now let $x B, y B \in A / B$. Then

$$

(x B)(y B)=(x y) B=(y x) B=(y B)(x B) .

$$

Hence $A / B$ is abelian.

\end{proof}


theorem exercise_3_1_22b {G : Type*} [group G] (I : Type*)
  (H : I → subgroup G) (hH : ∀ i : I, subgroup.normal (H i)) :
  subgroup.normal (⨅ (i : I), H i):=

Prove that the intersection of an arbitrary nonempty collection of normal subgroups of a group is a normal subgroup (do not assume the collection is countable).

\begin{proof}

Let $\left\{H_i \mid i \in I\right\}$ be an arbitrary collection of normal subgroups of $G$ and consider the intersection

$$

\bigcap_{i \in I} H_i

$$

Take an element $a$ in the intersection and an arbitrary element $g \in G$. Then $g a g^{-1} \in H_i$ because $H_i$ is normal for any $i \in H$

By the definition of the intersection, this shows that $g a g^{-1} \in \bigcap_{i \in I} H_i$ and therefore it is a normal subgroup.

\end{proof}


theorem exercise_3_2_11 {G : Type*} [group G] {H K : subgroup G}
  (hHK : H ≤ K) :
  H.index = K.index * H.relindex K :=

Let $H \leq K \leq G$. Prove that $|G: H|=|G: K| \cdot|K: H|$ (do not assume $G$ is finite).

\begin{proof}

    Proof. Let $G$ be a group and let $I$ be a nonempty set of indices, not necessarily countable. Consider the collection of subgroups $\left\{N_\alpha \mid \alpha \in I\right\}$, where $N_\alpha \unlhd G$ for each $\alpha \in I$. Let

$$

N=\bigcap_{\alpha \in I} N_\alpha .

$$

We know $N$ is a subgroup of $G$.

For any $g \in G$ and any $n \in N$, we must have $n \in N_\alpha$ for each $\alpha$. And since $N_\alpha \unlhd G$, we have $g n g^{-1} \in N_\alpha$ for each $\alpha$. Therefore $g n g^{-1} \in N$, which shows that $g N g^{-1} \subseteq N$ for each $g \in G$. As before, this is enough to complete the proof.

\end{proof}


theorem exercise_3_2_21a (H : add_subgroup ℚ) (hH : H ≠ ⊤) : H.index = 0 :=

Prove that $\mathbb{Q}$ has no proper subgroups of finite index.

\begin{proof}

    Solution: We begin with a lemma.

Lemma: If $D$ is a divisible abelian group, then no proper subgroup of $D$ has finite index.

Proof: We saw previously that no finite group is divisible and that every proper quotient $D / A$ of a divisible group is divisible; thus no proper quotient of a divisible group is finite. Equivalently, $[D: A]$ is not finite.

Because $\mathbb{Q}$ and $\mathbb{Q} / \mathbb{Z}$ are divisible, the conclusion follows.

\end{proof}


theorem exercise_3_4_1 (G : Type*) [comm_group G] [is_simple_group G] :
    is_cyclic G ∧ ∃ G_fin : fintype G, nat.prime (@card G G_fin) :=

Prove that if $G$ is an abelian simple group then $G \cong Z_{p}$ for some prime $p$ (do not assume $G$ is a finite group).

\begin{proof}

    Solution: Let $G$ be an abelian simple group.

Suppose $G$ is infinite. If $x \in G$ is a nonidentity element of finite order, then $\langle x\rangle<G$ is a nontrivial normal subgroup, hence $G$ is not simple. If $x \in G$ is an element of infinite order, then $\left\langle x^2\right\rangle$ is a nontrivial normal subgroup, so $G$ is not simple.

Suppose $G$ is finite; say $|G|=n$. If $n$ is composite, say $n=p m$ for some prime $p$ with $m \neq 1$, then by Cauchy's Theorem $G$ contains an element $x$ of order $p$ and $\langle x\rangle$ is a nontrivial normal subgroup. Hence $G$ is not simple. Thus if $G$ is an abelian simple group, then $|G|=p$ is prime. We saw previously that the only such group up to isomorphism is $\mathbb{Z} /(p)$, so that $G \cong \mathbb{Z} /(p)$. Moreover, these groups are indeed simple.

\end{proof}


theorem exercise_3_4_5a {G : Type*} [group G]
  (H : subgroup G) [is_solvable G] : is_solvable H :=

Prove that subgroups of a solvable group are solvable.

\begin{proof}

    Let $G$ be a solvable group and let $H \leq G$. Since $G$ is solvable, we may find a chain of subgroups

$$

1=G_0 \unlhd G_1 \unlhd G_2 \unlhd \cdots \unlhd G_n=G

$$

so that each quotient $G_{i+1} / G_i$ is abelian. For each $i$, define

$$

H_i=G_i \cap H, \quad 0 \leq i \leq n .

$$

Then $H_i \leq H_{i+1}$ for each $i$. Moreover, if $g \in H_{i+1}$ and $x \in H_i$, then in particular $g \in G_{i+1}$ and $x \in G_i$, so that

$$

g x g^{-1} \in G_i

$$

because $G_i \unlhd G_{i+1}$. But $g$ and $x$ also belong to $H$, so

$$

g x g^{-1} \in H_i,

$$

which shows that $H_i \unlhd H_{i+1}$ for each $i$.

Next, note that

$$

H_i=G_i \cap H=\left(G_i \cap G_{i+1}\right) \cap H=G_i \cap H_{i+1} .

$$

By the Second Isomorphism Theorem, we then have

$$

H_{i+1} / H_i=H_{i+1} /\left(H_{i+1} \cap G_i\right) \cong H_{i+1} G_i / G_i \leq G_{i+1} / G_i .

$$

Since $H_{i+1} / H_i$ is isomorphic to a subgroup of the abelian group $G_{i+1} / G_i$, it follows that $H_{i+1} / H_i$ is also abelian. This completes the proof that $H$ is solvable.

\end{proof}


theorem exercise_3_4_11 {G : Type*} [group G] [is_solvable G]
  {H : subgroup G} (hH : H ≠ ⊥) [H.normal] :
  ∃ A ≤ H, A.normal ∧ ∀ a b : A, a*b = b*a :=

Prove that if $H$ is a nontrivial normal subgroup of the solvable group $G$ then there is a nontrivial subgroup $A$ of $H$ with $A \unlhd G$ and $A$ abelian.

\begin{proof}

    Suppose $H$ is a nontrivial normal subgroup of the solvable group $G$.

First, notice that $H$, being a subgroup of a solvable group, is itself solvable. By exercise $8, H$ has a chain of subgroups

$$

1 \leq H_1 \leq \ldots \leq H

$$

such that each $H_i$ is a normal subgroup of $H$ itself and $H_{i+1} / H_i$ is abelian. But then the first group in the series

$$

H_1 / 1 \cong H

$$

is an abelian subgroup of $H$.

\end{proof}


theorem exercise_4_3_26 {α : Type*} [fintype α] (ha : fintype.card α > 1)
  (h_tran : ∀ a b: α, ∃ σ : equiv.perm α, σ a = b) :
  ∃ σ : equiv.perm α, ∀ a : α, σ a ≠ a :=

Let $G$ be a transitive permutation group on the finite set $A$ with $|A|>1$. Show that there is some $\sigma \in G$ such that $\sigma(a) \neq a$ for all $a \in A$.

\begin{proof}

    Let $G$ be a transitive permutation group on the finite set $A,|A|>1$. We want to find an element $\sigma$ which doesn't stabilize anything, that is, we want a $\sigma$ such that

$$

\sigma \notin G_a

$$

for all $a \in A$.

Since the group is transitive, there is always a $g \in G$ such that $b=g \cdot a$. Let us see in what relationship the stabilizers of $a$ and $b$ are. We find

$$

\begin{aligned}

G_b & =\{h \in G \mid h \cdot b=b\} \\

& =\{h \in G \mid h g \cdot a=g \cdot a\} \\

& =\left\{h \in G \mid g^{-1} h g \cdot a=a\right\}

\end{aligned}

$$

Putting $h^{\prime}=g^{-1} h g$, we have $h=g h^{\prime} g^{-1}$ and

$$

\begin{aligned}

G_b & =g\left\{h^{\prime} \in H \mid h^{\prime} \cdot a=a\right\} g^{-1} \\

& =g G_a g^{-1}

\end{aligned}

$$

By the above, the stabilizer subgroup of any element is conjugate to some other stabilizer subgroup. Now, the stabilizer cannot be all of $G$ (else $\{a\}$ would be a orbit). Thus it is a proper subgroup of $G$. By the previous exercise, we have

$$

\bigcup_{a \in A} G_a=\bigcup_{g \in G} g G_a g^{-1} \subset G

$$

(the union of conjugates of a proper subgroup can never be all of $G$ ). This shows there is an element $\sigma$ which is not in any stabilizer of any element of $A$. Then $\sigma(a) \neq a$ for all $a \in A$, as we wanted to show.

\end{proof}


theorem exercise_4_2_14 {G : Type*} [fintype G] [group G]
  (hG : ¬ (card G).prime) (hG1 : ∀ k ∣ card G,
  ∃ (H : subgroup G) (fH : fintype H), @card H fH = k) :
  ¬ is_simple_group G :=

Let $G$ be a finite group of composite order $n$ with the property that $G$ has a subgroup of order $k$ for each positive integer $k$ dividing $n$. Prove that $G$ is not simple.

\begin{proof}

    Solution: Let $p$ be the smallest prime dividing $n$, and write $n=p m$. Now $G$ has a subgroup $H$ of order $m$, and $H$ has index $p$. Then $H$ is normal in $G$.

\end{proof}


theorem exercise_4_4_6a {G : Type*} [group G] (H : subgroup G)
  [subgroup.characteristic H] : subgroup.normal H  :=

Prove that characteristic subgroups are normal.

\begin{proof}

    Let $H$ be a characterestic subgroup of $G$. By definition $\alpha(H) \subset H$ for every $\alpha \in \operatorname{Aut}(G)$. So, $H$ is in particular invariant under the inner automorphism. Let $\phi_g$ denote the conjugation automorphism by $g$. Then $\phi_g(H) \subset H \Longrightarrow$ $g H g^{-1} \subset H$. So, $H$ is normal.

\end{proof}


theorem exercise_4_4_7 {G : Type*} [group G] {H : subgroup G} [fintype H]
  (hH : ∀ (K : subgroup G) (fK : fintype K), card H = @card K fK → H = K) :
  H.characteristic :=

If $H$ is the unique subgroup of a given order in a group $G$ prove $H$ is characteristic in $G$.

\begin{proof}

    Let $G$ be group and $H$ be the unique subgroup of order $n$. Now, let $\sigma \in \operatorname{Aut}(G)$. Now Clearly $|\sigma(G)|=n$, because $\sigma$ is a one-one onto map. But then as $H$ is the only subgroup of order $n$, and because of the fact that a automorphism maps subgroups to subgroups, we have $\sigma(H)=$ $H$ for every $\sigma \in \operatorname{Aut}(G)$. Hence, $H$ is a characterestic subgroup of $G$.

\end{proof}


theorem exercise_4_5_1a {p : ℕ} {G : Type*} [group G]
  {P : subgroup G} (hP : is_p_group p P) (H : subgroup G)
  (hH : P ≤ H) : is_p_group p H :=

Prove that if $P \in \operatorname{Syl}_{p}(G)$ and $H$ is a subgroup of $G$ containing $P$ then $P \in \operatorname{Syl}_{p}(H)$.

\begin{proof}

If $P \leq H \leq G$ is a Sylow $p$-subgroup of $G$, then $p$ does not divide $[G: P]$. Now $[G: P]=[G: H][H: P]$, so that $p$ does not divide $[H: P]$; hence $P$ is a Sylow $p$-subgroup of $H$.

\end{proof}


theorem exercise_4_5_14 {G : Type*} [group G] [fintype G]
  (hG : card G = 312) :
  ∃ (p : ℕ) (P : sylow p G), P.normal :=

Prove that a group of order 312 has a normal Sylow $p$-subgroup for some prime $p$ dividing its order.

\begin{proof}

    Since $|G|=351=3^{2}.13$, $G$ has $3-$Sylow subgroup of order $9$, as well as $13-$Sylow subgroup of order $13$. Now, we count the number of such subgroups. Let $n_{13}$ be the number of $13-$Sylow subgroup and $n_{3}$ be the number of  $3-$Sylow subgroup. Now $n_{13}=1+13k$ where $1+13k|9$. The choices for $k$ is $0$. Hence, there is a unique $13-$Sylow subgroup and hence is normal.

\end{proof}


theorem exercise_4_5_16 {p q r : ℕ} {G : Type*} [group G]
  [fintype G]  (hpqr : p < q ∧ q < r)
  (hpqr1 : p.prime ∧ q.prime ∧ r.prime)(hG : card G = p*q*r) :
  nonempty (sylow p G) ∨ nonempty(sylow q G) ∨ nonempty(sylow r G) :=

Let $|G|=p q r$, where $p, q$ and $r$ are primes with $p<q<r$. Prove that $G$ has a normal Sylow subgroup for either $p, q$ or $r$.

\begin{proof}

    Let $|G|=p q r$. We also assume $p<q<r$. We prove that $G$ has a normal Sylow subgroup of $p$, $q$ or $r$. Now, Let $n_p, n_q, n_r$ be the number of Sylow-p subgroup, Sylow-q subgroup, Sylow-r subgroup resp. So, we have $n_r=1+r k$ such that $1+r k \mid p q$. So, in this case as $r$ is greatest $n_r$ can be 1 or $p q$. We assume $n_r=p q$. Now we have $n_q=1+q k$ such that $1+q k \mid p r$. Now,as $p<q<r, n_q$ can be 1 or $r$, or $p r$. Assume that $n_q=r$. Now we turn to $n_p$. Again my similar method we can conclude $n_p$ can be $1, q, r$, or $q r$. We assume that $n_p$ is $q$. Now we count the number of elements of order $p, q, r$. Since $n_r=p q$, the number of elements of order $r$ is $p q(r-1)$. Since $n_q=r$, the number of elements of order $q$ is $(q-1) r$. And as $n_p=q$, the number of elements of order $p$ is $(p-1) q$. So, in total we get $p q(r-1)+(q-1) r+(p-$ 1) $q=p q r+q r-r-q=p q r+r(q-1)-r$. But observe that as $q>1, r(q-1)-r>$ 0 . So the number of elements exceeds $p q r$. So, it proves that atleast $n_p$ or $n_q$ or $n_r$ is 1, which ultimately proves the result, because a unique Sylow-p subgroup is always normal.

\end{proof}


theorem exercise_4_5_18 {G : Type*} [fintype G] [group G]
  (hG : card G = 200) :
  ∃ N : sylow 5 G, N.normal :=

Prove that a group of order 200 has a normal Sylow 5-subgroup.

\begin{proof}

    Let $G$ be a group of order $200=5^2 \cdot 8$. Note that 5 is a prime not dividing 8 . Let $P \in$ $S y l_5(G)$. [We know $P$ exists since $S y l_5(G) \neq \emptyset$ by Sylow's Theorem]

The number of Sylow 5-subgroups of $G$ is of the form $1+k \cdot 5$, i.e., $n_5 \equiv 1(\bmod 5)$ and $n_5$ divides 8 . The only such number that divides 8 and equals $1 (\bmod 5)$ is 1 so $n_5=1$. Hence $P$ is the unique Sylow 5-subgroup.

Since $P$ is the unique Sylow 5-subgroup, this implies that $P$ is normal in $G$.

\end{proof}


theorem exercise_4_5_20 {G : Type*} [fintype G] [group G]
  (hG : card G = 1365) : ¬ is_simple_group G :=

Prove that if $|G|=1365$ then $G$ is not simple.

\begin{proof}

Since $|G|=1365=3.5.7.13$, $G$ has $13-$Sylow subgroup of order $13$. Now, we count the number of such subgroups. Let $n_{13}$ be the number of $13-$Sylow subgroup. Now $n_{13}=1+13k$ where $1+13k|3.5.7$. The choices for $k$ is $0$. Hence, there is a unique $13-$Sylow subgroup and hence is normal. so $G$ is not simple.

\end{proof}


theorem exercise_4_5_22 {G : Type*} [fintype G] [group G]
  (hG : card G = 132) : ¬ is_simple_group G :=

Prove that if $|G|=132$ then $G$ is not simple.

\begin{proof}

Since $|G|=132=2^{2}.3.11$, $G$ has $2-$Sylow subgroup of order $4$, as well as $11-$Sylow subgroup of order $11$, and $3-$Sylow subgroup of order $3$. Now, we count the number of such subgroups. Let $n_{11}$ be the number of  $11-$Sylow subgroup and $n_{3}$ be the number of  $3-$Sylow subgroup. Now $n_{11}=1+11k$ where $1+11k|12$. The choices for $k$ are $0$ or $1$. If $k=0$, there is only one $11-$Sylow subgroup and hence normal. So, assume now, that there are $12$ $11-$Sylow subgroup(for $k=1$). Now we look at $3-$ Sylow subgroups. $n_{3}=1+3k| 44$. So choice for $k$ are $0$, $1$, and $7$. If $k=0$, there is only one $3-$Sylow subgroup and hence normal. So, assume now, that there are $4$ $2-$Sylow subgroup (for $k=3$). Now we claim that simultaneously, there cannot be $12$ $11-$Sylow subgroup and $4$ $3-$Sylow subgroups provided there is more than one $2-$Sylow subgroups. So, either $2-$Sylow subgroup is normal or if not, then, either $11-$Sylow subgroup is normal being unique, or  the $3-$Sylow subgroup is normal(We don't consider the possibility of $22$ $3-$Sylow subgroup because of obvious reason). Now, to prove the claim, we observe that there are $120$ elements of order $11$. Also there are $8$ elements of order $3$. So we already get $120+8+1=129$ distinct elements in the group. Let us count the number of $2-$Sylow subgroups in $G$. $n_{2}=1+2k|33$. The possibilities for $k$ are $0$, $1$, $5$, $16$. Now, assume there is more than one $2-$Sylow subgroups. Let $H_{1}$ and $H_{2}$ be two distinct  $2-$Sylow subgroup. Now $|H_{1}|=4$. So we already get $129+3=132$ distinct elements in the group. Now $H_{2}$ being distinct from $H_{1}$, has at least one element which is not in $H_{1}$. This adds one more element in the group, at the least. Now already we have number of elements in the group exceeding the number of element in $G$. This gives a contradiction and proves the claim.

Hence $G$ is not simple.

\end{proof}


theorem exercise_4_5_28 {G : Type*} [group G] [fintype G]
  (hG : card G = 105) (P : sylow 3 G) [hP : P.normal] :
  comm_group G :=

Let $G$ be a group of order 105. Prove that if a Sylow 3-subgroup of $G$ is normal then $G$ is abelian.

\begin{proof}

    Given that $G$ is a group of order $1575=3^2 .5^2 .7$. Now, Let $n_p$ be the number of Sylow-p subgroups. It is given that Sylow-3 subgroup is normal and hence is unique, so $n_3=1$. First we prove that both Sylow-5 subgroup and Sylow 7-subgroup are normal. Let $P$ be the Sylow3 subgroup. Now, Consider $G / P$, which has order $5^2 .7$. Now, the number of Sylow $-5$ subgroup of $G / P$ is given by $1+5 k$, where $1+5 k \mid 7$. Clearly $k=0$ is the only choice and hence there is a unique Sylow-5 subgroup of $G / P$, and hence normal. In the same way Sylow-7 subgroup of $G / P$ is also unique and hence normal. Consider now the canonical map $\pi: G \rightarrow G / P$. The inverse image of Sylow-5 subgroup of $G / P$ under $\pi$, call it $H$, is a normal subgroup of $G$, and $|H|=3^2 .5^2$. Similarly, the inverse image of Sylow-7 subgroup of $G / P$ under $\pi$ call it $K$ is also normal in $G$ and $|K|=3^2 .7$. Now, consider $H$. Observe first that the number of Sylow-5 subgroup in $H$ is $1+5 k$ such that $1+5 k \mid 9$. Again $k=0$ and hence $H$ has a unique Sylow-5 subgroup, call it $P_1$. But, it is easy to see that $P_1$ is also a Sylow-5 subgroup of $G$, because $\left|P_1\right|=25$. But now any other Sylow 5 subgroup of $G$ is of the form $g P_1 g^{-1}$ for some $g \in G$. But observe that since $P_1 \subset H$ and $H$ is normal in $G$, so $g P_1 g^1 \subset H$, and $g P_1 g^{-1}$ is also Sylow-5 subgroup of $H$. But, then as Sylow-5 subgroup of $H$ is unique we have $g P_1 g^{-1}=P_1$. This shows that Sylow-5 subgroup of $G$ is unique and hence normal in $G$.

Similarly, one can argue the same for $K$ and deduce that Sylow-7 subgroup of $G$ is unique and hence normal. So, the first part of the problem is done.

\end{proof}


theorem exercise_5_4_2 {G : Type*} [group G] (H : subgroup G) :
  H.normal ↔ ⁅(⊤ : subgroup G), H⁆ ≤ H :=

Prove that a subgroup $H$ of $G$ is normal if and only if $[G, H] \leq H$.

\begin{proof}

    $H \unlhd G$ is equivalent to $g^{-1} h g \in H, \forall g \in G, \forall h \in H$. We claim that holds if and only if $h^{-1} g^{-1} h g \in H, \forall g \in G, \forall h \in H$, i.e., $\left\{h^{-1} g^{-1} h g: h \in H, g \in G\right\} \subseteq H$. That holds by the following argument:

If $g^{-1} h g \in H, \forall g \in G, \forall h \in H$, note that $h^{-1} \in H$, so multiplying them, we also obtain an element of $H$.

On the other hand, if $h^{-1} g^{-1} h g \in H, \forall g \in G, \forall h \in H$, then

$$

h h^{-1} g^{-1} h g=g^{-1} h g \in H, \forall g \in G, \forall h \in H .

$$

Since $\left\{h^{-1} g^{-1} h g: h \in H, g \in G\right\} \subseteq H \Leftrightarrow\left\langle\left\{h^{-1} g^{-1} h g: h \in H, g \in G\right\}\right\rangle \leq H$, we've solved the exercise by definition of $[H, G]$.

\end{proof}


theorem exercise_7_1_11 {R : Type*} [ring R] [is_domain R]
  {x : R} (hx : x^2 = 1) : x = 1 ∨ x = -1 :=

Prove that if $R$ is an integral domain and $x^{2}=1$ for some $x \in R$ then $x=\pm 1$.

\begin{proof}

    Solution: If $x^2=1$, then $x^2-1=0$. Evidently, then,

$$

(x-1)(x+1)=0 .

$$

Since $R$ is an integral domain, we must have $x-1=0$ or $x+1=0$; thus $x=1$ or $x=-1$.

\end{proof}


theorem exercise_7_1_15 {R : Type*} [ring R] (hR : ∀ a : R, a^2 = a) :
  comm_ring R :=

A ring $R$ is called a Boolean ring if $a^{2}=a$ for all $a \in R$. Prove that every Boolean ring is commutative.

\begin{proof}

    Solution: Note first that for all $a \in R$,

$$

-a=(-a)^2=(-1)^2 a^2=a^2=a .

$$

Now if $a, b \in R$, we have

$$

a+b=(a+b)^2=a^2+a b+b a+b^2=a+a b+b a+b .

$$

Thus $a b+b a=0$, and we have $a b=-b a$. But then $a b=b a$. Thus $R$ is commutative.

\end{proof}


theorem exercise_7_2_12 {R G : Type*} [ring R] [group G] [fintype G] :
  ∑ g : G, monoid_algebra.of R G g ∈ center (monoid_algebra R G) :=

Let $G=\left\{g_{1}, \ldots, g_{n}\right\}$ be a finite group. Prove that the element $N=g_{1}+g_{2}+\ldots+g_{n}$ is in the center of the group ring $R G$.

\begin{proof}

    Let $M=\sum_{i=1}^n r_i g_i$ be an element of $R[G]$. Note that for each $g_i \in G$, the action of $g_i$ on $G$ by conjugation permutes the subscripts. Then we have the following.

$$

\begin{aligned}

N M &=\left(\sum_{i=1}^n g_i\right)\left(\sum_{j=1}^n r_j g_j\right) \\

&=\sum_{j=1}^n \sum_{i=1}^n r_j g_i g_j \\

&=\sum_{j=1}^n \sum_{i=1}^n r_j g_j g_j^{-1} g_i g_j \\

&=\sum_{j=1}^n r_j g_j\left(\sum_{i=1}^n g_j^{-1} g_i g_j\right) \\

&=\sum_{j=1}^n r_j g_j\left(\sum_{i=1}^n g_i\right) \\

&=\left(\sum_{j=1}^n r_j g_j\right)\left(\sum_{i=1}^n g_i\right) \\

&=M N .

\end{aligned}

$$

Thus $N \in Z(R[G])$.

\end{proof}


theorem exercise_7_3_37 {R : Type*} {p m : ℕ} (hp : p.prime)
  (N : ideal $ zmod $ p^m) :
  is_nilpotent N ↔  is_nilpotent (ideal.span ({p} : set $ zmod $ p^m)) :=

An ideal $N$ is called nilpotent if $N^{n}$ is the zero ideal for some $n \geq 1$. Prove that the ideal $p \mathbb{Z} / p^{m} \mathbb{Z}$ is a nilpotent ideal in the ring $\mathbb{Z} / p^{m} \mathbb{Z}$.

\begin{proof}

    First we prove a lemma.

Lemma: Let $R$ be a ring, and let $I_1, I_2, J \subseteq R$ be ideals such that $J \subseteq I_1, I_2$. Then $\left(I_1 / J\right)\left(I_2 / J\right)=I_1 I_2 / J$.

Proof: ( $\subseteq$ ) Let

$$

\alpha=\sum\left(x_i+J\right)\left(y_i+J\right) \in\left(I_1 / J\right)\left(I_2 / J\right) .

$$

Then

$$

\alpha=\sum\left(x_i y_i+J\right)=\left(\sum x_i y_i\right)+J \in\left(I_1 I_2\right) / J .

$$

Now let $\alpha=\left(\sum x_i y_i\right)+J \in\left(I_1 I_2\right) / J$. Then

$$

\alpha=\sum\left(x_i+J\right)\left(y_i+J\right) \in\left(I_1 / J\right)\left(I_2 / J\right) .

$$

From this lemma and the lemma to Exercise 7.3.36, it follows by an easy induction that

$$

\left(p \mathbb{Z} / p^m \mathbb{Z}\right)^m=(p \mathbb{Z})^m / p^m \mathbb{Z}=p^m \mathbb{Z} / p^m \mathbb{Z} \cong 0 .

$$

Thus $p \mathbb{Z} / p^m \mathbb{Z}$ is nilpotent in $\mathbb{Z} / p^m \mathbb{Z}$.

\end{proof}


theorem exercise_8_1_12 {N : ℕ} (hN : N > 0) {M M': ℤ} {d : ℕ}
  (hMN : M.gcd N = 1) (hMd : d.gcd N.totient = 1)
  (hM' : M' ≡ M^d [ZMOD N]) :
  ∃ d' : ℕ, d' * d ≡ 1 [ZMOD N.totient] ∧
  M ≡ M'^d' [ZMOD N] :=

Let $N$ be a positive integer. Let $M$ be an integer relatively prime to $N$ and let $d$ be an integer relatively prime to $\varphi(N)$, where $\varphi$ denotes Euler's $\varphi$-function. Prove that if $M_{1} \equiv M^{d} \pmod N$ then $M \equiv M_{1}^{d^{\prime}} \pmod N$ where $d^{\prime}$ is the inverse of $d \bmod \varphi(N)$: $d d^{\prime} \equiv 1 \pmod {\varphi(N)}$.

\begin{proof}

    Note that there is some $k \in \mathbb{Z}$ such that $M^{d d^{\prime}} \equiv M^{k \varphi(N)+1} \equiv\left(M^{\varphi(N)}\right)^k \cdot M \bmod N$. By Euler's Theorem we have $M^{\varphi(N)} \equiv 1 \bmod N$, so that $M_1^{d^{\prime}} \equiv M \bmod N$.

\end{proof}


theorem exercise_8_3_4 {R : Type*} {n : ℤ} {r s : ℚ}
  (h : r^2 + s^2 = n) :
  ∃ a b : ℤ, a^2 + b^2 = n :=

Prove that if an integer is the sum of two rational squares, then it is the sum of two integer squares.

\begin{proof}

    Let $n=\frac{a^2}{b^2}+\frac{c^2}{d^2}$, or, equivalently, $n(b d)^2=a^2 d^2+c^2 b^2$. From this, we see that $n(b d)^2$ can be written as a sum of two squared integers. Therefore, if $q \equiv 3(\bmod 4)$ and $q^i$ appears in the prime power factorization of $n, i$ must be even. Let $j \in \mathbb{N} \cup\{0\}$ such that $q^j$ divides $b d$. Then $q^{i-2 j}$ divides $n$. But since $i$ is even, $i-2 j$ is even as well. Consequently, $n$ can be written as a sum of two squared integers.

\end{proof}


theorem exercise_8_3_6a {R : Type*} [ring R]
  (hR : R = (gaussian_int ⧸ ideal.span ({⟨0, 1⟩} : set gaussian_int))) :
  is_field R ∧ ∃ finR : fintype R, @card R finR = 2 :=

Prove that the quotient ring $\mathbb{Z}[i] /(1+i)$ is a field of order 2.

\begin{proof}

    Let $a+b i \in \mathbb{Z}[i]$. If $a \equiv b \bmod 2$, then $a+b$ and $b-a$ are even and $(1+i)\left(\frac{a+b}{2}+\frac{b-a}{2} i\right)=a+b i \in\langle 1+i\rangle$. If $a \not \equiv b \bmod 2$ then $a-1+b i \in\langle 1+i\rangle$. Therefore every element of $\mathbb{Z}[i]$ is in either $\langle 1+i\rangle$ or $1+\langle 1+i\rangle$, so $\mathbb{Z}[i] /\langle 1+i\rangle$ is a finite ring of order 2 , which must be a field.

\end{proof}


theorem exercise_9_1_6 : ¬ is_principal
  (ideal.span ({X 0, X 1} : set (mv_polynomial (fin 2) ℚ))) :=

Prove that $(x, y)$ is not a principal ideal in $\mathbb{Q}[x, y]$.

\begin{proof}

    Suppose, to the contrary, that $(x, y)=p$ for some polynomial $p \in \mathbb{Q}[x, y]$. From $x, y \in$ $(x, y)=(p)$ there are $s, t \in \mathbb{Q}[x, y]$ such that $x=s p$ and $y=t p$.

Then:

$$

\begin{aligned}

& 0=\operatorname{deg}_y(x)=\operatorname{deg}_y(s)+\operatorname{deg}_y(p) \text { so } \\

& 0=\operatorname{deg}_y(p) \\

& 0=\operatorname{deg}_x(y)=\operatorname{deg}_x(s)+\operatorname{deg}_x(p) \text { so } \\

& 0=\operatorname{deg}_x(p) \text { so }

\end{aligned}

$$

From : $\quad 0=\operatorname{deg}_y(p)=\operatorname{deg}_x(p)$ we get $\operatorname{deg}(p)=0$ and $p \in \mathbb{Q}$.

But $p \in(p)=(x, y)$ so $p=a x+b y$ for some $a, b \in \mathbb{Q}[x, y]$

$$

\begin{aligned}

\operatorname{deg}(p) & =\operatorname{deg}(a x+b y) \\

& =\min (\operatorname{deg}(a)+\operatorname{deg}(x), \operatorname{deg}(b)+\operatorname{deg}(y)) \\

& =\min (\operatorname{deg}(a)+1, \operatorname{deg}(b)+1) \geqslant 1

\end{aligned}

$$

which contradicts $\operatorname{deg}(p)=0$.

So we conclude that $(x, y)$ is not principal ideal in $\mathbb{Q}[x, y]$

\end{proof}


theorem exercise_9_3_2 {f g : polynomial ℚ} (i j : ℕ)
  (hfg : ∀ n : ℕ, ∃ a : ℤ, (f*g).coeff = a) :
  ∃ a : ℤ, f.coeff i * g.coeff j = a :=

Prove that if $f(x)$ and $g(x)$ are polynomials with rational coefficients whose product $f(x) g(x)$ has integer coefficients, then the product of any coefficient of $g(x)$ with any coefficient of $f(x)$ is an integer.

\begin{proof}

    Let $f(x), g(x) \in \mathbb{Q}[x]$ be such that $f(x) g(x) \in \mathbb{Z}[x]$.

By Gauss' Lemma there exists $r, s \in \mathbb{Q}$ such that $r f(x), s g(x) \in \mathbb{Z}[x]$, and $(r f(x))(s g(x))=r s f(x) g(x)=f(x) g(x)$. From this last relation we can conclude that $s=r^{-1}$.

Therefore for any coefficient $f_i$ of $f(x)$ and $g_j$ of $g(x)$ we have that $r f_i, r^{-1} g_j \in$ $\mathbb{Z}$ and by multiplicative closure and commutativity of $\mathbb{Z}$ we have that $r f_i r^{-1} g_j=$ $f_i g_j \in \mathbb{Z}$

\end{proof}


theorem exercise_9_4_2b : irreducible
  (X^6 + 30*X^5 - 15*X^3 + 6*X - 120 : polynomial ℤ) :=

Prove that $x^6+30x^5-15x^3 + 6x-120$ is irreducible in $\mathbb{Z}[x]$.

\begin{proof}

    $$

x^6+30 x^5-15 x^3+6 x-120

$$

The coefficients of the low order.: $30,-15,0,6,-120$

They are divisible by the prime 3 , but $3^2=9$ doesn 't divide $-120$. So this polynomial is irreducible over $\mathbb{Z}$.

\end{proof}


theorem exercise_9_4_2d {p : ℕ} (hp : p.prime ∧ p > 2)
  {f : polynomial ℤ} (hf : f = (X + 2)^p):
  irreducible (∑ n in (f.support - {0}), (f.coeff n) * X ^ (n-1) :
  polynomial ℤ) :=

Prove that $\frac{(x+2)^p-2^p}{x}$, where $p$ is an odd prime, is irreducible in $\mathbb{Z}[x]$.

\begin{proof}

$\frac{(x+2)^p-2^p}{x} \quad \quad p$ is on add pprime $Z[x]$

$$

\frac{(x+2)^p-2^p}{x} \quad \text { as a polynomial we expand }(x+2)^p

$$

$2^p$ cancels with $-2^p$, every remaining term has $x$ as $a$ factor

$$

\begin{aligned}

& x^{p-1}+2\left(\begin{array}{l}

p \\

1

\end{array}\right) x^{p-2}+2^2\left(\begin{array}{l}

p \\

2

\end{array}\right) x^{p-3}+\ldots+2^{p-1}\left(\begin{array}{c}

p \\

p-1

\end{array}\right) \\

& 2^k\left(\begin{array}{l}

p \\

k

\end{array}\right) x^{p-k-1}=2^k \cdot p \cdot(p-1) \ldots(p-k-1), \quad 0<k<p

\end{aligned}

$$

Every lower order coef. has $p$ as a factor but doesnt have $\$ \mathrm{p}^{\wedge} 2 \$$ as a fuction so the polynomial is irreducible by Eisensteins Criterion.

\end{proof}


theorem exercise_9_4_11 :
  irreducible ((X 0)^2 + (X 1)^2 - 1 : mv_polynomial (fin 2) ℚ) :=

Prove that $x^2+y^2-1$ is irreducible in $\mathbb{Q}[x,y]$.

\begin{proof}

$$

p(x)=x^2+y^2-1 \in Q[y][x] \cong Q[y, x]

$$

We have that $y+1 \in Q[y]$ is prime and $Q[y]$ is an UFD, since $p(x)=x^2+y^2-1=x^2+$ $(y+1)(y-1)$ by the Eisenstein criterion $x^2+y^2-1$ is irreducibile in $Q[x, y]$.

\end{proof}


theorem exercise_1_13a {f : ℂ → ℂ} (Ω : set ℂ) (a b : Ω) (h : is_open Ω)
  (hf : differentiable_on ℂ f Ω) (hc : ∃ (c : ℝ), ∀ z ∈ Ω, (f z).re = c) :
  f a = f b :=

import .common

open complex filter function interval_integral metric

open_locale big_operators
open_locale filter
open_locale topology

Suppose that $f$ is holomorphic in an open set $\Omega$. Prove that if $\text{Re}(f)$ is constant, then $f$ is constant.

\begin{proof}

Let $f(z)=f(x, y)=u(x, y)+i v(x, y)$, where $z=x+i y$.

Since $\operatorname{Re}(f)=$ constant,

$$

\frac{\partial u}{\partial x}=0, \frac{\partial u}{\partial y}=0 .

$$

By the Cauchy-Riemann equations,

$$

\frac{\partial v}{\partial x}=-\frac{\partial u}{\partial y}=0 .

$$

Thus, in $\Omega$,

$$

f^{\prime}(z)=\frac{\partial f}{\partial x}=\frac{\partial u}{\partial x}+i \frac{\partial v}{\partial x}=0+0=0 .

$$

3

Thus $f(z)$ is constant.

\end{proof}


theorem exercise_1_13c {f : ℂ → ℂ} (Ω : set ℂ) (a b : Ω) (h : is_open Ω)
  (hf : differentiable_on ℂ f Ω) (hc : ∃ (c : ℝ), ∀ z ∈ Ω, abs (f z) = c) :
  f a = f b :=

Suppose that $f$ is holomorphic in an open set $\Omega$. Prove that if $|f|$ is constant, then $f$ is constant.

\begin{proof}

Let $f(z)=f(x, y)=u(x, y)+i v(x, y)$, where $z=x+i y$.

We first give a mostly correct argument; the reader should pay attention to find the difficulty. Since $|f|=\sqrt{u^2+v^2}$ is constant,

$$

\left\{\begin{array}{l}

0=\frac{\partial\left(u^2+v^2\right)}{\partial x}=2 u \frac{\partial u}{\partial x}+2 v \frac{\partial v}{\partial x} . \\

0=\frac{\partial\left(u^2+v^2\right)}{\partial y}=2 u \frac{\partial u}{\partial y}+2 v \frac{\partial v}{\partial y} .

\end{array}\right.

$$

Plug in the Cauchy-Riemann equations and we get

$$

\begin{gathered}

u \frac{\partial v}{\partial y}+v \frac{\partial v}{\partial x}=0 \\

-u \frac{\partial v}{\partial x}+v \frac{\partial v}{\partial y}=0 \\

(1.14) \Rightarrow \frac{\partial v}{\partial x}=\frac{v}{u} \frac{\partial v}{\partial y}

\end{gathered}

$$

Plug (1.15) into (1.13) and we get

$$

\frac{u^2+v^2}{u} \frac{\partial v}{\partial y}=0 .

$$

So $u^2+v^2=0$ or $\frac{\partial v}{\partial y}=0$.

If $u^2+v^2=0$, then, since $u, v$ are real, $u=v=0$, and thus $f=0$ which is constant.

Thus we may assume $u^2+v^2$ equals a non-zero constant, and we may divide by it. We multiply both sides by $u$ and find $\frac{\partial v}{\partial y}=0$, then by (1.15), $\frac{\partial v}{\partial x}=0$, and by Cauchy-Riemann, $\frac{\partial u}{\partial x}=0$.

$$

f^{\prime}=\frac{\partial f}{\partial x}=\frac{\partial u}{\partial x}+i \frac{\partial v}{\partial x}=0 .

$$

Thus $f$ is constant.

Why is the above only mostly a proof? The problem is we have a division by $u$, and need to make sure everything is well-defined. Specifically, we need to know that $u$ is never zero. We do have $f^{\prime}=0$ except at points where $u=0$, but we would need to investigate that a bit more.

Let's return to

$$

\left\{\begin{array}{l}

0=\frac{\partial\left(u^2+v^2\right)}{\partial x}=2 u \frac{\partial u}{\partial x}+2 v \frac{\partial v}{\partial x} . \\

0=\frac{\partial\left(u^2+v^2\right)}{\partial y}=2 u \frac{\partial u}{\partial y}+2 v \frac{\partial v}{\partial y} .

\end{array}\right.

$$

Plug in the Cauchy-Riemann equations and we get

$$

\begin{array}{r}

u \frac{\partial v}{\partial y}+v \frac{\partial v}{\partial x}=0 \\

-u \frac{\partial v}{\partial x}+v \frac{\partial v}{\partial y}=0 .

\end{array}

$$

We multiply the first equation $u$ and the second by $v$, and obtain

$$

\begin{aligned}

u^2 \frac{\partial v}{\partial y}+u v \frac{\partial v}{\partial x} & =0 \\

-u v \frac{\partial v}{\partial x}+v^2 \frac{\partial v}{\partial y} & =0 .

\end{aligned}

$$

Adding the two yields

$$

u^2 \frac{\partial v}{\partial y}+v^2 \frac{\partial v}{\partial y}=0,

$$

or equivalently

$$

\left(u^2+v^2\right) \frac{\partial v}{\partial y}=0 .

$$

We now argue in a similar manner as before, except now we don't have the annoying $u$ in the denominator. If $u^2+v^2=0$ then $u=v=0$, else we can divide by $u^2+v^2$ and find $\partial v / \partial y=0$. Arguing along these lines finishes the proof.

\end{proof}


theorem exercise_1_19b (z : ℂ) (hz : abs z = 1) (s : ℕ → ℂ)
    (h : s = (λ n, ∑ i in (finset.range n), i * z / i ^ 2)) :
    ∃ y, tendsto s at_top (𝓝 y) :=

Prove that the power series $\sum zn/n^2$ converges at every point of the unit circle.

\begin{proof}

    Since $\left|z^n / n^2\right|=1 / n^2$ for all $|z|=1$, then $\sum z^n / n^2$ converges at every point in the unit circle as $\sum 1 / n^2$ does ( $p$-series $p=2$.)

\end{proof}


theorem exercise_1_26
  (f F₁ F₂ : ℂ → ℂ) (Ω : set ℂ) (h1 : is_open Ω) (h2 : is_connected Ω)
  (hF₁ : differentiable_on ℂ F₁ Ω) (hF₂ : differentiable_on ℂ F₂ Ω)
  (hdF₁ : ∀ x ∈ Ω, deriv F₁ x = f x) (hdF₂ : ∀ x ∈ Ω, deriv F₂ x = f x)
  : ∃ c : ℂ, ∀ x, F₁ x = F₂ x + c :=

Suppose $f$ is continuous in a region $\Omega$. Prove that any two primitives of $f$ (if they exist) differ by a constant.

\begin{proof}

    Suppose $F_1$ adn $F_2$ are primitives of $F$. Then $(F_1-F_2)^\prime = f - f = 0$, therefore $F_1$ and $F_2$ differ by a constant.

\end{proof}


theorem exercise_2_9
  {f : ℂ → ℂ} (Ω : set ℂ) (b : metric.bounded Ω) (h : is_open Ω)
  (hf : differentiable_on ℂ f Ω) (z ∈ Ω) (hz : f z = z) (h'z : deriv f z = 1) :
  ∃ (f_lin : ℂ →L[ℂ] ℂ), ∀ x ∈ Ω, f x = f_lin x :=

Let $\Omega$ be a bounded open subset of $\mathbb{C}$, and $\varphi: \Omega \rightarrow \Omega$ a holomorphic function. Prove that if there exists a point $z_{0} \in \Omega$ such that $\varphi\left(z_{0}\right)=z_{0} \quad \text { and } \quad \varphi^{\prime}\left(z_{0}\right)=1$ then $\varphi$ is linear.

\begin{proof}

    When $\Omega$ is connected, if $\varphi$ is not linear, then there exists $n \geq 2$ and $a_n \neq 0$, such that

$$

\varphi(z)=z+a_n\left(z-z_0\right)^n+O\left(\left(z-z_0\right)^{n+1}\right) .

$$

As you have noticed, by induction, it follows that for every $k \geq 1$,

$$

\varphi^k(z)=z+k a_n\left(z-z_0\right)^n+O\left(\left(z-z_0\right)^{n+1}\right) .

$$

Let $r>0$ be such that when $\left|z-z_0\right| \leq r$, then $z \in \Omega$. Then by (1),

$$

k a_n=\frac{1}{2 \pi i} \int_{\left|z-z_0\right|=r} \frac{\varphi^k(z)}{\left(z-z_0\right)^{n+1}} d z .

$$

Since $\varphi^k(\Omega) \subset \Omega$ and since $\Omega$ is bounded, there exists $M>0$, independent of $k$, such that $\left|\varphi^k\right| \leq M$ on $\Omega$. Then by (2),

$$

k\left|a_n\right| \leq M r^{-n} .

$$

Since $k$ is arbitrary, $a_n=0$, a contradiction.

\end{proof}


theorem exercise_3_3 (a : ℝ) (ha : 0 < a) :
    tendsto (λ y, ∫ x in -y..y, real.cos x / (x ^ 2 + a ^ 2))
    at_top (𝓝 (real.pi * (real.exp (-a) / a))) :=

Show that $ \int_{-\infty}^{\infty} \frac{\cos x}{x^2 + a^2} dx = \pi \frac{e^{-a}}{a}$ for $a > 0$.

\begin{proof}

    $\cos x=\frac{e^{i x}+e^{-i x}}{2}$. changing $x \rightarrow-x$ we see that we can just integrate $e^{i x} /\left(x^2+a^2\right)$ and we'll get the same answer. Again, we use the same semicircle and part of the real line. The only pole is $x=i a$, it has order 1 and the residue at it is $\lim _{x \rightarrow i a} \frac{e^{i x}}{x^2+a^2}(x-i a)=\frac{e^{-a}}{2 i a}$, which multiplied by $2 \pi i$ gives the answer.

\end{proof}


theorem exercise_3_9 : ∫ x in 0..1, real.log (real.sin (real.pi * x)) = - real.log 2 :=

Show that $\int_0^1 \log(\sin \pi x) dx = - \log 2$.

\begin{proof}

Consider

$$

\begin{gathered}

f(z)=\log \left(1-e^{2 \pi z i}\right)=\log \left(e^{\pi z i}\left(e^{-\pi z i}-e^{\pi z i}\right)\right)=\log (-2 i)+\pi z i+\log \\

(\sin (\pi z))

\end{gathered}

$$

Then we have

$$

\begin{aligned}

\int_0^1 f(z) d z & =\log (-2 i)+\frac{i \pi}{2}+\int_0^1 \log (\sin (\pi z)) d z \\

& =\int_0^1 \log (\sin (\pi z)) d z+\log (-2 i)+\log (i) \\

& =\log (2)+\int_0^1 \log (\sin (\pi z)) d z

\end{aligned}

$$

Now it suffices to show that $\int_0^1 f(z) d z=0$. Consider the contour $C(\epsilon, R)$ (which is the contour given in your question) given by the following.

1. $C_1(\epsilon, R)$ : The vertical line along the imaginary axis from $i R$ to $i \epsilon$.

2. $C_2(\epsilon)$ : The quarter turn of radius $\epsilon$ about 0 .

3. $C_3(\epsilon)$ : Along the real axis from $(\epsilon, 1-\epsilon)$.

4. $C_4(\epsilon)$ : The quarter turn of radius $\epsilon$ about 1 .

5. $C_5(\epsilon, R)$ : The vertical line from $1+i \epsilon$ to $1+i R$.

6. $C_6(R)$ : The horizontal line from $1+i R$ to $i R$.

$f(z)$ is analytic inside the contour $C$ and hence $\oint_C f(z)=0$. This gives us

$$

\begin{aligned}

\int_{C_1(\epsilon, R)} f d z+\int_{C_2(\epsilon)} f d z+\int_{C_3(\epsilon)} f d z+\int_{C_4(\epsilon)} f d z+\int_{C_5(\epsilon, R)} f d z+\int_{C_6(R)} f d z \\

=0

\end{aligned}

$$

Now the integral along 1 cancels with the integral along 5 due to symmetry. Integrals along 2 and 4 scale as $\epsilon \log (\epsilon)$. Integral along 6 goes to 0 as $R \rightarrow \infty$. This gives us

$$

\lim _{\epsilon \rightarrow 0} \int_{C_3(\epsilon)} f d z=0

$$

which is what we need.

\end{proof}


theorem exercise_3_22 (D : set ℂ) (hD : D = ball 0 1) (f : ℂ → ℂ)
    (hf : differentiable_on ℂ f D) (hfc : continuous_on f (closure D)) :
    ¬ ∀ z ∈ (sphere (0 : ℂ) 1), f z = 1 / z :=

Show that there is no holomorphic function $f$ in the unit disc $D$ that extends continuously to $\partial D$ such that $f(z) = 1/z$ for $z \in \partial D$.

\begin{proof}

    Consider $g(r)=\int_{|z|=r} f(z) d z$. Cauchy theorem implies that $g(r)=0$ for all $r<1$. Now since $\left.f\right|_{\partial D}=1 / z$ we have $\lim _{r \rightarrow 1} \int_{|z|=r} f(z) d z=\int_{|z|=1} \frac{1}{z} d z=\frac{2}{\pi i} \neq 0$. Contradiction.

\end{proof}


theorem exercise_13_1 (X : Type*) [topological_space X] (A : set X)
  (h1 : ∀ x ∈ A, ∃ U : set X, x ∈ U ∧ is_open U ∧ U ⊆ A) :
  is_open A :=

import .common

open set topological_space filter
open_locale classical topology filter
noncomputable theory

Let $X$ be a topological space; let $A$ be a subset of $X$. Suppose that for each $x \in A$ there is an open set $U$ containing $x$ such that $U \subset A$. Show that $A$ is open in $X$.

\begin{proof}

    Since, from the given hypothesis given any $x \in A$ there exists an open set containing $x$ say, $U_x$ such that $U_x \subset A$. Thus, we claim that

$$

A=\bigcup_{x \in A} U_x

$$

Observe that if we prove the above claim, then $A$ will be open, being a union of arbitrary open sets. Since, for each $x \in A, U_x \subset A \Longrightarrow \cup U_x \subset A$. For the converse, observe that given any $x \in A, x \in U_x$ and hence in the union. Thus we proved our claim, and hence $A$ is an open set.

\end{proof}


theorem exercise_13_4a1 (X I : Type*) (T : I → set (set X)) (h : ∀ i, is_topology X (T i)) :
  is_topology X (⋂ i : I, T i) :=

If $\mathcal{T}_\alpha$ is a family of topologies on $X$, show that $\bigcap \mathcal{T}_\alpha$ is a topology on $X$.

\begin{proof}

    Since $\emptyset$ and $X$ belong to $\mathcal{T}_\alpha$ for each $\alpha$, they belong to $\bigcap_\alpha \mathcal{T}_\alpha$. Let $\left\{V_\beta\right\}_\beta$ be a collection of open sets in $\bigcap_\alpha \mathcal{T}_\alpha$. For any fixed $\alpha$ we have $\cup_\beta V_\beta \in \mathcal{T}_\alpha$ since $\mathcal{T}_\alpha$ is a topology on $X$, so $\bigcup_\beta V_\beta \in \bigcap_\alpha \mathcal{T}_\alpha$. Similarly, if $U_1, \ldots, U_n$ are elements of $\bigcap_\alpha \mathcal{T}_\alpha$, then for each $\alpha$ we have $\bigcup_{i=1}^n U_i \in \mathcal{T}_\alpha$ and therefore $\bigcup_{i=1}^n U_i \in \bigcap_\alpha \mathcal{T}_\alpha$. It follows that $\bigcap_\alpha \mathcal{T}_\alpha$ is a topology on $X$.

\end{proof}


theorem exercise_13_4b1 (X I : Type*) (T : I → set (set X)) (h : ∀ i, is_topology X (T i)) :
  ∃! T', is_topology X T' ∧ (∀ i, T i ⊆ T') ∧
  ∀ T'', is_topology X T'' → (∀ i, T i ⊆ T'') → T'' ⊆ T' :=

Let $\mathcal{T}_\alpha$ be a family of topologies on $X$. Show that there is a unique smallest topology on $X$ containing all the collections $\mathcal{T}_\alpha$.

\begin{proof}

    (b) First we prove that there is a unique smallest topology on $X$ containing all the collections $\mathcal{T}_\alpha$. Uniqueness of such topology is clear. For each $\alpha$ let $\mathcal{B}_\alpha$ be a basis for $\mathcal{T}_\alpha$. Let $\mathcal{T}$ be the topology generated by the subbasis $\mathcal{S}=\bigcup_\alpha \mathcal{B}_\alpha$. Then the collection $\mathcal{B}$ of all finite intersections of elements of $\mathcal{S}$ is a basis for $\mathcal{T}$. Clearly $\mathcal{T}_\alpha \subset \mathcal{T}$ for all $\alpha$. We now prove that if $\mathcal{O}$ is a topology on $X$ such that $\mathcal{T}_\alpha \subset \mathcal{O}$ for all $\alpha$, then $\mathcal{T} \subset \mathcal{O}$. Given such $\mathcal{O}$, we have $\mathcal{B}_\alpha \subset \mathcal{O}$ for all $\alpha$, so $\mathcal{S} \subset \mathcal{O}$. Since $\mathcal{O}$ is a topology, it must contain all finite intersections of elements of $\mathcal{S}$, so $\mathcal{B} \subset \mathcal{O}$ and hence $\mathcal{T} \subset \mathcal{O}$. We conclude that the topology $\mathcal{T}$ generated by the subbasis $\mathcal{S}=\cup_\alpha \mathcal{B}_\alpha$ is the unique smallest topology on $X$ containing all the collections $\mathcal{T}_\alpha$.

\end{proof}


theorem exercise_13_5a {X : Type*}
  [topological_space X] (A : set (set X)) (hA : is_topological_basis A) :
  generate_from A = generate_from (sInter {T | is_topology X T ∧ A ⊆ T}) :=

Show that if $\mathcal{A}$ is a basis for a topology on $X$, then the topology generated by $\mathcal{A}$ equals the intersection of all topologies on $X$ that contain $\mathcal{A}$.

\begin{proof}

    Let $\mathcal{T}$ be the topology generated by $\mathcal{A}$ and let $\mathcal{O}$ be the intersection of all topologies on $X$ that contains $\mathcal{A}$. Clearly $\mathcal{O} \subset \mathcal{T}$ since $\mathcal{T}$ is a topology on $X$ that contain $\mathcal{A}$. Conversely, let $U \in \mathcal{T}$, so that $U$ is a union of elements of $\mathcal{A}$. Since each of this elements is also an element of $\mathcal{O}$, their union $U$ belongs to $\mathcal{O}$. Thus $\mathcal{T} \subset \mathcal{O}$ and the equality holds.

\end{proof}


theorem exercise_13_6 :
  ¬ (∀ U, Rl.is_open U → K_topology.is_open U) ∧ ¬ (∀ U, K_topology.is_open U → Rl.is_open U) :=

Show that the lower limit topology $\mathbb{R}_l$ and $K$-topology $\mathbb{R}_K$ are not comparable.

\begin{proof}

    Let $\mathcal{T}_{\ell}$ and $\mathcal{T}_K$ denote the topologies of $\mathbb{R}_{\ell}$ and $\mathbb{R}_K$ respectively. Given the basis element $[0,1)$ for $\mathcal{T}_{\ell}$, there is no basis element for $\mathcal{T}_K$ containing 0 and contained in $[0,1)$, so $\mathcal{T}_{\ell} \not \subset \mathcal{T}_K$. Similarly, given the basis element $(-1,1) \backslash K$ for $\mathcal{T}_K$, there is no basis element for $\mathcal{T}_{\ell}$ containing 0 contained in $(-1,1) \backslash K$, so $\mathcal{T}_K \not \subset \mathcal{T}_{\ell}$.

\end{proof}


theorem exercise_13_8b :
  (topological_space.generate_from {S : set ℝ | ∃ a b : ℚ, a < b ∧ S = Ico a b}).is_open ≠
  (lower_limit_topology ℝ).is_open :=

Show that the collection $\{(a,b) \mid a < b, a \text{ and } b \text{ rational}\}$ is a basis that generates a topology different from the lower limit topology on $\mathbb{R}$.

\begin{proof}

    (b) $\mathcal{C}$ is a basis for a topology on $\mathbb{R}$ since the union of its elements is $\mathbb{R}$ and the intersection of two elements of $\mathcal{C}$ is either empty or another element of $\mathcal{C}$. Now consider $[r, s)$ where $r$ is any irrational number and $s$ is any real number greater than $r$. Then $[r, s)$ is a basis element for the topology of $\mathbb{R}_{\ell}$, but $[r, s)$ is not a union of elements of $\mathcal{C}$. Indeed, suppose that $[r, s)=\cup_\alpha\left[a_\alpha, b_\alpha\right)$ for rationals $a_\alpha, b_\alpha$. Then $r \in\left[a_\alpha, b_\alpha\right)$ for some $\alpha$. Since $r$ is irrational we must have $a_\alpha<r$, but then $a_\alpha \notin[r, s)$, a contradiction. It follows that the topology generated by $\mathcal{C}$ is strictly coarser than the lower limit topology on $\mathbb{R}$.

\end{proof}


theorem exercise_16_4 {X Y : Type*} [topological_space X] [topological_space Y]
  (π₁ : X × Y → X)
  (π₂ : X × Y → Y)
  (h₁ : π₁ = prod.fst)
  (h₂ : π₂ = prod.snd) :
  is_open_map π₁ ∧ is_open_map π₂ :=

A map $f: X \rightarrow Y$ is said to be an open map if for every open set $U$ of $X$, the set $f(U)$ is open in $Y$. Show that $\pi_{1}: X \times Y \rightarrow X$ and $\pi_{2}: X \times Y \rightarrow Y$ are open maps.

\begin{proof}

    Exercise 16.4. Let $U \times V$ be a (standard) basis element for $X \times Y$, so that $U$ is open in $X$ and $V$ is open in $Y$. Then $\pi_1(U \times V)=U$ is open in $X$ and $\pi_2(U \times V)=V$ is open in $Y$. Since arbitrary maps and unions satisfy $f\left(\bigcup_\alpha W_\alpha\right)=\bigcup_\alpha f\left(W_\alpha\right)$, it follows that $\pi_1$ and $\pi_2$ are open maps.

\end{proof}


theorem exercise_17_4 {X : Type*} [topological_space X]
  (U A : set X) (hU : is_open U) (hA : is_closed A) :
  is_open (U \ A) ∧ is_closed (A \ U) :=

Show that if $U$ is open in $X$ and $A$ is closed in $X$, then $U-A$ is open in $X$, and $A-U$ is closed in $X$.

\begin{proof}

Since

$$

X \backslash(U \backslash A)=(X \backslash U) \cup A \text { and } \quad X \backslash(A \backslash U)=(X \backslash A) \cup U,

$$

it follows that $X \backslash(U \backslash A)$ is closed in $X$ and $X \backslash(A \backslash U)$ is open in $X$.

\end{proof}


theorem exercise_18_8b {X Y : Type*} [topological_space X] [topological_space Y]
  [linear_order Y] [order_topology Y] {f g : X → Y}
  (hf : continuous f) (hg : continuous g) :
  continuous (λ x, min (f x) (g x)) :=

Let $Y$ be an ordered set in the order topology. Let $f, g: X \rightarrow Y$ be continuous. Let $h: X \rightarrow Y$ be the function $h(x)=\min \{f(x), g(x)\}.$ Show that $h$ is continuous.

\begin{proof}

    Let $A=\{x \mid f(x) \leq g(x)\}$ and $B=\{x \mid g(x) \leq f(x)\}$. Then $A$ and $B$ are closed in $X$ by (a), $A \cap B=\{x \mid f(x)=g(x)\}$, and $X=A \cup B$. Since $f$ and $g$ are continuous, their restrictions $f^{\prime}: A \rightarrow Y$ and $g^{\prime}: B \rightarrow Y$ are continuous. It follows from the pasting lemma that

$$

h: X \rightarrow Y, \quad h(x)=\min \{f(x), g(x)\}= \begin{cases}f^{\prime}(x) & \text { if } x \in A \\ g^{\prime}(x) & \text { if } x \in B\end{cases}

$$

is continuous

\end{proof}


theorem exercise_19_6a
  {n : ℕ}
  {f : fin n → Type*} {x : ℕ → Πa, f a}
  (y : Πi, f i)
  [Πa, topological_space (f a)] :
  tendsto x at_top (𝓝 y) ↔ ∀ i, tendsto (λ j, (x j) i) at_top (𝓝 (y i)) :=

Let $\mathbf{x}_1, \mathbf{x}_2, \ldots$ be a sequence of the points of the product space $\prod X_\alpha$.  Show that this sequence converges to the point $\mathbf{x}$ if and only if the sequence $\pi_\alpha(\mathbf{x}_i)$ converges to $\pi_\alpha(\mathbf{x})$ for each $\alpha$.

\begin{proof}

    For each $n \in \mathbb{Z}_{+}$, we write $\mathbf{x}_n=\left(x_n^\alpha\right)_\alpha$, so that $\pi_\alpha\left(\mathbf{x}_n\right)=x_n^\alpha$ for each $\alpha$.

First assume that the sequence $\mathbf{x}_1, \mathbf{x}_2, \ldots$ converges to $\mathbf{x}=\left(x_\alpha\right)_\alpha$ in the product space $\prod_\alpha X_\alpha$. Fix an index $\beta$ and let $U$ be a neighbourhood of $\pi_\beta(\mathbf{x})=x_\beta$. Let $V=\prod_\alpha U_\alpha$, where $U_\alpha=X_\alpha$ for each $\alpha \neq \beta$ and $U_\beta=U$. Then $V$ is a neighbourhood of $\mathbf{x}$, so there exists $N \in \mathbb{Z}_{+}$such that $\mathbf{x}_n \in V$ for all $n \geq N$. Therefore $\pi_\beta\left(\mathbf{x}_n\right)=x_n^\beta \in U$ for all $n \geq N$. Since $U$ was arbitrary, it follows that $\pi_\beta\left(\mathbf{x}_1\right), \pi_\beta\left(\mathbf{x}_2\right), \ldots$ converges to $\pi_\beta(\mathbf{x})$. Since $\beta$ was arbitrary, this holds for all indices $\alpha$.

\end{proof}


theorem exercise_21_6a
  (f : ℕ → I → ℝ )
  (h : ∀ x n, f n x = x ^ n) :
  ∀ x, ∃ y, tendsto (λ n, f n x) at_top (𝓝 y) :=

Define $f_{n}:[0,1] \rightarrow \mathbb{R}$ by the equation $f_{n}(x)=x^{n}$. Show that the sequence $\left(f_{n}(x)\right)$ converges for each $x \in[0,1]$.

\begin{proof}

If $0 \leq x<1$ is fixed, then $f_n(x) \rightarrow 0$ as $n \rightarrow \infty$. As $f_n(1)=1$ for all $n, f_n(1) \rightarrow 1$. Thus $\left(f_n\right)_n$ converges to $f:[0,1] \rightarrow \mathbb{R}$ given by $f(x)=0$ if $x=0$ and $f(1)=1$. The sequence

\end{proof}


theorem exercise_21_8
  {X : Type*} [topological_space X] {Y : Type*} [metric_space Y]
  {f : ℕ → X → Y} {x : ℕ → X}
  (hf : ∀ n, continuous (f n))
  (x₀ : X)
  (hx : tendsto x at_top (𝓝 x₀))
  (f₀ : X → Y)
  (hh : tendsto_uniformly f f₀ at_top) :
  tendsto (λ n, f n (x n)) at_top (𝓝 (f₀ x₀)) :=

Let $X$ be a topological space and let $Y$ be a metric space. Let $f_{n}: X \rightarrow Y$ be a sequence of continuous functions. Let $x_{n}$ be a sequence of points of $X$ converging to $x$. Show that if the sequence $\left(f_{n}\right)$ converges uniformly to $f$, then $\left(f_{n}\left(x_{n}\right)\right)$ converges to $f(x)$.

\begin{proof}

    Let $d$ be the metric on $Y$. Let $V$ be a neighbourhood of $f(x)$, and let $\varepsilon>0$ be such that $f(x) \in B_d(f(x), \varepsilon) \subset V$. Since $\left(f_n\right)_n$ converges uniformly to $f$, there exists $N_1 \in \mathbb{Z}_{+}$such that $d\left(f_n(x), f(x)\right)<\varepsilon / 2$ for all $x \in X$ and all $n \geq N_1$, so that $d\left(f_n\left(x_n\right), f\left(x_n\right)\right)<\varepsilon / 2$ for all $n \geq N_1$. Moreover, $f$ is continuous, so there exists $N_2 \in \mathbb{Z}_{+}$such that $d\left(f\left(x_n\right), f(x)\right)<\varepsilon / 2$ for all $n \geq N_2$. Thus, if $N>\max \left\{N_1, N_2\right\}$, then

$$

d\left(f_n\left(x_n\right), f(x)\right) \leq d\left(f_n\left(x_n\right), f\left(x_n\right)\right)+d\left(f\left(x_n\right), f(x)\right)<\frac{\varepsilon}{2}+\frac{\varepsilon}{2}=\varepsilon

$$

for all $n \geq N$, so $f_n\left(x_n\right) \in V$ for all $n \geq N$. It follows that $\left(f_n\left(x_n\right)\right)_n$ converges to $f(x)$.

\end{proof}


theorem exercise_22_2b {X : Type*} [topological_space X]
  {A : set X} (r : X → A) (hr : continuous r) (h : ∀ x : A, r x = x) :
  quotient_map r :=

If $A \subset X$, a retraction of $X$ onto $A$ is a continuous map $r: X \rightarrow A$ such that $r(a)=a$ for each $a \in A$. Show that a retraction is a quotient map.

\begin{proof}

The inclusion map $i: A \rightarrow X$ is continuous and $r \circ i=1_A$ is the identity. Thus $r$ is a quotient map by (a).

\end{proof}


theorem exercise_23_2 {X : Type*}
  [topological_space X] {A : ℕ → set X} (hA : ∀ n, is_connected (A n))
  (hAn : ∀ n, A n ∩ A (n + 1) ≠ ∅) :
  is_connected (⋃ n, A n) :=

Let $\left\{A_{n}\right\}$ be a sequence of connected subspaces of $X$, such that $A_{n} \cap A_{n+1} \neq \varnothing$ for all $n$. Show that $\bigcup A_{n}$ is connected.

\begin{proof}

    Suppose that $\bigcup_n A_n=B \cup C$, where $B$ and $C$ are disjoint open subsets of $\bigcup_n A_n$. Since $A_1$ is connected and a subset of $B \cup C$, by Lemma $23.2$ it lies entirely within either $B$ or $C$. Without any loss of generality, we may assume $A_1 \subset B$. Note that given $n$, if $A_n \subset B$ then $A_{n+1} \subset B$, for if $A_{n+1} \subset C$ then $A_n \cap A_{n+1} \subset B \cap C=\emptyset$, in contradiction with the assumption. By induction, $A_n \subset B$ for all $n \in \mathbb{Z}_{+}$, so that $\bigcup_n A_n \subset B$. It follows that $\bigcup_n A_n$ is connected.

\end{proof}


theorem exercise_23_4 {X : Type*} [topological_space X] [cofinite_topology X]
  (s : set X) : set.infinite s → is_connected s :=

Show that if $X$ is an infinite set, it is connected in the finite complement topology.

\begin{proof}

    Suppose that $A$ is a non-empty subset of $X$ that is both open and closed, i.e., $A$ and $X \backslash A$ are finite or all of $X$. Since $A$ is non-empty, $X \backslash A$ is finite. Thus $A$ cannot be finite as $X \backslash A$ is infinite, so $A$ is all of $X$. Therefore $X$ is connected.

\end{proof}


theorem exercise_23_9 {X Y : Type*}
  [topological_space X] [topological_space Y]
  (A₁ A₂ : set X)
  (B₁ B₂ : set Y)
  (hA : A₁ ⊂ A₂)
  (hB : B₁ ⊂ B₂)
  (hA : is_connected A₂)
  (hB : is_connected B₂) :
  is_connected ({x | ∃ a b, x = (a, b) ∧ a ∈ A₂ ∧ b ∈ B₂} \
      {x | ∃ a b, x = (a, b) ∧ a ∈ A₁ ∧ b ∈ B₁}) :=

Let $A$ be a proper subset of $X$, and let $B$ be a proper subset of $Y$. If $X$ and $Y$ are connected, show that $(X \times Y)-(A \times B)$ is connected.

\begin{proof}

This is similar to the proof of Theorem 23.6. Take $c \times d \in(X \backslash A) \times(Y \backslash B)$. For each $x \in X \backslash A$, the set

$$

U_x=(X \times\{d\}) \cup(\{x\} \times Y)

$$

is connected since $X \times\{d\}$ and $\{x\} \times Y$ are connected and have the common point $x \times d$. Then $U=\bigcup_{x \in X \backslash A} U_x$ is connected because it is the union of the connected spaces $U_x$ which have the point $c \times d$ in common. Similarly, for each $y \in Y \backslash B$ the set

$$

V_y=(X \times\{y\}) \cup(\{c\} \times Y)

$$

is connected, so $V=\bigcup_{y \in Y \backslash B} V_y$ is connected. Thus $(X \times Y) \backslash(A \times B)=U \cup V$ is connected since $c \times d$ is a common point of $U$ and $V$.

\end{proof}


theorem exercise_24_2 {f : (metric.sphere 0 1 : set ℝ) → ℝ}
  (hf : continuous f) : ∃ x, f x = f (-x) :=

Let $f: S^{1} \rightarrow \mathbb{R}$ be a continuous map. Show there exists a point $x$ of $S^{1}$ such that $f(x)=f(-x)$.

\begin{proof}

    Let $f: S^1 \rightarrow \mathbb{R}$ be continuous. Let $x \in S^1$. If $f(x)=f(-x)$ we are done, so assume $f(x) \neq f(-x)$. Define $g: S^1 \rightarrow \mathbb{R}$ by setting $g(x)=f(x)-f(-x)$. Then $g$ is continuous. Suppose $f(x)>f(-x)$, so that $g(x)>0$. Then $-x \in S^1$ and $g(-x)<0$. By the intermediate value theorem, since $S^1$ is connected and $g(-x)<0<g(x)$, there exists $y \in S^1$ such that $g(y)=0$. i.e, $f(y)=f(-y)$. Similarly, if $f(x)<f(-x)$, then $g(x)<0<g(-x)$ and again the intermediate value theorem gives the result.

\end{proof}


theorem exercise_25_4 {X : Type*} [topological_space X]
  [loc_path_connected_space X] (U : set X) (hU : is_open U)
  (hcU : is_connected U) : is_path_connected U :=

Let $X$ be locally path connected. Show that every connected open set in $X$ is path connected.

\begin{proof}

    Let $U$ be a open connected set in $X$. By Theorem 25.4, each path component of $U$ is open in $X$, hence open in $U$. Thus, each path component in $U$ is both open and closed in $U$, so must be empty or all of $U$. It follows that $U$ is path-connected.

\end{proof}


theorem exercise_26_11
  {X : Type*} [topological_space X] [compact_space X] [t2_space X]
  (A : set (set X)) (hA : ∀ (a b : set X), a ∈ A → b ∈ A → a ⊆ b ∨ b ⊆ a)
  (hA' : ∀ a ∈ A, is_closed a) (hA'' : ∀ a ∈ A, is_connected a) :
  is_connected (⋂₀ A) :=

Let $X$ be a compact Hausdorff space. Let $\mathcal{A}$ be a collection of closed connected subsets of $X$ that is simply ordered by proper inclusion. Then $Y=\bigcap_{A \in \mathcal{A}} A$ is connected.

\begin{proof}

 Since each $A \in \mathcal{A}$ is closed, $Y$ is closed. Suppose that $C$ and $D$ form a separation of $Y$. Then $C$ and $D$ are closed in $Y$, hence closed in $X$. Since $X$ is compact, $C$ and $D$ are compact by Theorem 26.2. Since $X$ is Hausdorff, by Exercise 26.5, there exist $U$ and $V$ open in $X$ and disjoint containing $C$ and $D$, respectively. We show that

$$

\bigcap_{A \in \mathcal{A}}(A \backslash(U \cup V))

$$

is not empty. Let $\left\{A_1, \ldots, A_n\right\}$ be a finite subcollection of elements of $\mathcal{A}$. We may assume that $A_i \subsetneq A_{i+1}$ for all $i=1, \ldots, n-1$. Then

$$

\bigcap_{i=1}^n\left(A_i \backslash(U \cup V)\right)=A_1 \backslash(U \cup V) \text {. }

$$

Suppose that $A_1 \backslash(U \cup V)=\emptyset$. Then $A_1 \subset U \cup V$. Since $A_1$ is connected and $U \cap V=\emptyset, A_1$ lies within either $U$ or $V$, say $A_1 \subset U$. Then $Y \subset A_1 \subset U$, so that $C=Y \cap C \subset Y \cap V=\emptyset$, contradicting the fact that $C$ and $D$ form a separation of $Y$. Hence, $\bigcap_{i=1}^n\left(A_i \backslash(U \cup V)\right)$ is non-empty. Therefore, the collection $\{A \backslash(U \cup V) \mid A \in \mathcal{A}\}$ has the finite intersection property, so

$$

\bigcap_{A \in \mathcal{A}}(A \backslash(U \cup V))=\left(\bigcap_{A \in \mathcal{A}} A\right) \backslash(U \cup V)=Y \backslash(U \cup V)

$$

is non-empty. So there exists $y \in Y$ such that $y \notin U \cup V \supset C \cup D$, contradicting the fact that $C$ and $D$ form a separation of $Y$. We conclude that there is no such separation, so that $Y$ is connected.

\end{proof}


theorem exercise_27_4
  {X : Type*} [metric_space X] [connected_space X] (hX : ∃ x y : X, x ≠ y) :
  ¬ countable (univ : set X) :=

Show that a connected metric space having more than one point is uncountable.

\begin{proof}

    The distance function $d: X \times X \rightarrow \mathbb{R}$ is continuous by Exercise 20.3(a), so given $x \in X$, the function $d_x: X \rightarrow \mathbb{R}$ given by $d_x(y)=d(x, y)$ is continuous by Exercise 19.11. Since $X$ is connected, the image $d_x(X)$ is a connected subspace of $\mathbb{R}$, and contains 0 since $d_x(x)=0$. Thus, if $y \in X$ and $y \neq x$, then $d_x(X)$ contains the set $[0, \delta]$, where $\delta=d_x(y)>0$. Therefore $X$ must be uncountable.

\end{proof}


theorem exercise_28_5
  (X : Type*) [topological_space X] :
  countably_compact X ↔ ∀ (C : ℕ → set X), (∀ n, is_closed (C n)) ∧
  (∀ n, C n ≠ ∅) ∧ (∀ n, C n ⊆ C (n + 1)) → ∃ x, ∀ n, x ∈ C n :=

Show that X is countably compact if and only if every nested sequence $C_1 \supset C_2 \supset \cdots$ of closed nonempty sets of X has a nonempty intersection.

\begin{proof}

We could imitate the proof of Theorem 26.9, but we prove directly each direction. First let $X$ be countable compact and let $C_1 \supset C_2 \supset \cdots$ be a nested sequence of closed nonempty sets of $X$. For each $n \in \mathbb{Z}_{+}, U_n=X \backslash C_n$ is open in $X$. Then $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$is a countable collection of open sets with no finite subcollection covering $X$, for if $U_{i_1} \cup \cdots \cup U_{1_n}$ covers $X$, then $C_{i_1} \cap \cdots \cap C_{i_n}$ is empty, contrary to the assumption. Hence $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$does not cover $X$, so there exist $x \in X \backslash \bigcup_{n \in \mathbb{Z}_{+}} U_n=\bigcap_{n \in Z_{+}}\left(X \backslash U_n\right)=\bigcap_{n \in Z_{+}} C_n$.

Conversely, assume that every nested sequence $C_1 \supset C_2 \supset \cdots$ of closed non-empty sets of $X$ has a non-empty intersection and let $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$be a countable open covering of $X$. For each $n$, let $V_n=U_1 \cup \cdots \cup U_n$ and $C_n=X \backslash V_n$. Suppose that no finite subcollection of $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$covers $X$. Then each $C_n$ is non-empty, so $C_1 \supset C_2 \supset \cdots$ is a nested sequence of non-empty closed sets and $\bigcap_{n \in \mathbb{Z}_{+}} C_n$ is non-empty by assumption. Then there exists $x \in \bigcap_{n \in \mathbb{Z}_{+}} C_n$, so that $x \notin V_n$ for all $n$, contradicting the fact that $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$covers $X$. It follows that there exists $N \in \mathbb{Z}_{+}$such that $C_N=\emptyset$, so that $X=V_N$ and hence some finite subcollection of $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$covers $X$. We deduce that $X$ is countable compact.

\end{proof}


theorem exercise_29_1 : ¬ locally_compact_space ℚ :=

Show that the rationals $\mathbb{Q}$ are not locally compact.

\begin{proof}

    First, we prove that each set $\mathbb{Q} \cap[a, b]$, where $a, b$ are irrational numbers, is not compact. Indeed, since $\mathbb{Q} \cap[a, b]$ is countable, we can write $\mathbb{Q} \cap[a, b]=\left\{q_1, q_2, \ldots\right\}$. Then $\left\{U_i\right\}_{i \in \mathbb{Z}_{+}}$, where $U_i=\mathbb{Q} \cap\left[a, q_i\right)$ for each $i$, is an open covering of $\mathbb{Q} \cap[a, b]$ with no finite subcovering. Now let $x \in \mathbb{Q}$ and suppose that $\mathbb{Q}$ is locally compact at $x$. Then there exists a compact set $C$ containing a neighbourhood $U$ of $x$. Then $U$ contains a set $\mathbb{Q} \cap[a, b]$ where $a, b$ are irrational numbers. Since this set is closed and contained in the compact $C$, it follows $\mathbb{Q} \cap[a, b]$ is compact, a contradiction. Therefore, $\mathbb{Q}$ is not locally compact.

\end{proof}


theorem exercise_29_10 {X : Type*}
  [topological_space X] [t2_space X] (x : X)
  (hx : ∃ U : set X, x ∈ U ∧ is_open U ∧ (∃ K : set X, U ⊂ K ∧ is_compact K))
  (U : set X) (hU : is_open U) (hxU : x ∈ U) :
  ∃ (V : set X), is_open V ∧ x ∈ V ∧ is_compact (closure V) ∧ closure V ⊆ U :=

Show that if $X$ is a Hausdorff space that is locally compact at the point $x$, then for each neighborhood $U$ of $x$, there is a neighborhood $V$ of $x$ such that $\bar{V}$ is compact and $\bar{V} \subset U$.

\begin{proof}

    Let $U$ be a neighbourhood of $x$. Since $X$ is locally compact at $x$, there exists a compact subspace $C$ of $X$ containing a neighbourhood $W$ of $x$. Then $U \cap W$ is open in $X$, hence in $C$. Thus, $C \backslash(U \cap W)$ is closed in $C$, hence compact. Since $X$ is Hausdorff, there exist disjoint open sets $V_1$ and $V_2$ of $X$ containing $x$ and $C \backslash(U \cap W)$ respectively. Let $V=V_1 \cap U \cap W$. Since $\bar{V}$ is closed in $C$, it is compact. Furthermore, $\bar{V}$ is disjoint from $C \backslash(U \cap W) \supset C \backslash U$, so $\bar{V} \subset U$.

\end{proof}


theorem exercise_30_13 {X : Type*} [topological_space X]
  (h : ∃ (s : set X), countable s ∧ dense s) (U : set (set X))
  (hU : ∀ (x y : set X), x ∈ U → y ∈ U → x ≠ y → x ∩ y = ∅) :
  countable U :=

Show that if $X$ has a countable dense subset, every collection of disjoint open sets in $X$ is countable.

\begin{proof}

    Let $\mathcal{U}$ be a collection of disjoint open sets in $X$ and let $A$ be a countable dense subset of $X$.

Since $A$ is dense in $X$, every $U \in \mathcal{U}$ intesects $S$. Therefore, there exists a point $x_U \in U \cap S$.

Let $U_1, U_2 \in \mathcal{U}, U_1 \neq U_2$. Then $x_{U_1} \neq x_{U_2}$ since $U_1 \cap U_2=\emptyset$.

Thus, the function $\mathcal{U} \rightarrow S$ given by $U \mapsto x_U$ is injective and therefore, since $S$ is countable, it follows that $\mathcal{U}$ is countable.

\end{proof}


theorem exercise_31_2 {X : Type*}
  [topological_space X] [normal_space X] {A B : set X}
  (hA : is_closed A) (hB : is_closed B) (hAB : disjoint A B) :
  ∃ (U V : set X), is_open U ∧ is_open V ∧ A ⊆ U ∧ B ⊆ V ∧ closure U ∩ closure V = ∅ :=

Show that if $X$ is normal, every pair of disjoint closed sets have neighborhoods whose closures are disjoint.

\begin{proof}

    Let $A$ and $B$ be disjoint closed sets. Then there exist disjoint open sets $U$ and $V$ containing $A$ and $B$ respectively.

Since $X \backslash V$ is closed and contains $U$, the closure of $U$ is contained in $X \backslash V$ hence $B$ and closure of $U$ are disjoint.

Repeat steps 1 and 2 for $B$ and $\bar{U}$ instead of $A$ and $B$ respectively and you will have open set $V^{\prime}$ which contains $B$ and its closure doesn't intersect with $\bar{U}$.

\end{proof}


theorem exercise_32_1 {X : Type*} [topological_space X]
  (hX : normal_space X) (A : set X) (hA : is_closed A) :
  normal_space {x // x ∈ A} :=

Show that a closed subspace of a normal space is normal.

\begin{proof}

    Let $X$ be a normal space and $Y$ a closed subspace of $X$.

First we shows that $Y$ is a $T_1$-space.

Let $y \in Y$ be any point. Since $X$ is normal, $X$ is also a $T_1$ space and therefore $\{y\}$ is closed in $X$.

Then it follows that $\{y\}=\{y\} \cap Y$ is closed in $Y$ (in relative topology).

Now let's prove that $X$ is a $T_4$-space.

Let $F, G \subseteq Y$ be disjoint closed sets. Since $F$ and $G$ are closed in $Y$ and $Y$ is closed in $X$, it follows that $F$ and $G$ are closed in $X$.

Since $X$ is normal, $X$ is also a $T_4$-space and therefore there exist disjoint open sets $U, V \subseteq$ $X$ such that $F \subseteq U$ and $G \subseteq V$.

However, then $U \cap Y$ and $V \cap Y$ are open disjoint sets in $Y$ (in relative topology) which separate $F$ and $G$.

\end{proof}


theorem exercise_32_2b
  {ι : Type*} {X : ι → Type*} [∀ i, topological_space (X i)]
  (h : ∀ i, nonempty (X i)) (h2 : regular_space (Π i, X i)) :
  ∀ i, regular_space (X i) :=

Show that if $\prod X_\alpha$ is regular, then so is $X_\alpha$. Assume that each $X_\alpha$ is nonempty.

\begin{proof}

    Suppose that $X=\prod_\beta X_\beta$ is regular and let $\alpha$ be any index.

We have to prove that $X_\alpha$ satisfies the $T_1$ and the $T_3$ axiom.

Since $X$ is regular, it follows that $X$ is Hausdorff, which then implies that $X_\alpha$ is Hausdorff. However, this implies that $X_\alpha$ satisfies the $T_1$ axiom.

Let now $F \subseteq X_\alpha$ be a closed set and $x \in X_\alpha \backslash F$ a point.

Then $\prod_\beta F_\beta$, where $F_\alpha=F$ and $F_\beta=X_\beta$ for $\beta \neq \alpha$, is a closed set in $X$ since $\left(\prod_\beta F_\beta\right)^c=\prod_\beta U_\beta$, where $U_\alpha=F^c$ and $U_\beta=X_\beta$ for $\beta \neq \alpha$, which is an open set because it is a base element for the product topology.

Since all $X_\beta$ are nonempty, there exists a point $\mathbf{x} \in X$ such that $x_\alpha=x$. Then $\mathbf{x} \notin \prod_\beta F_\beta$.

Now since $X$ is regular (and therefore satisfies the $T_3$ axiom), there exist disjoint open sets $U, V \subseteq X$ such that $\mathbf{x} \in U$ and $\prod_\beta F_\beta \subseteq V$.

Now for every $\beta \neq \alpha$ we have that $x_\beta \in X_\beta=\pi_\beta(V)$. However, since $x_\beta \in \pi_\beta(U)$, it follows that $\pi_\beta(U) \cap \pi_\beta(V) \neq \emptyset$.

Then $U \cap V=\emptyset$ implies that $\pi_\alpha(U) \cap \pi_\alpha(V)=\emptyset$.. Also, $x \in \pi_\alpha(U)$ and $F \subseteq \pi_\alpha(V)$ and $\pi_\alpha(U), \pi_\alpha(V)$ are open sets since $\pi_\alpha$ is an open map.

Therefore, $X_\alpha$ satisfies the $T_3$ axiom.

\end{proof}


theorem exercise_32_3 {X : Type*} [topological_space X]
  (hX : locally_compact_space X) (hX' : t2_space X) :
  regular_space X :=

Show that every locally compact Hausdorff space is regular.

\begin{proof}

    Let $X$ be a LCH space.

Then it follows that for every $x \in X$ and for every open neighborhood $U \subseteq X$ of $x$ there exists an open neighborhood $V \subseteq X$ of $x$ such that $\bar{V} \subseteq U$ (and $\bar{V}$ is compact, but this is not important here).

Since $X$ is a Hausdorff space, it satisfies the $T_1$ axiom.

Then it follows that $X$ is regular.

\end{proof}


theorem exercise_33_8
  (X : Type*) [topological_space X] [regular_space X]
  (h : ∀ x A, is_closed A ∧ ¬ x ∈ A →
  ∃ (f : X → I), continuous f ∧ f x = (1 : I) ∧ f '' A = {0})
  (A B : set X) (hA : is_closed A) (hB : is_closed B)
  (hAB : disjoint A B)
  (hAc : is_compact A) :
  ∃ (f : X → I), continuous f ∧ f '' A = {0} ∧ f '' B = {1} :=

Let $X$ be completely regular, let $A$ and $B$ be disjoint closed subsets of $X$. Show that if $A$ is compact, there is a continuous function $f \colon X \rightarrow [0, 1]$ such that $f(A) = \{0\}$ and $f(B) = \{1\}$.

\begin{proof}

    Since $X$ is completely regular $\forall a \in A, \exists f_a: X \rightarrow[0,1]: f_a(a)=0$ and $f_a(B)=\{1\}$. For some $\epsilon_a \in(0,1)$ we have that $U_a:=f_a^{-1}([0, \epsilon))$ is an open neighborhood of $a$ that does not intersect $B$. We therefore have an open covering $\left\{U_a \mid a \in A\right\}$ of $A$, so since $A$ is compact we have a finite subcover $\left\{U_{a_i} \mid 1 \leq i \leq m\right\}$. For each $1 \leq i \leq m$ define

$$

\begin{aligned}

\tilde{f}_{a_i}: X & \rightarrow[0,1] \\

x & \mapsto \frac{\max \left(f_{a_i}(x), \epsilon_{a_i}\right)-\epsilon_{a_i}}{1-\epsilon_{a_i}}

\end{aligned}

$$

so that $\forall x \in U_{a_i}: \tilde{f}_{a_i}(x)=0$ and $\forall x \in B, \forall 1 \leq i \leq m: \tilde{f}_{a_i}(x)=1$, and define $f:=$ $\prod_{i=1}^m \tilde{f}_{a_i}$. Then since $A \subset \cup_{i=1}^m U_{a_i}$ we have that $f(A)=\{0\}$ and also we have $f(B)=\{1\}$.

\end{proof}


theorem exercise_38_6 {X : Type*}
  (X : Type*) [topological_space X] [regular_space X]
  (h : ∀ x A, is_closed A ∧ ¬ x ∈ A →
  ∃ (f : X → I), continuous f ∧ f x = (1 : I) ∧ f '' A = {0}) :
  is_connected (univ : set X) ↔ is_connected (univ : set (stone_cech X)) :=

Let $X$ be completely regular. Show that $X$ is connected if and only if the Stone-Čech compactification of $X$ is connected.

\begin{proof}

    The closure of a connected set is connected, so if $X$ is connected so is $\beta(X)$

Suppose $X$ is the union of disjoint open subsets $U, V \subset X$. Define the continuous map

$$

\begin{aligned}

& f: X \rightarrow\{0,1\} \\

& x \mapsto \begin{cases}0, & x \in U \\

1, & x \in V\end{cases}

\end{aligned}

$$

By the fact that $\{0,1\}$ is compact and Hausdorff we can extend $f$ to a surjective map $\bar{f}: \beta(X) \rightarrow\{0,1\}$ such that $\bar{f}^{-1}(\{0\})$ and $\bar{f}^{-1}(\{1\})$ are disjoint open sets that cover $\beta(X)$, which makes this space not-connected.

\end{proof}