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

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

\begin{proof}

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

\end{proof}


theorem exercise_2018_a5 (f : ℝ → ℝ) (hf : cont_diff ℝ ⊤ f)
  (hf0 : f 0 = 0) (hf1 : f 1 = 1) (hf2 : ∀ x, f x ≥ 0) :
  ∃ (n : ℕ) (x : ℝ), iterated_deriv n f x = 0 :=

import .common

open real topological_space filter polynomial
open_locale topology big_operators complex_conjugate filter ennreal

Let $f: \mathbb{R} \rightarrow \mathbb{R}$ be an infinitely differentiable function satisfying $f(0)=0, f(1)=1$, and $f(x) \geq 0$ for all $x \in$ $\mathbb{R}$. Show that there exist a positive integer $n$ and a real number $x$ such that $f^{(n)}(x)<0$.

\begin{proof}

    Call a function $f\colon \mathbb{R} \to \mathbb{R}$ \textit{ultraconvex} if $f$ is infinitely differentiable and $f^{(n)}(x) \geq 0$ for all $n \geq 0$ and all $x \in \mathbb{R}$, where $f^{(0)}(x) = f(x)$;

note that if $f$ is ultraconvex, then so is $f'$.

Define the set

\[

S = \{ f :\thinspace \mathbb{R} \to \mathbb{R} \,|\,f \text{ ultraconvex and } f(0)=0\}.

\]

For $f \in S$, we must have $f(x) = 0$ for all $x < 0$: if $f(x_0) > 0$ for some $x_0 < 0$, then

by the mean value theorem there exists $x \in (0,x_0)$ for which $f'(x) = \frac{f(x_0)}{x_0} < 0$.

In particular, $f'(0) = 0$, so $f' \in S$ also.

We show by induction that for all $n \geq 0$,

\[

f(x) \leq \frac{f^{(n)}(1)}{n!} x^n \qquad (f \in S, x \in [0,1]).

\]

We induct with base case $n=0$, which holds because any $f \in S$ is nondecreasing. Given the claim for $n=m$,

we apply the induction hypothesis to $f' \in S$ to see that

\[

f'(t) \leq \frac{f^{(n+1)}(1)}{n!} t^n \qquad (t \in [0,1]),

\]

then integrate both sides from $0$ to $x$ to conclude.

Now for $f \in S$, we have $0 \leq f(1) \leq \frac{f^{(n)}(1)}{n!}$ for all $n \geq 0$.

On the other hand, by Taylor's theorem with remainder,

\[

f(x) \geq \sum_{k=0}^n \frac{f^{(k)}(1)}{k!}(x-1)^k \qquad (x \geq 1).

\]

Applying this with $x=2$, we obtain $f(2) \geq \sum_{k=0}^n \frac{f^{(k)}(1)}{k!}$ for all $n$;

this implies that $\lim_{n\to\infty}  \frac{f^{(n)}(1)}{n!} = 0$.

Since $f(1) \leq \frac{f^{(n)}(1)}{n!}$, we must have $f(1) = 0$.

For $f \in S$, we proved earlier that $f(x) = 0$ for all $x\leq 0$, as well as for $x=1$. Since

the function $g(x) = f(cx)$ is also ultraconvex for $c>0$, we also have $f(x) = 0$ for all $x>0$;

hence $f$ is identically zero.

To sum up, if $f\colon \mathbb{R} \to \mathbb{R}$ is infinitely differentiable, $f(0)=0$, and $f(1) = 1$,

then $f$ cannot be ultraconvex. This implies the desired result.

\end{proof}


theorem exercise_2018_b4 (a : ℝ) (x : ℕ → ℝ) (hx0 : x 0 = a)
  (hx1 : x 1 = a)
  (hxn : ∀ n : ℕ, n ≥ 2 → x (n+1) = 2*(x n)*(x (n-1)) - x (n-2))
  (h : ∃ n, x n = 0) :
  ∃ c, function.periodic x c :=

Given a real number $a$, we define a sequence by $x_{0}=1$, $x_{1}=x_{2}=a$, and $x_{n+1}=2 x_{n} x_{n-1}-x_{n-2}$ for $n \geq 2$. Prove that if $x_{n}=0$ for some $n$, then the sequence is periodic.

\begin{proof}

    We first rule out the case $|a|>1$. In this case, we prove that $|x_{n+1}| \geq |x_n|$ for all $n$, meaning that we cannot have $x_n = 0$. We proceed by induction; the claim is true for $n=0,1$ by hypothesis. To prove the claim for  $n \geq 2$, write

\begin{align*}

|x_{n+1}| &= |2x_nx_{n-1}-x_{n-2}| \\

&\geq 2|x_n||x_{n-1}|-|x_{n-2}| \\

&\geq |x_n|(2|x_{n-1}|-1) \geq |x_n|,

\end{align*}

where the last step follows from $|x_{n-1}| \geq |x_{n-2}| \geq \cdots \geq |x_0| = 1$.

We may thus assume hereafter that $|a|\leq 1$. We can then write $a = \cos b$ for some $b \in [0,\pi]$.

Let $\{F_n\}$ be the Fibonacci sequence, defined as usual by $F_1=F_2=1$ and $F_{n+1}=F_n+F_{n-1}$. We show by induction that

\[

x_n = \cos(F_n b) \qquad (n \geq 0).

\]

Indeed, this is true for $n=0,1,2$; given that it is true for $n \leq m$, then

\begin{align*}

2x_mx_{m-1}&=2\cos(F_mb)\cos(F_{m-1}b) \\

&= \cos((F_m-F_{m-1})b)+\cos((F_m+F_{m-1})b) \\

&= \cos(F_{m-2}b)+\cos(F_{m+1}b)

\end{align*}

and so

$x_{m+1} = 2x_mx_{m-1}-x_{m-2} = \cos(F_{m+1}b)$. This completes the induction.

Since $x_n = \cos(F_n b)$, if $x_n=0$ for some $n$ then $F_n b = \frac{k}{2} \pi$ for some odd integer $k$. In particular, we can write $b = \frac{c}{d}(2\pi)$ where $c = k$ and $d = 4F_n$ are integers.

Let $x_n$ denote the pair $(F_n,F_{n+1})$, where each entry in this pair is viewed as an element of $\mathbb{Z}/d\mathbb{Z}$. Since there are only finitely many possibilities for $x_n$, there must be some $n_2>n_1$ such that $x_{n_1}=x_{n_2}$. Now $x_n$ uniquely determines both $x_{n+1}$ and $x_{n-1}$, and it follows that the sequence $\{x_n\}$ is periodic: for $\ell = n_2-n_1$, $x_{n+\ell} = x_n$ for all $n \geq 0$. In particular, $F_{n+\ell} \equiv F_n \pmod{d}$ for all $n$. But then $\frac{F_{n+\ell}c}{d}-\frac{F_n c}{d}$ is an integer, and so

\begin{align*}

x_{n+\ell} &= \cos\left(\frac{F_{n+\ell}c}{d}(2\pi)\right)\\

& = \cos\left(\frac{F_n c}{d}(2\pi)\right) = x_n

\end{align*}

for all $n$. Thus the sequence $\{x_n\}$ is periodic, as desired.

\end{proof}


theorem exercise_2014_a5 (P : ℕ → polynomial ℤ)
  (hP : ∀ n, P n = ∑ (i : fin n), (n+1) * X ^ n) :
  ∀ (j k : ℕ), j ≠ k → is_coprime (P j) (P k) :=


Prove that there are unique positive integers $a, n$ such that $a^{n+1}-(a+1)^n=2001$.

\begin{proof}

    Suppose $a^{n+1} - (a+1)^n = 2001$.

Notice that $a^{n+1} + [(a+1)^n - 1]$ is a multiple of $a$; thus

$a$ divides $2002 = 2 \times 7 \times 11 \times 13$.

Since $2001$ is divisible by 3, we must have $a \equiv 1 \pmod{3}$,

otherwise one of $a^{n+1}$ and $(a+1)^n$ is a multiple of 3 and the

other is not, so their difference cannot be divisible by 3. Now

$a^{n+1} \equiv 1 \pmod{3}$, so we must have $(a+1)^n \equiv 1

\pmod{3}$, which forces $n$ to be even, and in particular at least 2.

If $a$ is even, then $a^{n+1} - (a+1)^n \equiv -(a+1)^n \pmod{4}$.

Since $n$ is even, $-(a+1)^n \equiv -1 \pmod{4}$. Since $2001 \equiv 1

\pmod{4}$, this is impossible. Thus $a$ is odd, and so must divide

$1001 = 7 \times 11 \times 13$. Moreover, $a^{n+1} - (a+1)^n \equiv a

\pmod{4}$, so $a \equiv 1 \pmod{4}$.

Of the divisors of $7 \times 11 \times 13$, those congruent to 1 mod 3

are precisely those not divisible by 11 (since 7 and 13 are both

congruent to 1 mod 3). Thus $a$ divides $7 \times 13$. Now

$a \equiv 1 \pmod{4}$ is only possible if $a$ divides $13$.

We cannot have $a=1$, since $1 - 2^n \neq 2001$ for any $n$. Thus

the only possibility is $a = 13$. One easily checks that $a=13, n=2$ is a

solution; all that remains is to check that no other $n$ works. In fact,

if $n > 2$, then $13^{n+1} \equiv 2001 \equiv 1 \pmod{8}$.

But $13^{n+1} \equiv 13 \pmod{8}$ since $n$ is even, contradiction.

Thus $a=13, n=2$ is the unique solution.

Note: once one has that $n$ is even, one can use that $2002

=a^{n+1} + 1 - (a+1)^n$ is divisible by $a+1$ to rule out cases.

\end{proof}


theorem exercise_1999_b4 (f : ℝ → ℝ) (hf: cont_diff ℝ 3 f)
  (hf1 : ∀ (n ≤ 3) (x : ℝ), iterated_deriv n f x > 0)
  (hf2 : ∀ x : ℝ, iterated_deriv 3 f x ≤ f x) :
  ∀ x : ℝ, deriv f x < 2 * f x :=

Let $f$ be a real function with a continuous third derivative such that $f(x), f^{\prime}(x), f^{\prime \prime}(x), f^{\prime \prime \prime}(x)$ are positive for all $x$. Suppose that $f^{\prime \prime \prime}(x) \leq f(x)$ for all $x$. Show that $f^{\prime}(x)<2 f(x)$ for all $x$.

\begin{proof}

\setcounter{equation}{0}

We make repeated use of the following fact: if $f$ is a differentiable function on all of

$\mathbb{R}$, $\lim_{x \to -\infty} f(x) \geq 0$, and $f'(x) > 0$ for all $x \in \mathbb{R}$, then

$f(x) > 0$ for all $x \in \mathbb{R}$. (Proof: if $f(y) < 0$ for some $x$, then $f(x)< f(y)$ for all

$x<y$ since $f'>0$, but then $\lim_{x \to -\infty} f(x) \leq f(y) < 0$.)

From the inequality $f'''(x) \leq f(x)$ we obtain

\[

f'' f'''(x) \leq f''(x) f(x) < f''(x) f(x) + f'(x)^2

\]

since $f'(x)$ is positive. Applying the fact to the difference between the right and left sides,

we get

\begin{equation}

\frac{1}{2} (f''(x))^2 < f(x) f'(x).

\end{equation}

On the other hand, since $f(x)$ and $f'''(x)$ are both positive for all $x$,

we have

\[

2f'(x) f''(x) < 2f'(x)f''(x) + 2f(x) f'''(x).

\]

Applying the fact to the difference between the sides yields

\begin{equation}

f'(x)^2 \leq 2f(x) f''(x).

\end{equation}

Combining (1) and (2), we obtain

\begin{align*}

\frac{1}{2} \left( \frac{f'(x)^2}{2f(x)} \right)^2

&< \frac{1}{2} (f''(x))^2 \\

&< f(x) f'(x),

\end{align*}

or $(f'(x))^3 < 8 f(x)^3$. We conclude $f'(x) < 2f(x)$, as desired.

\end{proof}


theorem exercise_1998_b6 (a b c : ℤ) :
  ∃ n : ℤ, n > 0 ∧ ¬ ∃ m : ℤ, sqrt (n^3 + a*n^2 + b*n + c) = m :=

Prove that, for any integers $a, b, c$, there exists a positive integer $n$ such that $\sqrt{n^3+a n^2+b n+c}$ is not an integer.

\begin{proof}

    We prove more generally that for any polynomial $P(z)$ with integer

coefficients which is not a perfect square, there exists a positive

integer $n$ such that $P(n)$ is not a perfect square. Of course it

suffices to assume $P(z)$ has no repeated factors, which is to say $P(z)$

and its derivative $P'(z)$ are relatively prime.

In particular, if we carry out the Euclidean algorithm on $P(z)$ and $P'(z)$

without dividing, we get an integer $D$ (the discriminant of $P$) such that

the greatest common divisor of $P(n)$ and $P'(n)$ divides $D$ for any $n$.

Now there exist infinitely many primes $p$ such that $p$ divides $P(n)$ for

some $n$: if there were only finitely many, say, $p_1, \dots, p_k$, then

for any $n$ divisible by $m = P(0) p_1 p_2 \cdots p_k$, we have $P(n)

\equiv P(0) \pmod{m}$, that is, $P(n)/P(0)$ is not divisible by $p_1,

\dots, p_k$, so must be $\pm 1$, but then $P$ takes some value infinitely

many times, contradiction. In particular, we can choose some such $p$ not

dividing $D$, and choose $n$ such that $p$ divides $P(n)$. Then $P(n+kp)

\equiv P(n) + kp P'(n) (\mathrm{mod}\,p)$

(write out the Taylor series of the left side);

in particular, since $p$ does not divide $P'(n)$, we can find some $k$

such that $P(n+kp)$ is divisible by $p$ but not by $p^2$, and so

is not a perfect square.

\end{proof}


theorem exercise_2_26 {M : Type*} [topological_space M]
  (U : set M) : is_open U ↔ ∀ x ∈ U, ¬ cluster_pt x (𝓟 Uᶜ) :=

import .common

open set real filter function ring_hom topological_space

open_locale big_operators
open_locale filter
open_locale topology
noncomputable theory

Prove that a set $U \subset M$ is open if and only if none of its points are limits of its complement.

\begin{proof}

    Assume that none of the points of $U$ are limits of its complement, and let us prove that $U$ is open. Assume by contradiction that $U$ is not open, so there exists $p \in M$ so that $\forall r>0$ there exists $q \in M$ with $d(p, q)<r$ but $q \notin U$. Applying this to $r=1 / n$ we obtain $q_n \in U^c$ such that $d\left(q_n, p\right)<1 / n$. But then $q_n \rightarrow p$ and $p$ is a limit of a sequence of points in $U^c$, a contradiction.

Assume now that $U$ is open. Assume by contradiction there exists $p \in U$ and $p_n \in U^c$ such that $p_n \rightarrow p$. Since $U$ is open, there exists $r>0$ such that $d(p, x)<r$ for $x \in M$ implies $x \in U$. But since $p_n \rightarrow p$, there exists $n_0 \in \mathbb{N}$ such that $n \geq n_0$ implies $d\left(p_n, p\right)<r$, therefore $p_n \in U$ for $n \geq n_0$, a contradiction since $p_n \in U^c$.

\end{proof}


theorem exercise_2_32a (A : set ℕ) : is_clopen A :=

Show that every subset of $\mathbb{N}$ is clopen.

\begin{proof}

    32. The one-point set $\{n\} \subset \mathbb{N}$ is open, since it contains all $m \in \mathbb{N}$ that satisfy $d(m, n)<\frac{1}{2}$. Every subset of $\mathbb{N}$ is a union of one-point sets, hence is open. Then every set it closed, since its complement is necessarily open.

\end{proof}


theorem exercise_2_46 {M : Type*} [metric_space M]
  {A B : set M} (hA : is_compact A) (hB : is_compact B)
  (hAB : disjoint A B) (hA₀ : A ≠ ∅) (hB₀ : B ≠ ∅) :
  ∃ a₀ b₀, a₀ ∈ A ∧ b₀ ∈ B ∧ ∀ (a : M) (b : M),
  a ∈ A → b ∈ B → dist a₀ b₀ ≤ dist a b :=

Assume that $A, B$ are compact, disjoint, nonempty subsets of $M$. Prove that there are $a_0 \in A$ and $b_0 \in B$ such that for all $a \in A$ and $b \in B$ we have $d(a_0, b_0) \leq d(a, b)$.

\begin{proof}

Let $A$ and $B$ be compact, disjoint and non-empty subsets of $M$. We want to show that there exist $a_0 \in A, b_0 \in B$ such that for all $a \in A, b \in B$,

$$

d\left(a_0, b_0\right) \leq d(a, b) .

$$

We saw in class that the distance function $d: M \times M \rightarrow \mathbb{R}$ is continuous. We also saw in class that any continuous, real-valued function assumes maximum and minimum values on a compact set. Since $A$ and $B$ are compact, $A \times B$ is (non-empty) compact in $M \times M$. Therefore there exists $\left(a_0, b_0\right) \in A \times B$ such that $d\left(a_0, b_0\right) \leq d(a, b), \forall(a, b) \in A \times B$.

\end{proof}


theorem exercise_2_92 {α : Type*} [topological_space α]
  {s : ℕ → set α}
  (hs : ∀ i, is_compact (s i))
  (hs : ∀ i, (s i).nonempty)
  (hs : ∀ i, (s i) ⊃ (s (i + 1))) :
  (⋂ i, s i).nonempty :=

Give a direct proof that the nested decreasing intersection of nonempty covering compact sets is nonempty.

\begin{proof}

    Let

$$

A_1 \supset A_2 \supset \cdots \supset A_n \supset \cdots

$$

be a nested decreasing sequence of compacts. Suppose that $\bigcap A_n=\emptyset$. Take $U_n=A_n^c$, then

$$

\bigcup U_n=\bigcup A_n^c=\left(\bigcap A_n\right)^c=A_1 .

$$

Here, I'm thinking of $A_1$ as the main metric space. Since $\left\{U_n\right\}$ is an open covering of $A_1$, we can extract a finite subcovering, that is,

$$

A_{\alpha_1}^c \cup A_{\alpha_2}^c \cup \cdots \cup A_{\alpha_m}^c \supset A_1

$$

or

$$

\left(A_1 \backslash A_{\alpha_1}\right) \cup\left(A_1 \backslash A_{\alpha_2}\right) \cup \cdots \cup\left(A_1 \backslash A_{\alpha_m}\right) \supset A_1 .

$$

But, this is true only if $A_{\alpha_i}=\emptyset$ for some $i$, a contradiction.

\end{proof}


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

Assume that $f \colon \mathbb{R} \rightarrow \mathbb{R}$ satisfies $|f(t)-f(x)| \leq|t-x|^{2}$ for all $t, x$. Prove that $f$ is constant.

\begin{proof}

    We have $|f(t)-f(x)| \leq|t-x|^2, \forall t, x \in \mathbb{R}$. Fix $x \in \mathbb{R}$ and let $t \neq x$. Then

$$

\left|\frac{f(t)-f(x)}{t-x}\right| \leq|t-x| \text {, hence } \lim _{t \rightarrow x}\left|\frac{f(t)-f(x)}{t-x}\right|=0 \text {, }

$$

so $f$ is differentiable in $\mathbb{R}$ and $f^{\prime}=0$. This implies that $f$ is constant, as seen in class.

\end{proof}


theorem exercise_3_63a (p : ℝ) (f : ℕ → ℝ) (hp : p > 1)
  (h : f = λ k, (1 : ℝ) / (k * (log k) ^ p)) :
  ∃ l, tendsto f at_top (𝓝 l) :=

Prove that $\sum 1/k(\log(k))^p$ converges when $p > 1$.

\begin{proof}

    Using the integral test, for a set $a$, we see

$$

\lim _{b \rightarrow \infty} \int_a^b \frac{1}{x \log (x)^c} d x=\lim _{b \rightarrow \infty}\left(\frac{\log (b)^{1-c}}{1-c}-\frac{\log (a)^{1-c}}{1-c}\right)

$$

which goes to infinity if $c \leq 1$ and converges if $c>1$. Thus,

$$

\sum_{n=2}^{\infty} \frac{1}{n \log (n)^c}

$$

converges if and only if $c>1$.

\end{proof}


theorem exercise_4_15a {α : Type*}
  (a b : ℝ) (F : set (ℝ → ℝ)) :
  (∀ (x : ℝ) (ε > 0), ∃ (U ∈ (𝓝 x)),
  (∀ (y z ∈ U) (f : ℝ → ℝ), f ∈ F → (dist (f y) (f z) < ε)))
  ↔
  ∃ (μ : ℝ → ℝ), ∀ (x : ℝ), (0 : ℝ) ≤ μ x ∧ tendsto μ (𝓝 0) (𝓝 0) ∧
  (∀ (s t : ℝ) (f : ℝ → ℝ), f ∈ F → |(f s) - (f t)| ≤ μ (|s - t|)) :=

A continuous, strictly increasing function $\mu \colon (0, \infty) \rightarrow (0, \infty)$ is a modulus of continuity if $\mu(s) \rightarrow 0$ as $s \rightarrow 0$. A function $f \colon [a, b] \rightarrow \mathbb{R}$ has modulus of continuity $\mu$ if $|f(s) - f(t)| \leq \mu(|s - t|)$ for all $s, t \in [a, b]$. Prove that a function is uniformly continuous if and only if it has a modulus of continuity.

\begin{proof}

    Suppose there exists a modulus of continuity $w$ for $f$, then fix $\varepsilon>0$, since $\lim _{s \rightarrow 0} w(s)=0$, there exists $\delta>0$ such that for any $|s|<\delta$, we have $w(s)<\varepsilon$, then we have for any $x, z \in X$ such that $d_X(x, z)<\delta$, we have $d_Y(f(x), f(z)) \leq w\left(d_X(x, z)\right)<\varepsilon$, which means $f$ is uniformly continuous.

Suppose $f:\left(X, d_X\right) \rightarrow\left(Y, d_Y\right)$ is uniformly continuous.

Let $\delta_1>0$ be such that $d_X(a, b)<\delta_1$ implies $d_Y(f(a), f(b))<1$.

Define $w:[0, \infty) \rightarrow[0, \infty]$ by

$$

w(s)= \begin{cases}\left.\sup \left\{d_Y(f(a), f(b))\right\} \mid d_X(a, b) \leq s\right\} & \text { if } s \leq \delta_1 \\ \infty & \text { if } s>\delta_1\end{cases}

$$

We'll show that $w$ is a modulus of continuity for $f \ldots$

By definition of $w$, it's immediate that $w(0)=0$ and it's clear that

$$

d_Y(f(a), f(b)) \leq w\left(d_X(a, b)\right)

$$

for all $a, b \in X$.

It remains to show $\lim _{s \rightarrow 0^{+}} w(s)=0$.

It's easily seen that $w$ is nonnegative and non-decreasing, hence $\lim _{s \rightarrow 0^{+}}=L$ for some $L \geq 0$, where $L=\inf w((0, \infty))$

Let $\epsilon>0$.

By uniform continuity of $f$, there exists $\delta>0$ such that $d_X(a, b)<\delta$ implies $d_Y(f(a), f(b))<\epsilon$, hence by definition of $w$, we get $w(\delta) \leq \epsilon$.

Thus $L \leq \epsilon$ for all $\epsilon>0$, hence $L=0$.

This completes the proof.

\end{proof}


theorem exercise_2_1_18 {G : Type*} [group G]
  [fintype G] (hG2 : even (fintype.card G)) :
  ∃ (a : G), a ≠ 1 ∧ a = a⁻¹ :=

import .common

open set function nat fintype real subgroup ideal polynomial submodule zsqrtd
open char_p mul_aut matrix
open_locale big_operators
noncomputable theory

If $G$ is a finite group of even order, show that there must be an element $a \neq e$ such that $a=a^{-1}$.

\begin{proof}

    First note that $a=a^{-1}$ is the same as saying $a^2=e$, where $e$ is the identity. I.e. the statement is that there exists at least one element of order 2 in $G$.

Every element $a$ of $G$ of order at least 3 has an inverse $a^{-1}$ that is not itself -- that is, $a \neq a^{-1}$. So the subset of all such elements has an even cardinality (/size). There's exactly one element with order 1 : the identity $e^1=e$. So $G$ contains an even number of elements -call it $2 k$-- of which an even number are elements of order 3 or above -- call that $2 n$ where $n<k$-- and exactly one element of order 1 . Hence the number of elements of order 2 is

$$

2 k-2 n-1=2(k-n)-1

$$

This cannot equal 0 as $2(k-n)$ is even and 1 is odd. Hence there's at least one element of order 2 in $G$, which concludes the proof.

\end{proof}


theorem exercise_2_1_26 {G : Type*} [group G]
  [fintype G] (a : G) : ∃ (n : ℕ), a ^ n = 1 :=

If $G$ is a finite group, prove that, given $a \in G$, there is a positive integer $n$, depending on $a$, such that $a^n = e$.

\begin{proof}

    Because there are only a finite number of elements of $G$, it's clear that the set $\left\{a, a^2, a^3, \ldots\right\}$ must be a finite set and in particular, there should exist some $i$ and $j$ such that $i \neq j$ and $a^i=a^j$. WLOG suppose further that $i>j$ (just reverse the roles of $i$ and $j$ otherwise). Then multiply both sides by $\left(a^j\right)^{-1}=a^{-j}$ to get

$$

a^i * a^{-j}=a^{i-j}=e

$$

Thus the $n=i-j$ is a positive integer such that $a^n=e$.

\end{proof}


theorem exercise_2_2_3 {G : Type*} [group G]
  {P : ℕ → Prop} {hP : P = λ i, ∀ a b : G, (a*b)^i = a^i * b^i}
  (hP1 : ∃ n : ℕ, P n ∧ P (n+1) ∧ P (n+2)) : comm_group G :=

If $G$ is a group in which $(a b)^{i}=a^{i} b^{i}$ for three consecutive integers $i$, prove that $G$ is abelian.

\begin{proof}

    Let $G$ be a group, $a, b \in G$ and $i$ be any integer. Then from given condition,

$$

\begin{aligned}

(a b)^i & =a^i b^i \\

(a b)^{i+1} & =a^{i+1} b^{i+1} \\

(a b)^{i+2} & =a^{i+2} b^{i+2}

\end{aligned}

$$

From first and second, we get

$$

a^{i+1} b^{i+1}=(a b)^i(a b)=a^i b^i a b \Longrightarrow b^i a=a b^i

$$

From first and third, we get

$$

a^{i+2} b^{i+2}=(a b)^i(a b)^2=a^i b^i a b a b \Longrightarrow a^2 b^{i+1}=b^i a b a

$$

This gives

$$

a^2 b^{i+1}=a\left(a b^i\right) b=a b^i a b=b^i a^2 b

$$

Finally, we get

$$

b^i a b a=b^i a^2 b \Longrightarrow b a=a b

$$

This shows that $G$ is Abelian.

\end{proof}


theorem exercise_2_2_6c {G : Type*} [group G] {n : ℕ} (hn : n > 1)
  (h : ∀ (a b : G), (a * b) ^ n = a ^ n * b ^ n) :
  ∀ (a b : G), (a * b * a⁻¹ * b⁻¹) ^ (n * (n - 1)) = 1 :=

Let $G$ be a group in which $(a b)^{n}=a^{n} b^{n}$ for some fixed integer $n>1$ for all $a, b \in G$. For all $a, b \in G$, prove that $\left(a b a^{-1} b^{-1}\right)^{n(n-1)}=e$.

\begin{proof}

    We start with the following two intermediate results.

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

(2) $a^n b^{n-1}=b^{n-1} a^n$.

To prove (1), notice by the given condition for all $a, b \in G$

$(b a)^n=b^n a^n$, for some fixed integers $n>1$.

Then,

$(b a)^n=b^n a^n \Longrightarrow b .(a b)(a b) \ldots .(a b) . a=b\left(b^{n-1} a^{n-1}\right) a$, where $(a b)$ occurs $n-1$ times $\Longrightarrow(a b)^{n-1}=b^{n-1} a^{n-1}$, by cancellation law.

Hence, for all $a, b \in G$

$$

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

$$

To prove (2), notice by the given condition for all $a, b \in G$

$(b a)^n=b^n a^n$, for some fixed integers $n>1$.

Then we have

$$

\begin{aligned}

& (b a)^n=b^n a^n \\

\Longrightarrow & b \cdot(a b)(a b) \ldots(a b) \cdot a=b\left(b^{n-1} a^{n-1}\right) a, \text { where }(a b) \text { occurs } n-1 \text { times } \\

\Longrightarrow & (a b)^{n-1}=b^{n-1} a^{n-1}, \text { by cancellation law } \\

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

\Longrightarrow & (a b)^n=b^{n-1} a^n b \\

\Longrightarrow & a^n b^n=b^{n-1} a^n b, \text { given condition } \\

\Longrightarrow & a^n b^{n-1}=b^{n-1} a^n, \text { by cancellation law. }

\end{aligned}

$$

Therefore for all $a, b \in G$ we have

$$

a^n b^{n-1}=b^{n-1} a^n

$$

In order to show that

$$

\left(a b a^{-1} b^{-1}\right)^{n(n-1)}=e, \text { for all } a, b \in G

$$

it is enough to show that

$$

(a b)^{n(n-1)}=(b a)^{n(n-1)}, \quad \forall x, y \in G .

$$

Step 3

This is because of

$$

\begin{aligned}

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

& \Longrightarrow\left(a^{-1} b^{-1}\right)^{n(n-1)}(a b)^{n(n-1)}=e \\

& \Longrightarrow\left(\left(a^{-1} b^{-1}\right)^n\right)^{n-1}\left((a b)^n\right)(n-1)=e \\

& \Longrightarrow\left((a b)^n\left(a^{-1} b^{-1}\right)^n\right)^{n-1}=e, \text { by }(1) \\

& \Longrightarrow\left(a b a^{-1} b^{-1}\right)^{n(n-1)}=e, \text { ( given condition) }

\end{aligned}

$$

Now, it suffices to show that

$$

(a b)^{n(n-1)}=(b a)^{n(n-1)}, \quad \forall x, y \in G .

$$

Now, we have

$$

\begin{aligned}

(a b)^{n(n-1)} & =\left(a^n b^n\right)^{n-1}, \text { by the given condition } \\

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

& =\left(b^{n-1} a^n b\right)^{n-1}, \text { by }(2) \\

& =\left(a^n b\right)^{n-1}\left(b^{n-1}\right)^{n-1}, \text { by }(1) \\

& =b^{n-1}\left(a^n\right)^{n-1}\left(b^{n-1}\right)^{n-1}, \text { by }(1) \\

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

& =\left(a^{n-1}\right)^n b^{n-1}\left(b^{n-1}\right)^{n-1}, \text { by }(2) \\

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

& =\left(a^{n-1} b^{n-1}\right)^n, \text { by }(1) \\

& =(b a)^{n(n-1)}, \text { by }(1) .

\end{aligned}

$$

This completes our proof.

\end{proof}


theorem exercise_2_3_16 {G : Type*} [group G]
  (hG : ∀ H : subgroup G, H = ⊤ ∨ H = ⊥) :
  is_cyclic G ∧ ∃ (p : ℕ) (fin : fintype G), nat.prime p ∧ @card G fin = p :=

If a group $G$ has no proper subgroups, prove that $G$ is cyclic of order $p$, where $p$ is a prime number.

\begin{proof}

    Case-1: $G=(e), e$ being the identity element in $G$. Then trivially $G$ is cyclic.

    Case-2: $G \neq(e)$. Then there exists an non-identity element in $G.$ Let us consider an non-identity element in $G$, say $a\neq (e)$. Now look at the cyclic subgroup generated by $a$, that is, $\langle a\rangle$. Since

    $a\neq (e) \in G,\langle a\rangle$ is a subgroup of $G$.

If $G \neq\langle a\rangle$ then $\langle a\rangle$ is a proper non-trivial subgroup of $G$, which is an impossibility. Therfore we must have

$$

G=\langle a\rangle .

$$

This implies, $G$ is a cyclic group generated by $a$. Then it follows that every non-identity element of $G$ is a generator of $G$. Now we claim that $G$ is finite.

\end{proof}


theorem exercise_2_5_23 {G : Type*} [group G]
  (hG : ∀ (H : subgroup G), H.normal) (a b : G) :
  ∃ (j : ℤ) , b*a = a^j * b:=

Let $G$ be a group such that all subgroups of $G$ are normal in $G$. If $a, b \in G$, prove that $ba = a^jb$ for some $j$.

\begin{proof}

    Let $G$ be a group where each subgroup is normal in $G$. let $a, b \in G$.

$$

\begin{aligned}

    \langle a\rangle\triangleright  G  &\Rightarrow b \cdot\langle a\rangle=\langle a\rangle \cdot b . \\

& \Rightarrow \quad b \cdot a=a^j \cdot b \text { for some } j \in \mathbb{Z}.

\end{aligned}

$$

(hence for $a_1 b \in G \quad a^j b=b \cdot a$ ).

\end{proof}


theorem exercise_2_5_31 {G : Type*} [comm_group G] [fintype G]
  {p m n : ℕ} (hp : nat.prime p) (hp1 : ¬ p ∣ m) (hG : card G = p^n*m)
  {H : subgroup G} [fintype H] (hH : card H = p^n) :
  characteristic H :=

Suppose that $G$ is an abelian group of order $p^nm$ where $p \nmid m$ is a prime.  If $H$ is a subgroup of $G$ of order $p^n$, prove that $H$ is a characteristic subgroup of $G$.

\begin{proof}

    Let $G$ be an abelian group of order $p^n m$, such that $p \nmid m$. Now, Given that $H$ is a subgroup of order $p^n$. Since $G$ is abelian $H$ is normal. Now we want to prove that $H$ is a characterestic subgroup, that is $\phi(H)=H$ for any automorphism $\phi$ of $G$. Now consider $\phi(H)$. Clearly $|\phi(H)|=p^n$. Suppose $\phi(H) \neq H$, then $|H \cap \phi(H)|=p^s$, where $s<n$. Consider $H \phi(H)$, this is a subgroup of $G$ as $H$ is normal. Also $|H \phi(H)|=\frac{|H||\phi(H)|}{|H \cap \phi(H)|}=\frac{p^{2 n}}{p^s}=p^{2 n-s}$, where $2 n-s>n$. By lagrange's theorem then $p^{2 n-s}\left|p^n m \Longrightarrow p^{n-s}\right| m \Longrightarrow p \mid m$-contradiction. So $\phi(H)=H$, and $H$ is characterestic subgroup of $G$.

\end{proof}


theorem exercise_2_5_43 (G : Type*) [group G] [fintype G]
  (hG : card G = 9) :
  comm_group G :=

Prove that a group of order 9 must be abelian.

\begin{proof}

    We use the result from problem 40 which is as follows: Suppose $G$ is a group, $H$ is a subgroup and $|G|=n$ and $n \nmid\left(i_G(H)\right) !$. Then there exists a normal subgroup $\$ K \backslash$ neq $\{$ e $\} \$$ and $K \subseteq H$.

So, we have now a group $G$ of order 9. Suppose that $G$ is cyclic, then $G$ is abelian and there is nothing more to prove. Suppose that $G$ s not cyclic,then there exists an element $a$ of order 3 , and $A=\langle a\rangle$. Now $i_G(A)=3$, now $9 \nmid 3$ !, hence by the above result there is a normal subgroup $K$, non-trivial and $K \subseteq A$. But $|A|=3$, a prime order subgroup, hence has no non-trivial subgroup, so $K=A$. So $A$ is normal subgroup. Now since $G$ is not cyclic any non-identity element is of order 3.So Let $a(\neq$ $e) \in G$.Consider $A=\langle a\rangle$. As shown before $A$ is normal. $a$ commutes with any if its powers. Now Let $b \in G$ such that $b \notin A$. Then $b a b^{-1} \in A$ and hence $b a b^{-1}=a^i$.This implies $a=b^3 a b^{-3}=a^{i^3} \Longrightarrow a^{i^3-1}=e$. So, 3 divides $i^3-1$. Also by fermat's little theorem 3 divides $i^2-1$.So 3 divides $i-1$. But $0 \leq i \leq 2$. So $i=1$, is the only possibility and hence $a b=b a$. So $a \in Z(G)$ as $b$ was arbitrary. Since $a$ was arbitrary $G=Z(G)$. Hence $G$ is abelian.

\end{proof}


theorem exercise_2_5_52 {G : Type*} [group G] [fintype G]
  (φ : G ≃* G) {I : finset G} (hI : ∀ x ∈ I, φ x = x⁻¹)
  (hI1 : 0.75 * card G ≤ card I) :
  ∀ x : G, φ x = x⁻¹ ∧ ∀ x y : G, x*y = y*x :=

Let $G$ be a finite group and $\varphi$ an automorphism of $G$ such that $\varphi(x) = x^{-1}$ for more than three-fourths of the elements of $G$. Prove that $\varphi(y) = y^{-1}$ for all $y \in G$, and so $G$ is abelian.

\begin{proof}

Let us start with considering $b$ to be an arbitrary element in $A$.

1. Show that $\left|A \cap\left(b^{-1} A\right)\right|>\frac{|G|}{2}$, where

$$

b^{-1} A=\left\{b^{-1} a \mid a \in A\right\}

$$

First notice that if we consider a map $f: A \rightarrow b^{-1} A$ defined by $f(a)=b^{-1} a$, for all $a \in A$, then $f$ is a 1-1 map and so $\left|b^{-1} A\right| \geq|A|>\frac{3}{4}|G|$. Now using inclusion-exclusion principle we have

$$

\left|A \cap\left(b^{-1} A\right)\right|=|A|+\left|b^{-1} A\right|-\left|A \cup\left(b^{-1} A\right)\right|>\frac{3}{4}|G|+\frac{3}{4}|G|-|G|=\frac{1}{2}|G|

$$

2. Argue that $A \cap\left(b^{-1} A\right) \subseteq C(b)$, where $C(b)$ is the centralizer of $b$ in $G$.

Suppose $x \in A \cap\left(b^{-1} A\right)$, that means, $x \in A$ and $x \in b^{-1} A$. Thus there exist an element $a \in A$ such that $x=$ $b^{-1} a$, which gives us $x b=a \in A$. Now notice that $x, b \in A$ and $x b \in A$, therefore we get

$$

\phi(x b)=(x b)^{-1} \Longrightarrow \phi(x) \phi(b)=(x b)^{-1} \Longrightarrow x^{-1} b^{-1}=b^{-1} x^{-1} \Longrightarrow x b=b x

$$

Therefore, we get $x b=b x$, for any $x \in A \cap\left(b^{-1} A\right)$, that means, $x \in C(b)$.

3. Argue that $C(b)=G$.

We know that centralizer of an element in a group $G$ is a subgroup (See Page 53). Therefore $C(b)$ is a subgroup of $G$. From statements $\mathbf{1}$ and $\mathbf{2}$, we have

$$

|C(b)| \geq\left|A \cap\left(b^{-1} A\right)\right|>\frac{|G|}{2}

$$

We need to use the following remark to argue $C(b)=G$ from the above step.

Remark. Let $G$ be a finite group and $H$ be a subgroup with more then $|G| / 2$ elements then $H=G$.

Proof of Remark. Suppose $|H|=p$ Then by Lagrange Theorem, there exist an $n \in \mathbb{N}$, such that $|G|=n p$, as $|H|$ divide $|G|$. Now by hypothesis $p>\frac{G]}{2}$ gives us,

$$

p>\frac{|G|}{2} \Longrightarrow n p>\frac{n|G|}{2} \Longrightarrow n<2 \Longrightarrow n=1

$$

Therefore we get $H=G$.

Now notice that $C(b)$ is a subgroup of $G$ with $C(b)$ having more than $|G| / 2$ elements. Therefore, $C(b)=G$.

4. Show that $A \in Z(G)$.

We know that $x \in Z(G)$ if and only if $C(a)=G$. Now notice that, for any $b \in A$ we have $C(b)=G$. Therefore, every element of $A$ is in the center of $G$, that means, $A \subseteq Z(G)$.

5. 5how that $Z(G)=G$.

As it is given that $|A|>\frac{3|G|}{4}$ and $A \leq|Z(G)|$, therefore we get

$$

|Z(G)|>\frac{3}{4}|G|>\frac{1}{2}|G| .

$$

As $Z(G)$ is a subgroup of $G$, so by the above Remark we have $Z(G)=G$. Hence $G$ is abelian.

6. Finally show that $A=G$.

First notice that $A$ is a subgroup of $G$. To show this let $p, q \in A$. Then we have

$$

\phi(p q)=\phi(p) \phi(q)=p^{-1} q^{-1}=(q p)^{-1}=(p q)^{-1}, \quad \text { As } G \text { is abelian. }

$$

Therefore, $p q \in A$ and so we have $A$ is a subgroup of $G$. Again by applying the above remark. we get $A=G$. Therefore we have

$$

\phi(y)=y^{-1}, \quad \text { for all } y \in G

$$

\end{proof}


theorem exercise_2_7_7 {G : Type*} [group G] {G' : Type*} [group G']
  (φ : G →* G') (N : subgroup G) [N.normal] :
  (map φ N).normal  :=

If $\varphi$ is a homomorphism of $G$ onto $G'$ and $N \triangleleft G$, show that $\varphi(N) \triangleleft G'$.

\begin{proof}

We first claim that $\varphi(N)$ is a subgroup of $G'$. To see this, note that since $N$ is a subgroup of $G$, the identity element $e_G$ of $G$ belongs to $N$. Therefore, the element $\varphi(e_G) \in \varphi(N)$, so $\varphi(N)$ is a non-empty subset of $G'$.

Now, let $a', b' \in \varphi(N)$. Then there exist elements $a, b \in N$ such that $\varphi(a) = a'$ and $\varphi(b) = b'$. Since $N$ is a subgroup of $G$, we have $a, b \in N$, so $ab^{-1} \in N$. Thus, we have

$$\varphi(ab^{-1}) = \varphi(a) \varphi(b^{-1}) = a'b'^{-1} \in \varphi(N),$$

which shows that $a', b' \in \varphi(N)$ implies $a'b'^{-1} \in \varphi(N)$. Therefore, $\varphi(N)$ is a subgroup of $G'$.

Next, we will show that $\varphi(N)$ is a normal subgroup of $G'$. Let $\varphi(N) = N'$, a subgroup of $G'$. Let $x' \in G'$ and $h' \in N'$. Since $\varphi$ is onto, there exist elements $x \in G$ and $h \in N$ such that $\varphi(x) = x'$ and $\varphi(h) = h'$.

Since $N$ is a normal subgroup of $G$, we have $xhx^{-1} \in N$. Thus,

$$\varphi(xhx^{-1}) = \varphi(x)\varphi(h)\varphi(x^{-1}) = x'h'x'^{-1} \in \varphi(N),$$

which shows that $x' \in G'$ and $h' \in N'$ implies $x'h'x'^{-1} \in \varphi(N)$. Therefore, $\varphi(N)$ is a normal subgroup of $G'$. This completes the proof.

\end{proof}


theorem exercise_2_8_15 {G H: Type*} [fintype G] [group G] [fintype H]
  [group H] {p q : ℕ} (hp : nat.prime p) (hq : nat.prime q)
  (h : p > q) (h1 : q ∣ p - 1) (hG : card G = p*q) (hH : card G = p*q) :
  G ≃* H :=

Prove that if $p > q$ are two primes such that $q \mid p - 1$, then any two nonabelian groups of order $pq$ are isomorphic.

\begin{proof}

    For a nonabelian group of order $p q$, the structure of the group $G$ is set by determining the relation $a b a^{-1}=b^{k^{\frac{p-1}{q}}}$ for some generator $k$ of the cyclic group. Here we are using the fact that $k^{\frac{p-1}{q}}$ is a generator for the unique subgroup of order $q$ in $U_p$ (a cyclic group of order $m$ has a unique subgroup of order $d$ for each divisor $d$ of $m$ ). The other possible generators of this subgroup are $k^{\frac{l(p-1)}{q}}$ for each $1 \leq l \leq q-1$, so these give potentially new group structures. Let $G^{\prime}$ be a group with an element $c$ of order $q$, an element $d$ of order $p$ with structure defined by the relation $c d c^{-1}=d^{k^{\frac{l(p-1)}{q}}}$. We may then define

$$

\begin{aligned}

\phi: G^{\prime} & \rightarrow G \\

c & \mapsto a^l \\

d & \mapsto b

\end{aligned}

$$

since $c$ and $a^l$ have the same order and $b$ and $d$ have the same order this is a well defined function.

Since

$$

\begin{aligned}

\phi(c) \phi(d) \phi(c)^{-1} & =a^l b a^{-l} \\

& =b^{\left(k^{\frac{p-1}{q}}\right)^l} \\

& =b^{k^{\frac{l(p-1)}{q}}} \\

& =\phi(d)^{k^{\frac{l(p-1)}{q}}}

\end{aligned}

$$

$\phi\left(c^i d^j\right)=a^{l i} b^j=e$ only if $i=j=0$, so $\phi$ is 1-to-l. Therefore $G$ and $G^{\prime}$ are isomorphic and so up to isomorphism there is only one nonabelian group of order $p q$.

\end{proof}


theorem exercise_2_10_1 {G : Type*} [group G] (A : subgroup G)
  [A.normal] {b : G} (hp : nat.prime (order_of b)) :
  A ⊓ (closure {b}) = ⊥ :=

Let $A$ be a normal subgroup of a group $G$, and suppose that $b \in G$ is an element of prime order $p$, and that $b \not\in A$. Show that $A \cap (b) = (e)$.

\begin{proof}

If $b \in G$ has order $p$, then $(b)$ is a cyclic group of order $p$. Since $A$ is a subgroup of $G$, we have $A \cap (b)$ is a subgroup of $G$. Also, $A \cap (b) \subseteq (b)$. So $A \cap (b)$ is a subgroup of $(b)$. Since $(b)$ is a cyclic group of order $p$, the only subgroups of $(b)$ are $(e)$ and $(b)$ itself.

Therefore, either $A \cap (b) = (e)$ or $A \cap (b) = (b)$. If $A \cap (b) = (e)$, then we are done. Otherwise, if $A \cap (b) = (b)$, then $A \subseteq (b)$. Since $A$ is a subgroup of $G$ and $A \subseteq (b)$, it follows that $A$ is a subgroup of $(b)$.

Since the only subgroups of $(b)$ are $(e)$ and $(b)$ itself, we have either $A = (e)$ or $A = (b)$. If $A = (e)$, then $A \cap (b) = (e)$ and we are done. But if $A = (b)$, then $b \in A$ as $b \in (b)$, which contradicts our hypothesis that $b \notin A$. So $A \neq (b)$.

Hence $A \cap (b) \neq (b)$. Therefore, $A \cap (b) = (e)$. This completes our proof.

\end{proof}


theorem exercise_2_11_7 {G : Type*} [group G] {p : ℕ} (hp : nat.prime p)
  {P : sylow p G} (hP : P.normal) :
  characteristic (P : subgroup G) :=

If $P \triangleleft G$, $P$ a $p$-Sylow subgroup of $G$, prove that $\varphi(P) = P$ for every automorphism $\varphi$ of $G$.

\begin{proof}

    Let $\phi$ be an automorphism of $G$. Let $P$ be a normal sylow p-subgroup. $\phi(P)$ is also a sylow-p subgroup. But since $P$ is normal, it is unique. Hence $\phi(P)=P$.

\end{proof}


theorem exercise_3_2_21 {α : Type*} [fintype α] {σ τ: equiv.perm α}
  (h1 : ∀ a : α, σ a = a ↔ τ a ≠ a) (h2 : τ ∘ σ = id) :
  σ = 1 ∧ τ = 1 :=

If $\sigma, \tau$ are two permutations that disturb no common element and $\sigma \tau = e$, prove that $\sigma = \tau = e$.

\begin{proof}

    Note that $\sigma \tau=e$ can equivalentnly be phrased as $\tau$ being the inverse of $\sigma$. Our statement is then equivalent to the statement that an inverse of a nonidentity permutation disturbs at least one same element as that permutation. To prove this, let $\sigma$ be a nonidentity permutation, then let $\left(i_1 \cdots i_n\right)$ be a cycle in $\sigma$. Then we have that

$$

\sigma\left(i_1\right)=i_2, \sigma\left(i_2\right)=i_2, \ldots, \sigma\left(i_{n-1}\right)=i_n, \sigma\left(i_n\right)=i_1,

$$

but then also

$$

i_1=\tau\left(i_2\right), i_2=\tau\left(i_3\right), \ldots, i_{n-1}=\tau\left(i_n\right), i_n=\tau\left(i_1\right),

$$

i.e. its inverse disturbs $i_1, \ldots, i_n$.

\end{proof}


theorem exercise_4_1_34 : equiv.perm (fin 3) ≃* general_linear_group (fin 2) (zmod 2) :=

Let $T$ be the group of $2\times 2$ matrices $A$ with entries in the field $\mathbb{Z}_2$ such that $\det A$ is not equal to 0. Prove that $T$ is isomorphic to $S_3$, the symmetric group of degree 3.

\begin{proof}

    The order of $T$ is $2^4-2^3-2^2+2=6$; we now find those six matrices:

$$

\begin{array}{ll}

A_1=\left(\begin{array}{ll}

1 & 0 \\

0 & 1

\end{array}\right), & A_2=\left(\begin{array}{ll}

0 & 1 \\

1 & 0

\end{array}\right) \\

A_3=\left(\begin{array}{ll}

1 & 0 \\

1 & 1

\end{array}\right), & A_4=\left(\begin{array}{ll}

1 & 1 \\

0 & 1

\end{array}\right) \\

A_5=\left(\begin{array}{ll}

0 & 1 \\

1 & 1

\end{array}\right), & A_6=\left(\begin{array}{ll}

1 & 1 \\

1 & 0

\end{array}\right)

\end{array}

$$

with orders $1,2,2,2,3,3$ respectively.

Note that $S_3$ is composed of elements

$$

\text{ id, (1 2), (1 3), (2 3), (1 2 3), (1 3 2)}

$$

with orders 1, 2, 2, 2, 3, 3 respectively. Also note that, by Problem 17 of generate $S_3$. We also have that $\left(\begin{array}{llll}1 & 3 & 2\end{array}\right)=\left(\begin{array}{llll}1 & 2 & 3\end{array}\right)\left(\begin{array}{lll}1 & 2 & 3\end{array}\right)$, that $\left(\begin{array}{lll}1 & 3\end{array}\right)=\left(\begin{array}{lll}1 & 2 & 3\end{array}\right)\left(\begin{array}{ll}1 & 2\end{array}\right)$, $\left(\begin{array}{ll}1 & 2\end{array}\right)\left(\begin{array}{lll}1 & 2 & 3\end{array}\right)=\left(\begin{array}{ll}2 & 3\end{array}\right)$ and $\left(\begin{array}{lll}1 & 2\end{array}\right)\left(\begin{array}{ll}1 & 2\end{array}\right)=\mathrm{id}$

Now we can check that $\tau\left(A_2\right)=\left(\begin{array}{ll}1 & 2\end{array}\right), \tau\left(A_5\right)=\left(\begin{array}{lll}1 & 2 & 3\end{array}\right)$ induces an isomorphism. We compute

$$

\begin{aligned}

& \tau\left(A_1\right)=\tau\left(A_2 A_2\right)=\tau\left(A_2\right) \tau\left(A_2\right)=\mathrm{id} \\

& \tau\left(A_3\right)=\tau\left(A_5 A_2\right)=\tau\left(A_5\right) \tau\left(A_2\right)=\left(\begin{array}{llll}

1 & 2 & 3

\end{array}\right)\left(\begin{array}{lll}

1 & 2

\end{array}\right)=\left(\begin{array}{ll}

1 & 3

\end{array}\right) \\

& \tau\left(A_4\right)=\tau\left(A_2 A_5\right)=\tau\left(A_2\right) \tau\left(A_5\right)=\left(\begin{array}{lll}

1 & 2

\end{array}\right)\left(\begin{array}{lll}

1 & 2 & 3

\end{array}\right)=\left(\begin{array}{ll}

2 & 3

\end{array}\right) \\

& \tau\left(A_6\right)=\tau\left(A_5 A_5\right)=\tau\left(A_5\right) \tau\left(A_5\right)=\left(\begin{array}{lll}

1 & 3 & 2

\end{array}\right)

\end{aligned}

$$

Thus we see that $\tau$ extendeds to an isomorphism, since $A_2$ and $A_5$ generate $T$, so that $\tau\left(A_i A_j\right)=\tau\left(A_i\right) \tau\left(A_j\right)$ follows from writing $A_i$ and $A_j$ in terms of $A_2$ and $A_5$ and using the equlities and relations shown above.

\end{proof}


theorem exercise_4_2_6 {R : Type*} [ring R] (a x : R)
  (h : a ^ 2 = 0) : a * (a * x + x * a) = (x + x * a) * a :=

If $a^2 = 0$ in $R$, show that $ax + xa$ commutes with $a$.

\begin{proof}

We need to show that

$$

a(a x+x a)=(a x+x a) a \text { for } a, x \in R .

$$

Now,

$$

\begin{gathered}

a(a x+x a)=a(a x)+a(x a) \\

=a^2 x+a x a \\

=0+a x a=a x a .

\end{gathered}

$$

Again,

$$

\begin{gathered}

(a x+x a) a=(a x) a+(x a) a \\

=a x a+x a^2 \\

=a x a+0=a x a .

\end{gathered}

$$

It follows that,

$$

a(a x+x a)=(a x+x a) a, \text { for } x, a \in R .

$$

This shows that $a x+x a$ commutes with $a$. This completes the proof.

\end{proof}


theorem exercise_4_3_1 {R : Type*} [comm_ring R] (a : R) :
  ∃ I : ideal R, {x : R | x*a=0} = I :=

If $R$ is a commutative ring and $a \in R$, let $L(a) = \{x \in R \mid xa = 0\}$. Prove that $L(a)$ is an ideal of $R$.

\begin{proof}

    First, note that if $x \in L(a)$ and $y \in L(a)$ then $x a=0$ and $y a=0$, so that

$$

\begin{aligned}

x a-y a & =0 \\

(x-y) a & =0,

\end{aligned}

$$

i.e. $L(a)$ is an additive subgroup of $R$. (We have used the criterion that $H$ is a subgroup of $G$ if for any $h_1, h_2 \in H$ we have that $h_1 h_2^{-1} \in H$.

Now we prove the conclusion. Let $r \in R$ and $b \in L(a)$, then $b a=0$, and so $x b a=0$ which by associativity of multiplication in $R$ is equivalent to

$$

(x b) a=0,

$$

so that $x b \in L(a)$. Since $R$ is commutative, (1) implies that $(bx)a=0$, so that $b x \in L(a)$, which concludes the proof that $L(a)$ is an ideal.

\end{proof}


theorem exercise_4_4_9 (p : ℕ) (hp : nat.prime p) :
  (∃ S : finset (zmod p), S.card = (p-1)/2 ∧ ∃ x : zmod p, x^2 = p) ∧
  (∃ S : finset (zmod p), S.card = (p-1)/2 ∧ ¬ ∃ x : zmod p, x^2 = p) :=

Show that $(p - 1)/2$ of the numbers $1, 2, \ldots, p - 1$ are quadratic residues and $(p - 1)/2$ are quadratic nonresidues $\mod p$.

\begin{proof}

    To find all the quadratic residues $\bmod p$ among the integers $1,2, \ldots, p-1$, we compute the least positive residues modulo $p$ of the squares of the integers $1,2, \ldots, p-1\}$.

Since there are $p-1$ squares to consider, and since each congruence $x^2 \equiv a (\bmod p)$ has either zero or two solutions, there must be exactly $\frac{(p-1)}{2}$ quadratic residues mod $p$ among the integers $1,2, \ldots, p-1$.

The remaining

$$

(p-1)-\frac{(p-1)}{2}=\frac{(p-1)}{2}

$$

positive integers less than $p-1$ are quadratic non-residues of $\bmod p$.

\end{proof}


theorem exercise_4_5_23 {p q: polynomial (zmod 7)}
  (hp : p = X^3 - 2) (hq : q = X^3 + 2) :
  irreducible p ∧ irreducible q ∧
  (nonempty $ polynomial (zmod 7) ⧸ ideal.span ({p} : set $ polynomial $ zmod 7) ≃+*
  polynomial (zmod 7) ⧸ ideal.span ({q} : set $ polynomial $ zmod 7)) :=

Let $F = \mathbb{Z}_7$ and let $p(x) = x^3 - 2$ and $q(x) = x^3 + 2$ be in $F[x]$. Show that $p(x)$ and $q(x)$ are irreducible in $F[x]$ and that the fields $F[x]/(p(x))$ and $F[x]/(q(x))$ are isomorphic.

\begin{proof}

    We have that $p(x)$ and $q(x)$ are irreducible if they have no roots in $\mathbb{Z}_7$, which can easily be checked. E.g. for $p(x)$ we have that $p(0)=5, p(1)=6, p(2)=6, p(3)=4, p(4)=6$, $p(5)=4, p(6)=4$, and similarly for $q(x)$.

We have that every element of $F[x] /(p(x))$ is equal to $a x^2+b x+c+(p(x))$, and likewise for $F[x] /(q(x))$. We consider a map $\tau$ : $F[x] /(p(x)) \rightarrow F[x] /(q(x))$ given by

$$

\tau\left(a x^2+b x+c+(p(x))\right)=a x^2-b x+c+(q(x)) .

$$

This map is obviously onto, and since $|F[x] /(p(x))|=|F[x] /(q(x))|=7^3$ by Problem 16, it is also one-to-one. We claim that it is a homomorphism. Additivity of $\tau$ is immediate by the linearity of addition of polynomial coefficient, so we just have to check the multiplicativity; if $n=a x^2+b x+$ $c+(p(x))$ and $m=d x^2+e x+f+(p(x))$ then

$$

\begin{aligned}

\tau(n m) & =\tau\left(a d x^4+(a e+b d) x^3+(a f+b e+c d) x^2+(b f+c e) x+c f+(p(x))\right) \\

& =\tau\left(2 a d x+2(a e+b d)+(a f+b e+c d) x^2+(b f+c e) x+c f+(p(x))\right) \\

& =\tau\left((a f+b e+c d) x^2+(b f+c e+2 a d) x+(c f+2 a e+2 b d)+(p(x))\right) \\

& =(a f+b e+c d) x^2-(b f+c e+2 a d) x+c f+2 a e+2 b d+(q(x)) \\

& =a d x^4-(a e+b d) x^3+(a f+b e+c d) x^2-(b f+c e) x+c f+(q(x)) \\

& =\left(a x^2-b x+c+(q(x))\right)\left(d x^2-e x+f+(q(x))\right) \\

& =\tau(n) \tau(m) .

\end{aligned}

$$

where in the second equality we used that $x^3+p(x)=2+p(x)$ and in the fifth we used that $x^3+$ $q(x)=-2+q(x)$

\end{proof}


theorem exercise_4_6_2 : irreducible (X^3 + 3*X + 2 : polynomial ℚ) :=

Prove that $f(x) = x^3 + 3x + 2$ is irreducible in $Q[x]$.

\begin{proof}

Let us assume that $f(x)$ is reducible over $\mathbb{Q}[x]$.

Then there exists a rational root of $f(x)$.

Let $p / q$ be a rational root of $f(x)$, where $\operatorname{gcd}(p, q)=1$.

Then $f(p / q)=0$.

Now,

$$

\begin{aligned}

& f(p / q)=(p / q)^3+3(p / q)+2 \\

\Longrightarrow & (p / q)^3+3(p / q)+2=0 \\

\Longrightarrow & p^3+3 p q^2=-2 q^3 \\

\Longrightarrow & p\left(p^2+3 q^2\right)=-q^3

\end{aligned}

$$

It follows that, $p$ divides $q$ which is a contradiction to the fact that $\operatorname{gcd}(p, q)=1$.

This implies that $f(x)$ has no rational root.

Now we know that, a polynomial of degree two or three over a field $F$ is reducible if and only if it has a root in $F$.

Now $f(x)$ is a 3 degree polynomial having no root in $\mathbb{Q}$.

So, $f(x)$ is irreducible in $\mathbb{Q}[x]$.

This completes the proof.

\end{proof}


theorem exercise_5_1_8 {p m n: ℕ} {F : Type*} [field F]
  (hp : nat.prime p) (hF : char_p F p) (a b : F) (hm : m = p ^ n) :
  (a + b) ^ m = a^m + b^m :=

If $F$ is a field of characteristic $p \neq 0$, show that $(a + b)^m = a^m + b^m$, where $m = p^n$, for all $a, b \in F$ and any positive integer $n$.

\begin{proof}

    Since $F$ is of characteristic $p$ and we have considered arbitrary two elements $a, b$ in $F$ we have

$$

\begin{aligned}

& p a=p b=0 \\

& \Longrightarrow p^n a=p^n b=0 \\

& \Longrightarrow m a=m b=0 \text {. } \\

&

\end{aligned}

$$

Now we know from Binomial Theorem that

$$

(a+b)^m=\sum_{i=0}^m\left(\begin{array}{c}

m \\

i

\end{array}\right) a^i b^{m-i}

$$

Here

$$

\left(\begin{array}{c}

m \\

i

\end{array}\right)=\frac{m !}{i !(m-i) !} .

$$

Now we know that for any integer $n$ and any integer $k$ satisfying $1 \leq k<n, n$ always divides $\left(\begin{array}{l}n \\ k\end{array}\right)$. So in our case for $i$ in the range $1 \leq i<m, m$ divides $\left(\begin{array}{c}m \\ i\end{array}\right)$. It follows that $p$ divides $\left(\begin{array}{c}m \\ i\end{array}\right)$, for $i$ satisfying $1 \leq i<m$, since $m=p^n$ for any integer $n$. Therefore other than the terms $a^m$ and $b^m$ in the expansion $\sum_{i=0}^m\left(\begin{array}{c}m \\ i\end{array}\right) a^i b^{m-i}$ will vanish due to char $p$ nature of $F$.

Hence we have

$$

\sum_{i=0}^m\left(\begin{array}{c}

m \\

i

\end{array}\right) a^i b^{m-i}=a^m+b^m

$$

This follows that, for all $a, b \in F$

$$

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

$$

This completes the proof.

\end{proof}


theorem exercise_5_3_7 {K : Type*} [field K] {F : subfield K}
  {a : K} (ha : is_algebraic F (a ^ 2)) : is_algebraic F a :=

If $a \in K$ is such that $a^2$ is algebraic over the subfield $F$ of $K$, show that a is algebraic over $F$.

\begin{proof}

    Since $a^2$ is algebraic over $F$, there exist a non-zero polynomial $f(x)$ in $F[x]$ such that $f\left(a^2\right)=0$. Consider a new polynomial $g(x)$ defined as $g(x)=f\left(x^2\right)$. Clearly $g(x) \in F[x]$ and $g(a)=f\left(a^2\right)= 0$.

\end{proof}


theorem exercise_5_4_3 {a : ℂ} {p : ℂ → ℂ}
  (hp : p = λ x, x^5 + real.sqrt 2 * x^3 + real.sqrt 5 * x^2 +
  real.sqrt 7 * x + 11)
  (ha : p a = 0) :
  ∃ p : polynomial ℂ , p.degree < 80 ∧ a ∈ p.roots ∧
  ∀ n : p.support, ∃ a b : ℤ, p.coeff n = a / b :=

If $a \in C$ is such that $p(a) = 0$, where $p(x) = x^5 + \sqrt{2}x^3 + \sqrt{5}x^2 + \sqrt{7}x + \sqrt{11}$, show that $a$ is algebraic over $\mathbb{Q}$ of degree at most 80.

\begin{proof}

    Given $a \in \mathbb{C}$ such that $p(a)=0$, where

$$

p(x)=x^5+\sqrt{2} x^3+\sqrt{5} x^2+\sqrt{7} x+\sqrt{11}

$$

Here, we note that $p(x) \in \mathbb{Q}(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11})$ and

$$

\begin{aligned}

    {[Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11}): \mathbb{Q}] } & =[Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11}): Q(\sqrt{2}, \sqrt{5}, \sqrt{7})] \cdot[\mathbb{Q}(\sqrt{2}, \sqrt{5}, \sqrt{7}): \mathbb{Q}(\sqrt{2}, \sqrt{5})] \\

& \cdot[\mathbb{Q}(\sqrt{2}, \sqrt{5}): \mathbb{Q}(\sqrt{2})] \cdot[\mathbb{Q}(\sqrt{2}): \mathbb{Q}] \\

& =2 \cdot 2 \cdot 2 \cdot 2 \\

& =16

\end{aligned}

$$

Here, we note that $p(x)$ is of degree 5 over $\mathbb{Q}(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11})$. If $a$ is root of $p(x)$, then

$$

[Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11}, a): \mathbb{Q}]=[Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11}): Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11})] \cdot 15

$$

and $[Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11}): Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11})] \leq 5$. We get equality if $p(x)$ is irreducible over $Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11})$. This gives

$$

[Q(\sqrt{2}, \sqrt{5}, \sqrt{7}, \sqrt{11}, a): \mathbb{Q}] \leq 16 \cdot 5=80

$$

\end{proof}


theorem exercise_5_6_14 {p m n: ℕ} (hp : nat.prime p) {F : Type*}
  [field F] [char_p F p] (hm : m = p ^ n) :
  card (root_set (X ^ m - X : polynomial F) F) = m :=

If $F$ is of characteristic $p \neq 0$, show that all the roots of $x^m - x$, where $m = p^n$, are distinct.

\begin{proof}

    Let us consider $f(x)=x^m-x$. Then $f \in F[x]$.

Claim: $f(x)$ has a multiple root in some extension of $F$ if and only if $f(x)$ is not relatively prime to its formal derivative, $f^{\prime}(x)$.

Proof of the Claim: Let us assume that $f(x)$ has a multiple root in some extension of $F$. Let $y$ be a multiple root of $f(x)$. Then over a splitting field, we have

$$

f(x)=(x-y)^n g(x), \text { for some integer } n \geq 2 .

$$

Here $g(x)$ is a polynomial such that $g(y) \neq 0$. Now taking derivative of $f$ we get

$$

f^{\prime}(x)=n \cdot(x-y)^{n-1} g(x)+(x-y)^n g^{\prime}(x)

$$

here $g^{\prime}(x)$ implies derivative of $g$ with respect to $x$. Since we have $n \geq 2$, this implies $(n-1) \geq 1$. Hence, (1) shows that $f^{\prime}(x)$ has $y$ as a root. Therefore, $f(x)$ is not relatively prime to $f^{\prime}(x)$. We now prove the other direction.

Conversely, let us assume that $f(x)$ is not relatively prime to $f^{\prime}(x)$. Let $y$ is a root of both $f(x)$ and $f^{\prime}(x)$. Since $y$ is a root of $f(x)$, we can write

$$

f(x)=(x-y) \cdot g(x)

$$

for some polynomial $g(x)$. then taking derivative of $f(x)$ we have

$$

f^{\prime}(x)=g(x)+(x-y) \cdot g^{\prime}(x)

$$

where $g^{\prime}(x)$ is the derivative of $g(x)$ with respect to $x$. Since $y$ is a root of $f^{\prime}(x)$ also we have

$$

f^{\prime}(y)=0

$$

Then we have

$$

\begin{aligned}

& f^{\prime}(y)=g(y)+(y-y) \cdot g^{\prime}(y) \\

\Longrightarrow & f^{\prime}(y)=g(y) \\

\Longrightarrow & g(y)=0 .

\end{aligned}

$$

This implies $y$ is a root of $g(x)$ also. Therefore we have

$$

g(x)=(x-y) \cdot h(x)

$$

for some polynomial $h(x)$. Now form (2) we have

$$

f(x)=(x-y)^2 \cdot h(x) .

$$

This follows that $y$ is a multiple root of $f(x)$. Therefore, $f(x)$ has a multiple root in some extension of the field $F$. This completes the proof of the Claim.

In our case, $f(x)=x^m-x$, where $m=p^n$. Now we calculate the derivative of $f$. That is

$$

f^{\prime}(x)=m x^{m-1}-1=-1(\bmod p) .

$$

By the above condition it follows that, $f^{\prime}$ has no root same as $f$, that is, $f(x)$ and $f^{\prime}(x)$ are relatively prime. Hence, $f(x)$ has no multiple root in $F$. Since $f(x)=x^m-x$ is a polynomial of degree $m$, it follows that $f(x)$ has $m$ distinct roots in $F$, where $m=p^n$. This completes the proof.

\end{proof}


theorem exercise_2_3_2 {G : Type*} [group G] (a b : G) :
  ∃ g : G, b* a = g * a * b * g⁻¹ :=

import .common

open function fintype subgroup ideal polynomial submodule zsqrtd char_p
open_locale big_operators
noncomputable theory

Prove that the products $a b$ and $b a$ are conjugate elements in a group.

\begin{proof}

    We have that $(a^{-1})ab(a^{-1})^{-1} = ba$.

\end{proof}


theorem exercise_2_8_6 {G H : Type*} [group G] [group H] :
  center (G × H) ≃* (center G) × (center H) :=

Prove that the center of the product of two groups is the product of their centers.

\begin{proof}

    We have that $(g_1, g_2)\cdot (h_1, h_2) = (h_1, h_2)\cdot (g_1, g_2)$ if and only if $g_1h_1 = h_1g_1$ and $g_2h_2 = h_2g_2$.

\end{proof}


theorem exercise_3_2_7 {F : Type*} [field F] {G : Type*} [field G]
  (φ : F →+* G) : injective φ :=

Prove that every homomorphism of fields is injective.

\begin{proof}

    Suppose $f(a)=f(b)$, then $f(a-b)=0=f(0)$. If $u=(a-b) \neq 0$, then $f(u) f\left(u^{-1}\right)=f(1)=1$, but that means that $0 f\left(u^{-1}\right)=1$, which is impossible. Hence $a-b=0$ and $a=b$.

\end{proof}


theorem exercise_3_7_2 {K V : Type*} [field K] [add_comm_group V]
  [module K V] {ι : Type*} [fintype ι] (γ : ι → submodule K V)
  (h : ∀ i : ι, γ ι ≠ ⊤) :
  (⋂ (i : ι), (γ i : set V)) ≠ ⊤ :=

Let $V$ be a vector space over an infinite field $F$. Prove that $V$ is not the union of finitely many proper subspaces.

\begin{proof}

    If $V$ is the set-theoretic union of $n$ proper subspaces $W_i$ ( $1 \leq i \leq n$ ), then $|F| \leq n-1$.

Proof. We may suppose no $W_i$ is contained in the union of the other subspaces. Let $u \in W_i, \quad u \notin \bigcup_{j \neq i} W_j$ and $v \notin W_i$.

Then $(v+F u) \cap W_i=\varnothing$ and $(v+F u) \cap W_j(j \neq i)$ contains at most one vector since otherwise $W_j$ would contain $u$. Hence

$$

|v+F u|=|F| \leq n-1 .

$$

Corollary: Avoidance lemma for vector spaces.

Let $E$ be a vector space over an infinite field. If a subspace is contained in a finite union of subspaces, it is contained in one of them.

\end{proof}


theorem exercise_6_4_2 {G : Type*} [group G] [fintype G] {p q : ℕ}
  (hp : prime p) (hq : prime q) (hG : card G = p*q) :
  is_simple_group G → false :=

Prove that no group of order $p q$, where $p$ and $q$ are prime, is simple.

\begin{proof}

    If $|G|=n=p q$ then the only two Sylow subgroups are of order $p$ and $q$.

From Sylow's third theorem we know that $n_p \mid q$ which means that $n_p=1$ or $n_p=q$.

If $n_p=1$ then we are done (by a corollary of Sylow's theorem)

If $n_p=q$ then we have accounted for $q(p-1)=p q-q$ elements of $G$ and so there is only one group of order $q$ and again we are done.

\end{proof}


theorem exercise_6_4_12 {G : Type*} [group G] [fintype G]
  (hG : card G = 224) :
  is_simple_group G → false :=

Prove that no group of order 224 is simple.

\begin{proof}

    The following proves there must exist a normal Sylow 2 -subgroup of order 32 ,

Suppose there are $n_2=7$ Sylow 2 -subgroups in $G$. Making $G$ act on the set of these Sylow subgroups by conjugation (Mitt wrote about this but on the set of the other Sylow subgroups, which gives no contradiction), we get a homomorphism $G \rightarrow S_7$ which must be injective if $G$ is simple (why?).

But this cannot be since then we would embed $G$ into $S_7$, which is impossible since $|G| \nmid 7 !=\left|S_7\right|$ (why?)

\end{proof}


theorem exercise_10_1_13 {R : Type*} [ring R] {x : R}
  (hx : is_nilpotent x) : is_unit (1 + x) :=

An element $x$ of a ring $R$ is called nilpotent if some power of $x$ is zero. Prove that if $x$ is nilpotent, then $1+x$ is a unit in $R$.


theorem exercise_10_6_7 {I : ideal gaussian_int}
  (hI : I ≠ ⊥) : ∃ (z : I), z ≠ 0 ∧ (z : gaussian_int).im = 0 :=

Prove that every nonzero ideal in the ring of Gauss integers contains a nonzero integer.

\begin{proof}

    Let $I$ be some nonzero ideal. Then there exists some $z \in \mathbb{Z}[i], z \neq 0$ such that $z \in I$. We know that $z=a+b i$, for some $a, b \in \mathbb{Z}$. We consider three cases:

1. If $b=0$, then $z=a$, so $z \in \mathbb{Z} \cap I$, and $z \neq 0$, so the statement of the exercise holds.

2. If $a=0$, then $z=i b$. Since $z \neq 0$, we conclude that $b \neq 0$. Since $I$ is an ideal in $\mathbb{Z}[i]$, and $i \in \mathbb{Z}[i]$, we conclude that $i z \in I$. Furthermore, $i z=-b \in \mathbb{Z}$. Thus, $i z$ is a nonzero integer which is in $I$.

3. Let $a \neq 0$ and $b \neq 0$. Since $I$ is an ideal and $z \in I$, we conclude that $z^2 \in I$; that is,

$$

(a+b i)^2=a^2-b^2+2 a b i \in I

$$

Furthermore, since $-2 a \in \mathbb{Z}[i]$, and $z \in I$ and $I$ is an ideal, $-2 a z \in I$; that is,

$$

-2 a z=-2 a(a+b i)=-2 a^2-2 a b i \in I

$$

Since $I$ is closed under addition,

$$

\left(a^2-b^2+2 a b i\right)+\left(-2 a^2-2 a b i\right) \in I \Longrightarrow-a^2-b^2 \in I

$$

Notice that $-a^2-b^2 \neq 0$ since $a^2>0$ and $b^2>0$, so $-a^2-b^2<0$. Furthermore, it is an integer. Thus, we have found a nonzero integer in $I$.

\end{proof}


theorem exercise_10_4_7a {R : Type*} [comm_ring R] [no_zero_divisors R]
  (I J : ideal R) (hIJ : I + J = ⊤) : I * J = I ⊓ J :=

Let $I, J$ be ideals of a ring $R$ such that $I+J=R$. Prove that $I J=I \cap J$.

\begin{proof}

    We have seen that $IJ \subset I \cap J$, so it remains to show that $I \cap J \subset IJ$.  Since $I+J = (1)$, there are elements $i \in I$ and $j \in J$ such that $i+j = 1$.  Let $k \in I \cap J$, and multiply $i+j=1$ through by $k$ to get $ki+kj = k$.  Write this more suggestively as

\[ k = ik+kj. \]

The first term is in $IJ$ because $k \in J$, and the second term is in $IJ$ because $k \in I$, so $k \in IJ$ as desired.

\end{proof}


theorem exercise_11_2_13 (a b : ℤ) :
  (of_int a : gaussian_int) ∣ of_int b → a ∣ b :=

If $a, b$ are integers and if $a$ divides $b$ in the ring of Gauss integers, then $a$ divides $b$ in $\mathbb{Z}$.

\begin{proof}

    Suppose $a|b$ in $\mathbb{Z}[i]$ and $a,b\in\mathbb{Z}$. Then $a(x+yi)=b$ for $x,y\in\mathbb{Z}$. Expanding this we get $ax+ayi=b$, and equating imaginary parts gives us $ay=0$, implying $y=0$.

\end{proof}


theorem exercise_11_4_6a {F : Type*} [field F] [fintype F] (hF : card F = 7) :
  irreducible (X ^ 2 + 1 : polynomial F) :=

Prove that $x^2+x+1$ is irreducible in the field $\mathbb{F}_2$.

\begin{proof}

    If $x^2+x+1$ were reducible in $\mathbb{F}_2$, its factors must be linear. But we neither have that $0^2+0+1=$ nor $1^2+1+1=0$, therefore $x^2+x+1$ is irreducible.

\end{proof}


theorem exercise_11_4_6c : irreducible (X^3 - 9 : polynomial (zmod 31)) :=

Prove that $x^3 - 9$ is irreducible in $\mathbb{F}_{31}$.

\begin{proof}

    If $p(x) = x^3-9$ were reducible, it would have a linear factor, since it either has a linear factor and a quadratic factor or three linear factors. We can then verify by brute force that $p(x)\neq 0$ for $x \in \mathbb{F}_31$.

\end{proof}


theorem exercise_11_13_3 (N : ℕ):
  ∃ p ≥ N, nat.prime p ∧ p + 1 ≡ 0 [MOD 4] :=

Prove that there are infinitely many primes congruent to $-1$ (modulo $4$).

\begin{proof}

    First we show a lemma: if $a \equiv 3(\bmod 4)$ then there exists a prime $p$ such that $p \mid a$ and $p \equiv 3(\bmod 4)$.

    Clearly, all primes dividing $a$ are odd. Suppose all of them would be $\equiv 1(\bmod 4)$. Then their product would also be $a \equiv 1(\bmod 4)$, which is a contradiction.

To prove the main claim, suppose that $p_1, \ldots, p_n$ would be all such primes. (In particular, we have $p_1=3$.) Consider $a=4 p_2 \cdots p_n+3$. (Or you can take $a=4 p_2 \cdots p_n-1$.) Show that $p_i \nmid a$ for $i=1, \ldots, n$. (The case $3 \nmid a$ is solved differently than the other primes - this is the reason for omitting $p_1$ in the definition of $a$.) Then use the above lemma to get a contradiction.

\end{proof}


theorem exercise_13_6_10 {K : Type*} [field K] [fintype Kˣ] :
  ∏ (x : Kˣ), x = -1 :=

Let $K$ be a finite field. Prove that the product of the nonzero elements of $K$ is $-1$.

\begin{proof}

    Since we are working with a finite field with $q$ elements, anyone of them is a root of the following polynomial

$$

x^q-x=0 .

$$

In particular if we rule out the 0 element, any $a_i \neq 0$ is a root of

$$

x^{q-1}-1=0 .

$$

This polynomial splits completely in $\mathbb{F}_q$ so we find

$$

\left(x-a_1\right) \cdots\left(x-a_{q-1}\right)=0

$$

in particular

$$

x^{q-1}-1=\left(x-a_1\right) \cdots\left(x-a_{q-1}\right)

$$

Thus $a_1 \cdots a_{q-1}=-1$.

\end{proof}


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

import .common

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

open_locale pointwise
open_locale big_operators
noncomputable theory

Prove the the operation $\star$ on $\mathbb{Z}$ defined by $a\star b=a-b$ is not commutative.

\begin{proof}

    Not commutative since

$$

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

$$

$$

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

$$

\end{proof}


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

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

\begin{proof}

    We have

$$

\begin{aligned}

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

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

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

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

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

\end{aligned}

$$

since integer multiplication is associative.

\end{proof}


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

\begin{proof}

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

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

$$

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

$$

since

$$

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

$$

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

$$

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

$$

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

$$

\begin{aligned}

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

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

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

\end{aligned}

$$

using associativity and the base case where necessary.

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

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

$$

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

$$

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

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

$$

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

$$

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

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

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

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

$$

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

$$

Hence $A \times B$ is abelian.

\end{proof}


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

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

\begin{proof}

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

$$

\begin{gathered}

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

f(n)=(1 n)

\end{gathered}

$$

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

\end{proof}


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

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

\begin{proof}

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

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

$$

\begin{aligned}

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

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

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

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

\end{aligned}

$$

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

\end{proof}


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

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

\begin{proof}

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

Claim: $f$ is injective.

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

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

$$

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

$$

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

\end{proof}


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

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

\begin{proof}

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

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

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

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

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

$$

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

$$

\end{proof}


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

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

\begin{proof}

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

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

\end{proof}


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

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

\begin{proof}

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

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

$$

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

$$

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

\end{proof}


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

Prove that quotient groups of a solvable group are solvable.

\begin{proof}

    Next, note that

$$

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

$$

By the Second Isomorphism Theorem, we then have

$$

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

$$

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

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

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

$$

Moreover, the Third Isomorphism Theorem says that

$$

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

$$

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

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

$$

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

$$

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

$$

\begin{aligned}

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

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

\end{aligned}

$$

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

$$

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

$$

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

$$

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

$$

and we get

$$

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

$$

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

\end{proof}


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

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

\begin{proof}

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

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

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

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

$$

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

$$

a prime.

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

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


theorem exercise_4_4_6b :
  ∃ (G : Type*) (hG : group G) (H : @subgroup G hG), @characteristic G hG H  ∧ ¬ @subgroup.normal G hG H :=

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

Since $|G|=56=2^{3}.7$, $G$ has $2-$Sylow subgroup of order $8$, as well as $7-$Sylow subgroup of order $7$. Now, we count the number of such subgroups. Let $n_{7}$ be the number of  $7-$Sylow subgroup and $n_{2}$ be the number of  $2-$Sylow subgroup. Now $n_{7}=1+7k$ where $1+7k|8$. The choices for $k$ are $0$ or $1$. If $k=0$, there is only one $7-$Sylow subgroup and hence normal. So, assume now, that there are $8$ $7-$Sylow subgroup(for $k=1$). Now we look at $2-$ Sylow subgroups. $n_{2}=1+2k| 7$. So choice for $k$ are $0$ and $3$. If $k=0$, there is only one $2-$Sylow subgroup and hence normal. So, assume now, that there are $7$ $2-$Sylow subgroup (for $k=3$). Now we claim that simultaneously, there cannot be $8$ $7-$Sylow subgroup and $7$ $2-$Sylow subgroup. So, either $7-$Sylow subgroup is normal being unique, or  the $2-$Sylow subgroup is normal. Now, to prove the claim, we observe that there are 48 elements of order $7$. Let $H_{1}$ and $H_{2}$ be two distinct  $2-$Sylow subgroup. Now $|H_{1}|=8$. So we already get $48+8=56$ distinct elements in the group. Now $H_{2}$ being distinct from $H_{1}$, has at least one element which is not in $H_{1}$. This adds one more element in the group, at the least. Now already we have number of elements in the group exceeding the number of element in $G$. This gives a contradiction and proves the claim.

\end{proof}


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

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

\begin{proof}

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

\end{proof}


theorem exercise_4_5_17 {G : Type*} [fintype G] [group G]
  (hG : card G = 105) :
  nonempty(sylow 5 G) ∧ nonempty(sylow 7 G) :=

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

\begin{proof}

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

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

\end{proof}


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

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

\begin{proof}

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

Hence $G$ is not simple.

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

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

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

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

and

$$

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

$$

Thus $-u$ is a unit.

\end{proof}


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

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

\begin{proof}

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

\end{proof}


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

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

\begin{proof}

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

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

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

For the base case, note that

$$

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

$$

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

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

$$

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

$$

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

$$

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

$$

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

$$

a_t q(x) p(x)=0

$$

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

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

\end{proof}


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

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

\begin{proof}

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

$$

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

$$

Thus $r \in Z(S)$.

\end{proof}


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

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

\begin{proof}

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

\end{proof}