theorem exercise_1_9 {F V : Type*} [add_comm_group V] [field F]
  [module F V] (U W : submodule F V):
  ∃ U' : submodule F V, (U'.carrier = ↑U ∩ ↑W ↔ (U ≤ W ∨ W ≤ U)) :=

Prove that the union of two subspaces of $V$ is a subspace of $V$ if and only if one of the subspaces is contained in the other.

\begin{proof}

    To prove this one way, suppose for purposes of contradiction that for $U_1$ and $U_2$, which are subspaces of $V$, that $U_1 \cup U_2$ is a subspace and neither is completely contained within the other. In other words, $U_1 \nsubseteq U_2$ and $U_2 \nsubseteq U_1$. We will show that you can pick a vector $v \in U_1$ and a vector $u \in U_2$ such that $v+u \notin U_1 \cup U_2$, proving that if $U_1 \cup U_2$ is a subspace, one must be completely contained inside the other.

If $U_1 \nsubseteq U_2$, we can pick a $v \in U_1$ such that $v \notin U_2$. Since $v$ is in the subspace $U_1$, then $(-v)$ must also be, by definition. Similarly, if $U_2 \nsubseteq U_1$, then we can pick a $u \in U_2$ such that $u \notin U_1$. Since $u$ is in the subspace $U_2$, then $(-u)$ must also be, by definition.

If $v+u \in U_1 \cup U_2$, then $v+u$ must be in $U_1$ or $U_2$. But, $v+u \in U_1 \Rightarrow v+u+(-v) \in U_1 \Rightarrow u \in U_1$

Similarly,

$$

v+u \in U_2 \Rightarrow v+u+(-u) \in U_2 \Rightarrow v \in U_2

$$

This is clearly a contradiction, as each element was defined to not be in these subspaces. Thus our initial assumption must have been wrong, and $U_1 \subseteq U_2$ or $U_2 \subseteq U_1$

To prove the other way, Let $U_1 \subseteq U_2$ (WLOG). $U_1 \subseteq U_2 \Rightarrow U_1 \cup U_2=U_2$. Since $U_2$ is a subspace, $U_1 \cup U_2$ is as well. QED.

\end{proof}


theorem exercise_3_8 {F V W : Type*}  [add_comm_group V]
  [add_comm_group W] [field F] [module F V] [module F W]
  (L : V →ₗ[F] W) :
  ∃ U : submodule F V, U ⊓ L.ker = ⊥ ∧
  linear_map.range L = range (dom_restrict L U):=

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 $V$ is finite dimensional and that $T \in \mathcal{L}(V, W)$. Prove that there exists a subspace $U$ of $V$ such that $U \cap \operatorname{null} T=\{0\}$ and range $T=\{T u: u \in U\}$.

\begin{proof}

    The point here is to note that every subspace of a vector space has a complementary subspace.

In this example, $U$ will precisely turn out to be the complementary subspace of null $T$. That is, $V=U \oplus \operatorname{null} T$

How should we characterize $U$ ? This can be achieved by extending a basis $B_1=\left\{v_1, v_2, \ldots, v_m\right\}$ of null $T$ to a basis of $V$. Let $B_2=\left\{u_1, u_2, \ldots, u_n\right\}$ be such that $B=B_1 \cup B_2$ is a basis of $V$.

Define $U=\operatorname{span}\left(B_2\right)$. Now, since $B_1$ and $B_2$ are complementary subsets of the basis $B$ of $V$, their spans will turn out to be complementary subspaces of $V$. Let's prove that $V=U \oplus$ null $T$.

Let $v \in V$. Then, $v$ can be expressed as a linear combination of the vectors in $B$.

Let $v=a_1 u_1+\cdots+a_n u_n+c_1 v_1+\cdots+c_m v_m$. However, since $\left\{u_1, u_2, \ldots, u_n\right\}$ is a basis of $U, a_1 u_1+$ $\cdots+a_n u_n=u \in U$ and since $\left\{v_1, v_2, \ldots, v_m\right\}$ is a basis of null $T, c_1 v_1+\cdots+c_m v_m=w \in$ null $T$.

Hence, $v=u+w \in U+\operatorname{null} T$. This shows that

$$

V=U+\operatorname{null} T

$$

Now, let $v \in U \cap \operatorname{null} T$.

Since $v \in U, u$ can be expressed as a linear combination of basis vectors of $U$. Let

$$

v=a_1 u_1+\cdots+a_n u_n

$$

Similarly, since $v \in \operatorname{null} T$, it can also be expressed as a tinear combination of the basis vectors of null $T$. Let

$$

v=c_1 v_1+\cdots+c_m v_m

$$

The left hand sides of the above two equations are equal. Therefore, we can equate the right hand sides.

$$

\begin{aligned}

& a_1 u_1+\cdots+a_n u_n=v=c_1 v_1+\cdots+c_m v_m \\

& a_1 u_1+\cdots+a_n u_n-c_1 v_1-\cdots-c_m v_m=0

\end{aligned}

$$

We have found a linear combination of $u_i^{\prime}$ 's and $v_i$ 's which is equal to zero. However, they are basis vectors of $V$. Hence, all the multipliers $c_i$ 's and $a_i$ 's must be zero implying that $v=0$.

Therefore, if $v \in U \cap$ null $T$, then $v=0$. this means that

$$

U \cap \operatorname{null} T=\{0\}

$$

The above shows that $U$ satisfies the first of the required conditions.

Now let $w \in$ range $T$. Then, there exists $v \in V$ such that $T v=w$. This allows us to write $v=u+w$ where $u \in U$ and $w \in$ null $T$. This implies

$$

\begin{aligned}

w & =T v \\

& =T(u+w) \\

& =T u+T w \\

& =T u+0 \quad \quad(\text { since } w \in \operatorname{null} T) \\

& =T u

\end{aligned}

$$

This shows that if $w \in$ range $T$ then $w=T u$ for some $u \in U$. Therefore, range $T \subseteq\{T u \mid u \in U\}$.

Since $U$ is a subspace of $V$, it follows that $T u \in$ range $T$ for all $u \in U$. Thus, $\{T u \mid u \in U\} \subseteq$ range $T$.

Therefore, range $T=\{T u \mid u \in U\}$.

This shows that $U$ satisfies the second required condition as well.

\end{proof}


theorem exercise_5_1 {F V : Type*} [add_comm_group V] [field F]
  [module F V] {L : V →ₗ[F] V} {n : ℕ} (U : fin n → submodule F V)
  (hU : ∀ i : fin n, map L (U i) = U i) :
  map L (∑ i : fin n, U i : submodule F V) =
  (∑ i : fin n, U i : submodule F V) :=

Suppose $T \in \mathcal{L}(V)$. Prove that if $U_{1}, \ldots, U_{m}$ are subspaces of $V$ invariant under $T$, then $U_{1}+\cdots+U_{m}$ is invariant under $T$.

\begin{proof}

    First off, assume that $U_1, \ldots, U_m$ are subspaces of $V$ invariant under $T$. Now, consider a vector $u \in$ $U_1+\ldots+U_m$. There does exist $u_1 \in U_1, \ldots, u_m \in U_m$ such that $u=u_1+\ldots+u_m$.

Once you apply $T$ towards both sides of the previous equation, we would then get $T u=T u_1+\ldots+$ $T u_m$.

Since each $U_j$ is invariant under $T$, then we would have $T u_1 \in U_1+\ldots+T u_m$. This would then make the equation shows that $T u \in U_1+\ldots+T u_m$, which does imply that $U_1+. .+U_m$ is invariant under $T$

\end{proof}


theorem exercise_5_11 {F V : Type*} [add_comm_group V] [field F]
  [module F V] (S T : End F V) :
  (S * T).eigenvalues = (T * S).eigenvalues  :=

Suppose $S, T \in \mathcal{L}(V)$. Prove that $S T$ and $T S$ have the same eigenvalues.

\begin{proof}

    To start, let $\lambda \in F$ be an eigenvalue of $S T$. Now, we would want $\lambda$ to be an eigenvalue of $T S$. Since $\lambda$, by itself, is an eigenvalue of $S T$, then there has to be a nonzero vector $v \in V$ such that $(S T) v=\lambda v$.

Now, With a given reference that $(S T) v=\lambda v$, you will then have the following: $(T S)(T v)=$ $T(S T v)=T(\lambda v)=\lambda T v$

If $T v \neq 0$, then the listed equation above shows that $\lambda$ is an eigenvalue of $T S$.

If $T v=0$, then $\lambda=0$, since $S(T v)=\lambda T v$. This also means that $T$ isn't invertible, which would imply that $T S$ isn't invertible, which can also be implied that $\lambda$, which equals 0 , is an eigenvalue of $T S$.

Step 3

3 of 3

Now, regardless of whether $T v=0$ or not, we would have shown that $\lambda$ is an eigenvalue of $T S$. Since $\lambda$ (was) an arbitrary eigenvalue of $S T$, we have shown that every single eigenvalue of $S T$ is an eigenvalue of $T S$. When you do reverse the roles of both $S$ and $T$, then we can conclude that that every single eigenvalue of $T S$ is also an eigenvalue of $S T$. Therefore, both $S T$ and $T S$ have the exact same eigenvalues.

\end{proof}


theorem exercise_5_13 {F V : Type*} [add_comm_group V] [field F]
  [module F V] [finite_dimensional F V] {T : End F V}
  (hS : ∀ U : submodule F V, finrank F U = finrank F V - 1 →
  map T U = U) : ∃ c : F, T = c • id :=

Suppose $T \in \mathcal{L}(V)$ is such that every subspace of $V$ with dimension $\operatorname{dim} V-1$ is invariant under $T$. Prove that $T$ is a scalar multiple of the identity operator.

\begin{proof}

    First off, let $T$ isn't a scalar multiple of the identity operator. So, there does exists that $v \in V$ such that $u$ isn't an eigenvector of $T$. Therefore, $(u, T u)$ is linearly independent.

Next, you should extend $(u, T u)$ to a basis of $\left(u, T u, v_1, \ldots, v_n\right)$ of $V$. So, let $U=\operatorname{span}\left(u, v_1, \ldots, v_n\right)$. Then, $U$ is a subspace of $V$ and $\operatorname{dim} U=\operatorname{dim} V-1$. However, $U$ isn't invariant under $T$ since both $u \in U$ and $T u \in U$. This given contradiction to our hypothesis about $T$ actually shows us that our guess that $T$ is not a scalar multiple of the identity must have been false.

\end{proof}


theorem exercise_5_24 {V : Type*} [add_comm_group V]
  [module ℝ V] [finite_dimensional ℝ V] {T : End ℝ V}
  (hT : ∀ c : ℝ, eigenspace T c = ⊥) {U : submodule ℝ V}
  (hU : map T U = U) : even (finrank U) :=

Suppose $V$ is a real vector space and $T \in \mathcal{L}(V)$ has no eigenvalues. Prove that every subspace of $V$ invariant under $T$ has even dimension.

\begin{proof}

    First off, let us assume that $U$ is a subspace of $V$ that is invariant under $T$. Therefore, $\left.T\right|_U \in \mathcal{L}(U)$. If $\operatorname{dim}$ $U$ were odd, then $\left.T\right|_U$ would have an eigenvalue $\lambda \in \mathbb{R}$, so there would exist a nonzero vector $u \in U$ such that

$$

\left.T\right|_U u=\lambda u .

$$

So, this would imply that $T_u=\lambda u$, which would imply that $\lambda$ is an eigenvalue of $T$. But $T$ has no eigenvalues, so $\operatorname{dim} U$ must be even.

\end{proof}


theorem exercise_6_3 {n : ℕ} (a b : fin n → ℝ) :
  (∑ i, a i * b i) ^ 2 ≤ (∑ i : fin n, i * a i ^ 2) * (∑ i, b i ^ 2 / i) :=

Prove that $\left(\sum_{j=1}^{n} a_{j} b_{j}\right)^{2} \leq\left(\sum_{j=1}^{n} j a_{j}{ }^{2}\right)\left(\sum_{j=1}^{n} \frac{b_{j}{ }^{2}}{j}\right)$ for all real numbers $a_{1}, \ldots, a_{n}$ and $b_{1}, \ldots, b_{n}$.

\begin{proof}

    Let $a_1, a_2, \ldots, a_n, b_1, b_2, \ldots, b_n \in R$.

We have that

$$

\left(\sum_{j=1}^n a_j b_j\right)^2

$$

is equal to the

$$

\left(\sum_{j=1}^n a_j b_j \frac{\sqrt{j}}{\sqrt{j}}\right)^2=\left(\sum_{j=1}^n\left(\sqrt{j} a_j\right)\left(b_j \frac{1}{\sqrt{j}}\right)\right)^2

$$

This can be observed as an inner product, and using the Cauchy-Schwarz Inequality, we get

$$

\begin{aligned}

&\left(\sum_{j=1}^n a_j b_j\right)^2=\left(\sum_{j=1}^n\left(\sqrt{j} a_j\right)\left(b_j \frac{1}{\sqrt{j}}\right)\right)^2 \\

&=\left\langle\left(a, \sqrt{2} a_2, \ldots, \sqrt{n} a_n\right),\left(b_1, \frac{b_2}{\sqrt{2}}, \ldots, \frac{b_n}{\sqrt{n}}\right)\right\rangle \\

& \leq\left\|\left(a, \sqrt{2} a_2, \ldots, \sqrt{n} a_n\right)\right\|^2\left\|\left(b_1, \frac{b_2}{\sqrt{2}}, \ldots, \frac{b_n}{\sqrt{n}}\right)\right\|^2 \\

&=\left(\sum_{j=1}^n j a_j^2\right)\left(\sum_{j=1}^n \frac{b_j^2}{j}\right) \\

& \text { Hence, }\left(\sum_{j=1}^n a_j b_j\right)^2=\left(\sum_{j=1}^n j a_j^2\right)\left(\sum_{j=1}^n \frac{b_j^2}{j}\right) .

\end{aligned}

$$

\end{proof}


theorem exercise_6_13 {V : Type*} [inner_product_space ℂ V] {n : ℕ}
  {e : fin n → V} (he : orthonormal ℂ e) (v : V) :
  ∥v∥^2 = ∑ i : fin n, ∥⟪v, e i⟫_ℂ∥^2 ↔ v ∈ span ℂ (e '' univ) :=

Suppose $\left(e_{1}, \ldots, e_{m}\right)$ is an or thonormal list of vectors in $V$. Let $v \in V$. Prove that $\|v\|^{2}=\left|\left\langle v, e_{1}\right\rangle\right|^{2}+\cdots+\left|\left\langle v, e_{m}\right\rangle\right|^{2}$ if and only if $v \in \operatorname{span}\left(e_{1}, \ldots, e_{m}\right)$.

\begin{proof}

If $v \in \operatorname{span}\left(e_1, \ldots, e_m\right)$, it means that

$$

v=\alpha_1 e_1+\ldots+\alpha_m e_m .

$$

for some scalars $\alpha_i$. We know that $\alpha_k=\left\langle v, e_k\right\rangle, \forall k \in\{1, \ldots, m\}$. Therefore,

$$

\begin{aligned}

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

& =\left\langle\alpha_1 e_1+\ldots+\alpha_m e_m, \alpha_1 e_1+\ldots+\alpha_m e_m\right\rangle \\

& =\left|\alpha_1\right|^2\left\langle e_1, e_1\right\rangle+\ldots+\left|\alpha_m\right|^2\left\langle e_m, e_m\right\rangle \\

& =\left|\alpha_1\right|^2+\ldots+\left|\alpha_m\right|^2 \\

& =\left|\left\langle v, e_1\right\rangle\right|^2+\ldots+\left|\left\langle v, e_m\right\rangle\right|^2 .

\end{aligned}

$$

$\Rightarrow$ Assume that $v \notin \operatorname{span}\left(e_1, \ldots, e_m\right)$. Then, we must have

$$

v=v_{m+1}+\frac{\left\langle v, v_0\right\rangle}{\left\|v_0\right\|^2} v_0,

$$

where $v_0=\alpha_1 e_1+\ldots+\alpha_m e_m, \alpha_k=\left\langle v, e_k\right\rangle, \forall k \in\{1, \ldots, m\}$, and $v_{m+1}=v-$ $\frac{\left\langle v, v_0\right\rangle}{\left\|v_0\right\|^2} v_0 \neq 0$.

We have $\left\langle v_0, v_{m+1}\right\rangle=0$ (from which we get $\left\langle v, v_0\right\rangle=\left\langle v_0, v_0\right\rangle$ and $\left\langle v, v_{m+1}\right\rangle=$ $\left.\left\langle v_{m+1}, v_{m+1}\right\rangle\right)$. Now,

$$

\begin{aligned}

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

& =\left\langle v, v_{m+1}+\frac{\left\langle v, v_0\right\rangle}{\left\|v_0\right\|^2} v_0\right\rangle \\

& =\left\langle v, v_{m+1}\right\rangle+\left\langle v, \frac{\left\langle v, v_0\right\rangle}{\left\|v_0\right\|^2} v_0\right\rangle \\

& =\left\langle v_{m+1}, v_{m+1}\right\rangle+\frac{\left\langle v_0, v_0\right\rangle}{\left\|v_0\right\|^2}\left\langle v_0, v_0\right\rangle \\

& =\left\|v_{m+1}\right\|^2+\left\|v_0\right\|^2 \\

& >\left\|v_0\right\|^2 \\

& =\left|\alpha_1\right|^2+\ldots+\left|\alpha_m\right|^2 \\

& =\left|\left\langle v, e_1\right\rangle\right|^2+\ldots+\left|\left\langle v, e_m\right\rangle\right|^2 .

\end{aligned}

$$

By contrapositive, if $\left\|v_1\right\|^2=\left|\left\langle v, e_1\right\rangle\right|^2+\ldots+\left|\left\langle v, e_m\right\rangle\right|^2$, then $v \in \operatorname{span}\left(e_1, \ldots, e_m\right)$.

\end{proof}


theorem exercise_7_5 {V : Type*} [inner_product_space ℂ V]
  [finite_dimensional ℂ V] (hV : finrank V ≥ 2) :
  ∀ U : submodule ℂ (End ℂ V), U.carrier ≠
  {T | T * T.adjoint = T.adjoint * T} :=

Show that if $\operatorname{dim} V \geq 2$, then the set of normal operators on $V$ is not a subspace of $\mathcal{L}(V)$.

\begin{proof}

    First off, suppose that $\operatorname{dim} V \geq 2$. Next let $\left(e_1, \ldots, e_n\right)$ be an orthonormal basis of $V$. Now, define $S, T \in L(V)$ by both $S\left(a_1 e_1+\ldots+a_n e_n\right)=a_2 e_1-a_1 e_2$ and $T\left(a_1 e_1+\ldots+\right.$ $\left.a_n e_n\right)=a_2 e_1+a_1 e_2$. So, just by now doing a simple calculation verifies that $S^*\left(a_1 e_1+\right.$ $\left.\ldots+a_n e_n\right)=-a_2 e_1+a_1 e_2$

Now, based on this formula, another calculation would show that $S S^*=S^* S$. Another simple calculation would that that $T$ is self-adjoint. Therefore, both $S$ and $T$ are normal. However, $S+T$ is given by the formula of $(S+T)\left(a_1 e_1+\ldots+a_n e_n\right)=2 a_2 e_1$. In this case, a simple calculator verifies that $(S+T)^*\left(a_1 e_1+\ldots+a_n e_n\right)=2 a_1 e_2$.

Therefore, there is a final simple calculation that shows that $(S+T)(S+T)^* \neq(S+$ $T)^*(S+T)$. So, in other words, $S+T$ isn't normal. Thereofre, the set of normal operators on $V$ isn't closed under addition and hence isn't a subspace of $L(V)$.

\end{proof}


theorem exercise_7_9 {V : Type*} [inner_product_space ℂ V]
  [finite_dimensional ℂ V] (T : End ℂ V)
  (hT : T * T.adjoint = T.adjoint * T) :
  is_self_adjoint T ↔ ∀ e : T.eigenvalues, (e : ℂ).im = 0 :=

Prove that a normal operator on a complex inner-product space is self-adjoint if and only if all its eigenvalues are real.

\begin{proof}

    First off, suppose $V$ is a complex inner product space and $T \in L(V)$ is normal. If $T$ is self-adjoint, then all its eigenvalues are real. So, conversely, let all of the eigenvalues of $T$ be real. By the complex spectral theorem, there's an orthonormal basis $\left(e_1, \ldots, e_n\right)$ of $V$ consisting of eigenvectors of $T$. Thus, there exists real numbers $\lambda_1, \ldots, \lambda_n$ such that $T e_j=\lambda_j e_j$ for $j=$ $1, \ldots, n$.

The matrix of $T$ with respect to the basis of $\left(e_1, \ldots, e_n\right)$ is the diagonal matrix with $\lambda_1, \ldots, \lambda_n$ on the diagonal. So, the matrix equals its conjugate transpose. Therefore, $T=T^*$. In other words, $T$ s self-adjoint.

\end{proof}


theorem exercise_7_11 {V : Type*} [inner_product_space ℂ V]
  [finite_dimensional ℂ V] {T : End ℂ V} (hT : T*T.adjoint = T.adjoint*T) :
  ∃ (S : End ℂ V), S ^ 2 = T :=

Suppose $V$ is a complex inner-product space. Prove that every normal operator on $V$ has a square root. (An operator $S \in \mathcal{L}(V)$ is called a square root of $T \in \mathcal{L}(V)$ if $S^{2}=T$.)

\begin{proof}

    Let $V$ be a complex inner product space.

It is known that an operator $S \in \mathcal{L}(V)$ is called a square root of $T \in \mathcal{L}(V)$ if

$$

S^2=T

$$

Now, suppose that $T$ is a normal operator on $V$.

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

Define $S$ by

$$

S e_j=\sqrt{\lambda_j} e_j,

$$

for each $j=1, \ldots, n$.

Obviously, $S^2 e_j=\lambda_j e_j=T e_j$.

Hence, $S^2=T$ so there exist a square root of $T$.

\end{proof}


theorem exercise_1_1_2a : ∃ a b : ℤ, a - b ≠ b - a :=

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 the the operation $\star$ on $\mathbb{Z}$ defined by $a\star b=a-b$ is not commutative.

\begin{proof}

    Not commutative since

$$

1 \star(-1)=1-(-1)=2

$$

$$

(-1) \star 1=-1-1=-2 .

$$

\end{proof}


theorem exercise_1_1_4 (n : ℕ) :
  ∀ (a b c : ℕ), (a * b) * c ≡ a * (b * c) [ZMOD n] :=

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

\begin{proof}

    We have

$$

\begin{aligned}

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

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

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

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

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

\end{aligned}

$$

since integer multiplication is associative.

\end{proof}


theorem exercise_1_1_15 {G : Type*} [group G] (as : list G) :
  as.prod⁻¹ = (as.reverse.map (λ x, x⁻¹)).prod :=

\begin{proof}

    For $n=1$, note that for all $a_1 \in G$ we have $a_1^{-1}=a_1^{-1}$.

Now for $n \geq 2$ we proceed by induction on $n$. For the base case, note that for all $a_1, a_2 \in G$ we have

$$

\left(a_1 \cdot a_2\right)^{-1}=a_2^{-1} \cdot a_1^{-1}

$$

since

$$

a_1 \cdot a_2 \cdot a_2^{-1} a_1^{-1}=1 .

$$

For the inductive step, suppose that for some $n \geq 2$, for all $a_i \in G$ we have

$$

\left(a_1 \cdot \ldots \cdot a_n\right)^{-1}=a_n^{-1} \cdot \ldots \cdot a_1^{-1} .

$$

Then given some $a_{n+1} \in G$, we have

$$

\begin{aligned}

\left(a_1 \cdot \ldots \cdot a_n \cdot a_{n+1}\right)^{-1} &=\left(\left(a_1 \cdot \ldots \cdot a_n\right) \cdot a_{n+1}\right)^{-1} \\

&=a_{n+1}^{-1} \cdot\left(a_1 \cdot \ldots \cdot a_n\right)^{-1} \\

&=a_{n+1}^{-1} \cdot a_n^{-1} \cdot \ldots \cdot a_1^{-1},

\end{aligned}

$$

using associativity and the base case where necessary.

\end{proof}


theorem exercise_1_1_17 {G : Type*} [group G] {x : G} {n : ℕ}
  (hxn: order_of x = n) :
  x⁻¹ = x ^ (n-1) :=

Let $x$ be an element of $G$. Prove that if $|x|=n$ for some positive integer $n$ then $x^{-1}=x^{n-1}$.

\begin{proof}

    We have $x \cdot x^{n-1}=x^n=1$, so by the uniqueness of inverses $x^{-1}=x^{n-1}$.

\end{proof}


theorem exercise_1_1_20 {G : Type*} [group G] {x : G} :
  order_of x = order_of x⁻¹ :=

For $x$ an element in $G$ show that $x$ and $x^{-1}$ have the same order.

\begin{proof}

    Recall that the order of a group element is either a positive integer or infinity.

Suppose $|x|$ is infinite and that $\left|x^{-1}\right|=n$ for some $n$. Then

$$

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

$$

a contradiction. So if $|x|$ is infinite, $\left|x^{-1}\right|$ must also be infinite. Likewise, if $\left|x^{-1}\right|$ is infinite, then $\left|\left(x^{-1}\right)^{-1}\right|=|x|$ is also infinite.

Suppose now that $|x|=n$ and $\left|x^{-1}\right|=m$ are both finite. Then we have

$$

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

$$

so that $m \leq n$. Likewise, $n \leq m$. Hence $m=n$ and $x$ and $x^{-1}$ have the same order.

\end{proof}


theorem exercise_1_1_22b {G: Type*} [group G] (a b : G) :
  order_of (a * b) = order_of (b * a) :=

Deduce that $|a b|=|b a|$ for all $a, b \in G$.

\begin{proof}

    Let $a$ and $b$ be arbitrary group elements. Letting $x=a b$ and $g=a$, we see that

$$

|a b|=\left|a^{-1} a b a\right|=|b a| .

$$

\end{proof}


theorem exercise_1_1_29 {A B : Type*} [group A] [group B] :
  ∀ x y : A × B, x*y = y*x ↔ (∀ x y : A, x*y = y*x) ∧
  (∀ x y : B, x*y = y*x) :=

Prove that $A \times B$ is an abelian group if and only if both $A$ and $B$ are abelian.

\begin{proof}

    $(\Rightarrow)$ Suppose $a_1, a_2 \in A$ and $b_1, b_2 \in B$. Then

$$

\left(a_1 a_2, b_1 b_2\right)=\left(a_1, b_1\right) \cdot\left(a_2, b_2\right)=\left(a_2, b_2\right) \cdot\left(a_1, b_1\right)=\left(a_2 a_1, b_2 b_1\right) .

$$

Since two pairs are equal precisely when their corresponding entries are equal, we have $a_1 a_2=a_2 a_1$ and $b_1 b_2=b_2 b_1$. Hence $A$ and $B$ are abelian.

$(\Leftarrow)$ Suppose $\left(a_1, b_1\right),\left(a_2, b_2\right) \in A \times B$. Then we have

$$

\left(a_1, b_1\right) \cdot\left(a_2, b_2\right)=\left(a_1 a_2, b_1 b_2\right)=\left(a_2 a_1, b_2 b_1\right)=\left(a_2, b_2\right) \cdot\left(a_1, b_1\right) .

$$

Hence $A \times B$ is abelian.

\end{proof}


theorem exercise_1_3_8 : infinite (equiv.perm ℕ) :=

Prove that if $\Omega=\{1,2,3, \ldots\}$ then $S_{\Omega}$ is an infinite group

\begin{proof}

    Recall that the codomain of an injective function must be at least as large (in cardinality) as the domain of the function. With that in mind, define the function

$$

\begin{gathered}

f: \mathbb{N} \rightarrow S_{\mathbb{N}} \\

f(n)=(1 n)

\end{gathered}

$$

where $(1 n)$ is the cycle decomposition of an element of $S_{\mathbb{N}}$ (specifically it's the function given by $g(1)=n, g(2)=2, g(3)=3, \ldots)$. The function $f$ maps every natural number to a distinct one of these functions. Hence $f$ is injective. Hence $\infty=|\mathbb{N}| \leq\left|S_{\mathbb{N}}\right|$.

\end{proof}


theorem exercise_1_6_11 {A B : Type*} [group A] [group B] :
  A × B ≃* B × A :=

Let $A$ and $B$ be groups. Prove that $A \times B \cong B \times A$.

\begin{proof}

    We know from set theory that the mapping $\varphi: A \times B \rightarrow B \times A$ given by $\varphi((a, b))=(b, a)$ is a bijection with inverse $\psi: B \times A \rightarrow A \times B$ given by $\psi((b, a))=(a, b)$. Also $\varphi$ is a homomorphism, as we show below.

Let $a_1, a_2 \in A$ and $b_1, b_2 \in B$. Then

$$

\begin{aligned}

\varphi\left(\left(a_1, b_1\right) \cdot\left(a_2, b_2\right)\right) &=\varphi\left(\left(a_1 a_2, b_1 b_2\right)\right) \\

&=\left(b_1 b_2, a_1 a_2\right) \\

&=\left(b_1, a_1\right) \cdot\left(b_2, a_2\right) \\

&=\varphi\left(\left(a_1, b_1\right)\right) \cdot \varphi\left(\left(a_2, b_2\right)\right)

\end{aligned}

$$

Hence $A \times B \cong B \times A$.

\end{proof}


theorem exercise_1_6_23 {G : Type*}
  [group G] (σ : mul_aut G) (hs : ∀ g : G, σ g = 1 → g = 1)
  (hs2 : ∀ g : G, σ (σ g) = g) :
  ∀ x y : G, x*y = y*x :=

Let $G$ be a finite group which possesses an automorphism $\sigma$ such that $\sigma(g)=g$ if and only if $g=1$. If $\sigma^{2}$ is the identity map from $G$ to $G$, prove that $G$ is abelian.

\begin{proof}

    Solution: We define a mapping $f: G \rightarrow G$ by $f(x)=x^{-1} \sigma(x)$.

Claim: $f$ is injective.

Proof of claim: Suppose $f(x)=f(y)$. Then $y^{-1} \sigma(y)=x^{-1} \sigma(x)$, so that $x y^{-1}=\sigma(x) \sigma\left(y^{-1}\right)$, and $x y^{-1}=\sigma\left(x y^{-1}\right)$. Then we have $x y^{-1}=1$, hence $x=y$. So $f$ is injective.

Since $G$ is finite and $f$ is injective, $f$ is also surjective. Then every $z \in G$ is of the form $x^{-1} \sigma(x)$ for some $x$. Now let $z \in G$ with $z=x^{-1} \sigma(x)$. We have

$$

\sigma(z)=\sigma\left(x^{-1} \sigma(x)\right)=\sigma(x)^{-1} x=\left(x^{-1} \sigma(x)\right)^{-1}=z^{-1} .

$$

Thus $\sigma$ is in fact the inversion mapping, and we assumed that $\sigma$ is a homomorphism. By a previous example, then, $G$ is abelian.

\end{proof}


theorem exercise_2_1_13 (H : add_subgroup ℚ) {x : ℚ}
  (hH : x ∈ H → (1 / x) ∈ H):
  H = ⊥ ∨ H = ⊤ :=

Let $H$ be a subgroup of the additive group of rational numbers with the property that $1 / x \in H$ for every nonzero element $x$ of $H$. Prove that $H=0$ or $\mathbb{Q}$.

\begin{proof}

    Solution: First, suppose there does not exist a nonzero element in $H$. Then $H=0$.

Now suppose there does exist a nonzero element $a \in H$; without loss of generality, say $a=p / q$ in lowest terms for some integers $p$ and $q$ - that is, $\operatorname{gcd}(p, q)=1$. Now $q \cdot \frac{p}{q}=p \in H$, and since $q / p \in H$, we have $p \cdot \frac{q}{p} \in H$. There exist integers $x, y$ such that $q x+p y=1$; note that $q x \in H$ and $p y \in H$, so that $1 \in H$. Thus $n \in H$ for all $n \in \mathbb{Z}$. Moreover, if $n \neq 0,1 / n \in H$. Then $m / n \in H$ for all integers $m, n$ with $n \neq 0$; hence $H=\mathbb{Q}$.

\end{proof}


theorem exercise_2_4_16a {G : Type*} [group G] {H : subgroup G}
  (hH : H ≠ ⊤) :
  ∃ M : subgroup G, M ≠ ⊤ ∧
  ∀ K : subgroup G, M ≤ K → K = M ∨ K = ⊤ ∧
  H ≤ M :=

A subgroup $M$ of a group $G$ is called a maximal subgroup if $M \neq G$ and the only subgroups of $G$ which contain $M$ are $M$ and $G$. Prove that if $H$ is a proper subgroup of the finite group $G$ then there is a maximal subgroup of $G$ containing $H$.

\begin{proof}

If $H$ is maximal, then we are done. If $H$ is not maximal, then there is a subgroup $K_1$ of $G$ such that $H<K_1<G$. If $K_1$ is maximal, we are done. But if $K_1$ is not maximal, there is a subgroup $K_2$ with $H<K_1<K_2<G$. If $K_2$ is maximal, we are done, and if not, keep repeating the procedure. Since $G$ is finite, this process must eventually come to an end, so that $K_n$ is maximal for some positive integer $n$. Then $K_n$ is a maximal subgroup containing $H$.

\end{proof}


theorem exercise_2_4_16c {n : ℕ} (H : add_subgroup (zmod n)) :
  ∃ p : ℕ, nat.prime p ∧ H = add_subgroup.closure {p} ↔
  H ≠ ⊤ ∧ ∀ K : add_subgroup (zmod n), H ≤ K → K = H ∨ K = ⊤ :=

Show that if $G=\langle x\rangle$ is a cyclic group of order $n \geq 1$ then a subgroup $H$ is maximal if and only $H=\left\langle x^{p}\right\rangle$ for some prime $p$ dividing $n$.

\begin{proof}

    Suppose $H$ is a maximal subgroup of $G$. Then $H$ is cyclic, and we may write $H=\left\langle x^k\right\rangle$ for some integer $k$, with $k>1$. Let $d=(n, k)$. Since $H$ is a proper subgroup, we know by Proposition 6 that $d>1$. Choose a prime factor $p$ of $d$. If $k=p=d$ then $k \mid n$ as required.

If, however, $k$ is not prime, then consider the subgroup $K=\left\langle x^p\right\rangle$. Since $p$ is a proper divisor of $k$, it follows that $H<K$. But $H$ is maximal, so we must have $K=G$. Again by Proposition 6 , we must then have $(p, n)=1$. However, $p$ divides $d$ which divides $n$, so $p \mid n$ and $(p, n)=p>1$, a contradiction. Therefore $k=p$ and the left-to-right implication holds.

Now, for the converse, suppose $H=\left\langle x^p\right\rangle$ for $p$ a prime dividing $n$. If $H$ is not maximal then the first part of this exercise shows that there is a maximal subgroup $K$ containing $H$. Then $K=\left\langle x^q\right\rangle$. So $x^p \in\left\langle x^q\right\rangle$, which implies $q \mid p$. But the only divisors of $p$ are 1 and $p$. If $q=1$ then $K=G$ and $K$ cannot be a proper subgroup, and if $q=p$ then $H=K$ and $H$ cannot be a proper subgroup of $K$. This contradiction shows that $H$ is maximal.

\end{proof}


theorem exercise_3_1_22a (G : Type*) [group G] (H K : subgroup G)
  [subgroup.normal H] [subgroup.normal K] :
  subgroup.normal (H ⊓ K) :=

Prove that if $H$ and $K$ are normal subgroups of a group $G$ then their intersection $H \cap K$ is also a normal subgroup of $G$.

\begin{proof}

    Suppose $H$ and $K$ are normal subgroups of $G$. We already know that $H \cap K$ is a subgroup of $G$, so we need to show that it is normal. Choose any $g \in G$ and any $x \in H \cap K$. Since $x \in H$ and $H \unlhd G$, we know $g x g^{-1} \in H$. Likewise, since $x \in K$ and $K \unlhd G$, we have $g x g^{-1} \in K$. Therefore $g x g^{-1} \in H \cap K$. This shows that $g(H \cap K) g^{-1} \subseteq H \cap K$, and this is true for all $g \in G$. By Theorem 6 (5) (which we will prove in Exercise 3.1.25), this is enough to show that $H \cap K \unlhd G$.

\end{proof}


theorem exercise_3_2_8 {G : Type*} [group G] (H K : subgroup G)
  [fintype H] [fintype K]
  (hHK : nat.coprime (fintype.card H) (fintype.card K)) :
  H ⊓ K = ⊥ :=

Prove that if $H$ and $K$ are finite subgroups of $G$ whose orders are relatively prime then $H \cap K=1$.

\begin{proof}

    Solution: Let $|H|=p$ and $|K|=q$. We saw in a previous exercise that $H \cap K$ is a subgroup of both $H$ and $K$; by Lagrange's Theorem, then, $|H \cap K|$ divides $p$ and $q$. Since $\operatorname{gcd}(p, q)=1$, then, $|H \cap K|=1$. Thus $H \cap K=1$.

\end{proof}


theorem exercise_3_2_16 (p : ℕ) (hp : nat.prime p) (a : ℕ) :
  nat.coprime a p → a ^ p ≡ a [ZMOD p] :=

Use Lagrange's Theorem in the multiplicative group $(\mathbb{Z} / p \mathbb{Z})^{\times}$to prove Fermat's Little Theorem: if $p$ is a prime then $a^{p} \equiv a(\bmod p)$ for all $a \in \mathbb{Z}$.

\begin{proof}

    Solution: If $p$ is prime, then $\varphi(p)=p-1$ (where $\varphi$ denotes the Euler totient). Thus

$$

\mid\left((\mathbb{Z} /(p))^{\times} \mid=p-1 .\right.

$$

So for all $a \in(\mathbb{Z} /(p))^{\times}$, we have $|a|$ divides $p-1$. Hence

$$

a=1 \cdot a=a^{p-1} a=a^p \quad(\bmod p) .

$$

\end{proof}


theorem exercise_3_3_3 {p : primes} {G : Type*} [group G]
  {H : subgroup G} [hH : H.normal] (hH1 : H.index = p) :
  ∀ K : subgroup G, K ≤ H ∨ H ⊔ K = ⊤ ∨ (K ⊓ H).relindex K = p :=

Prove that if $H$ is a normal subgroup of $G$ of prime index $p$ then for all $K \leq G$ either $K \leq H$, or $G=H K$ and $|K: K \cap H|=p$.

\begin{proof}

    Solution: Suppose $K \backslash N \neq \emptyset$; say $k \in K \backslash N$. Now $G / N \cong \mathbb{Z} /(p)$ is cyclic, and moreover is generated by any nonidentity- in particular by $\bar{k}$

Now $K N \leq G$ since $N$ is normal. Let $g \in G$. We have $g N=k^a N$ for some integer a. In particular, $g=k^a n$ for some $n \in N$, hence $g \in K N$. We have $[K: K \cap N]=p$ by the Second Isomorphism Theorem.

\end{proof}


theorem exercise_3_4_4 {G : Type*} [comm_group G] [fintype G] {n : ℕ}
    (hn : n ∣ (fintype.card G)) :
    ∃ (H : subgroup G) (H_fin : fintype H), @card H H_fin = n  :=

Use Cauchy's Theorem and induction to show that a finite abelian group has a subgroup of order $n$ for each positive divisor $n$ of its order.

\begin{proof}

    Let $G$ be a finite abelian group. We use induction on $|G|$. Certainly the result holds for the trivial group. And if $|G|=p$ for some prime $p$, then the positive divisors of $|G|$ are 1 and $p$ and the result is again trivial.

Now assume that the statement is true for all groups of order strictly smaller than $|G|$, and let $n$ be a positive divisor of $|G|$ with $n>1$. First, if $n$ is prime then Cauchy's Theorem allows us to find an element $x \in G$ having order $n$. Then $\langle x\rangle$ is the desired subgroup. On the other hand, if $n$ is not prime, then $n$ has a prime divisor $p$, so that $n=k p$ for some integer $k$. Cauchy's Theorem allows us to find an element $x$ having order $p$. Set $N=\langle x\rangle$. By Lagrange's Theorem,

$$

|G / N|=\frac{|G|}{|N|}<|G| .

$$

Now, by the inductive hypothesis, the group $G / N$ must have a subgroup of order $k$. And by the Lattice Isomorphism Theorem, this subgroup has the form $H / N$ for some subgroup $H$ of $G$. Then $|H|=k|N|=k p=n$, so that $H$ has order $n$. This completes the inductive step.

\end{proof}


theorem exercise_3_4_5b {G : Type*} [group G] [is_solvable G]
  (H : subgroup G) [subgroup.normal H] :
  is_solvable (G ⧸ H) :=

Prove that quotient groups of a solvable group are solvable.

\begin{proof}

    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.

Next, let $N \unlhd G$. For each $i$, define

$$

N_i=G_i N, \quad 0 \leq i \leq n .

$$

Now let $g \in N_{i+1}$, where $g=g_0 n_0$ with $g_0 \in G_{i+1}$ and $n_0 \in N$. Also let $x \in N_i$, where $x=g_1 n_1$ with $g_1 \in G_i$ and $n_1 \in N$. Then

$$

g x g^{-1}=g_0 n_0 g_1 n_1 n_0^{-1} g_0^{-1} .

$$

Now, since $N$ is normal in $G, N g=g N$, so $n_0 g_1=g_1 n_2$ for some $n_2 \in N$. Then

$$

g x g^{-1}=g_0 g_1\left(n_2 n_1 n_0^{-1}\right) g_0^{-1}=g_0 g_1 n_3 g_0^{-1}

$$

for some $n_3 \in N$. Then $n_3 g_0^{-1}=g_0^{-1} n_4$ for some $n_4 \in N$. And $g_0 g_1 g_0^{-1} \in G_i$ since $G_i \unlhd G_{i+1}$, so

$$

g x g^{-1}=g_0 g_1 g_0^{-1} n_4 \in N_i .

$$

This shows that $N_i \unlhd N_{i+1}$. So by the Lattice Isomorphism Theorem, we have $N_{i+1} / N \unlhd N_i / N$. This shows that

$$

1=N_0 / N \unlhd N_1 / N \unlhd N_2 / N \unlhd \cdots \unlhd N_n / N=G / N .

$$

Moreover, the Third Isomorphism Theorem says that

$$

\left(N_{i+1} / N\right) /\left(N_i / N\right) \cong N_{i+1} / N_i,

$$

so the proof will be complete if we can show that $N_{i+1} / N_i$ is abelian.

Let $x, y \in N_{i+1} / N_i$. Then

$$

x=\left(g_0 n_0\right) N_i \quad \text { and } \quad y=\left(g_1 n_1\right) N_i

$$

for some $g_0, g_1 \in G_{i+1}$ and $n_0, n_1 \in N$. We have

$$

\begin{aligned}

x y x^{-1} y^{-1} & =\left(g_0 n_0\right)\left(g_1 n_1\right)\left(g_0 n_0\right)^{-1}\left(g_1 n_1\right)^{-1} N_i \\

& =g_0 n_0 g_1 n_1 n_0^{-1} g_0^{-1} n_1^{-1} g_1^{-1} N_i .

\end{aligned}

$$

Since $N \unlhd G, g N=N g$ for any $g \in G$, so we can find $n_2 \in N$ such that

$$

x y x^{-1} y^{-1}=g_0 g_1 g_0^{-1} g^{-1} n_2 N_i .

$$

Now $N_i=G_i N=N G_i$ since $N \unlhd G$ (see Proposition 14 and its corollary). Therefore

$$

n_2 N_i=n_2 N G_i=N G_i=G_i N

$$

and we get

$$

x y x^{-1} y^{-1}=g_0 g_1 g_0^{-1} g^{-1} G_i N=G_i N .

$$

So $x y x^{-1} y^{-1}=1 N_i$ or $x y=y x$. This completes the proof that $G / N$ is solvable.

\end{proof}


theorem exercise_4_2_8 {G : Type*} [group G] {H : subgroup G}
  {n : ℕ} (hn : n > 0) (hH : H.index = n) :
  ∃ K ≤ H, K.normal ∧ K.index ≤ n.factorial :=

Prove that if $H$ has finite index $n$ then there is a normal subgroup $K$ of $G$ with $K \leq H$ and $|G: K| \leq n!$.

\begin{proof}

    Solution: $G$ acts on the cosets $G / H$ by left multiplication. Let $\lambda: G \rightarrow S_{G / H}$ be the permutation representation induced by this action, and let $K$ be the kernel of the representation.

Now $K$ is normal in $G$, and $K \leq \operatorname{stab}_G(H)=H$. By the First Isomorphism Theorem, we have an injective group homomorphism $\bar{\lambda}: G / K \rightarrow S_{G / H}$. Since $\left|S_{G / H}\right|=n !$, we have $[G: K] \leq n !$.

\end{proof}


theorem exercise_4_2_9a {G : Type*} [fintype G] [group G] {p α : ℕ}
  (hp : p.prime) (ha : α > 0) (hG : card G = p ^ α) :
  ∀ H : subgroup G, H.index = p → H.normal :=

Prove that if $p$ is a prime and $G$ is a group of order $p^{\alpha}$ for some $\alpha \in \mathbb{Z}^{+}$, then every subgroup of index $p$ is normal in $G$.

\begin{proof}

    Solution: Let $G$ be a group of order $p^k$ and $H \leq G$ a subgroup with $[G: H]=p$. Now $G$ acts on the conjugates $g H g^{-1}$ by conjugation, since

$$

g_1 g_2 \cdot H=\left(g_1 g_2\right) H\left(g_1 g_2\right)^{-1}=g_1\left(g_2 H g_2^{-1}\right) g_1^{-1}=g_1 \cdot\left(g_2 \cdot H\right)

$$

and $1 \cdot H=1 H 1=H$. Moreover, under this action we have $H \leq \operatorname{stab}(H)$. By Exercise 3.2.11, we have

$$

[G: \operatorname{stab}(H)][\operatorname{stab}(H): H]=[G: H]=p,

$$

a prime.

If $[G: \operatorname{stab}(H)]=p$, then $[\operatorname{stab}(H): H]=1$ and we have $H=\operatorname{stab}(H)$; moreover, $H$ has exactly $p$ conjugates in $G$. Let $\varphi: G \rightarrow S_p$ be the permutation representation induced by the action of $G$ on the conjugates of $H$, and let $K$ be the kernel of this representation. Now $K \leq \operatorname{stab}(H)=H$. By the first isomorphism theorem, the induced map $\bar{\varphi}: G / K \rightarrow S_p$ is injective, so that $|G / K|$ divides $p$ !. Note, however, that $|G / K|$ is a power of $p$ and that the only powers of $p$ that divide $p$ ! are 1 and $p$. So $[G: K]$ is 1 or $p$. If $[G: K]=1$, then $G=K$ so that $g H g^{-1}=H$ for all $g \in G$; then $\operatorname{stab}(H)=G$ and we have $[G: \operatorname{stab}(H)]=1$, a contradiction. Now suppose $[G: K]=p$. Again by Exercise $3.2$.11 we have $[G: K]=[G: H][H: K]$, so that $[H: K]=1$, hence $H=K$. Again, this implies that $H$ is normal so that $g H g^{-1}=H$ for all $g \in G$, and we have $[G: \operatorname{stab}(H)]=1$, a contradiction. Thus $[G: \operatorname{stab}(H)] \neq p$

If $[G: \operatorname{stab}(H)]=1$, then $G=\operatorname{stab}(H)$. That is, $g H g^{-1}=H$ for all $g \in G$; thus $H \leq G$ is normal.

\end{proof}


theorem exercise_4_4_2 {G : Type*} [fintype G] [group G]
  {p q : nat.primes} (hpq : p ≠ q) (hG : card G = p*q) :
  is_cyclic G :=

Prove that if $G$ is an abelian group of order $p q$, where $p$ and $q$ are distinct primes, then $G$ is cyclic.

\begin{proof}

    Let $G$ be an abelian group of order $p q$. We need to prove that if $p$ and $q$ are distinct primes than $G$ is cyclic. By Cauchy's theorem there are $a, b \in G$ with $a$ of order $p$ and $b$ of order $q$. Since $(|a|,|b|)=1$ and $a b=b a$ then $|a b|=|a| \cdot|b|=p q$. Therefore $a b$ is an element of order $p q$, the order of $G$, which means $G$ is cyclic.

\end{proof}


theorem exercise_4_4_6b {G : Type*} [group G] :
  ∃ H : subgroup G, H.characteristic ∧ ¬ H.normal :=

Prove that there exists a normal subgroup that is not characteristic.

\begin{proof}

    We have to produce a group $G$ and a subgroup $H$ such that $H$ is normal in $G$, but not characterestic. Consider the Klein's four group $G=\{ e, a, b, a b\}$. This is an abelian group with each element having order 2. Consider $H=\{ e, a\}$. $H$ is normal in $G$. Define $\sigma: G \rightarrow G$ as $\sigma(a)=b, \sigma(b)=a, \sigma(a b)=a b$. Clearly $\sigma$ does not fix $H$. So, $H$ is not characterestic.

\end{proof}


theorem exercise_4_4_8a {G : Type*} [group G] (H K : subgroup G)
  (hHK : H ≤ K) [hHK1 : (H.subgroup_of K).normal] [hK : K.normal] :
  H.normal :=

Let $G$ be a group with subgroups $H$ and $K$ with $H \leq K$. Prove that if $H$ is characteristic in $K$ and $K$ is normal in $G$ then $H$ is normal in $G$.

\begin{proof}

We prove that $H$ is invariant under every inner automorphism of $G$. Consider a inner automorphism $\phi_g$ of $G$. Now, $\left.\phi_g\right|_K$ is a automorphism of $K$ because $K$ is normal in $G$. But $H$ is a characterestic subgroup of $K$, so $\left.\phi_g\right|_K(H) \subset H$, so in general $\phi_g(H) \subset H$. Hence $H$ is characteretstic in $G$.

\end{proof}


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

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

\begin{proof}

Since $|G|=56=2^{3}.7$, $G$ has $2-$Sylow subgroup of order $8$, as well as $7-$Sylow subgroup of order $7$. Now, we count the number of such subgroups. Let $n_{7}$ be the number of  $7-$Sylow subgroup and $n_{2}$ be the number of  $2-$Sylow subgroup. Now $n_{7}=1+7k$ where $1+7k|8$. The choices for $k$ are $0$ or $1$. If $k=0$, there is only one $7-$Sylow subgroup and hence normal. So, assume now, that there are $8$ $7-$Sylow subgroup(for $k=1$). Now we look at $2-$ Sylow subgroups. $n_{2}=1+2k| 7$. So choice for $k$ are $0$ and $3$. If $k=0$, there is only one $2-$Sylow subgroup and hence normal. So, assume now, that there are $7$ $2-$Sylow subgroup (for $k=3$). Now we claim that simultaneously, there cannot be $8$ $7-$Sylow subgroup and $7$ $2-$Sylow subgroup. So, either $7-$Sylow subgroup is normal being unique, or  the $2-$Sylow subgroup is normal. Now, to prove the claim, we observe that there are 48 elements of order $7$. Let $H_{1}$ and $H_{2}$ be two distinct  $2-$Sylow subgroup. Now $|H_{1}|=8$. So we already get $48+8=56$ 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.

\end{proof}


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

Prove that a group of order 351 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_17 {G : Type*} [fintype G] [group G]
  (hG : card G = 105) :
  nonempty(sylow 5 G) ∧ nonempty(sylow 7 G) :=

Prove that if $|G|=105$ then $G$ has a normal Sylow 5 -subgroup and a normal Sylow 7-subgroup.

\begin{proof}

Since $|G|=105=3.5.7$, $G$ has $3-$Sylow subgroup of order $3$, as well as $5-$Sylow subgroup of order $5$ and, $7-$Sylow subgroup of order 7. Now, we count the number of such subgroups. Let $n_{3}$ be the number of $3-$Sylow subgroup, $n_{5}$ be the number of  $5-$Sylow subgroup, and $n_{7}$ be the number of $7-$Sylow subgroup. Now $n_{7}=1+7k$ where $1+7k|15$. The choices for $k$ are $0$ or $1$. If $k=0$, there is only one $7-$Sylow subgroup and hence normal. So, assume now, that there are $15$ $7-$Sylow subgroup(for $k=1$). Now we look at $5-$ Sylow subgroups. $n_{5}=1+5k| 21$. So choice for $k$ are $0$ and $4$. If $k=0$, there is only one $5-$Sylow subgroup and hence normal. So, assume now, that there are $24$ $5-$Sylow subgroup (for $k=4$). Now we claim that simultaneously, there cannot be $15$ $7-$Sylow subgroup and $24$ $5-$Sylow subgroup. So, either $7-$Sylow subgroup is normal being unique, or  the $5-$Sylow subgroup is normal. Now, to prove the claim, we observe that there are 90 elements of order $7$. Also, see that there are $24\times 4=96$ number of elements of order 5. So we get $90+94=184$ number of elements which exceeds the order of the group. This gives a contradiction and proves the claim. So, now we have proved that there is either a normal $5-$Sylow subgroup or a normal $7-$Sylow subgroup.

    Now we prove that indeed both $5-$ Sylow subgroup and 7 -Sylow subgroup are normal. Assume that 7 -Sylow subgroup is normal. So, there is a unique 7 -Sylow subgroup, say $H$. Now assume that there are 245 -Sylow subgroups. So, we get again $24 \times 4=96$ elements of order 5 . From $H$ we get 7 elements which gives us total of $96+7=103$ elements. Now consider the number of 3 -Sylow subgroups. $n_3=1+3 k \mid 35$. Then the possibilities for $k$ are 0 and 2 . But we can rule out $k=2$ because having 73 -Sylow subgroup, will mean we have 14 elements of order 3 . So we get $103+14=117$ elements in total which exceeds the order of the group. So we have now that there is a unique 3 -Sylow subgroup and hence normal. Call that subgroup $K$. Now take any one 5 -Sylow subgroup, call it $L$. Now observe $L K$ is a subgroup of $G$ with order 15 . We know that a group of order 15 is cyclic by an example in Page-143 of the book. So, there is an element of order 15. Actually we have $\phi(15)=8$ number of elements of order 15. But then again we already had 103 elements and then we actually get at least $103+8=111$ elements which exceeds the order of the group. So, there can't be 24 5-Sylow subgroups, and hence there is a unique 5-Sylow subgroup, and hence normal.

\end{proof}


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

Prove that if $|G|=6545$ 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_21 {G : Type*} [fintype G] [group G]
  (hG : card G = 2907) : ¬ is_simple_group G :=

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

    Let $G$ be a group of order $462=11 \cdot 42$. Note that 11 is a prime not dividing 42 . Let $P \in$ $S y l_{11}(G)$. [We know $P$ exists since $S y l_{11}(G) \neq \emptyset$]. Note that $|P|=11^1=11$ by definition.

The number of Sylow 11-subgroups of $G$ is of the form $1+k \cdot 11$, i.e., $n_{11} \equiv 1$ (mod 11) and $n_{11}$ divides 42 . The only such number that divides 42 and equals 1 (mod 11) is 1 so $n_{11}=1$. Hence $P$ is the unique Sylow 11-subgroup.

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

\end{proof}


theorem exercise_4_5_33 {G : Type*} [group G] [fintype G] {p : ℕ}
  (P : sylow p G) [hP : P.normal] (H : subgroup G) [fintype H] :
  ∀ R : sylow p H, R.to_subgroup = (H ⊓ P.to_subgroup).subgroup_of H ∧
  nonempty (sylow p H) :=

Let $P$ be a normal Sylow $p$-subgroup of $G$ and let $H$ be any subgroup of $G$. Prove that $P \cap H$ is the unique Sylow $p$-subgroup of $H$.

\begin{proof}

    Let $G$ be a group and $P$ is a normal $p$-Sylow subgroup of $G .|G|=p^a . m$ where $p \nmid m$. Then $|P|=p^a$. Let $H$ be a subgroup of $G$. Now if $|H|=k$ such that $p \nmid k$. Then $P \cap H=\{e\}$. There is nothing to prove in this case. Let $|H|=p^b . n$, where $b \leq a$, and $p \nmid n$. Now consider $P H$ which is a subgroup of $G$, as $P$ is normal. Now $|P H|=\frac{|P||H|}{|P \cap H|}=\frac{p^{a+b} \cdot n}{|P \cap H|}$. Now since $P H \leq G$, so $|P H|=p^a$.l, as $P \leq P H$. This forces $|P \cap H|=p^b$. So by order consideration we have $P \cap H$ is a sylow $-p$ subgroup of $H$. Now we know $P$ is unique $p$ - Sylow subgroup. Suppose $H$ has a sylow-p subgroup distinct from $P \cap H$, call it $H_1$. Now $H_1$ is a p-subgroup of $G$. So, $H_1$ is contained in some Sylow-p subgroup of $G$, call it $P_1$. Clearly $P_1$ is distinct from $P$, which is a contradiction. So $P \cap H$ is the only $p$-Sylow subgroup of $H$, and hence normal in $H$

\end{proof}


theorem exercise_7_1_2 {R : Type*} [ring R] {u : R}
  (hu : is_unit u) : is_unit (-u) :=

Prove that if $u$ is a unit in $R$ then so is $-u$.

\begin{proof}

    Solution: Since $u$ is a unit, we have $u v=v u=1$ for some $v \in R$. Thus, we have

$$

(-v)(-u)=v u=1

$$

and

$$

(-u)(-v)=u v=1 .

$$

Thus $-u$ is a unit.

\end{proof}


theorem exercise_7_1_12 {F : Type*} [field F] {K : subring F}
  (hK : (1 : F) ∈ K) : is_domain K :=

Prove that any subring of a field which contains the identity is an integral domain.

\begin{proof}

    Solution: Let $R \subseteq F$ be a subring of a field. (We need not yet assume that $1 \in R$ ). Suppose $x, y \in R$ with $x y=0$. Since $x, y \in F$ and the zero element in $R$ is the same as that in $F$, either $x=0$ or $y=0$. Thus $R$ has no zero divisors. If $R$ also contains 1 , then $R$ is an integral domain.

\end{proof}


theorem exercise_7_2_2 {R : Type*} [ring R] (p : polynomial R) :
  p ∣ 0 ↔ ∃ b : R, b ≠ 0 ∧ b • p = 0 :=

Let $p(x)=a_{n} x^{n}+a_{n-1} x^{n-1}+\cdots+a_{1} x+a_{0}$ be an element of the polynomial ring $R[x]$. Prove that $p(x)$ is a zero divisor in $R[x]$ if and only if there is a nonzero $b \in R$ such that $b p(x)=0$.

\begin{proof}

    Solution: If $b p(x)=0$ for some nonzero $b \in R$, then it is clear that $p(x)$ is a zero divisor.

Now suppose $p(x)$ is a zero divisor; that is, for some $q(x)=\sum_{i=0}^m b_i x^i$, we have $p(x) q(x)=0$. We may choose $q(x)$ to have minimal degree among the nonzero polynomials with this property.

We will now show by induction that $a_i q(x)=0$ for all $0 \leq i \leq n$.

For the base case, note that

$$

p(x) q(x)=\sum_{k=0}^{n+m}\left(\sum_{i+j=k} a_i b_j\right) x^k=0 .

$$

The coefficient of $x^{n+m}$ in this product is $a_n b_m$ on one hand, and 0 on the other. Thus $a_n b_m=0$. Now $a_n q(x) p(x)=0$, and the coefficient of $x^m$ in $q$ is $a_n b_m=0$. Thus the degree of $a_n q(x)$ is strictly less than that of $q(x)$; since $q(x)$ has minimal degree among the nonzero polynomials which multiply $p(x)$ to 0 , in fact $a_n q(x)=0$. More specifically, $a_n b_i=0$ for all $0 \leq i \leq m$.

For the inductive step, suppose that for some $0 \leq t<n$, we have $a_r q(x)=0$ for all $t<r \leq n$. Now

$$

p(x) q(x)=\sum_{k=0}^{n+m}\left(\sum_{i+j=k} a_i b_j\right) x^k=0 .

$$

On one hand, the coefficient of $x^{m+t}$ is $\sum_{i+j=m+t} a_i b_j$, and on the other hand, it is 0 . Thus

$$

\sum_{i+j=m+t} a_i b_j=0 .

$$

By the induction hypothesis, if $i \geq t$, then $a_i b_j=0$. Thus all terms such that $i \geq t$ are zero. If $i<t$, then we must have $j>m$, a contradiction. Thus we have $a_t b_m=0$. As in the base case,

$$

a_t q(x) p(x)=0

$$

and $a_t q(x)$ has degree strictly less than that of $q(x)$, so that by minimality, $a_t q(x)=0$.

By induction, $a_i q(x)=0$ for all $0 \leq i \leq n$. In particular, $a_i b_m=0$. Thus $b_m p(x)=0$.

\end{proof}


theorem exercise_7_3_16 {R S : Type*} [ring R] [ring S]
  {φ : R →+* S} (hf : surjective φ) :
  φ '' (center R) ⊂ center S :=

Let $\varphi: R \rightarrow S$ be a surjective homomorphism of rings. Prove that the image of the center of $R$ is contained in the center of $S$.

\begin{proof}

    Suppose $r \in \varphi[Z(R)]$. Then $r=\varphi(z)$ for some $z \in Z(R)$. Now let $x \in S$. Since $\varphi$ is surjective, we have $x=\varphi y$ for some $y \in R$. Now

$$

x r=\varphi(y) \varphi(z)=\varphi(y z)=\varphi(z y)=\varphi(z) \varphi(y)=r x .

$$

Thus $r \in Z(S)$.

\end{proof}


theorem exercise_7_4_27 {R : Type*} [comm_ring R] (hR : (0 : R) ≠ 1)
  {a : R} (ha : is_nilpotent a) (b : R) :
  is_unit (1-a*b) :=

Let $R$ be a commutative ring with $1 \neq 0$. Prove that if $a$ is a nilpotent element of $R$ then $1-a b$ is a unit for all $b \in R$.

\begin{proof}

    $\mathfrak{N}(R)$ is an ideal of $R$. Thus for all $b \in R,-a b$ is nilpotent. Hence $1-a b$ is a unit in $R$.

\end{proof}


theorem exercise_8_2_4 {R : Type*} [ring R][no_zero_divisors R]
  [cancel_comm_monoid_with_zero R] [gcd_monoid R]
  (h1 : ∀ a b : R, a ≠ 0 → b ≠ 0 → ∃ r s : R, gcd a b = r*a + s*b)
  (h2 : ∀ a : ℕ → R, (∀ i j : ℕ, i < j → a i ∣ a j) →
  ∃ N : ℕ, ∀ n ≥ N, ∃ u : R, is_unit u ∧ a n = u * a N) :
  is_principal_ideal_ring R :=

Let $R$ be an integral domain. Prove that if the following two conditions hold then $R$ is a Principal Ideal Domain: (i) any two nonzero elements $a$ and $b$ in $R$ have a greatest common divisor which can be written in the form $r a+s b$ for some $r, s \in R$, and (ii) if $a_{1}, a_{2}, a_{3}, \ldots$ are nonzero elements of $R$ such that $a_{i+1} \mid a_{i}$ for all $i$, then there is a positive integer $N$ such that $a_{n}$ is a unit times $a_{N}$ for all $n \geq N$.

\begin{proof}

    Let $I \leq R$ be a nonzero ideal and let $I / \sim$ be the set of equivalence classes of elements of $I$ with regards to the relation of being associates. We can equip $I / \sim$ with a partial order with $[x] \leq[y]$ if $y \mid x$. Condition (ii) implies all chains in $I / \sim$ have an upper bound, so By Zorn's lemma $I / \sim$ contains a maximal element, i.e. $I$ contains a class of associated elements which are minimal with respect to divisibility.

Now let $a, b \in I$ be two elements such that $[a]$ and $[b]$ are minimal with respect to divisibility. By condition (i) $a$ and $b$ have a greatest common divisor $d$ which can be expressed as $d=$ $a x+b y$ for some $x, y \in R$. In particular, $d \in I$. Since $a$ and $b$ are minimal with respect to divisibility, we have that $[a]=[b]=[d]$. Therefore $I$ has at least one element $a$ that is minimal with regard to divisibility and all such elements are associate, and we have $I=\langle a\rangle$ and so $I$ is principal. We conclude $R$ is a principal ideal domain.

\end{proof}


theorem exercise_8_3_5a {n : ℤ} (hn0 : n > 3) (hn1 : squarefree n) :
  irreducible (2 :zsqrtd $ -n) ∧
  irreducible (⟨0, 1⟩ : zsqrtd $ -n) ∧
  irreducible (1 + ⟨0, 1⟩ : zsqrtd $ -n) :=

Let $R=\mathbb{Z}[\sqrt{-n}]$ where $n$ is a squarefree integer greater than 3. Prove that $2, \sqrt{-n}$ and $1+\sqrt{-n}$ are irreducibles in $R$.

\begin{proof}

    Suppose $a=a_1+a_2 \sqrt{-n}, b=b_1+b_2 \sqrt{-n} \in R$ are such that $2=a b$, then $N(a) N(b)=4$. Without loss of generality we can assume $N(a) \leq N(b)$, so $N(a)=1$ or $N(a)=2$. Suppose $N(a)=2$, then $a_1^2+n a_2^2=2$ and since $n>3$ we have $a_2=0$, which implies $a_1^2=2$, a contradiction. So $N(a)=1$ and $a$ is a unit. Therefore 2 is irreducible in $R$.

Suppose now $\sqrt{-n}=a b$, then $N(a) N(b)=n$ and we can assume $N(a)<$ $N(b)$ since $n$ is square free. Suppose $N(a)>1$, then $a_1^2+n a_2^2>1$ and $a_1^2+n a_2^2 \mid n$, so $a_2=0$, and therefore $a_1^2 \mid n$. Since $n$ is squarefree, $a_1=\pm 1$, a contradiction. Therefore $N(a)=1$ and so $a$ is a unit and $\sqrt{-n}$ is irreducible.

Suppose $1+\sqrt{-n}=a b$, then $N(a) N(b)=n+1$ and we can assume $N(a) \leq N(b)$. Suppose $N(a)>1$, then $a_1^2+n a_2^2>1$ and $a_1^2+n a_2^2 \mid n+1$. If $\left|a_2\right| \geq 2$, then since $n>3$ we have a contradiction since $N(a)$ is too large. If $\left|a_2\right|=1$, then $a_1^2+n$ divides $1+n$ and so $a_1=\pm 1$, and in either case $N(a)=n+1$ which contradicts $N(a) \leq N(b)$. If $a_2=0$ then $a_1^2\left(b_1^2+n b_2^2\right)=\left(a_1 b_1\right)^2+n\left(a_1 b_2\right)^2=n+1$. If $\left|a_1 b_2\right| \geq 2$ we have a contradiction. If $\left|a_1 b_2\right|=1$ then $a_1=\pm 1$ which contradicts $N(a)>1$. If $\left|a_1 b_2\right|=0$, then $b_2=0$ and so $a_1 b_1=\sqrt{-n}$, a contradiction. Therefore $N(a)=1$ and so $a$ is a unit and $1+\sqrt{-n}$ is irreducible.

\end{proof}


theorem exercise_8_3_6b {q : ℕ} (hq0 : q.prime)
  (hq1 : q ≡ 3 [ZMOD 4]) {R : Type*} [ring R]
  (hR : R = (gaussian_int ⧸ ideal.span ({q} : set gaussian_int))) :
  is_field R ∧ ∃ finR : fintype R, @card R finR = q^2 :=

Let $q \in \mathbb{Z}$ be a prime with $q \equiv 3 \bmod 4$. Prove that the quotient ring $\mathbb{Z}[i] /(q)$ is a field with $q^{2}$ elements.

\begin{proof}

    The division algorithm gives us that every element of $\mathbb{Z}[i] /\langle q\rangle$ is represented by an element $a+b i$ such that $0 \leq a, b<q$. Each such choice is distinct since if $a_1+b_1 i+\langle q\rangle=a_2+b_2 i+\langle q\rangle$, then $\left(a_1-a_2\right)+\left(b_1-b_2\right) i$ is divisible by $q$, so $a_1 \equiv a_2 \bmod q$ and $b_1 \equiv b_2 \bmod q$. So $\mathbb{Z}[i] /\langle q\rangle$ has order $q^2$.

Since $q \equiv 3 \bmod 4, q$ is irreducible, hence prime in $\mathbb{Z}[i]$. Therefore $\langle q\rangle$ is a prime ideal in $\mathbb{Z}[i]$, and so $\mathbb{Z}[i] /\langle q\rangle$ is an integral domain. So $\mathbb{Z}[i] /\langle q\rangle$ is a field.

\end{proof}


theorem exercise_9_1_10 {f : ℕ → mv_polynomial ℕ ℤ}
  (hf : f = λ i, X i * X (i+1)):
  infinite (minimal_primes (mv_polynomial ℕ ℤ ⧸ ideal.span (range f))) :=

Prove that the ring $\mathbb{Z}\left[x_{1}, x_{2}, x_{3}, \ldots\right] /\left(x_{1} x_{2}, x_{3} x_{4}, x_{5} x_{6}, \ldots\right)$ contains infinitely many minimal prime ideals.

\begin{proof}

    Let $R=\mathbb{Z}\left[x_1, x_2, \ldots, x_n\right]$ and consider the ideal $K=\left(x_{2 k+1} x_{2 k+2} \mid k \in \mathbb{Z}_{+}\right)$in $R$.

Consider the family of subsets $X=\left\{\left\{x_{2 k+1}, x_{2 k+2}\right\} \mid k \in \mathbb{Z}_{+}\right\}$, and $Y$ the set of choice function on $X$, ie the set of functions $\lambda: \mathbb{Z}_{+} \rightarrow \cup_{\mathbb{Z}_{+}}\left\{x_{2 k+1}, x_{2 k+2}\right\}$ with $\lambda(a) \in$ $\left\{x_{2 a+1}, x_{2 a+2}\right\}$

For each $\lambda \in Y$ we have the ideal $I_\lambda=(\lambda(0), \lambda(1), \ldots)$.

All these ideals are distinct, ie for $\lambda \neq \lambda^{\prime}$ we have $I_\lambda \neq I_{\lambda^{\prime}}$.

We also have that by construction $K \subset I_\lambda$ for all $\lambda \in Y$.

By the Third Isomorphism Treorem

$$

(R / K) /\left(I_\lambda / K\right) \cong R / I_\lambda

$$

Note also that $R / I_\lambda$ is isomorphic to the polynomial ring over $R$ with indeterminates the $x_i$ not in the image of $\lambda$, and since there is a countably infinite number of them we can conclude $R / I_\lambda \cong R$, an integral domain. Therefore $I_\lambda / K$ is a prime ideal of $R / K$

We prove now that $I_\lambda / K$ is a minimal prime ideal. Let $J / K \subseteq I_\lambda / K$ be a prime ideal. For each pair $\left(x_{2 k+1}, x_{2 k+2}\right)$ we have that $x_{2 k+1} x_{2 k+2} \in K$ so $x_{2 k+1} x_{2 k+2} \bmod K \in J / K$ so $J$ must contain one of the elements in $\left\{x_{2 k+1}, x_{2 k+2}\right\}$. But since $J / K \subseteq I_\lambda / K$ it must be $\lambda(k)$ for all $k \in \mathbb{Z}_{+}$. Therefore $J / K=I_\lambda / K$

\end{proof}


theorem exercise_9_4_2a : irreducible (X^4 - 4*X^3 + 6 : polynomial ℤ) :=

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

\begin{proof}

$$

x^4-4 x^3+6

$$

The polynomial is irreducible by Eisenstiens Criterion since the prime $2$ doesnt divide the leading coefficient 2 divide coefficients of the low order term $-4,0,0$ but 6 is not divided by the square of 2.

\end{proof}


theorem exercise_9_4_2c : irreducible
  (X^4 + 4*X^3 + 6*X^2 + 2*X + 1 : polynomial ℤ) :=

Prove that $x^4+4x^3+6x^2+2x+1$ is irreducible in $\mathbb{Z}[x]$.

\begin{proof}

$$

p(x)=x^4+6 x^3+4 x^2+2 x+1

$$

We calculate $p(x-1)$

$$

\begin{aligned}

(x-1)^4 & =x^4-4 x^3+6 x^2-4 x+1 \\

6(x-1)^3 & =6 x^3-18 x^2+18 x-6 \\

4(x-1)^2 & =4 x^2-8 x+4 \\

2(x-1) & =2 x-2 \\

1 & =1

\end{aligned}

$$

$$

\begin{aligned}

& p(x-1)=(x-1)^4+6(x-1)^3+4(x-1)^2+2(x-1)+1=x^4+2 x^3-8 x^2+ \\

& 8 x-2 \\

& q(x)=x^4+2 x^3-8 x^2+8 x-2

\end{aligned}

$$

$q(x)$ is irreducible by Eisenstiens Criterion since the prime $\$ 2 \$$ divides the lower coefficient but $\$ 2^{\wedge} 2 \$$ doesnt divide constant $-2$. Any factorization of $p(x)$ would provide a factor of $p(x)(x-1)$

Since:

$$

\begin{aligned}

& p(x)=a(x) b(x) \\

& q(x)=p(x)(x-1)=a(x-1) b(x-1)

\end{aligned}

$$

We get a contradiction with the irreducibility of $p(x-1)$, so $p(x)$ is irreducible in $Z[x]$

\end{proof}


theorem exercise_9_4_9 :
  irreducible (X^2 - C sqrtd : polynomial (zsqrtd 2)) :=

Prove that the polynomial $x^{2}-\sqrt{2}$ is irreducible over $\mathbb{Z}[\sqrt{2}]$. You may assume that $\mathbb{Z}[\sqrt{2}]$ is a U.F.D.

\begin{proof}

$Z[\sqrt{2}]$ is an Euclidean domain, and so a unique factorization domain.

We have to prove $p(x)=x^2-\sqrt{2}$ irreducible.

Suppose to the contrary.

if $p(x)$ is reducible then it must have root.

Let $a+b \sqrt{2}$ be a root of $x^2-\sqrt{2}$.

Now we have

$$

a^2+2 b^2+2 a b \sqrt{2}=\sqrt{2}

$$

By comparing the coefficients we get $2 a b=1$ for some pair of integers $a$ and $b$, a contradiction.

So $p(x)$ is irredicible over $Z[\sqrt{2}]$.

\end{proof}


theorem exercise_11_1_13 {ι : Type*} [fintype ι] :
  (ι → ℝ) ≃ₗ[ℚ] ℝ :=

Prove that as vector spaces over $\mathbb{Q}, \mathbb{R}^n \cong \mathbb{R}$, for all $n \in \mathbb{Z}^{+}$.

\begin{proof}

Since $B$ is a basis of $V$, every element of $V$ can be written uniquely as a finite linear combination of elements of $B$. Let $X$ be the set of all such finite linear combinations. Then $X$ has the same cardinality as $V$, since the map from $X$ to $V$ that takes each linear combination to the corresponding element of $V$ is a bijection.

We will show that $X$ has the same cardinality as $B$. Since $B$ is countable and $X$ is a union of countable sets, it suffices to show that each set $X_n$, consisting of all finite linear combinations of $n$ elements of $B$, is countable.

Let $P_n(X)$ be the set of all subsets of $X$ with cardinality $n$. Then we have $X_n \subseteq P_n(B)$. Since $B$ is countable, we have $\mathrm{card}(P_n(B)) \leq \mathrm{card}(B^n) = \mathrm{card}(B)$, where $B^n$ is the Cartesian product of $n$ copies of $B$.

Thus, we have $\mathrm{card}(X_n) \leq \mathrm{card}(P_n(B)) \leq \mathrm{card}(B)$, so $X_n$ is countable. It follows that $X$ is countable, and hence has the same cardinality as $B$.

Therefore, we have shown that the cardinality of $V$ is equal to the cardinality of $B$. Since $F$ is countable, it follows that the cardinality of $V$ is countable as well.

Now let $Q$ be a countable field, and let $R$ be a vector space over $Q$. Let $n$ be a positive integer. Then any basis of $R^n$ over $Q$ has the same cardinality as $R^n$, which is countable. Since $R$ is a direct sum of $n$ copies of $R^n$, it follows that any basis of $R$ over $Q$ has the same cardinality as $R$. Hence, the cardinality of $R$ is countable.

Finally, since $R$ is a countable vector space and $Q$ is a countable field, it follows that $R$ and $Q^{\oplus \mathrm{card}(R)}$ are isomorphic as additive abelian groups. Therefore, we have $R \cong_Q Q^{\oplus \mathrm{card}(R)}$, and in particular $R \cong_Q R^n$ for any positive integer $n$.

\end{proof}


theorem exercise_1_13b {f : ℂ → ℂ} (Ω : set ℂ) (a b : Ω) (h : is_open Ω)
  (hf : differentiable_on ℂ f Ω) (hc : ∃ (c : ℝ), ∀ z ∈ Ω, (f z).im = 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{Im}(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{Im}(f)=$ constant,

$$

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

$$

By the Cauchy-Riemann equations,

$$

\frac{\partial u}{\partial x}=\frac{\partial v}{\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 .

$$

Thus $f$ is constant.

\end{proof}


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

Prove that the power series $\sum nz^n$ does not converge on any point of the unit circle.

\begin{proof}

    For $z \in S:=\{z \in \mathbb{C}:|z|=1\}$ it also holds $z^n \in S$ for all $n \in \mathbb{N}$ (since in this case $\left.\left|z^n\right|=|z|^n=1^n=1\right)$

Thus, the sequence $\left(a_n\right)_{n \in \mathbb{N}}$ with $a_n=n z^n$ does not converge to zero which is necessary for the corresponding sum $\sum_{n \in \mathbb{N}} a_n$ to be convergent. Hence this sum does not converge.

\end{proof}


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

Prove that the power series $\sum zn/n$ converges at every point of the unit circle except $z = 1$.

\begin{proof}

    If $z=1$ then $\sum z^n / n=\sum 1 / n$ is divergent (harmonic series). If $|z|=1$ and $z \neq 1$, write $z=e^{2 \pi i t}$ with $t \in(0,1)$ and apply Dirichlet's test: if $\left\{a_n\right\}$ is a sequence of real numbers and $\left\{b_n\right\}$ a sequence of complex numbers satisfying

- $a_{n+1} \leq a_n$

- $\lim _{n \rightarrow \infty} a_n=0$

- $\left|\sum_{n=1}^N b_n\right| \leq M$ for every positive integer $N$ and some $M>0$,

then $\sum a_n b_n$ converges. Let $a_n=1 / n$, so $a_n$ satisfies $a_{n+1} \leq a_n$ and $\lim _{n \rightarrow \infty} a_n=0$. Let $b_n=e^{2 \pi i n t}$, then

$$

\left|\sum_{n=1}^N b_n\right|=\left|\sum_{n=1}^N e^{2 \pi i n t}\right|=\left|\frac{e^{2 \pi i t}-e^{2 \pi i(N+1) t}}{1-e^{2 \pi i t}}\right| \leq \frac{2}{\left|1-e^{2 \pi i t}\right|}=M \text { for all } N

$$

Thus $\sum a_n b_n=\sum z^n / n$ converges for every point in the unit circle except $z=1$.

\end{proof}


theorem exercise_2_2 :
  tendsto (λ y, ∫ x in 0..y, real.sin x / x) at_top (𝓝 (real.pi / 2)) :=

Show that $\int_{0}^{\infty} \frac{\sin x}{x} d x=\frac{\pi}{2}$.

\begin{proof}

    We have $\int_0^{\infty} \frac{\sin x}{x} d x=\frac{1}{2 * i} \int_0^{\infty} \frac{e^{i * x}-e^{-i * x}}{x} d x=\frac{1}{2 * i}\left(\int_0^{\infty} \frac{e^{i * x}-1}{x} d x-\int_0^{\infty} \frac{e^{-i * x}-1}{x} d x=\right.$ $\frac{1}{2 * i} \int_{-\infty}^{\infty} \frac{e^{i * x}-1}{x} d x$. Now integrate along the big and small semicircles $C_0$ and $C_1$ shown below. For $C_0$ : we have that $\int_{C_0} \frac{1}{x} d x=\pi * i$ and $\left|\int_{C_0} \frac{e^{i * x}}{x} d x\right| \leq$ $2 *\left|\int_{C_{00}} \frac{e^{i * x}}{x} d x\right|+\left|\int_{C_{01}} \frac{e^{i * x}}{x} d x\right|$ where $C_{00}$ and $C_{01}$ are shown below $\left(C_{01}\right.$ contains the part of $C_0$ that has points with imaginary parts more than $a$ and $C_{00}$ is one of the other 2 components). We have $\left|\int_{C_{00}} \frac{e^{i * x}}{x} d x\right| \leq$ $\sup _{x \in C_{00}}\left(e^{i * x}\right) / R * \int_{C_{00}}|d x| \leq e^{-a} * \pi$ and $\left|\int_{C_{01}} \frac{e^{i * x}}{x} d x\right| \leq\left|\int_{C_{01}} \frac{1}{x} d x\right| \leq$ $\frac{1}{R} * C * a$ for some constant $C$ (the constant $C$ exists because the length of the curve approaches $a$ as $a / R \rightarrow 0)$. Thus, the integral of $e^{i * x} / x$ over $C_0$ is bounded by $A * e^{-a}+B * a / R$ for some constants $A$ and $B$. Pick $R$ large and $a=\sqrt{R}$ and note that the above tends to 0 . About the integral over $C_1$ : We have $e^{i * x}-1=1+O(x)$ for $x \rightarrow 0$ (this is again from $\sin (x) / x \rightarrow 1$ ),

4

so $\left|\int_{C_1} \frac{e^{i * x}-1}{x} d x\right| \leq O(1) *\left|\int_{C_1} d x\right| \rightarrow 0$ as $x \rightarrow 0$. Thus, we only care about the integral over $C_{00}$ which is $-\pi * i$. Using Cauchy's theorem we get that our integral equals $\frac{1}{2 * i}(-(\pi * i))=\pi / 2$.

\end{proof}


theorem exercise_2_13 {f : ℂ → ℂ}
    (hf : ∀ z₀ : ℂ, ∃ (s : set ℂ) (c : ℕ → ℂ), is_open s ∧ z₀ ∈ s ∧
      ∀ z ∈ s, tendsto (λ n, ∑ i in finset.range n, (c i) * (z - z₀)^i) at_top (𝓝 (f z₀))
      ∧ ∃ i, c i = 0) :
    ∃ (c : ℕ → ℂ) (n : ℕ), f = λ z, ∑ i in finset.range n, (c i) * z ^ n :=

Suppose $f$ is an analytic function defined everywhere in $\mathbb{C}$ and such that for each $z_0 \in \mathbb{C}$ at least one coefficient in the expansion $f(z) = \sum_{n=0}^\infty c_n(z - z_0)^n$ is equal to 0. Prove that $f$ is a polynomial.

\begin{proof}

Say that at least one of the coefficients of the Taylor series vanishes is the same as saying that for every $a \in \mathbb{C}$ there is $m \in \mathbb{N}$ such that $f^{(m)}(a)=0$.

Consider $A_n:=\left\{z \in \mathbb{C}: f^{(n)}(z)=0\right\}$ for each $n \in \mathbb{N}$. Note that:

$f$ is polynomial iff $A_n$ is not countable for some $n \in \mathbb{N}$.

Indeed, if $f$ is polynomial of degree $n$, then $f^{(n+1)}(z)=0$ for all $z \in \mathbb{C}$, then $A_{n+1}=\mathbb{C}$, so, $A_{n+1}$ is not countable. Conversely, if there is $n \in \mathbb{C}$ such that $A_n$ is not countable, then $A_n$ has a limit point, then by Identity principle we have $f^{(n)}(z)=0$ for all $z \in \mathbb{C}$, so, $f$ is a polynomial of degree at most $n-1$.

Therefore, tt suffices to show that there is $n \in \mathbb{N}$ such that $A_n$ is not countable. Indeed, consider $\bigcup_{n \in \mathbb{N}} A_n$, by hypothesis for each $a \in \mathbb{C}$ there is $m \in \mathbb{N}$ such that $f^{(m)}(a)=0$, then $\mathbb{C} \subseteq \bigcup_{n \in \mathbb{N}} A_n$. Therefore, $\bigcup_{n \in \mathbb{N}} A_n$ is not countable, then there is $n \in \mathbb{N}$ such that $A_n$ is not countable.

\end{proof}


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

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


theorem exercise_3_14 {f : ℂ → ℂ} (hf : differentiable ℂ f)
    (hf_inj : function.injective f) :
    ∃ (a b : ℂ), f = (λ z, a * z + b) ∧ a ≠ 0 :=

Prove that all entire functions that are also injective take the form $f(z) = az + b$, $a, b \in \mathbb{C}$ and $a \neq 0$.

\begin{proof}

Look at $f(1 / z)$. If it has an essential singularity at 0 , then pick any $z_0 \neq 0$. Now we know that the range of $f$ is dense as $z \rightarrow 0$. We also know that the image of $f$ in some small ball around $z_0$ contains a ball around $f\left(z_0\right)$. But this means that the image of $f$ around this ball intersects the image of $f$ in any arbitrarily small ball around 0 (because of the denseness). Thus, $f$ cannot be injective. So the singularity at 0 is not essential, so $f(1 / z)$ is some polynomial of $1 / z$, so $f$ is some polynomial of $z$. If its degree is more than 1 it is not injective (fundamental theorem of algebra), so the degree of $f$ is 1 .

\end{proof}


theorem exercise_5_1 (f : ℂ → ℂ) (hf : differentiable_on ℂ f (ball 0 1))
  (hb : bounded (set.range f)) (h0 : f ≠ 0) (zeros : ℕ → ℂ) (hz : ∀ n, f (zeros n) = 0)
  (hzz : set.range zeros = {z | f z = 0 ∧ z ∈ (ball (0 : ℂ) 1)}) :
  ∃ (z : ℂ), tendsto (λ n, (∑ i in finset.range n, (1 - zeros i))) at_top (𝓝 z) :=

Prove that if $f$ is holomorphic in the unit disc, bounded and not identically zero, and $z_{1}, z_{2}, \ldots, z_{n}, \ldots$ are its zeros $\left(\left|z_{k}\right|<1\right)$, then $\sum_{n}\left(1-\left|z_{n}\right|\right)<\infty$.

\begin{proof}

    Fix $\mathrm{N}$ and let $D(0, R)$ contains the first $\mathrm{N}$ zeroes of f. Let $S_N=\sum_{k=1}^N\left(1-\left|z_k\right|\right)=$ $\sum_{k=1}^N \int_{\left|z_k\right|}^1 1 d r$. Let $\eta_k$ be the characteristic function of the interval $\left.\| z_k \mid, 1\right]$. We have $S_N=\sum_{k=1}^N \int_0^1 \eta(r) d r=\int_0^1\left(\sum_{k=1}^N \eta_k(r)\right) d r \leq \int_0^1 n(r) d r$, where $n(r)$ is the number of zeroes of $f$ at the disk $D(0, r)$. For $r \leq 1$ we have $n(r) \leq \frac{n(r)}{r}$. This means that $S_N \leq \int_0^1 n(r) \frac{d r}{r}$. If $f(0)=0$ then we have $f(z)=z^m g(z)$ for some integer $\mathrm{m}$ and some holomorphic $g$ with $g(0) \neq 0$. The other zeroes of $\mathrm{f}$ are precisely the zeroes of $g$. Thus we have reduced the problem to $f(0) \neq 0$. By the Corollary of the Jensen's equality we get $S_N \leq \int_0^1 n(r) \frac{d r}{r}=\frac{1}{2 \pi} \int_0^{2 \pi} \log \left|f\left(R e^{i \pi}\right)\right| d \phi-\log |f(0)|<M$ since $f$ is bounded. The partial sums of the series are boundend and therefore the series converges.

\end{proof}


theorem exercise_13_3b : ¬ ∀ X : Type, ∀s : set (set X),
  (∀ t : set X, t ∈ s → (set.infinite tᶜ ∨ t = ∅ ∨ t = ⊤)) →
  (set.infinite (⋃₀ s)ᶜ ∨ (⋃₀ s) = ∅ ∨ (⋃₀ s) = ⊤) :=

import .common

open set topological_space filter
open_locale classical topology filter
noncomputable theory

Show that the collection $$\mathcal{T}_\infty = \{U | X - U \text{ is infinite or empty or all of X}\}$$ does not need to be a topology on the set $X$.

\begin{proof}

    Let $X=\mathbb{R}, U_1=(-\infty, 0)$ and $U_2=(0, \infty)$. Then $U_1$ and $U_2$ are in $\mathcal{T}_{\infty}$ but $U_1 \cup U_2=\mathbb{R} \backslash\{0\}$ is not.

\end{proof}


theorem exercise_13_4a2 :
  ∃ (X I : Type*) (T : I → set (set X)),
  (∀ 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 $\bigcup \mathcal{T}_\alpha$ does not need to be a topology on $X$.

\begin{proof}

    On the other hand, the union $\bigcup_\alpha \mathcal{T}_\alpha$ is in general not a topology on $X$. For instance, let $X=\{a, b, c\}$. Then $\mathcal{T}_1=\{\emptyset, X,\{a\}\}$ and $\mathcal{T}_2=\{\emptyset, X,\{b\}\}$ are topologies on $X$ but $\mathcal{T}_1 \cup \mathcal{T}_2=$ $\{\emptyset, X,\{a\},\{b\}\}$ is not.

\end{proof}


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

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

\begin{proof}

    Now we prove that there exists a unique largest topology contained in all $\mathcal{T}_\alpha$. Uniqueness of such topology is clear. Consider $\mathcal{T}=\bigcap_\alpha \mathcal{T}_\alpha$. We already know that $\mathcal{T}$ is a topology by, and clearly $\mathcal{T} \subset \mathcal{T}_\alpha$ for all $\alpha$. If $\mathcal{O}$ is another topology contained in all $\mathcal{T}_\alpha$, it must be contained in their intersection, so $\mathcal{O} \subset \mathcal{T}$. I follows that $\mathcal{T}$ is the unique largest topology contained in all $\mathcal{T}_\alpha$.

\end{proof}


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

Show that if $\mathcal{A}$ is a subbasis 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}

    If we now considered $\mathcal{A}$ as a subbasis, then the elements of $\mathcal{T}$ are union of finite intersections of elements of $\mathcal{A}$. The inclusion $\mathcal{O} \subset \mathcal{T}$ is again clear and $\mathcal{T} \subset \mathcal{O}$ holds since every union of finite intersections of elements of $\mathcal{A}$ belongs to $\mathcal{O}$.

\end{proof}


theorem exercise_13_8a :
  topological_space.is_topological_basis {S : set ℝ | ∃ a b : ℚ, a < b ∧ S = Ioo a b} :=

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

\begin{proof}

    Exercise 13.8. (a) First note that $\mathcal{B}$ is a basis for a topology on $\mathbb{R}$. This follows from the fact that the union of its elements is all of $\mathbb{R}$ and the intersection of two elements of $\mathcal{B}$ is either empty or another element of $\mathcal{B}$. Let $\mathcal{T}$ be the standard topology on $\mathbb{R}$. Clearly the topology generated by $\mathcal{B}$ is coarser than $\mathcal{T}$. Let $U \in \mathcal{T}$ and $x \in U$. Then $U$ contains an open interval with centre $x$. Since the rationals are dense in $\mathbb{R}$ with the standard topology, there exists $q \in \mathbb{Q}$ such that $x \in(x-q, x+q) \subset U$. This proves that $\mathcal{T}$ is coarser than the topology generated by $\mathcal{B}$. We conclude that $\mathcal{B}$ generates the standard topology on $\mathbb{R}$.

\end{proof}


theorem exercise_16_1 {X : Type*} [topological_space X]
  (Y : set X)
  (A : set Y) :
  ∀ U : set A, is_open U ↔ is_open (subtype.val '' U) :=

Show that if $Y$ is a subspace of $X$, and $A$ is a subset of $Y$, then the topology $A$ inherits as a subspace of $Y$ is the same as the topology it inherits as a subspace of $X$.

\begin{proof}

    Exercise 16.1. Let $\mathcal{T}$ be the topology $A$ inherits as a subspace of $Y$, and $\mathcal{O}$ be the topology it inherits as a subspace of $X$. A (standard) basis element for $\mathcal{T}$ has the form $U \cap A$ where $U$ is open in $Y$, so is of the form $(Y \cap V) \cap A=V \cap A$ where $V$ is open in $X$. Therefore every basis element for $\mathcal{T}$ is also a basis element for $\mathcal{O}$. Conversely, a (standard) basis element for $\mathcal{O}$ have the form $W \cap A=W \cap Y \cap A$ where $W$ is open in $X$. Since $W \cap Y$ is open in $Y$, this is a basis element for $\mathcal{T}$, so every basis element for $\mathcal{O}$ is a basis element for $\mathcal{T}$. It follows that $\mathcal{T}=\mathcal{O}$.

\end{proof}


theorem exercise_16_6
  (S : set (set (ℝ × ℝ)))
  (hS : ∀ s, s ∈ S → ∃ a b c d, (rational a ∧ rational b ∧ rational c ∧ rational d
  ∧ s = {x | ∃ x₁ x₂, x = (x₁, x₂) ∧ a < x₁ ∧ x₁ < b ∧ c < x₂ ∧ x₂ < d})) :
  is_topological_basis S :=

Show that the countable collection \[\{(a, b) \times (c, d) \mid a < b \text{ and } c < d, \text{ and } a, b, c, d \text{ are rational}\}\] is a basis for $\mathbb{R}^2$.

\begin{proof}

    We know that $\mathcal{B}=\{(a,b)|a<b, a \text{ and } b \text rational\}$ is a basis for $\mathcal{R}$, therefore the set we are concerned with in the above question is a basis for $\mathcal{R}^2$.

\end{proof}


theorem exercise_18_8a {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) :
  is_closed {x | f x ≤ g x} :=

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

\begin{proof}

    We prove that $U=\{x \mid g(x)<f(x)\}$ is open in $X$. Let $a \in U$, so that $g(a)<f(a)$. If there is an element $c$ between $g(a)$ and $f(a)$, then $a \in g^{-1}((-\infty, c)) \cap f^{-1}((c,+\infty))$. If there are no elements between $g(a)$ and $f(a)$, then $a \in g^{-1}\left((-\infty, f(a)) \cap f^{-1}((g(a),+\infty))\right.$. Note that all these preimages are open since $f$ and $g$ are continuous. Thus $U=V \cup W$, where

$$

V=\bigcup_{c \in X} g^{-1}((-\infty, c)) \cap f^{-1}((c,+\infty)) \quad \text { and } \quad W=\bigcup_{\substack{g(a)<f(a) \\(g(a), f(a))=\emptyset}} g^{-1}\left((-\infty, f(a)) \cap f^{-1}((g(a),+\infty))\right.

$$

are open in $X$. So $U$ is open in $X$ and therefore $X \backslash U=\{x \mid f(x) \leq g(x)\}$ is closed in $X$.

\end{proof}


theorem exercise_18_13
  {X : Type*} [topological_space X] {Y : Type*} [topological_space Y]
  [t2_space Y] {A : set X} {f : A → Y} (hf : continuous f)
  (g : closure A → Y)
  (g_con : continuous g) :
  ∀ (g' : closure A → Y), continuous g' →  (∀ (x : closure A), g x = g' x) :=

Let $A \subset X$; let $f: A \rightarrow Y$ be continuous; let $Y$ be Hausdorff. Show that if $f$ may be extended to a continuous function $g: \bar{A} \rightarrow Y$, then $g$ is uniquely determined by $f$.

\begin{proof}

    Let $h, g: \bar{A} \rightarrow Y$ be continuous extensions of $f$. Suppose that there is a point $x \in \bar{A}$ such that $h(x) \neq g(x)$. Since $h=g$ on $A$, we must have $x \in A^{\prime}$. Since $Y$ is Hausdorff, there is a neighbourhood $U$ of $h(x)$ and a neighbourhood $V$ of $g(x)$ such that $U \cap V=\emptyset$. Since $h$ and $g$ are continuous, $h^{-1}(U) \cap g^{-1}(V)$ is a neighbourhood of $x$. Since $x \in A^{\prime}$, there is a point $y \in h^{-1}(U) \cap g^{-1}(V) \cap A$ different from $x$. But $h=g$ on $A$, so $g^{-1}(V) \cap A=h^{-1}(V) \cap A$ and hence $y \in h^{-1}(U) \cap h^{-1}(V)=h^{-1}(U \cap V)=\emptyset$, a contradiction. It follows that $h=g$ on $\bar{A}$.

\end{proof}


theorem exercise_20_2
  [topological_space (ℝ ×ₗ ℝ)] [order_topology (ℝ ×ₗ ℝ)]
  : metrizable_space (ℝ ×ₗ ℝ) :=

Show that $\mathbb{R} \times \mathbb{R}$ in the dictionary order topology is metrizable.

\begin{proof}

    The dictionary order topology on $\mathbb{R} \times \mathbb{R}$ is the same as the product topology $\mathbb{R}_d \times \mathbb{R}$, where $\mathbb{R}_d$ denotes $\mathbb{R}$ with the discrete topology. We know that $\mathbb{R}_d$ and $\mathbb{R}$ are metrisable. Thus, it suffices to show that the product of two metrisable spaces is metrisable.

So let $X$ and $Y$ be metrisable spaces, with metrics $d$ and $d^{\prime}$ respectively. On $X \times Y$, define

$$

\rho(x \times y, w \times z)=\max \left\{d(x, w), d^{\prime}(y, z)\right\} .

$$

Then $\rho$ is a metric on $X \times Y$; it remains to prove that it induces the product topology on $X \times Y$. If $B_d\left(x, r_1\right) \times B_d\left(y, r_2\right)$ is a basis element for the product space $X \times Y$, and $r=\min \left\{r_1, r_2\right\}$, then $x \times y \in B_\rho(x \times y, r) \subset B_d\left(x, r_1\right) \times B_d\left(y, r_2\right)$, so the product topology is coarser than the $\rho$-topology. Conversely, if $B_\rho(x \times y, \delta)$ is a basis element for the $\rho$-topology, then $x \times y \in B_d(x, \delta) \times B_{d^{\prime}}(y, \delta) \subset$ $B_\rho(x \times y, \delta)$, so the product topology is finer than the $\rho$-topology. It follows that both topologies are equal, so the product space $X \times Y$ is metrisable.

\end{proof}


theorem exercise_21_6b
  (f : ℕ → I → ℝ )
  (h : ∀ x n, f n x = x ^ n) :
  ¬ ∃ f₀, tendsto_uniformly f f₀ at_top :=

Define $f_{n}:[0,1] \rightarrow \mathbb{R}$ by the equation $f_{n}(x)=x^{n}$. Show that the sequence $\left(f_{n}\right)$ does not converge uniformly.

\begin{proof}

    The sequence $\left(f_n\right)_n$ does not converge uniformly, since given $0<\varepsilon<1$ and $N \in \mathbb{Z}_{+}$, for $x=\varepsilon^{1 / N}$ we have $d\left(f_N(x), f(x)\right)=\varepsilon$. We can also apply Theorem 21.6: the convergence is not uniform since $f$ is not continuous.

\end{proof}


theorem exercise_22_2a {X Y : Type*} [topological_space X]
  [topological_space Y] (p : X → Y) (h : continuous p) :
  quotient_map p ↔ ∃ (f : Y → X), continuous f ∧ p ∘ f = id :=

Let $p: X \rightarrow Y$ be a continuous map. Show that if there is a continuous map $f: Y \rightarrow X$ such that $p \circ f$ equals the identity map of $Y$, then $p$ is a quotient map.

\begin{proof}

Let $1_Y: Y \rightarrow Y$ be the identity map in $Y$. If $U$ is a subset of $Y$ and $p^{-1}(U)$ is open in $X$, then $f^{-1}\left(p^{-1}(U)\right)=1_Y^{-1}(U)=U$ is open in $Y$ by continuity of $f$. Thus $p$ is a quotient map.

\end{proof}


theorem exercise_22_5 {X Y : Type*} [topological_space X]
  [topological_space Y] (p : X → Y) (hp : is_open_map p)
  (A : set X) (hA : is_open A) : is_open_map (p ∘ subtype.val : A → Y) :=

Let $p \colon X \rightarrow Y$ be an open map. Show that if $A$ is open in $X$, then the map $q \colon A \rightarrow p(A)$ obtained by restricting $p$ is an open map.

\begin{proof}

Let $U$ be open in $A$. Since $A$ is open in $X, U$ is open in $X$ as well, so $p(U)$ is open in $Y$. Since $q(U)=p(U)=p(U) \cap p(A)$, the set $q(U)$ is open in $p(A)$. Thus $q$ is an open map.

\end{proof}


theorem exercise_23_3 {X : Type*} [topological_space X]
  [topological_space X] {A : ℕ → set X}
  (hAn : ∀ n, is_connected (A n))
  (A₀ : set X)
  (hA : is_connected A₀)
  (h : ∀ n, A₀ ∩ A n ≠ ∅) :
  is_connected (A₀ ∪ (⋃ n, A n)) :=

Let $\left\{A_{\alpha}\right\}$ be a collection of connected subspaces of $X$; let $A$ be a connected subset of $X$. Show that if $A \cap A_{\alpha} \neq \varnothing$ for all $\alpha$, then $A \cup\left(\bigcup A_{\alpha}\right)$ is connected.

\begin{proof}

    For each $\alpha$ we have $A \cap A_\alpha \neq \emptyset$, so each $A \cup A_\alpha$ is connected by Theorem 23.3. In turn $\left\{A \cup A_\alpha\right\}_\alpha$ is a collection of connected spaces that have a point in common (namely any point in $A)$, so $\bigcup_\alpha\left(A \cup A_\alpha\right)=A \cup\left(\bigcup_\alpha A_\alpha\right)$ is connected.

\end{proof}


theorem exercise_23_6 {X : Type*}
  [topological_space X] {A C : set X} (hc : is_connected C)
  (hCA : C ∩ A ≠ ∅) (hCXA : C ∩ Aᶜ ≠ ∅) :
  C ∩ (frontier A) ≠ ∅ :=

Let $A \subset X$. Show that if $C$ is a connected subspace of $X$ that intersects both $A$ and $X-A$, then $C$ intersects $\operatorname{Bd} A$.

\begin{proof}

    Suppose that $C \cap B d A=C \cap \bar{A} \cap \overline{X-A}=\emptyset$. Then $C \cap A$ and $C \cap(X \backslash A)$ are a pair of disjoint non-empty sets whose union is all of $C$, neither of which contains a limit point of the other. Indeed, if $C \cap(X-A)$ contains a limit point $x$ of $C \cap A$, then $x \in C \cap(X-A) \cap A^{\prime} \subset C \cap \bar{A} \cap \overline{X-A}=\emptyset$, a contradiction, and similarly $C \cap A$ does not contain a limit point of $C \cap(X-A)$. Then $C \cap A$ and $C \cap(X-A)$ constitute a separation of $C$, contradicting the fact that $C$ is connected (Lemma 23.1).

\end{proof}


theorem exercise_23_11 {X Y : Type*} [topological_space X] [topological_space Y]
  (p : X → Y) (hq : quotient_map p)
  (hY : connected_space Y) (hX : ∀ y : Y, is_connected (p ⁻¹' {y})) :
  connected_space X :=

Let $p: X \rightarrow Y$ be a quotient map. Show that if each set $p^{-1}(\{y\})$ is connected, and if $Y$ is connected, then $X$ is connected.

\begin{proof}

    Suppose that $U$ and $V$ constitute a separation of $X$. If $y \in p(U)$, then $y=p(x)$ for some $x \in U$, so that $x \in p^{-1}(\{y\})$. Since $p^{-1}(\{y\})$ is connected and $x \in U \cap p^{-1}(\{y\})$, we have $p^{-1}(\{y\}) \subset U$. Thus $p^{-1}(\{y\}) \subset U$ for all $y \in p(U)$, so that $p^{-1}(p(U)) \subset U$. The inclusion $U \subset p^{-1}(p(U))$ if true for any subset and function, so we have the equality $U=p^{-1}(p(U))$ and therefore $U$ is saturated. Similarly, $V$ is saturated. Since $p$ is a quotient map, $p(U)$ and $p(V)$ are disjoint non-empty open sets in $Y$. But $p(U) \cup p(V)=Y$ as $p$ is surjective, so $p(U)$ and $p(V)$ constitute a separation of $Y$, contradicting the fact that $Y$ is connected. We conclude that $X$ is connected.

\end{proof}


theorem exercise_24_3a [topological_space I]
  (f : I → I) (hf : continuous f) :
  ∃ (x : I), f x = x :=

Let $f \colon X \rightarrow X$ be continuous. Show that if $X = [0, 1]$, there is a point $x$ such that $f(x) = x$. (The point $x$ is called a fixed point of $f$.)

\begin{proof}

    If $f(0)=0$ or $f(1)=1$ we are done, so suppose $f(0)>0$ and $f(1)<1$. Let $g:[0,1] \rightarrow[0,1]$ be given by $g(x)=f(x)-x$. Then $g$ is continuous, $g(0)>0$ and $g(1)<0$. Since $[0,1]$ is connected and $g(1)<0<g(0)$, by the intermediate value theorem there exists $x \in(0,1)$ such that $g(x)=0$, that is, such that $f(x)=x$.

\end{proof}


theorem exercise_25_9 {G : Type*} [topological_space G] [group G]
  [topological_group G] (C : set G) (h : C = connected_component 1) :
  is_normal_subgroup C :=

Let $G$ be a topological group; let $C$ be the component of $G$ containing the identity element $e$. Show that $C$ is a normal subgroup of $G$.

\begin{proof}

    Given $x \in G$, the maps $y \mapsto x y$ and $y \mapsto y x$ are homeomorphisms of $G$ onto itself. Since $C$ is a component, $x C$ and $C x$ are both components that contain $x$, so they are equal. Hence $x C=C x$ for all $x \in G$, so $C$ is a normal subgroup of $G$.

\end{proof}


theorem exercise_26_12 {X Y : Type*} [topological_space X] [topological_space Y]
  (p : X → Y) (h : function.surjective p) (hc : continuous p) (hp : ∀ y, is_compact (p ⁻¹' {y}))
  (hY : compact_space Y) : compact_space X :=

Let $p: X \rightarrow Y$ be a closed continuous surjective map such that $p^{-1}(\{y\})$ is compact, for each $y \in Y$. (Such a map is called a perfect map.) Show that if $Y$ is compact, then $X$ is compact.

\begin{proof}

    We first show that if $U$ is an open set containing $p^{-1}(\{y\})$, then there is a neighbourhood $W$ of $y$ such that $p^{-1}(W)$ is contained in $U$. Since $X-U$ is closed in $X$, $p(X-U)$ is closed in $Y$ and does not contain $y$, so $W=Y \backslash p(X \backslash U)$ is a neighbourhood of $y$. Moreover, since $X \backslash U \subset p^{-1}(p(X \backslash U)$ ) (by elementary set theory), we have

$$

p^{-1}(W)=p^{-1}(Y \backslash p(X \backslash U))=p^{-1}(Y) \backslash p^{-1}(p(X \backslash U)) \subset X \backslash(X \backslash U)=U .

$$

Now let $\mathcal{A}$ be an open covering of $X$. For each $y \in Y$, let $\mathcal{A}_y$ be a subcollection of $\mathcal{A}$ such that

$$

p^{-1}(\{y\}) \subset \bigcup_{A \in \mathcal{A}_y} A .

$$

Since $p^{-1}(\{y\})$ is compact, there exists a finite subcollection of $\mathcal{A}_y$ that also covers $p^{-1}(\{y\})$, say $\left\{A_y^1, \ldots, A_y^{n_y}\right\}$. Thus $\bigcup_{i=1}^{n_y} A_y^i$ is open and contains $p^{-1}(\{y\})$, so there exists a neighbourhood $W_y$ of $y$ such that $p^{-1}\left(W_y\right)$ is contained in $\bigcup_{i=1}^{n_y} A_y^i$. Then $\left\{W_y\right\}_{y \in Y}$ is an open covering of $Y$, so there exist $y_1, \ldots, y_k \in Y$ such that $\left\{W_{y_j}\right\}_{j=1}^k$ also covers $Y$. Then

$$

X=p^{-1}(Y) \subset p^{-1}\left(\bigcup_{j=1}^k W_{y_j}\right)=\bigcup_{j=1}^k p^{-1}\left(W_{y_j}\right) \subset \bigcup_{j=1}^k\left(\bigcup_{i=1}^{n_{y_j}} A_{y_j}^i\right)

$$

so

$$

\left\{A_{y_j}^i\right\}_{\substack{j=1, \ldots, k . \\ i=1, \ldots, n_{y_j}}}

$$

is a finite subcollection of $\mathcal{A}$ that also covers $X$. Therefore, $X$ is compact.

\end{proof}


theorem exercise_28_4 {X : Type*}
  [topological_space X] (hT1 : t1_space X) :
  countably_compact X ↔ limit_point_compact X :=

A space $X$ is said to be countably compact if every countable open covering of $X$ contains a finite subcollection that covers $X$. Show that for a $T_1$ space $X$, countable compactness is equivalent to limit point compactness.

\begin{proof}

    First let $X$ be a countable compact space. Note that if $Y$ is a closed subset of $X$, then $Y$ is countable compact as well, for if $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$is a countable open covering of $Y$, then $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}} \cup(X \backslash Y)$ is a countable open covering of $X$; there is a finite subcovering of $X$, hence a finite subcovering of $Y$. Now let $A$ be an infinite subset. We show that $A$ has a limit point. Let $B$ be a countable infinite subset of $A$. Suppose that $B$ has no limit point, so that $B$ is closed in $X$. Then $B$ is countable compact. Since $B$ has no limit point, for each $b \in B$ there is a neighbourhood $U_b$ of $b$ that intersects $B$ in the point $b$ alone. Then $\left\{U_b\right\}_{b \in B}$ is an open covering of $B$ with no finite subcovering, contradicting the fact that $B$ is countable compact. Hence $B$ has a limit point, so that $A$ has a limit point as well. Since $A$ was arbitrary, we deduce that $X$ is limit point compact. (Note that the $T_1$ property is not necessary in this direction.)

Now assume that $X$ is a limit point compact $T_1$ space. We show that $X$ is countable compact. Suppose, on the contrary, that $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$is a countable open covering of $X$ with no finite subcovering. For each $n$, take a point $x_n$ in $X$ not in $U_1 \cup \cdots \cup U_n$. By assumption, the infinite set $A=\left\{x_n \mid n \in \mathbb{Z}_{+}\right\}$has a limit point $y \in X$. Since $\left\{U_n\right\}_{n \in \mathbb{Z}_{+}}$covers $X$, there exists $N \in \mathbb{Z}_{+}$such that $y \in U_1 \cup \cdots \cup U_N$. Now $X$ is $T_1$, so for each $i=1, \ldots, N$ there exists a neighbourhood $V_i$ of $y$ that does not contain $x_i$. Then

$$

V=\left(V_1 \cap \cdots \cap V_N\right) \cap\left(U_1 \cup \cdots \cup U_N\right)

$$

is a neighbourhood of $y$ that does not contain any of the points $x_i$, contradicting the fact that $y$ is a limit point of $A$. It follows that every countable open covering of $X$ must have a finite subcovering, so $X$ is countable compact.

\end{proof}


theorem exercise_28_6 {X : Type*} [metric_space X]
  [compact_space X] {f : X → X} (hf : isometry f) :
  function.bijective f :=

Let $(X, d)$ be a metric space. If $f: X \rightarrow X$ satisfies the condition $d(f(x), f(y))=d(x, y)$ for all $x, y \in X$, then $f$ is called an isometry of $X$. Show that if $f$ is an isometry and $X$ is compact, then $f$ is bijective and hence a homeomorphism.

\begin{proof}

    Note that $f$ is an imbedding. It remains to prove that $f$ is surjective. Suppose it is not, and let $a \in f(X)$. Since $X$ is compact, $f(X)$ is compact and hence closed (every metric space is Hausdorff). Thus, there exists $\varepsilon>0$ such that the $\varepsilon^{-}$ neighbourhood of $a$ is contained in $X \backslash f(X)$. Set $x_1=a$, and inductively $x_{n+1}=f\left(x_n\right)$ for $n \in \mathbb{Z}_{+}$. We show that $d\left(x_n, x_m\right) \geq \varepsilon$ for $n \neq m$. Indeed, we may assume $n<m$. If $n \geq 1$, then $d\left(x_n, x_m\right)=$ $d\left(f^{-1}\left(x_n\right), f^{-1}\left(x_m\right)\right)=d\left(x_{n-1}, x_{m-1}\right)$. By induction it follows that $d\left(x_n, x_m\right)=d\left(x_{n-i}, x_{m-i}\right)$ for all $i \geq 1$, and hence $d\left(x_n, x_m\right)=d\left(a, x_{m-n}\right)=d\left(a, f\left(x_{m-n-1}\right)\right)$. Since $f\left(x_{m-n-1}\right) \in f(X)$ and $B(a, \varepsilon) \cap f(X)=\emptyset$, we have $d\left(x_n, x_m\right) \geq \varepsilon$, as claimed. Thus $\left\{x_n\right\}_{n \in \mathbb{Z}_{+}}$is a sequence with no convergent subsequence, so $X$ is not sequentially compact. This contradicts the fact that $X$ is compact. Therefore $f$ is surjective and hence a homeomorphism.

\end{proof}


theorem exercise_29_4 [topological_space (ℕ → I)] :
  ¬ locally_compact_space (ℕ → I) :=

Show that $[0, 1]^\omega$ is not locally compact in the uniform topology.

\begin{proof}

    Consider $\mathbf{0} \in[0,1]^\omega$ and suppose that $[0,1]^\omega$ is locally compact at $\mathbf{0}$. Then there exists a compact $C$ containing an open ball $B=B_\rho(\mathbf{0}, \varepsilon) \subset[0,1]^\omega$. Note that $\bar{B}=[0, \varepsilon]^\omega$. Then $[0, \varepsilon]^\omega$ is closed and contained in the compact $C$, so it is compact. But $[0, \varepsilon]^\omega$ is homeomorphic to $[0,1]^\omega$, which is not compact by Exercise 28.1. This contradiction proves that $[0,1]^\omega$ is not locally compact in the uniform topology.

\end{proof}


theorem exercise_30_10
  {X : ℕ → Type*} [∀ i, topological_space (X i)]
  (h : ∀ i, ∃ (s : set (X i)), countable s ∧ dense s) :
  ∃ (s : set (Π i, X i)), countable s ∧ dense s :=

Show that if $X$ is a countable product of spaces having countable dense subsets, then $X$ has a countable dense subset.

\begin{proof}

    Let $\left(X_n\right)$ be spaces having countable dense subsets $\left(A_n\right)$. For each $n$, fix an arbitrary $x_n \in X_n$. Consider the subset $A$ of $X$ defined by

$$

A=\bigcup\left\{\prod U_n: U_n=A_n \text { for finitely many } n \text { and is }\left\{x_n\right\} \text { otherwise }\right\} .

$$

This set is countable because the set of finite subsets of $\mathbb{N}$ is countable and each of the inner sets is countable. Now, let $x \in X$ and $V=\prod V_n$ be a basis element containing $x$ such that each $V_n$ is open in $X_n$ and $V_n=X_n$ for all but finitely many $n$. For each $n$, if $V_n \neq X_n$, choose a $y_n \in\left(A_n \cap V_n\right)$ (such a $y_n$ exists since $A_n$ is dense in $\left.X_n\right)$. Otherwise, let $y_n=x_n$. Then $\left(y_n\right) \in(A \cap V)$, proving that $A$ is dense in $X$.

\end{proof}


theorem exercise_31_1 {X : Type*} [topological_space X]
  (hX : regular_space X) (x y : X) :
  ∃ (U V : set X), is_open U ∧ is_open V ∧ x ∈ U ∧ y ∈ V ∧ closure U ∩ closure V = ∅ :=

Show that if $X$ is regular, every pair of points of $X$ have neighborhoods whose closures are disjoint.

\begin{proof}

    Let $x, y \in X$ be two points such that $x \neq y$. Since $X$ is regular (and thus Hausdorff), there exist disjoint open sets $U, V \subseteq X$ such that $x \in U$ and $y \in V$.

Note that $y \notin \bar{U}$. Otherwise $V$ must intersect $U$ in a point different from $y$ since $V$ is an open neighborhood of $y$, which is a contradiction since $U$ and $V$ are disjoint.

Since $X$ is regular and $\bar{U}$ is closed, there exist disjoint open sets $U^{\prime}, V^{\prime} \subseteq X$ such that $\bar{U} \subseteq U^{\prime}$ and $y \in V^{\prime}$.

And now $U$ and $V^{\prime}$ are neighborhoods of $x$ and $y$ whose closures are disjoint. If $\bar{U} \cap \overline{V^{\prime}} \neq \emptyset$, then it follows that $U^{\prime} \supseteq U$ intersects $\overline{V^{\prime}}$. Since $U^{\prime}$ is open, it follows that $U^{\prime}$ intersects $V^{\prime}$, which is a contradiction.

\end{proof}