\documentclass[../main_text.tex]{subfiles}
\begin{document}

\section*{Week 1}

\exercise*[0.3.6]
% For some reason I can't put a fitted tcbox here and I really don't like it
\begin{tcolorbox}
    Prove:
    \begin{enumerate}[label=\emph{\alph*)}]
        \item $A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$
        \item $A \cup (B \cap C) = (A \cup B) \cap (a \cup C)$
    \end{enumerate}
\end{tcolorbox}

\begin{enumerate}[label=\emph{\alph*)}, wide]
    \item In order to prove this equivalence, we have to prove the implication both ways. We use two lemmas for this.

        \begin{lemma}
            \label{lem:set1}
            $A \cap (B \cup C) \implies (A \cap B) \cup (A \cap C)$
        \end{lemma}

        Let $x \in A \cap (B \cup C)$.
        By the definition of set intersection, $x \in A$ and $x \in B \cup C$.
        By the definition of set union, $x \in A$ and $(x \in B$ or $x \in C)$.
        From propositional logic we know that for propositions $P$, $Q$ and $R$ the following holds:
        $P \land (Q \lor R) \iff (P \land Q) \lor (P \land R)$.
        So, substituting for this particular case yields $(x \in A$ and $x \in B)$ or $(x \in A$ and $x \in C)$.
        Using the definition of set intersection again gets $x \in A \cap B$ or $x \in A \cap C$. 
        Using the definition of set union again gives $x \in (A \cap B) \cup (A \cap C)$. \qed

        \begin{lemma}
            \label{lem:set2}
            $(A \cap B) \cup (A \cap C) \implies A \cap (B \cup C)$
        \end{lemma}

        Let $x \in (A \cap B) \cup (A \cap C)$.
        By the definition of set union, $x \in (A \cap B)$ or $x \in (A \cap C)$.
        By the definition of set intersection, $(x \in A$ or $x \in B)$ and $(x \in A$ or $x \in B)$.
        Using the same propositional logical equivalence as in Lemma \ref{lem:set1}, this gives 
        $x \in A$ and $(x \in B$ or $x \in C)$.
        Wrapping up, we use the definition of set union to get $x \in A$ and $x \in B \cup C$ and
        the definition of intersection to get $x \in A \cap (B \cup C)$. \qed

        Using Lemma \ref{lem:set1} and \ref{lem:set2}, we get the desired equivalence of 
        $A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$. \qed
    \item This proof is so similar to a) that it feels like a waste of time and will therefore be left to the reader.
\end{enumerate}


\exercise*[0.3.11]
\tcbox{Prove by induction that $n < 2^n$ for all $n \in \N$.}

For this proof we will use induction. For this, we have to prove the base case, i.e. $n = 1$,
and the inductive step, $n < 2^n \implies n + 1 < 2^{n+1}$.

First, let's prove the base case. When $n = 1$, we get $1 < 2^1$, which is certainly true.

Then, for the inductive step. We assume that the proposition holds for any $m \in \N$.
So, $m < 2^m$. Multiplying both sides with 2 gives $2m < 2^{m+1}$.
Since $m \geq 1$, $m + 1 < 2m$, and thus $m + 1 < 2m < 2^{m+1}$.

Since both the base case and inductive step hold, we can close the induction, proving the proposition. \qed


\exercise*[0.3.12]
\tcbox{Show that for a finite set $A$ of cardinality $n$, the cardinality of $\mathcal{P}(A)$ is $2^n$.}

The power set of a set $A$, $\mathcal{P}(A)$, is defined as the set of all possible subsets of $A$.
This is very similar to an inclusion/exclusion problem.
It is built up by all the possible combinations of the different elements being either inside a certain subset or not.
For all possible subsets of $A$, we have that for every element $x \in A$ there are 2 possibilities,
either $x$ is in the subset or it isn't.
This means that for every additional element, the number of subsets increases by a factor of 2, with a minimum of 1,
in case of $A = \emptyset$. We will prove this formally now, using induction. 

For this, the base case is a set of 1 element (but the theorem also holds for the empty set, where $n=0$).
Let us assume that $A := \{ \pi \}$.
Then the cardinality of $\mathcal{P}(A)$ is $2^1$, with $\mathcal{P}(A)= \{ \emptyset, \{ \pi \}\}$.

For the inductive step, we assume that for any set $B$ of cardinality $m$, the cardinality of the power set of $B$
is $2^m$. Then, we will add an element $x \notin B$ to $B$ to increase its cardinality by 1, to $m + 1$,
creating a new set $C$.
Note that all the possible subsets of $B$ are still viable subsets of $C$, since $B \subset C$.
In order to create the new subsets, we can simply keep all the subsets of $B$, duplicate them and take the union with
the new element $x$, so now we also have all combinations of the old sets with possibly $x$ being in them.
Since this doubles the number of subsets, the cardinality of $\mathcal{P}(C)$ is $2^{m+1}$.

Both the base case and the inductive step hold, which closes the induction and proves the proposition. \qed

\exercise*[0.3.15]
\tcbox{Prove that $n^3 + 5n$ is divisible by 6 for all $n \in \N$.}

In order to prove this proposition, we will use induction. To do this, we need to prove the following lemma,
of which we will see the usefulness later:

\begin{lemma}
    \label{lem:div6}
    $3n^2 + 3n + 6$ is divisible by 6 for all $n \in \N$.
\end{lemma}

This lemma we will also prove by induction. For this, we prove the base case and the inductive step.
First, for the base case we have $n = 1$, yielding $3 * 1^2 + 3 * 1 + 6 = 12$, which is divisibly by 6.

Then, for the inductive step we assume that the lemma holds for a certain $m \in \N$.
So, $3m^2 + 3m + 6$ is divisible by 6. 
Substituting $m$ with $m+1$ gives $3(m+1)^2 + 3(m+1) + 6$, which can be expanded to
$3m^2 + 9m + 12$. Rewriting this with our assumption in mind gives the following:
$(3m^2 + 3m + 6) + (6m + 6)$. We know from our assumption that the first part is divisible by 6, and since $m \in \N$,
$6m + 6$ is also divisible by 6, and so the whole expression is as well. \qed

Now for the original proposition. We will prove this by induction. First we prove the base case, where $n=1$.
Then, $1^3 + 5*1 = 6$, which is definitely divisible by 6.

For the inductive step, we assume that the proposition holds for a certain $m \in \N$. So, $m^3 + 5m$ is divisible by 6.
When we increase $m$ by 1, we get: $(m+1)^3 + 5(m+1)$.
Expanded, this is the same as $m^3 + 3m^2 + 8m + 6$. When we rearrange the terms we can get the following expression:
$(m^3 + 5m) + (3m^2 + 3m + 6)$. From Lemma \ref{lem:div6}, we know that the latter part is divisible by 6.
The prior part is divisible by 6 because of the assumption of the inductive step. So together, this expression
is also divisible by 6. \qed


\exercise*[0.3.19]
\begin{tcolorbox}
    Give an example of a countably infinite collection of finite sets $A_1, A_2,...$,
    whose union is not a finite set.
\end{tcolorbox}

The easiest example is simply the collection of singleton sets containing a natural number.
So each set $A_i := \{i\}  \forall  i \in \N$. Since $\N$ is countably infinite, so the collection of sets.
Each set is definitely finite, because they all contain just one element.
Finally, the union of the collection of sets is equal to $\N$, which is not a finite set.

\exercise*
\begin{tcolorbox}
    \begin{enumerate}[label=\emph{\alph*)}, wide]
        \item Compute $f(4/15)$. Find $q$ such that $f(q) = 108$.
        \item Use the \textbf{Theorem} to prove that $f$ is a bijection.
    \end{enumerate}
\end{tcolorbox}

See the assignment PDF for the full assignment specification and theorem.

\begin{enumerate}[label=\emph{\alph*)}, wide]
    \item $\frac{4}{15}$, if written as a product of prime factors, is equal to $\frac{2^2}{3^1*5^1}$.
        Since this fraction is not a natural number, we have to use the second part of the definition of $f$.
        So, $f(q) = 2^{2*2} * 3^{2 * 1 - 1} * 5^{2 * 1 - 1} = 240$.

        For the inverse of $f$, it is still necessary to compute the factorization in prime numbers.
        Using the powers of the primes we can deduce whether the prime present is, if applicable,
        part of either the numerator or the denominator.
        $180 = 2^2 * 3^2 * 5^1$. Because of the way $f$ is defined, we know that all the prime factors with an even
        power are part of the numerator and all prime factors with an odd power are part of the denominator (except 1,
        which just maps to itself). When we backtrack using this information, we then get the following fraction:
        $\frac{2^1 * 3^1}{5^1} = \frac{6}{5}$.
    \item In order to prove that $f$ is a bijection, we have to prove that $f$ is injective and surjective.
        \begin{description}
            \item[Injectivity:] We want to show that $f$ is 1-1,
                i.e. $f(x_1)=f(x_2) \implies x_1 = x_2$.

                So, let's assume that for any $x_1, x_2 \in \{ q > 0 : q \in \Q \}$, $f(x_1) = f(x_2)$.
                Since the function $f$ has 3 parts, based on the input, we have to prove this statement for those 3
                parts separately as well. First, the easiest case, where the input set is $\{1\}$.
                Then, $f(x) = 1 \forall x$, so $f$ is injective.

                For the case where $x \in \N\backslash\{1\}$, $f(x) := p_1^{2r_1}***p_N^{2r_N}$.
                We know from the \textbf{Theorem} that any fraction can be uniquely written as a product of prime
                factors with exponents, so when we assume $f(x_1) = f(x_2)$, we can also assume that $x_1$ and $x_2$
                have a unique prime factorization associated with them. So let's assume that $f(x_1) = f(x_2)$.
                This means that $p_1^{2r_1}***p_N^{2r_N} = q_1^{2s_1}***q_M^{2s_M}$, where $p_i^{r_i}$ and $q_j^{s_j}$
                denote the prime factors for both sides. We can further expand this expression into:

                \begin{align}
                    p_1^{r_1} * p_1^{r_1} *** p_N^{r_N} * p_N^{r_N} &=
                    q_1^{s_1} * q_1^{s_1} *** q_M^{s_M} * q_M^{s_M} \implies \\
                    p_1^{r_1}***p_N^{r_N} * p_1^{r_1}***p_N^{r_N} &=
                    q_1^{s_1}***q_M^{s_1} * q_1^{s_1}***q_N^{s_M} \implies \\
                    x_1 * x_1 &= x_2 * x_2
                \end{align}

                Because we know that each fraction constitutes a unique prime factorization, we also know that $x_1$ and
                $x_2$ are uniquely derived. This is why the implications in the equation above hold.
                Because both $x_1$ and $x_2 > 0$, $x_1 = x_2$.

                Now for the case where $x \in \Q\backslash\N$. 
                Then $f(x) := p_1^{2r_1}***p_N^{2r_N}q_1^{2s_1-1}***q_M^{2s_M-1}$, using the unique factorization
                derived from the \textbf{Theorem}. So again, we assume that for any $x_1, x_2 \in \Q\backslash\N$,
                $f(x_1) = f(x_2)$.
                Using the definition of $f$, we get:
                $p_1^{2r_1}***p_N^{2r_N}q_1^{2s_1-1}***q_M^{2s_M-1} =
                v_1^{2t_1}***v_n^{2t_n}w_1^{2u_1-1}***w_m^{2u_m-1}$.\footnote{The super- and subscripts become a bit
                abracadabra, but I think everything is unique and readable this way.}
                Expanding this expression further, we get:

                \begin{align}
                    \frac{p_1^{2r_1}}{p_1}***\frac{p_N^{2r_N}}{p_N}\frac{q_1^{2s_1}}{q_1}***\frac{q_M^{2s_M}}{q_M} &=
                    \frac{v_1^{2t_1}}{v_1}***\frac{v_n^{2t_n}}{v_n}\frac{w_1^{2u_1}}{w_1}***\frac{w_m^{2u_m}}{w_m} 
                    \implies \\
                    \frac{p_1^{r_1}*p_1^{r_1}}{p_1}***\frac{p_N^{r_N}*p_N^{r_N}}{p_N}
                    \frac{q_1^{s_1}*q_1^{s_1}}{q_1}***\frac{q_M^{s_M}*q_M^{s_M}}{q_M} &=
                    \frac{v_1^{t_1}*v_1^{t_1}}{v_1}***\frac{v_n^{t_n}*v_n^{t_n}}{v_n}
                    \frac{w_1^{u_1}*w_1^{u_1}}{w_1}***\frac{w_m^{u_m}*w_m^{u_m}}{w_m} \implies \\
                    \frac{x_1*x_1}{p_1***p_N*q_1***q_M} &= \frac{x_2*x_2}{v_1***v_n*w_1***w_m}
                \end{align}

                I'm kinda stuck at this point. I see that this is definitely injective, since the way the exponents
                are defined, you will always know which prime factors belong to the numerator or to the denominator.
                But I fail to prove this using the direct definition of $f$ like we could do for the natural numbers.
                This is because the products of the denominators in the last equation are not unique.
                So maybe I simplified them too much and shouldn't try and write them in terms of $x_1$ and $x_2$ like
                we did earlier, and try and focus more on just the exponents, but I feel it becomes really hard
                to show that $x_1 = x_2$ that way.

            \item[Surjectivity:] We want to show that $f$ is onto, i.e. $f(\{ q > 0 : q \in \Q \}) = \N$.

                In order to prove this, we will take an arbitrary $y \in \N$, and show that $\exists x : f(x)=y$.
                We know from the \textbf{Theorem} that $y$ can be written as a product of unique prime factors,
                $p_1^{r_1}***p_N^{r_N}$. From the definition of $f$ we know that if the exponents of the prime factors
                $r$ are even, they belong to the numerator of $x$ and if the exponents are
                odd, they belong to the denominator of $x$. If there are no prime factors with odd exponents,
                $x$ will be a natural number. If $y=1$, $x=1$.

                We will now only consider the case that $y$ is a prime factorization with factors with odd exponents
                \footnote{The case for a prime factorization with solely even exponents can be backtracked
                in a similar fashion, just without the case for odd exponents and making $x$ a fraction.}.
                Then, we can find $x$ in the following way: we multiply each prime factor $p_i^{2r_i-1}$ with $p_i$
                and take the square root. We know that the square root of $p_i^{2r_i}$ is defined, since the exponent
                is multiplied by a factor 2, which the root negates. This will yield a prime factorization that we will
                put in the denominator of a fraction. We do the same for the prime factors with even exponent, but
                without multiplying with $p_i$. The prime factors we gain like that we put as a product in the
                numerator of the fraction. So, we gain a fraction with both the numerator and the denominator
                consisting of products of prime numbers, which are natural numbers, and so the fraction is positive
                and in fact a fraction. \qed
        \end{description}
\end{enumerate}

\end{document}
