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

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

\begin{proof}

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

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

\end{proof}


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

import .common

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

open_locale pointwise
open_locale big_operators
noncomputable theory

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

\begin{proof}

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

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

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

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

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

By the Third Isomorphism Treorem

$$

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

$$

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

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

\end{proof}


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

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

\begin{proof}

$$

x^4-4 x^3+6

$$

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

\end{proof}


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

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

\begin{proof}

$$

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

$$

We calculate $p(x-1)$

$$

\begin{aligned}

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

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

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

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

1 & =1

\end{aligned}

$$

$$

\begin{aligned}

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

& 8 x-2 \\

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

\end{aligned}

$$

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

Since:

$$

\begin{aligned}

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

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

\end{aligned}

$$

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

\end{proof}


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

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

\begin{proof}

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

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

Suppose to the contrary.

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

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

Now we have

$$

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

$$

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

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

\end{proof}


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

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

\begin{proof}

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

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

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

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

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

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

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

\end{proof}