theorem exercise_1_1b
(x : ℝ)
(y : ℚ)
(h : y ≠ 0)
: ( irrational x ) -> irrational ( x * y ) :=

import .common

open real complex
open topological_space
open filter
open_locale real
open_locale topology
open_locale big_operators
open_locale complex_conjugate
open_locale filter

noncomputable theory

If $r$ is rational $(r \neq 0)$ and $x$ is irrational, prove that $rx$ is irrational.

\begin{proof}

    If $r x$ were rational, then $x=\frac{r x}{r}$ would also be rational.

\end{proof}


theorem exercise_1_4
(α : Type*) [partial_order α]
(s : set α)
(x y : α)
(h₀ : set.nonempty s)
(h₁ : x ∈ lower_bounds s)
(h₂ : y ∈ upper_bounds s)
: x ≤ y :=

Let $E$ be a nonempty subset of an ordered set; suppose $\alpha$ is a lower bound of $E$ and $\beta$ is an upper bound of $E$. Prove that $\alpha \leq \beta$.

\begin{proof}

Since $E$ is nonempty, there exists $x \in E$. Then by definition of lower and upper bounds we have $\alpha \leq x \leq \beta$, and hence by property $i i$ in the definition of an ordering, we have $\alpha<\beta$ unless $\alpha=x=\beta$.

\end{proof}


theorem exercise_1_8 : ¬ ∃ (r : ℂ → ℂ → Prop), is_linear_order ℂ r :=

Prove that no order can be defined in the complex field that turns it into an ordered field.

\begin{proof}

    By Part (a) of Proposition $1.18$, either $i$ or $-i$ must be positive. Hence $-1=i^2=(-i)^2$ must be positive. But then $1=(-1)^2$, must also be positive, and this contradicts Part $(a)$ of Proposition 1.18, since 1 and $-1$ cannot both be positive.

\end{proof}


theorem exercise_1_12 (n : ℕ) (f : ℕ → ℂ) :
  abs (∑ i in finset.range n, f i) ≤ ∑ i in finset.range n, abs (f i) :=

If $z_1, \ldots, z_n$ are complex, prove that $|z_1 + z_2 + \ldots + z_n| \leq |z_1| + |z_2| + \cdots + |z_n|$.

\begin{proof}

    We can apply the case $n=2$ and induction on $n$ to get

$$

\begin{aligned}

\left|z_1+z_2+\cdots z_n\right| &=\left|\left(z_1+z_2+\cdots+z_{n-1}\right)+z_n\right| \\

& \leq\left|z_1+z_2+\cdots+z_{n-1}\right|+\left|z_n\right| \\

& \leq\left|z_1\right|+\left|z_2\right|+\cdots+\left|z_{n-1}\right|+\left|z_n\right|

\end{aligned}

$$

\end{proof}


If $z$ is a complex number such that $|z|=1$, that is, such that $z \bar{z}=1$, compute $|1+z|^{2}+|1-z|^{2}$.


theorem exercise_1_17
  (n : ℕ)
  (x y : euclidean_space ℝ (fin n)) -- R^n
  : ‖x + y‖^2 + ‖x - y‖^2 = 2*‖x‖^2 + 2*‖y‖^2 :=

Prove that $|\mathbf{x}+\mathbf{y}|^{2}+|\mathbf{x}-\mathbf{y}|^{2}=2|\mathbf{x}|^{2}+2|\mathbf{y}|^{2}$ if $\mathbf{x} \in R^{k}$ and $\mathbf{y} \in R^{k}$.

\begin{proof}

    The proof is a routine computation, using the relation

$$

|x \pm y|^2=(x \pm y) \cdot(x \pm y)=|x|^2 \pm 2 x \cdot y+|y|^2 .

$$

If $\mathrm{x}$ and $\mathrm{y}$ are the sides of a parallelogram, then $\mathrm{x}+\mathrm{y}$ and $\mathbf{x}-\mathrm{y}$ are its diagonals. Hence this result says that the sum of the squares on the diagonals of a parallelogram equals the sum of the squares on the sides.

\end{proof}


theorem exercise_1_18b
  : ¬ ∀ (x : ℝ), ∃ (y : ℝ), y ≠ 0 ∧ x * y = 0 :=

If $k = 1$ and $\mathbf{x} \in R^{k}$, prove that there does not exist $\mathbf{y} \in R^{k}$ such that $\mathbf{y} \neq 0$ but $\mathbf{x} \cdot \mathbf{y}=0$

\begin{proof}

    Not true when $k=1$, since the product of two nonzero real numbers is nonzero.

\end{proof}


theorem exercise_2_19a {X : Type*} [metric_space X]
  (A B : set X) (hA : is_closed A) (hB : is_closed B) (hAB : disjoint A B) :
  separated_nhds A B :=

If $A$ and $B$ are disjoint closed sets in some metric space $X$, prove that they are separated.

\begin{proof}

    We are given that $A \cap B=\varnothing$. Since $A$ and $B$ are closed, this means $A \cap \bar{B}=\varnothing=\bar{A} \cap B$, which says that $A$ and $B$ are separated.

\end{proof}


theorem exercise_2_25 {K : Type*} [metric_space K] [compact_space K] :
  ∃ (B : set (set K)), set.countable B ∧ is_topological_basis B :=

Prove that every compact metric space $K$ has a countable base.

\begin{proof}

    $K$ can be covered by a finite union of neighborhoods of radius $1 / n$, and this shows that this implies that $K$ is separable.

It is not entirely obvious that a metric space with a countable base is separable. To prove this, let $\left\{V_n\right\}_{n=1}^{\infty}$ be a countable base, and let $x_n \in V_n$. The points $V_n$ must be dense in $X$. For if $G$ is any non-empty open set, then $G$ contains $V_n$ for some $n$, and hence $x_n \in G$. (Thus for a metric space, having a countable base and being separable are equivalent.)

\end{proof}


theorem exercise_2_27b (k : ℕ) (E P : set (euclidean_space ℝ (fin k)))
  (hE : E.nonempty ∧ ¬ set.countable E)
  (hP : P = {x | ∀ U ∈ 𝓝 x, (P ∩ E).nonempty ∧ ¬ set.countable (P ∩ E)}) :
  set.countable (E \ P) :=

Suppose $E\subset\mathbb{R}^k$ is uncountable, and let $P$ be the set of condensation points of $E$. Prove that at most countably many points of $E$ are not in $P$.

\begin{proof}

    If $x \in W^c$, and $O$ is any neighborhood of $x$, then $x \in V_n \subseteq O$ for some n. Since $x \notin W, V_n \cap E$ is uncountable. Hence $O$ contains uncountably many points of $E$, and so $x$ is a condensation point of $E$. Thus $x \in P$, i.e., $W^c \subseteq P$.

Conversely if $x \in W$, then $x \in V_n$ for some $V_n$ such that $V_n \cap E$ is countable. Hence $x$ has a neighborhood (any neighborhood contained in $V_n$ ) containing at most a countable set of points of $E$, and so $x \notin P$, i.e., $W \subseteq P^c$. Hence $P=W^c$.

It is clear that $P$ is closed (since its complement $W$ is open), so that we need only show that $P \subseteq P^{\prime}$. Hence suppose $x \in P$, and $O$ is any neighborhood of $x$. (By definition of $P$ this means $O \cap E$ is uncountable.) We need to show that there is a point $y \in P \cap(O \backslash\{x\})$. If this is not the case, i.e., if every point $y$ in $O \backslash\{x\}$ is in $P^c$, then for each such point $y$ there is a set $V_n$ containing $y$ such that $V_n \cap E$ is at most countable. That would mean that $y \in W$, i.e., that $O \backslash\{x\}$ is contained in $W$. It would follow that $O \cap E \subseteq\{x\} \cup(W \cap E)$, and so $O \cap E$ contains at most a countable set of points, contrary to the hypothesis that $x \in P$. Hence $O$ contains a point of $P$ different from $x$, and so $P \subseteq P^{\prime}$. Thus $P$ is perfect.

\end{proof}


theorem exercise_2_29 (U : set ℝ) (hU : is_open U) :
  ∃ (f : ℕ → set ℝ), (∀ n, ∃ a b : ℝ, f n = {x | a < x ∧ x < b}) ∧ (∀ n, f n ⊆ U) ∧
  (∀ n m, n ≠ m → f n ∩ f m = ∅) ∧
  U = ⋃ n, f n :=

Prove that every open set in $\mathbb{R}$ is the union of an at most countable collection of disjoint segments.

\begin{proof}

    Let $O$ be open. For each pair of points $x \in O, y \in O$, we define an equivalence relation $x \sim y$ by saying $x \sim y$ if and only if $[\min (x, y), \max (x, y)] \subset$ 0 . This is an equivalence relation, since $x \sim x([x, x] \subset O$ if $x \in O)$; if $x \sim y$, then $y \sim x$ (since $\min (x, y)=\min (y, x)$ and $\max (x, y)=\max (y, x))$; and if $x \sim y$ and $y \sim z$, then $x \sim z([\min (x, z), \max (x, z)] \subseteq[\min (x, y), \max (x, y)] \cup$ $[\min (y, z), \max (y, z)] \subseteq O)$. In fact it is easy to prove that

$$

\min (x, z) \geq \min (\min (x, y), \min (y, z))

$$

and

$$

\max (x, z) \leq \max (\max (x, y), \max (y, z))

$$

It follows that $O$ can be written as a disjoint union of pairwise disjoint equivalence classes. We claim that each equivalence class is an open interval.

To show this, for each $x \in O$; let $A=\{z:[z, x] \subseteq O\}$ and $B=\{z:[x, z] \subseteq$ $O\}$, and let $a=\inf A, b=\sup B$. We claim that $(a, b) \subset O$. Indeed if $a<z<b$, there exists $c \in A$ with $c<z$ and $d \in B$ with $d>z$. Then $z \in[c, x] \cup[x, d] \subseteq O$. We now claim that $(a, b)$ is the equivalence class containing $x$. It is clear that each element of $(a, b)$ is equivalent to $x$ by the way in which $a$ and $b$ were chosen. We need to show that if $z \notin(a, b)$, then $z$ is not equivalent to $x$. Suppose that $z<a$. If $z$ were equivalent to $x$, then $[z, x]$ would be contained in $O$, and so we would have $z \in A$. Hence $a$ would not be a lower bound for $A$. Similarly if $z>b$ and $z \sim x$, then $b$ could not be an upper bound for $B$.

We have now established that $O$ is a union of pairwise disjoint open intervals. Such a union must be at most countable, since each open interval contains a rational number not in any other interval.

\end{proof}


theorem exercise_3_2a
  : tendsto (λ (n : ℝ), (sqrt (n^2 + n) - n)) at_top (𝓝 (1/2)) :=

Prove that $\lim_{n \rightarrow \infty}\sqrt{n^2 + n} -n = 1/2$.

\begin{proof}

    Multiplying and dividing by $\sqrt{n^2+n}+n$ yields

$$

\sqrt{n^2+n}-n=\frac{n}{\sqrt{n^2+n}+n}=\frac{1}{\sqrt{1+\frac{1}{n}}+1} .

$$

It follows that the limit is $\frac{1}{2}$.

\end{proof}


theorem exercise_3_5 -- TODO fix
  (a b : ℕ → ℝ)
  (h : limsup a + limsup b ≠ 0) :
  limsup (λ n, a n + b n) ≤ limsup a + limsup b :=

For any two real sequences $\left\{a_{n}\right\},\left\{b_{n}\right\}$, prove that $\limsup _{n \rightarrow \infty}\left(a_{n}+b_{n}\right) \leq \limsup _{n \rightarrow \infty} a_{n}+\limsup _{n \rightarrow \infty} b_{n},$ provided the sum on the right is not of the form $\infty-\infty$.

\begin{proof}

    Since the case when $\limsup _{n \rightarrow \infty} a_n=+\infty$ and $\limsup _{n \rightarrow \infty} b_n=-\infty$ has been excluded from consideration, we note that the inequality is obvious if $\limsup _{n \rightarrow \infty} a_n=+\infty$. Hence we shall assume that $\left\{a_n\right\}$ is bounded above.

Let $\left\{n_k\right\}$ be a subsequence of the positive integers such that $\lim _{k \rightarrow \infty}\left(a_{n_k}+\right.$ $\left.b_{n_k}\right)=\limsup _{n \rightarrow \infty}\left(a_n+b_n\right)$. Then choose a subsequence of the positive integers $\left\{k_m\right\}$ such that

$$

\lim _{m \rightarrow \infty} a_{n_{k_m}}=\limsup _{k \rightarrow \infty} a_{n_k} .

$$

The subsequence $a_{n_{k_m}}+b_{n_{k_m}}$ still converges to the same limit as $a_{n_k}+b_{n_k}$, i.e., to $\limsup _{n \rightarrow \infty}\left(a_n+b_n\right)$. Hence, since $a_{n_k}$ is bounded above (so that $\limsup _{k \rightarrow \infty} a_{n_k}$ is finite), it follows that $b_{n_{k_m}}$ converges to the difference

$$

\lim _{m \rightarrow \infty} b_{n_{k_m}}=\lim _{m \rightarrow \infty}\left(a_{n_{k_m}}+b_{n_{k_m}}\right)-\lim _{m \rightarrow \infty} a_{n_{k_m}} .

$$

Thus we have proved that there exist subsequences $\left\{a_{n_{k_m}}\right\}$ and $\left\{b_{n_{k_m}}\right\}$ which converge to limits $a$ and $b$ respectively such that $a+b=\limsup _{n \rightarrow \infty}\left(a_n+b_n^*\right)$. Since $a$ is the limit of a subsequence of $\left\{a_n\right\}$ and $b$ is the limit of a subsequence of $\left\{b_n\right\}$, it follows that $a \leq \limsup _{n \rightarrow \infty} a_n$ and $b \leq \limsup _{n \rightarrow \infty} b_n$, from which the desired inequality follows.

\end{proof}


theorem exercise_3_7
  (a : ℕ → ℝ)
  (h : ∃ y, (tendsto (λ n, (∑ i in (finset.range n), a i)) at_top (𝓝 y))) :
  ∃ y, tendsto (λ n, (∑ i in (finset.range n), sqrt (a i) / n)) at_top (𝓝 y) :=

Prove that the convergence of $\Sigma a_{n}$ implies the convergence of $\sum \frac{\sqrt{a_{n}}}{n}$ if $a_n\geq 0$.

\begin{proof}

    Since $\left(\sqrt{a_n}-\frac{1}{n}\right)^2 \geq 0$, it follows that

$$

\frac{\sqrt{a_n}}{n} \leq \frac{1}{2}\left(a_n^2+\frac{1}{n^2}\right) .

$$

Now $\Sigma a_n^2$ converges by comparison with $\Sigma a_n$ (since $\Sigma a_n$ converges, we have $a_n<1$ for large $n$, and hence $\left.a_n^2<a_n\right)$. Since $\Sigma \frac{1}{n^2}$ also converges ($p$ series, $p=2$ ), it follows that $\Sigma \frac{\sqrt{a_n}}{n}$ converges.

\end{proof}


theorem exercise_3_13
  (a b : ℕ → ℝ)
  (ha : ∃ y, (tendsto (λ n, (∑ i in (finset.range n), |a i|)) at_top (𝓝 y)))
  (hb : ∃ y, (tendsto (λ n, (∑ i in (finset.range n), |b i|)) at_top (𝓝 y))) :
  ∃ y, (tendsto (λ n, (∑ i in (finset.range n),
  λ i, (∑ j in finset.range (i + 1), a j * b (i - j)))) at_top (𝓝 y)) :=

Prove that the Cauchy product of two absolutely convergent series converges absolutely.

\begin{proof}

    Since both the hypothesis and conclusion refer to absolute convergence, we may assume both series consist of nonnegative terms. We let $S_n=\sum_{k=0}^n a_n, T_n=\sum_{k=0}^n b_n$, and $U_n=\sum_{k=0}^n \sum_{l=0}^k a_l b_{k-l}$. We need to show that $U_n$ remains bounded, given that $S_n$ and $T_n$ are bounded. To do this we make the convention that $a_{-1}=T_{-1}=0$, in order to save ourselves from having to separate off the first and last terms when we sum by parts. We then have

$$

\begin{aligned}

U_n &=\sum_{k=0}^n \sum_{l=0}^k a_l b_{k-l} \\

&=\sum_{k=0}^n \sum_{l=0}^k a_l\left(T_{k-l}-T_{k-l-1}\right) \\

&=\sum_{k=0}^n \sum_{j=0}^k a_{k-j}\left(T_j-T_{j-1}\right) \\

&=\sum_{k=0}^n \sum_{j=0}^k\left(a_{k-j}-a_{k-j-1}\right) T_j \\

&=\sum_{j=0}^n \sum_{k=j}^n\left(a_{k-j}-a_{k-j-1}\right) T_j

&=\sum_{j=0}^n a_{n-j} T_j \\

&\leq T \sum_{m=0}^n a_m \\

&=T S_n \\

&\leq S T .

\end{aligned}

$$

Thus $U_n$ is bounded, and hence approaches a finite limit.

\end{proof}


theorem exercise_3_21
  {X : Type*} [metric_space X] [complete_space X]
  (E : ℕ → set X)
  (hE : ∀ n, E n ⊃ E (n + 1))
  (hE' : tendsto (λ n, metric.diam (E n)) at_top (𝓝 0)) :
  ∃ a, set.Inter E = {a} :=

If $\left\{E_{n}\right\}$ is a sequence of closed nonempty and bounded sets in a complete metric space $X$, if $E_{n} \supset E_{n+1}$, and if $\lim _{n \rightarrow \infty} \operatorname{diam} E_{n}=0,$ then $\bigcap_{1}^{\infty} E_{n}$ consists of exactly one point.

\begin{proof}

    Choose $x_n \in E_n$. (We use the axiom of choice here.) The sequence $\left\{x_n\right\}$ is a Cauchy sequence, since the diameter of $E_n$ tends to zero as $n$ tends to infinity and $E_n$ contains $E_{n+1}$. Since the metric space $X$ is complete, the sequence $x_n$ converges to a point $x$, which must belong to $E_n$ for all $n$, since $E_n$ is closed and contains $x_m$ for all $m \geq n$. There cannot be a second point $y$ in all of the $E_n$, since for any point $y \neq x$ the diameter of $E_n$ is less $\operatorname{than} d(x, y)$ for large $n$.

\end{proof}


theorem exercise_4_1a
  : ∃ (f : ℝ → ℝ), (∀ (x : ℝ), tendsto (λ y, f(x + y) - f(x - y)) (𝓝 0) (𝓝 0)) ∧ ¬ continuous f :=

Suppose $f$ is a real function defined on $\mathbb{R}$ which satisfies $\lim_{h \rightarrow 0} f(x + h) - f(x - h) = 0$ for every $x \in \mathbb{R}$. Show that $f$ does not need to be continuous.

\begin{proof}

    $$

f(x)= \begin{cases}1 & \text { if } x \text { is an integer } \\ 0 & \text { if } x \text { is not an integer. }\end{cases}

$$

(If $x$ is an integer, then $f(x+h)-f(x-h) \equiv 0$ for all $h$; while if $x$ is not an integer, $f(x+h)-f(x-h)=0$ for $|h|<\min (x-[x], 1+[x]-x)$.

\end{proof}


theorem exercise_4_3
  {α : Type} [metric_space α]
  (f : α → ℝ) (h : continuous f) (z : set α) (g : z = f⁻¹' {0})
  : is_closed z :=

Let $f$ be a continuous real function on a metric space $X$. Let $Z(f)$ (the zero set of $f$ ) be the set of all $p \in X$ at which $f(p)=0$. Prove that $Z(f)$ is closed.

\begin{proof}

    $Z(f)=f^{-1}(\{0\})$, which is the inverse image of a closed set. Hence $Z(f)$ is closed.

\end{proof}


theorem exercise_4_4b
  {α : Type} [metric_space α]
  {β : Type} [metric_space β]
  (f g : α → β)
  (s : set α)
  (h₁ : continuous f)
  (h₂ : continuous g)
  (h₃ : dense s)
  (h₄ : ∀ x ∈ s, f x = g x)
  : f = g :=

Let $f$ and $g$ be continuous mappings of a metric space $X$ into a metric space $Y$, and let $E$ be a dense subset of $X$. Prove that if $g(p) = f(p)$ for all $p \in P$ then $g(p) = f(p)$ for all $p \in X$.

\begin{proof}

    The function $\varphi: X \rightarrow R^1$ given by

$$

\varphi(p)=d_Y(f(p), g(p))

$$

is continuous, since

$$

\left|d_Y(f(p), g(p))-d_Y(f(q), g(q))\right| \leq d_Y(f(p), f(q))+d_Y(g(p), g(q))

$$

(This inequality follows from the triangle inequality, since

$$

d_Y(f(p), g(p)) \leq d_Y(f(p), f(q))+d_Y(f(q), g(q))+d_Y(g(q), g(p)),

$$

and the same inequality holds with $p$ and $q$ interchanged. The absolute value $\left|d_Y(f(p), g(p))-d_Y(f(q), g(q))\right|$ must be either $d_Y(f(p), g(p))-d_Y(f(q), g(q))$ or $d_Y(f(q), g(q))-d_Y(f(p), g(p))$, and the triangle inequality shows that both of these numbers are at most $d_Y(f(p), f(q))+d_Y(g(p), g(q))$.)

By the previous problem, the zero set of $\varphi$ is closed. But by definition

$$

Z(\varphi)=\{p: f(p)=g(p)\} .

$$

Hence the set of $p$ for which $f(p)=g(p)$ is closed. Since by hypothesis it is dense, it must be $X$.

\end{proof}


theorem exercise_4_5b
  : ∃ (E : set ℝ) (f : ℝ → ℝ), (continuous_on f E) ∧
  (¬ ∃ (g : ℝ → ℝ), continuous g ∧ ∀ x ∈ E, f x = g x) :=

Show that there exist a set $E \subset \mathbb{R}$ and a real continuous function $f$ defined on $E$, such that there does not exist a continuous real function $g$ on $\mathbb{R}$ such that $g(x)=f(x)$ for all $x \in E$.

\begin{proof}

    Let $E:=(0,1)$, and define $f(x):=1 / x$ for all $x \in E$. If $f$ has a continuous extension $g$ to $\mathbb{R}$, then $g$ is continuous on $[-1,1]$, and therefore bounded by the intermediate value theorem. However, $f$ is not bounded in any neighborhood of $x=0$, so therefore $g$ is not bounded either, a contradiction.

\end{proof}


theorem exercise_4_8a
  (E : set ℝ) (f : ℝ → ℝ) (hf : uniform_continuous_on f E)
  (hE : metric.bounded E) : metric.bounded (set.image f E) :=

Let $f$ be a real uniformly continuous function on the bounded set $E$ in $R^{1}$. Prove that $f$ is bounded on $E$.

\begin{proof}

    Let $a=\inf E$ and $b=\sup E$, and let $\delta>0$ be such that $|f(x)-f(y)|<1$ if $x, y \in E$ and $|x-y|<\delta$. Now choose a positive integer $N$ larger than $(b-a) / \delta$, and consider the $N$ intervals $I_k=\left[a+\frac{k-1}{b-a}, a+\frac{k}{b-a}\right], k=1,2, \ldots, N$. For each $k$ such that $I_k \cap E \neq \varnothing$ let $x_k \in E \cap I_k$. Then let $M=1+\max \left\{\left|f\left(x_k\right)\right|\right\}$. If $x \in E$, we have $\left|x-x_k\right|<\delta$ for some $k$, and hence $|f(x)|<M$.

\end{proof}


theorem exercise_4_11a
  {X : Type*} [metric_space X]
  {Y : Type*} [metric_space Y]
  (f : X → Y) (hf : uniform_continuous f)
  (x : ℕ → X) (hx : cauchy_seq x) :
  cauchy_seq (λ n, f (x n)) :=

Suppose $f$ is a uniformly continuous mapping of a metric space $X$ into a metric space $Y$ and prove that $\left\{f\left(x_{n}\right)\right\}$ is a Cauchy sequence in $Y$ for every Cauchy sequence $\{x_n\}$ in $X$.

\begin{proof}

    Suppose $\left\{x_n\right\}$ is a Cauchy sequence in $X$. Let $\varepsilon>0$ be given. Let $\delta>0$ be such that $d_Y(f(x), f(u))<\varepsilon$ if $d_X(x, u)<\delta$. Then choose $N$ so that $d_X\left(x_n, x_m\right)<\delta$ if $n, m>N$. Obviously $d_Y\left(f\left(x_n\right), f\left(x_m\right)\right)<\varepsilon$ if $m, n>N$, showing that $\left\{f\left(x_n\right)\right\}$ is a Cauchy sequence.

\end{proof}


theorem exercise_4_15 {f : ℝ → ℝ}
  (hf : continuous f) (hof : is_open_map f) :
  monotone f :=

Prove that every continuous open mapping of $R^{1}$ into $R^{1}$ is monotonic.

\begin{proof}

    Suppose $f$ is continuous and not monotonic, say there exist points $a<b<c$ with $f(a)<f(b)$, and $f(c)<f(b)$. Then the maximum value of $f$ on the closed interval $[a, c]$ is assumed at a point $u$ in the open interval $(a, c)$. If there is also a point $v$ in the open interval $(a, c)$ where $f$ assumes its minimum value on $[a, c]$, then $f(a, c)=[f(v), f(u)]$. If no such point $v$ exists, then $f(a, c)=(d, f(u)]$, where $d=\min (f(a), f(c))$. In either case, the image of $(a, c)$ is not open.

\end{proof}


theorem exercise_4_21a {X : Type*} [metric_space X]
  (K F : set X) (hK : is_compact K) (hF : is_closed F) (hKF : disjoint K F) :
  ∃ (δ : ℝ), δ > 0 ∧ ∀ (p q : X), p ∈ K → q ∈ F → dist p q ≥ δ :=

Suppose $K$ and $F$ are disjoint sets in a metric space $X, K$ is compact, $F$ is closed. Prove that there exists $\delta>0$ such that $d(p, q)>\delta$ if $p \in K, q \in F$.

\begin{proof}

Following the hint, we observe that $\rho_F(x)$ must attain its minimum value on $K$, i.e., there is some point $r \in K$ such that

$$

\rho_F(r)=\min _{q \in K} \rho_F(q) .

$$

Since $F$ is closed and $r \notin F$, it follows from Exercise $4.20$ that $\rho_F(r)>0$. Let $\delta$ be any positive number smaller than $\rho_F(r)$. Then for any $p \in F, q \in K$, we have

$$

d(p, q) \geq \rho_F(q) \geq \rho_F(r)>\delta .

$$

This proves the positive assertion.

\end{proof}


theorem exercise_5_1
  {f : ℝ → ℝ} (hf : ∀ x y : ℝ, | (f x - f y) | ≤ (x - y) ^ 2) :
  ∃ c, f = λ x, c :=

Let $f$ be defined for all real $x$, and suppose that $|f(x)-f(y)| \leq (x-y)^{2}$ for all real $x$ and $y$. Prove that $f$ is constant.

\begin{proof}

    Dividing by $x-y$, and letting $x \rightarrow y$, we find that $f^{\prime}(y)=0$ for all $y$. Hence $f$ is constant.

\end{proof}


theorem exercise_5_3 {g : ℝ → ℝ} (hg : continuous g)
  (hg' : ∃ M : ℝ, ∀ x : ℝ, | deriv g x | ≤ M) :
  ∃ N, ∀ ε > 0, ε < N → function.injective (λ x : ℝ, x + ε * g x) :=

Suppose $g$ is a real function on $R^{1}$, with bounded derivative (say $\left|g^{\prime}\right| \leq M$ ). Fix $\varepsilon>0$, and define $f(x)=x+\varepsilon g(x)$. Prove that $f$ is one-to-one if $\varepsilon$ is small enough.

\begin{proof}

    If $0<\varepsilon<\frac{1}{M}$, we certainly have

$$

f^{\prime}(x) \geq 1-\varepsilon M>0,

$$

and this implies that $f(x)$ is one-to-one, by the preceding problem.

\end{proof}


theorem exercise_5_5
  {f : ℝ → ℝ}
  (hfd : differentiable ℝ f)
  (hf : tendsto (deriv f) at_top (𝓝 0)) :
  tendsto (λ x, f (x + 1) - f x) at_top at_top :=

Suppose $f$ is defined and differentiable for every $x>0$, and $f^{\prime}(x) \rightarrow 0$ as $x \rightarrow+\infty$. Put $g(x)=f(x+1)-f(x)$. Prove that $g(x) \rightarrow 0$ as $x \rightarrow+\infty$.

\begin{proof}

    Let $\varepsilon>0$. Choose $x_0$ such that $\left|f^{\prime}(x)\right|<\varepsilon$ if $x>x_0$. Then for any $x \geq x_0$ there exists $x_1 \in(x, x+1)$ such that

$$

f(x+1)-f(x)=f^{\prime}\left(x_1\right) .

$$

Since $\left|f^{\prime}\left(x_1\right)\right|<\varepsilon$, it follows that $|f(x+1)-f(x)|<\varepsilon$, as required.

\end{proof}


theorem exercise_5_7
  {f g : ℝ → ℝ} {x : ℝ}
  (hf' : differentiable_at ℝ f 0)
  (hg' : differentiable_at ℝ g 0)
  (hg'_ne_0 : deriv g 0 ≠ 0)
  (f0 : f 0 = 0) (g0 : g 0 = 0) :
  tendsto (λ x, f x / g x) (𝓝 x) (𝓝 (deriv f x / deriv g x)) :=

Suppose $f^{\prime}(x), g^{\prime}(x)$ exist, $g^{\prime}(x) \neq 0$, and $f(x)=g(x)=0$. Prove that $\lim _{t \rightarrow x} \frac{f(t)}{g(t)}=\frac{f^{\prime}(x)}{g^{\prime}(x)}.$

\begin{proof}

    Since $f(x)=g(x)=0$, we have

$$

\begin{aligned}

\lim _{t \rightarrow x} \frac{f(t)}{g(t)} &=\lim _{t \rightarrow x} \frac{\frac{f(t)-f(x)}{t-x}}{\frac{g(t)-g(x)}{t-x}} \\

&=\frac{\lim _{t \rightarrow x} \frac{f(t)-f(x)}{t-x}}{\lim _{t \rightarrow x} \frac{g(t)-g(x)}{t-x}} \\

&=\frac{f^{\prime}(x)}{g^{\prime}(x)}

\end{aligned}

$$

\end{proof}


theorem exercise_5_17
  {f : ℝ → ℝ}
  (hf' : differentiable_on ℝ f (set.Icc (-1) 1))
  (hf'' : differentiable_on ℝ (deriv f) (set.Icc 1 1))
  (hf''' : differentiable_on ℝ (deriv (deriv f)) (set.Icc 1 1))
  (hf0 : f (-1) = 0)
  (hf1 : f 0 = 0)
  (hf2 : f 1 = 1)
  (hf3 : deriv f 0 = 0) :
  ∃ x, x ∈ set.Ioo (-1 : ℝ) 1 ∧ deriv (deriv (deriv f)) x ≥ 3 :=

Suppose $f$ is a real, three times differentiable function on $[-1,1]$, such that $f(-1)=0, \quad f(0)=0, \quad f(1)=1, \quad f^{\prime}(0)=0 .$ Prove that $f^{(3)}(x) \geq 3$ for some $x \in(-1,1)$.

\begin{proof}

    Following the hint, we observe that Theorem $5.15$ (Taylor's formula with remainder) implies that

$$

\begin{aligned}

f(1) &=f(0)+f^{\prime}(0)+\frac{1}{2} f^{\prime \prime}(0)+\frac{1}{6} f^{(3)}(s) \\

f(-1) &=f(0)-f^{\prime}(0)+\frac{1}{2} f^{\prime \prime}(0)-\frac{1}{6} f^{(3)}(t)

\end{aligned}

$$

for some $s \in(0,1), t \in(-1,0)$. By subtracting the second equation from the first and using the given values of $f(1), f(-1)$, and $f^{\prime}(0)$, we obtain

$$

1=\frac{1}{6}\left(f^{(3)}(s)+f^{(3)}(t)\right),

$$

which is the desired result. Note that we made no use of the hypothesis $f(0)=0$.

\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] [compact_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}


theorem exercise_31_3 {α : Type*} [partial_order α]
  [topological_space α] (h : order_topology α) : regular_space α :=

Show that every order topology is regular.

\begin{proof}

    Let $X$ be an ordered set.

First we show that $X$ is a $T_1$-space. For $x \in X$ we have that

$$

X \backslash\{x\}=\langle-\infty, x\rangle \cup\langle x,+\infty\rangle

$$

which is an open set as an union of two open intervals. Therefore, the set $\{x\}$ is closed.

Step 2

2 of 3

Now to prove that $X$ is regular we use Lemma $\mathbf{3 1 . 1 .}$

Let $x \in X$ be any point and $U \subseteq X$ any open neighborhood of $x$. Then there exist $a, b \in X$ such that $x \in\langle a, b\rangle \subseteq U$. Now we have four possibilities.

1. If there exist $x_1, x_2 \in U$ such that $a<x_1<x<x_2<b$, then

$$

x \in\left\langle x_1, x_2\right\rangle \subseteq \overline{\left\langle x_1, x_2\right\rangle} \subseteq\left[x_1, x_2\right] \subseteq\langle a, b\rangle \subseteq U

$$

2. If there exists $x_1 \in U$ such that $a<x_1<x$, but there's no $x_2 \in U$ such that $x<x_2<b$, then

$$

x \in\left\langle x_1, b\right\rangle=\left(x_1, x\right] \subseteq \overline{\left(x_1, x\right]} \subseteq\left[x_1, x\right] \subseteq\langle a, b\rangle \subseteq U

$$

3. If there exists $x_2 \in U$ such that $x<x_2<b$, but there's no $x_1 \in U$ such that $a<x_1<x$, then

$$

x \in\left\langle a, x_2\right\rangle=\left[x, x_2\right) \subseteq \overline{\left[x, x_2\right)} \subseteq\left[x, x_2\right] \subseteq\langle a, b\rangle \subseteq U

$$

4. If there's no $x_1 \in U$ such that $a<x_1<x$ and no $x_2 \in U$ such that $x<x_2<b$, then

$$

x \in\langle a, b\rangle=\{x\}=\overline{\{x\}}=\{x\} \subseteq U

$$

We have that $\overline{\{x\}}=\{x\}$ because $X$ is a $T_1$-space.

In all four cases we proved that there exists an open interval $V$ such that $x \in V \subseteq \bar{V} \subseteq U$, so $X$ is regular.

\end{proof}


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

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

\begin{proof}

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

Let $x, y \in X_\alpha$ be any points such that $x \neq y$. Since all $X_\beta$ are nonempty, there exist points $\mathbf{x}, \mathbf{y} \in X$ such that $x_\beta=y_\beta$ for every $\beta \neq \alpha$ and $x_\alpha=x, y_\alpha=y$.

Since $x \neq y$, it follows that $\mathbf{x} \neq \mathbf{y}$. Since $X$ is Hausdorff, there exist open disjoint sets $U, V \subseteq X$ such that $\mathbf{x} \in U$ and $\mathbf{y} \in V$.

For $\beta \neq \alpha$ we have that $x_\beta=y_\beta \in \pi_\beta(U) \cap \pi_\beta(V)$, hence $\pi_\beta(U)$ and $\pi_\beta(V)$ are not disjoint.

Since $U$ and $V$ are disjoint, it follows that $\pi_\alpha(U) \cap \pi_\alpha(V)=\emptyset$.

We also have that $x \in \pi_\alpha(U)$ and $y \in \pi_\alpha(V)$ and since the projections are open maps, it follows that the sets $\pi_\alpha(U)$ and $\pi_\alpha(V)$ are open.

This proves that $x$ and $y$ can be separated by open sets, so $X_\alpha$ is Hausdorff.

\end{proof}


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

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

\begin{proof}

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

Since $X$ is normal, it follows that $X$ is Hausdorff (or regular), which then implies that $X_\alpha$ is Hausdorff (or regular). This imples that $X_\alpha$ satisfies the $T_1$ axiom.

Now the proof that $X_\alpha$ satisfies the $T_4$ axiom is the same as for regular spaces.

If $F, G \subseteq X_\alpha$ are disjoint closed sets, then $\prod_\beta F_\beta$ and $\prod_\beta G_\beta$, where $F_\alpha=F, G_\alpha=G$ and $F_\beta=G_\beta=X_\beta$ for $\beta \neq \alpha$, are disjoint closed sets in $X$.

Since $X$ is normal (and therefore satisfies the $T_4$ axiom), there exist disjoint open sets $U, V \subseteq X$ such that $\prod_\beta F_\beta \subseteq U$ and $\prod_\beta G_\beta \subseteq V$

Then $\pi_\alpha(U)$ and $\pi_\alpha(V)$ are disjoint open sets in $X_\alpha$ such that $F \subseteq \pi_\alpha(U)$ and $G \subseteq \pi_\alpha(V)$.

\end{proof}


theorem exercise_33_7 {X : Type*} [topological_space X]
  (hX : locally_compact_space X) (hX' : t2_space X) :
  ∀ x A, is_closed A ∧ ¬ x ∈ A →
  ∃ (f : X → I), continuous f ∧ f x = 1 ∧ f '' A = {0}
  :=

Show that every locally compact Hausdorff space is completely regular.

\begin{proof}

    $X$ is a subspace of a compact Hausdorff space $Y$, its one-point compactification. $Y$ is normal, and so by the Urysohn lemma $Y$ is completely regular. Therefore by corollary $X$ is completely regular.

\end{proof}


theorem exercise_34_9
  (X : Type*) [topological_space X] [compact_space X]
  (X1 X2 : set X) (hX1 : is_closed X1) (hX2 : is_closed X2)
  (hX : X1 ∪ X2 = univ) (hX1m : metrizable_space X1)
  (hX2m : metrizable_space X2) : metrizable_space X :=

Let $X$ be a compact Hausdorff space that is the union of the closed subspaces $X_1$ and $X_2$. If $X_1$ and $X_2$ are metrizable, show that $X$ is metrizable.

\begin{proof}

    Both $X_1$ and $X_2$ are compact, Hausdorff and metrizable, so by exercise 3 they are second countable, i.e. there are countable bases $\left\{U_{i, n} \subset X_i \mid n \in \mathbb{N}\right\}$ for $i \in\{1,2\}$. By the same exercise it is enough to show that $X$ is second countable. If $X_1 \cap X_2=\emptyset$ both $X_1$ and $X_2$ are open and the union $\left\{U_{i, n} \mid i \in\{1,2\} ; n \in \mathbb{N}\right\}$ of their countable bases form a countable base for $X$.

Suppose now $X_1 \cap X_2 \neq \emptyset$. Let $x \in X$ and $U \subset X$ be an open neighborhood of $x$. If $x \in X_i-X_j=X-$ $X_j$ then $U \cap X_i$ is open in $X_i$ and there is a basis neighborhood $U_{i, n}$ of $x$ such that $x \in U_{i, n} \cap X-X_j$ is an open neighborhood of $x$ in the open subset $X-X_j$, so $U_{i, n} \cap X-X_j$ is also open in $X$.

Suppose now that $x \in X_1 \cap X_2$. We have that $U \cap X_i$ is open in $X_i$ so there is a basis neighborhood $U_{i, n_i}$ contained in $U \cap X_i$. By definition of sub-space topology there is some open subset $V_{i, n_i} \subset X$ such that $U_{i, n_i}=$ $X_i \cap V_{i, n_i}$. Then

$$

x \in V_{1, n_1} \cap V_{2, n_2}=\left(V_{1, n_1} \cap V_{2, n_2} \cap X_1\right) \cup\left(V_{1, n_1} \cap V_{2, n_2} \cap X_2\right)=\left(U_{1, n_1} \cap V_{2, n_2}\right) \cup\left(V_{1, n_1} \cap U_{2, n_2}\right) \subset U

$$

Therefore the open subsets $U_{i, n} \cap X-X_j$ and $V_{1, n_1} \cap V_{2, n_2}$ form a countable base for $X$.

\end{proof}


theorem exercise_43_2 {X : Type*} [metric_space X]
  {Y : Type*} [metric_space Y] [complete_space Y] (A : set X)
  (f : X → Y) (hf : uniform_continuous_on f A) :
  ∃! (g : X → Y), continuous_on g (closure A) ∧
  uniform_continuous_on g (closure A) ∧ ∀ (x : A), g x = f x :=

Let $(X, d_X)$ and $(Y, d_Y)$ be metric spaces; let $Y$ be complete. Let $A \subset X$. Show that if $f \colon A \rightarrow Y$ is uniformly continuous, then $f$ can be uniquely extended to a continuous function $g \colon \bar{A} \rightarrow Y$, and $g$ is uniformly continuous.

\begin{proof}

    Let $\left(X, d_X\right)$ and $\left(Y, d_Y\right)$ be metric spaces; let $Y$ be complete. Let $A \subset X$. It is also given that $f: A \longrightarrow X$ is a uniformly continuous function. Then we have to show that $f$ can be uniquely extended to a continuous function $g: \bar{A} \longrightarrow Y$, and $g$ is uniformly coninuous.

We define the function $g$ as follows:

$$

g(x)= \begin{cases}f(x) & \text { if } x \in A \\ \lim _{n \rightarrow \infty} f\left(x_n\right) & \text { if } x \in \bar{A},\end{cases}

$$

where $\left\{x_n\right\} \subset A$ is some sequence in $A$ such that $\lim _{n \rightarrow \infty} x_n=x$. Now we have to check that the above definition is well defined. We first note that since $\left\{x_n\right\} \subset A$ is convergent in $X,\left\{x_n\right\}$ is Cauchy in $A$ and since $f$ is uniformly continuous on $A,\left\{f\left(x_n\right)\right\}$ is Cauchy in $Y$. Further, since $Y$ is complete $\left\{f\left(x_n\right)\right\}$ is convergent. So let us now consider two sequences $\left\{x_n\right\}$ and $\left\{y_n\right\}$ such that $\lim _{n \rightarrow \infty} x_n=\lim _{n \rightarrow \infty} y_n=x$. Then we need to prove that $\lim _{n \rightarrow \infty} f\left(x_n\right)=\lim _{n \rightarrow \infty} f\left(y_n\right)=f(x)$. Let

$$

\lim _{n \rightarrow \infty} f\left(x_n\right)=a \text { and } b=\lim _{n \rightarrow \infty} f\left(y_n\right)

$$

Now since $f$ is uniformly continuous for any given $\epsilon>0$ there exists $\delta>0$ such that

$$

d_Y(f(x), f(y))<\epsilon \text { whenever } d_X(x, y)<\delta \text { and } x, y \in A

$$

So for this $\delta>0$ there exists $N \in \mathbb{N}$ such that

$$

d_X\left(x_n, x\right)<\frac{\delta}{2} \text { and } d_X\left(y_n, x\right)<\frac{\delta}{2}, \text { foe all } n \geq N .

$$

Therefore, we have that for all $n \geq N$,

$$

d_X\left(x_n, y_n\right)<\delta

$$

Thus the equation (1) yields us that

$$

d_Y\left(f\left(x_n\right), f\left(y_n\right)\right)<\epsilon \text { for all } n \geq N .

$$

Now since $\lim _{n \rightarrow \infty} f\left(x_n\right)=a$ and $b=\lim _{n \rightarrow \infty} f\left(y_n\right)$, so for the above $\epsilon>0$ we have a natural number $K \geq N$ such that

$$

\begin{gathered}

d_Y\left(f\left(x_n\right), a\right)<\epsilon \text { for all } n \geq K \text { and } \\

d_Y\left(f\left(y_n\right), b\right)<\epsilon \text { for all } n \geq K .

\end{gathered}

$$

Moreover, since $K \geq N$, from $(2)$ we get

$$

d_Y\left(f\left(x_n\right), f\left(y_n\right)\right)<\epsilon \text { for all } n \geq K .

$$

Now we calculate the following, for $n \geq K$,

$$

\begin{array}{rlr}

d_Y(a, b) & \leq & d_Y\left(a, f\left(x_n\right)\right)+d_Y\left(f\left(x_n\right), f\left(y_n\right)\right)+d\left(f\left(y_n\right), b\right) \\

& < & \epsilon+\epsilon+\epsilon \text { by }(3),(4) \text { and }(5) \\

& = & 3 \epsilon

\end{array}

$$

where the first inequality holds because of triangular inequality. Since $\epsilon>0$ is arbitrary the above calculation shows that $d_Y(a, b)=0$. Thus, the above definition is independent of the choice of the sequence $\left\{x_n\right\}$ and hence the map $g$ is well defined. Moreover, from the construction it follows that $g$ is continuous on $\bar{A}$.

Moreover, we observe that $g$ is unique extension of $f$ by the construction.

So it remains to show that $g$ is uniformly continuous. In order to that we take a Cauchy sequence $\left\{a_n\right\} \subset \bar{A}$. Then since $\bar{A}$ is a closed set so the sequence $\left\{a_n\right\}$ is convergent and hence $\left\{g\left(a_n\right)\right\}$ is also a convergent sequence as $g$ is continuous on $\bar{A}$. So $\left\{g\left(a_n\right)\right\}$ is a Cauchy sequence in $Y$. Since a function is uniformly continuous if and only if it sends Cauchy sequences to Cauchy sequences, we conclude that $g$ is uniformly continuous.

\end{proof}


theorem exercise_1_2 :
  (⟨-1/2, real.sqrt 3 / 2⟩ : ℂ) ^ 3 = -1 :=

import .common

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

open_locale big_operators

Show that $\frac{-1 + \sqrt{3}i}{2}$ is a cube root of 1 (meaning that its cube equals 1).

\begin{proof}

$$

\left(\frac{-1+\sqrt{3} i}{2}\right)^2=\frac{-1-\sqrt{3} i}{2},

$$

hence

$$

\left(\frac{-1+\sqrt{3} i}{2}\right)^3=\frac{-1-\sqrt{3} i}{2} \cdot \frac{-1+\sqrt{3} i}{2}=1

$$

This means $\frac{-1+\sqrt{3} i}{2}$ is a cube root of 1.

\end{proof}


theorem exercise_1_4 {F V : Type*} [add_comm_group V] [field F]
  [module F V] (v : V) (a : F): a • v = 0 ↔ a = 0 ∨ v = 0 :=

Prove that if $a \in \mathbf{F}$, $v \in V$, and $av = 0$, then $a = 0$ or $v = 0$.

\begin{proof}

    If $a=0$, then we immediately have our result. So suppose $a \neq 0$. Then, because $a$ is some nonzero real or complex number, it has a multiplicative inverse $\frac{1}{a}$. Now suppose that $v$ is some vector such that

$$

a v=0

$$

Multiply by $\frac{1}{a}$ on both sides of this equation to get

$$

\begin{aligned}

\frac{1}{a}(a v) & =\frac{1}{a} 0 & & \\

\frac{1}{a}(a v) & =0 & & \\

\left(\frac{1}{a} \cdot a\right) v & =0 & & \text { (associativity) } \\

1 v & =0 & & \text { (definition of } 1/a) \\

v & =0 & & \text { (multiplicative identity) }

\end{aligned}

$$

Hence either $a=0$ or, if $a \neq 0$, then $v=0$.

\end{proof}


theorem exercise_1_7 : ∃ U : set (ℝ × ℝ),
  (U ≠ ∅) ∧
  (∀ (c : ℝ) (u : ℝ × ℝ), u ∈ U → c • u ∈ U) ∧
  (∀ U' : submodule ℝ (ℝ × ℝ), U ≠ ↑U') :=

Give an example of a nonempty subset $U$ of $\mathbf{R}^2$ such that $U$ is closed under scalar multiplication, but $U$ is not a subspace of $\mathbf{R}^2$.

\begin{proof}

$$

U=\left\{(x, y) \in \mathbf{R}^2:|x|=|y|\right\}

$$

For $(x, y) \in U$ and $\lambda \in \mathbb{R}$, it follows $\lambda(x, y)=$ $(\lambda x, \lambda y)$, so $|\lambda x|=|\lambda||x|=|\lambda||y|=|\lambda y|$. Therefore, $\lambda(x, y) \in U$.

On the other hand, consider $a=(1,-1), b=$ $(1,1) \in U$. Then, $a+b=(1,-1)+(1,1)=$ $(2,0) \notin U$. So, $U$ is not a subspace of $\mathbb{R}^2$.

\end{proof}


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):=

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_30 {n : ℕ} :
  ¬ ∃ a : ℤ, ∑ (i : fin n), (1 : ℚ) / (n+2) = a :=

import .common

open set function nat int fintype real polynomial mv_polynomial
open zsqrtd gaussian_int char_p nat.arithmetic_function

open_locale big_operators
noncomputable theory

Prove that $\frac{1}{2}+\frac{1}{3}+\cdots+\frac{1}{n}$ is not an integer.

\begin{proof}

Let $2^s$ be the largest power of 2 occuring as a denominator in $H_n$, say $2^s=k \leqslant n$. Write $H_n=$ $\frac{1}{2^s}+\left(1+1 / 2+\ldots+1 /(k-1)+1 /(k+1)+\ldots+1 / n\right.$. The sum in parentheses can be written as $1 / 2^{s-1}$ times sum of fractions with odd denominators, so the denominator of the sum in parentheses will not be divisible by $2^s$, but it must equal $2^s$ by Ex $1.29$.

\end{proof}


theorem exercise_2_4 {a : ℤ} (ha : a ≠ 0)
  (f_a :=

If $a$ is a nonzero integer, then for $n>m$ show that $\left(a^{2^{n}}+1, a^{2^{m}}+1\right)=1$ or 2 depending on whether $a$ is odd or even.

\begin{proof}

\begin{align*}

\operatorname{ord}_p\, n!  &= \sum_{k\geq 1} \left \lfloor \frac{n}{p^{k}}\right \rfloor \leq  \sum_{k\geq 1}  \frac{n}{p^{k}} = \frac{n}{p} \frac{1}{1 - \frac{1}{p}} = \frac{n}{p-1}

\end{align*}

The decomposition of $n!$ in prime factors is

$n! = p_1^{\alpha_1}p_2^{\alpha_2}\cdots p_k^{\alpha_k}$

where $\alpha_i = \operatorname{ord}_{p_i}\, n! \leq \frac{n}{p_i-1}$, and $p_i \leq n, \ i=1,2,\cdots,k$.

Then

\begin{align*}

n! &\leq p_1^{\frac{n}{p_1-1}}p_2^{\frac{n}{p_2-1}}\cdots p_k^{\frac{n}{p_n-1}}\\

\sqrt[n]{n!} &\leq p_1^{\frac{1}{p_1-1}}p_2^{\frac{1}{p_2-1}}\cdots p_k^{\frac{1}{p_n-1}}\\

&\leq \prod_{p\leq n} p^{\frac{1}{p-1}}

\end{align*}

(the values of $p$ in this product describe all prime numbers $p\leq n$.)

\end{proof}


theorem exercise_2_27a :
  ¬ summable (λ i : {p : ℤ // squarefree p}, (1 : ℚ) / i) :=

Show that $\sum^{\prime} 1 / n$, the sum being over square free integers, diverges.

\begin{proof}

Let $S \subset \mathbb{N}^*$ the set of square free integers.

Let $N \in \mathbb{N}^*$. Every integer $n, \, 1\leq n \leq N$ can be written as $n = a b^2$, where $a,b$ are integers and $a$ is square free. Then $1\leq a \leq N$, and $1\leq b \leq \sqrt{N}$, so

$$\sum_{n\leq N} \frac{1}{n} \leq \sum_{a \in S, a\leq N}\  \sum_{1\leq b \leq \sqrt{N}} \frac{1}{ab^2} \leq  \sum_{a \in S, a\leq N}\ \frac{1}{a} \, \sum_{b=1}^\infty  \frac{1}{b^2} = \frac{\pi^2}{6} \sum_{a \in S, a\leq N}\ \frac{1}{a}.$$

So $$\sum_{a \in S, a\leq N} \frac{1}{a}  \geq \frac{6}{\pi^2} \sum_{n\leq N} \frac{1}{n}.$$

As $\sum_{n=1}^\infty \frac{1}{n}$ diverges, $\lim\limits_{N \to \infty} \sum\limits_{a \in S, a\leq N} \frac{1}{a} = +\infty$, so the family $\left(\frac{1}{a}\right)_{a\in S}$ of the inverse of square free integers is not summable.

Let $S_N = \prod_{p<N}(1+1/p)$ , and $p_1,p_2,\ldots, p_l\ (l = l(N))$ all prime integers less than $N$. Then

\begin{align*}

S_N &= \left(1+\frac{1}{p_1}\right) \cdots \left(1+\frac{1}{p_l}\right)\\

&=\sum_{(\varepsilon_1,\cdots,\varepsilon_l) \in \{0,1\}^l } \frac{1}{p_1^{\varepsilon_1} \cdots p_l^{\varepsilon_l}}

\end{align*}

We prove this last formula  by induction. This is true for $l=1$ : $\sum_{\varepsilon \in \{0,1\}} 1/p_1^\varepsilon = 1 + 1/p_1$.

If it is true for the integer $l$, then

\begin{align*}

\left(1+\frac{1}{p_1}\right) \cdots \left(1+\frac{1}{p_l}\right)\left(1+\frac{1}{p_{l+1}}\right) &= \sum_{(\varepsilon_1,\ldots,\varepsilon_l) \in \{0,1\}^l } \frac{1}{p_1^{\varepsilon_1} \cdots p_l^{\varepsilon_l}} \left(1+\frac{1}{p_{l+1}}\right)\\

&=\sum_{(\varepsilon_1,\ldots,\varepsilon_l) \in \{0,1\}^l } \frac{1}{p_1^{\varepsilon_1} \cdots p_l^{\varepsilon_l}} + \sum_{(\varepsilon_1,\ldots,\varepsilon_l) \in \{0,1\}^l } \frac{1}{p_1^{\varepsilon_1} \cdots p_l^{\varepsilon_l}p_{l+1}}\\

&=\sum_{(\varepsilon_1,\ldots,\varepsilon_l,\varepsilon_{l+1}) \in \{0,1\}^{l+1} } \frac{1}{p_1^{\varepsilon_1} \cdots p_l^{\varepsilon_l}p_{l+1}^{\varepsilon_{l+1}}}

\end{align*}

So it is true for all $l$.

Thus $S_N = \sum_{n\in \Delta} \frac{1}{n}$, where $\Delta$ is the set of square free integers whose prime factors are less than $N$.

As $\sum 1/n$, the sum being over square free integers, diverges, $\lim\limits_{N\to \infty} S_N = + \infty$ :

$$\lim_{N \to \infty} \prod_{p<N} \left(1+\frac{1}{p}\right) = +\infty.$$

 $e^x \geq 1+x, x \geq \log (1+x)$ for $x>0$, so

$$\log S_N = \sum_{k=1}^{l(N)} \log\left(1+\frac{1}{p_k}\right) \leq \sum_{k=1}^{l(N)} \frac{1}{p_k}.$$

$\lim\limits_{N\to \infty} \log S_N = +\infty$ and $\lim\limits_{N\to \infty} l(N) = +\infty$, so

$$\lim_{N\to \infty} \sum_{p<N} \frac{1}{p} = +\infty.$$

\end{proof}


theorem exercise_3_4 : ¬ ∃ x y : ℤ, 3*x^2 + 2 = y^2 :=

Show that the equation $3 x^{2}+2=y^{2}$ has no solution in integers.

\begin{proof}

If $3x^2+2 = y^2$, then  $\overline{y}^2 = \overline{2}$ in $\mathbb{Z}/3\mathbb{Z}$.

As $\{-1,0,1\}$ is a complete set of residues modulo $3$, the squares in $\mathbb{Z}/3\mathbb{Z}$ are $\overline{0} = \overline{0}^2$ and  $\overline{1} = \overline{1}^2 = (\overline{-1})^2$, so $\overline{2}$ is not a square in $\mathbb{Z}/3\mathbb{Z}$ : $\overline{y}^2 = \overline{2}$ is impossible in $\mathbb{Z}/3\mathbb{Z}$.

Thus $3x^2+2 = y^2$ has no solution in integers.

\end{proof}


theorem exercise_3_10 {n : ℕ} (hn0 : ¬ n.prime) (hn1 : n ≠ 4) :
  factorial (n-1) ≡ 0 [MOD n] :=

If $n$ is not a prime, show that $(n-1) ! \equiv 0(n)$, except when $n=4$.

\begin{proof}

Suppose that $n >1$ is not a prime. Then $n = uv$, where $2 \leq u \leq v \leq n-1$.

$\bullet$ If $u \neq v$, then $n = uv \mid (n-1)! = 1\times 2 \times\cdots \times u \times\cdots \times v \times \cdots \times (n-1)$ (even if $u\wedge v \neq 1$ !).

$\bullet$ If $u=v$, $n = u^2$ is a square.

If $u$ is not prime, $u =st,\ 2\leq s \leq t \leq u-1 \leq n-1$, and $n = u' v'$, where $u' =s,v' =st^2$ verify  $2 \leq u' < v' \leq n-1$. As in the first case, $n = u'v' \mid (n-1)!$.

If $u = p$ is a prime, then $n =p^2$.

In the case $p = 2$, $n = 4$ and $n=4  \nmid (n-1)! = 6$. In the other case $p >2$, and $(n-1)! = (p^2 - 1)!$ contains the factors $p < 2p < p^2$, so $p^2 \mid (p^2-1)!, n \mid (n-1)!$.

Conclusion : if $n$ is not a prime, $(n - 1)! \equiv 0 \pmod n$, except when $n=4$.

\end{proof}


theorem exercise_4_4 {p t: ℕ} (hp0 : p.prime) (hp1 : p = 4*t + 1)
  (a : zmod p) :
  is_primitive_root a p ↔ is_primitive_root (-a) p :=

Consider a prime $p$ of the form $4 t+1$. Show that $a$ is a primitive root modulo $p$ iff $-a$ is a primitive root modulo $p$.

\begin{proof}

    Suppose that $a$ is a primitive root modulo $p$. As $p-1$ is even, $(-a)^{p-1}=a^{p-1} \equiv 1$ $(\bmod p)$

If $(-a)^n \equiv 1(\bmod p)$, with $n \in \mathbb{N}$, then $a^n \equiv(-1)^n(\bmod p)$.

Therefore $a^{2 n} \equiv 1(\bmod p)$. As $a$ is a primitive root modulo $p, p-1|2 n, 2 t| n$, so $n$ is even.

Hence $a^n \equiv 1(\bmod p)$, and $p-1 \mid n$. So the least $n \in \mathbb{N}^*$ such that $(-a)^n \equiv 1$ $(\bmod p)$ is $p-1:$ the order of $-a$ modulo $p$ is $p-1,-a$ is a primitive root modulo $p$. Conversely, if $-a$ is a primitive root modulo $p$, we apply the previous result at $-a$ to to obtain that $-(-a)=a$ is a primitive root.

\end{proof}


theorem exercise_4_6 {p n : ℕ} (hp : p.prime) (hpn : p = 2^n + 1) :
  is_primitive_root 3 p :=

If $p=2^{n}+1$ is a Fermat prime, show that 3 is a primitive root modulo $p$.

\begin{proof}

 \newcommand{\legendre}[2]{\genfrac{(}{)}{}{}{#1}{#2}}

Write $p = 2^k + 1$, with $k = 2^n$.

We suppose that $n>0$, so $k\geq 2, p \geq 5$. As $p$ is prime, $3^{p-1} \equiv 1 \pmod p$.

In other words, $3^{2^k} \equiv 1 \pmod p$ : the order of $3$ is a divisor of $2^k$, a power of $2$.

$3$ has order $2^k$ modulo $p$ iff $3^{2^{k-1}} \not \equiv 1 \pmod p$. As $\left (3^{2^{k-1}} \right)^2 \equiv 1 \pmod p$, where $p$ is prime, this is equivalent to $3^{2^{k-1}}  \equiv -1 \pmod p$, which remains to prove.

$3^{2^{k-1}} = 3^{(p-1)/2} \equiv \legendre{3}{p} \pmod p$.

As the result is true for $p=5$, we can suppose $n\geq 2$.

From the law of quadratic reciprocity :

$$\legendre{3}{p} \legendre{p}{3} = (-1)^{(p-1)/2} = (-1)^{2^{k-1}} = 1.$$

So $\legendre{3}{p} = \legendre{p}{3}$

\begin{align*}

p = 2^{2^n}+1 &\equiv (-1)^{2^n} + 1 \pmod 3\\

&\equiv 2 \equiv -1 \pmod 3,

\end{align*}

so $\legendre{3}{p} = \legendre {p}{3} = -1$, that is to say

$$3^{2^{k-1}}  \equiv -1 \pmod p.$$

The order of $3$ modulo $p = 2^{2^n} + 1$ is $p-1 = 2^{2^n}$ : $3$ is a primitive root modulo $p$.

(On the other hand, if $3$ is of order $p-1$ modulo $p$, then $p$ is prime, so

$$ F_n = 2^{2^n} + 1 \ \mathrm{is}\ \mathrm{prime}\ \iff 3^{(F_n-1)/2} = 3^{2^{2^n - 1}} \equiv -1 \pmod {F_n}.)$$

\end{proof}


theorem exercise_4_11 {p : ℕ} (hp : p.prime) (k s: ℕ)
  (s :=

Prove that $1^{k}+2^{k}+\cdots+(p-1)^{k} \equiv 0(p)$ if $p-1 \nmid k$ and $-1(p)$ if $p-1 \mid k$.

\begin{proof}

Let $S_k = 1^k+2^k+\cdots+(p-1)^k$.

Let $g$ a primitive root modulo $p$ : $\overline{g}$ a generator of $\mathbb{F}_p^*$.

As $(\overline{1},\overline{g},\overline{g}^{2}, \ldots, \overline{g}^{p-2}) $ is a permutation of $ (\overline{1},\overline{2}, \ldots,\overline{p-1})$,

\begin{align*}

\overline{S_k} &= \overline{1}^k + \overline{2}^k+\cdots+ \overline{p-1}^k\\

&= \sum_{i=0}^{p-2} \overline{g}^{ki} =

\left\{

\begin{array}{ccc}

\overline{ p-1} = -\overline{1} &  \mathrm{if} &  p-1 \mid k  \\

 \frac{ \overline{g}^{(p-1)k} -1}{ \overline{g}^k -1} = \overline{0}&  \mathrm{if}  &   p-1 \nmid k

\end{array}

\right.

\end{align*}

since $p-1 \mid k \iff \overline{g}^k = \overline{1}$.

Conclusion :

\begin{align*}

1^k+2^k+\cdots+(p-1)^k&\equiv 0 \pmod p\ \mathrm{if} \ p-1 \nmid k\\

1^k+2^k+\cdots+(p-1)^k&\equiv -1 \pmod p\ \mathrm{if} \ p-1 \mid k\\

\end{align*}

\end{proof}


theorem exercise_5_28 {p : ℕ} (hp : p.prime) (hp1 : p ≡ 1 [MOD 4]):
  ∃ x, x^4 ≡ 2 [MOD p] ↔ ∃ A B, p = A^2 + 64*B^2 :=

Show that $x^{4} \equiv 2(p)$ has a solution for $p \equiv 1(4)$ iff $p$ is of the form $A^{2}+64 B^{2}$.

\begin{proof}

If  $p\equiv 1\ [4]$ and if there exists $x \in \mathbb{Z}$ such that $x^4 \equiv 2\ [p]$, then

$$2^{\frac{p-1}{4} }\equiv  x^{p-1} \equiv 1 \ [p].$$

From Ex. 5.27, where $p = a^2 +b^2, a$ odd,  we know that $$f^{\frac{ab}{2}} \equiv 2^{\frac{p-1}{4} } \equiv 1 \ [p].$$

Since $f^2 \equiv -1\ [p]$, the order of $f$ modulo $p$ is 4, thus $4 \mid \frac{ab}{2}$, so $8\mid ab$.

As $a$ is odd, $8 | b$, then $p = A^2 + 64 B^2$ (with $A = a, B = b/8$).

\bigskip

Conversely, if $p=A^2+64 B^2$, then $p\equiv A^2 \equiv 1 \ [4]$.

Let $a=A,b=8B$. Then $$2^{\frac{p-1}{4} } \equiv f^{\frac{ab}{2}} \equiv f^{4AB} \equiv (-1)^{2AB} \equiv 1 \ [p].$$

As $2^{\frac{p-1}{4} } \equiv 1 \ [p]$, $x^4 \equiv 2 \ [p]$ has a solution in $\mathbb{Z}$ (Prop. 4.2.1) : $2$ is a biquadratic residue modulo $p$.

Conclusion :

$$\exists A \in \mathbb{Z}, \exists B \in \mathbb{Z}\,, p = A^2+64 B^2 \iff( p\equiv 1 \ [4] \ \mathrm{and} \ \exists x \in \mathbb{Z}, \, x^4 \equiv 2 \ [p]).$$

\end{proof}


theorem exercise_12_12 : is_algebraic ℚ (sin (real.pi/12)) :=

Show that $\sin (\pi / 12)$ is an algebraic number.

\begin{proof}

$$

\begin{aligned}

    \sin \pi/12=\sin \left(\pi/4-\pi/6\right) & =\sin \pi/4 \cos \pi/6-\cos \pi/4 \sin \pi/6 \\

& =\frac{\sqrt{3}}{2 \sqrt{2}}-\frac{1}{2 \sqrt{2}} \\

& =\frac{\sqrt{3}-1}{2 \sqrt{2}}

\end{aligned}

$$

\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}