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]
  (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_3 {F V : Type*} [add_comm_group V] [field F]
  [module F V] {v : V} : -(-v) = v :=

import .common

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

open_locale big_operators

Prove that $-(-v) = v$ for every $v \in V$.

\begin{proof}

    By definition, we have

$$

(-v)+(-(-v))=0 \quad \text { and } \quad v+(-v)=0 .

$$

This implies both $v$ and $-(-v)$ are additive inverses of $-v$, by the uniqueness of additive inverse, it follows that $-(-v)=v$.

\end{proof}


theorem exercise_1_6 : ∃ U : set (ℝ × ℝ),
  (U ≠ ∅) ∧
  (∀ (u v : ℝ × ℝ), u ∈ U ∧ v ∈ U → u + v ∈ U) ∧
  (∀ (u : ℝ × ℝ), u ∈ U → -u ∈ U) ∧
  (∀ U' : submodule ℝ (ℝ × ℝ), U ≠ ↑U') :=

Give an example of a nonempty subset $U$ of $\mathbf{R}^2$ such that $U$ is closed under addition and under taking additive inverses (meaning $-u \in U$ whenever $u \in U$), but $U$ is not a subspace of $\mathbf{R}^2$.

\begin{proof}

    \[U=\mathbb{Z}^2=\left\{(x, y) \in \mathbf{R}^2: x, y \text { are integers }\right\}\]

$U=\mathbb{Z}^2$ satisfies the desired properties. To come up with this, note by assumption, $U$ must be closed under addition and subtraction, so in particular, it must contain 0 . We need to find a set which fails scalar multiplication. A discrete set like $\mathbb{Z}^2$ does this.

\end{proof}


theorem exercise_1_8 {F V : Type*} [add_comm_group V] [field F]
  [module F V] {ι : Type*} (u : ι → submodule F V) :
  ∃ U : submodule F V, (⋂ (i : ι), (u i).carrier) = ↑U :=

Prove that the intersection of any collection of subspaces of $V$ is a subspace of $V$.

\begin{proof}

Let $V_1, V_2, \ldots, V_n$ be subspaces of the vector space $V$ over the field $F$. We must show that their intersection $V_1 \cap V_2 \cap \ldots \cap V_n$ is also a subspace of $V$.

To begin, we observe that the additive identity $0$ of $V$ is in $V_1 \cap V_2 \cap \ldots \cap V_n$. This is because $0$ is in each subspace $V_i$, as they are subspaces and hence contain the additive identity.

Next, we show that the intersection of subspaces is closed under addition. Let $u$ and $v$ be vectors in $V_1 \cap V_2 \cap \ldots \cap V_n$. By definition, $u$ and $v$ belong to each of the subspaces $V_i$. Since each $V_i$ is a subspace and therefore closed under addition, it follows that $u+v$ belongs to each $V_i$. Thus, $u+v$ belongs to the intersection $V_1 \cap V_2 \cap \ldots \cap V_n$.

Finally, we show that the intersection of subspaces is closed under scalar multiplication. Let $a$ be a scalar in $F$ and let $v$ be a vector in $V_1 \cap V_2 \cap \ldots \cap V_n$. Since $v$ belongs to each $V_i$, we have $av$ belongs to each $V_i$ as well, as $V_i$ are subspaces and hence closed under scalar multiplication. Therefore, $av$ belongs to the intersection $V_1 \cap V_2 \cap \ldots \cap V_n$.

Thus, we have shown that $V_1 \cap V_2 \cap \ldots \cap V_n$ is a subspace of $V$.

\end{proof}


theorem exercise_3_1 {F V : Type*}
  [add_comm_group V] [field F] [module F V] [finite_dimensional F V]
  (T : V →ₗ[F] V) (hT : finrank F V = 1) :
  ∃ c : F, ∀ v : V, T v = c • v:=

Show that every linear map from a one-dimensional vector space to itself is multiplication by some scalar. More precisely, prove that if $\operatorname{dim} V=1$ and $T \in \mathcal{L}(V, V)$, then there exists $a \in \mathbf{F}$ such that $T v=a v$ for all $v \in V$.

\begin{proof}

    If $\operatorname{dim} V=1$, then in fact, $V=\mathbf{F}$ and it is spanned by $1 \in \mathbf{F}$.

Let $T$ be a linear map from $V$ to itself. Let $T(1)=\lambda \in V(=\mathbf{F})$.

Step 2

2 of 3

Every $v \in V$ is a scalar. Therefore,

$$

\begin{aligned}

T(v) & =T(v \cdot 1) \\

& =v T(1) \ldots .(\text { By the linearity of } T) \\

& =v \lambda

\end{aligned}

$$

Hence, $T v=\lambda v$ for every $v \in V$.

\end{proof}


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

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

\begin{proof}

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

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

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

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

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

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

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

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

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

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

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

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

\end{proof}


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

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

\begin{proof}

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

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

\end{proof}


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

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

\begin{proof}

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

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

The Pythagorean theorem thus implies that

$$

\begin{aligned}

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

& \geq\|u\|^2

\end{aligned}

$$

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

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

$$

\begin{gathered}

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

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

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

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

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

\end{gathered}

$$

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

Therefore,

$$

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

$$

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

$$

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

$$

for all $t>0$.

Step 4

4 of 4

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

$$

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

$$

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

$$

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

$$

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

\end{proof}


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

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

\begin{proof}

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

$$

\begin{aligned}

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

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

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

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

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

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

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

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

\end{aligned}

$$

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

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

$$

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

$$

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

Hence

$$

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

$$

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

Now we have

$$

\begin{aligned}

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

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

& =\operatorname{range} T^*,

\end{aligned}

$$

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

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

\end{proof}


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

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

\begin{proof}

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

$$

T e_1=\lambda_j e_j

$$

for $j=1 \ldots n$.

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

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

$$

\begin{aligned}

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

& =\lambda_j e_j \\

& =T e_j

\end{aligned}

$$

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

\end{proof}


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

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

\begin{proof}

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

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

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

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

$$

v=a_1 e_1+\cdots+a_n e_n .

$$

Thus, we have

$$

\begin{aligned}

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

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

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

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

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

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

\end{aligned}

$$

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

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

\end{proof}


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

import .common

open complex filter function interval_integral metric

open_locale big_operators
open_locale filter
open_locale topology

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

\begin{proof}

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

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

$$

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

$$

By the Cauchy-Riemann equations,

$$

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

$$

Thus, in $\Omega$,

$$

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

$$

3

Thus $f(z)$ is constant.

\end{proof}


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

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

\begin{proof}

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

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

$$

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

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

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

\end{array}\right.

$$

Plug in the Cauchy-Riemann equations and we get

$$

\begin{gathered}

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

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

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

\end{gathered}

$$

Plug (1.15) into (1.13) and we get

$$

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

$$

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

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

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

$$

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

$$

Thus $f$ is constant.

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

Let's return to

$$

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

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

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

\end{array}\right.

$$

Plug in the Cauchy-Riemann equations and we get

$$

\begin{array}{r}

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

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

\end{array}

$$

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

$$

\begin{aligned}

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

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

\end{aligned}

$$

Adding the two yields

$$

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

$$

or equivalently

$$

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

$$

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

Consider

$$

\begin{gathered}

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

(\sin (\pi z))

\end{gathered}

$$

Then we have

$$

\begin{aligned}

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

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

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

\end{aligned}

$$

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

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

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

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

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

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

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

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

$$

\begin{aligned}

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

=0

\end{aligned}

$$

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

$$

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

$$

which is what we need.

\end{proof}


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

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

\begin{proof}

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

\end{proof}