% vim: tw=50
% 12/10/2022 11AM

\begin{proof}
    Induction. Suppose that we have replaced $l$
    ($\ge 0$) of the $w_i$. Reordering if
    necessary:
    \[ \langle v_1, \dots, v_l, w_{l + 1}, \dots,
    w_n \rangle = V \]
    If $m = l$ then we are done. So assume $l <
    m$. Then take $v_{l + 1} \in V$, and we must
    have
    \[ v_{l + 1} = \sum_{i \le l} a_i v_i  + \sum_{i
    > l} \beta_i w_i \]
    Since the family $(v_1, \dots, v_{l + 1})$ is
    free, we must have that one of the $\beta_i$
    is non zero. So up to reordering, $\beta_{l +
    1} \neq 0$
    \[ \implies w_{l + 1} = \frac{1}{\beta_{l
    + 1}} \left[ v_{l + 1} - \sum_{i \le l}
    \alpha_i v_i - \sum_{i > l + 1} \beta_i w_i \right] \]
    So
    \[ w_{l + 1} \in \langle v_1, \dots, v_{l +
    1}, w_{l
    + 2}, \dots, w_n \rangle \]
    hence we have that
    \begin{align*}
        V
        &= \langle v_1, \dots, v_l, w_{l + 1},
        \dots, w_n \rangle \\
        &= \langle v_1, \dots, v_{l + 1}, w_{l + 2},
        \dots, w_n \rangle
    \end{align*}
    so we can induct up on $l$. The base case $l =
    0$ is trivial, so we deduce the last part of
    the lemma (which also trivially proves that $m
    \le n$).
\end{proof}

\subsection{Basis, dimension, direct sums}

\begin{corollary*}[of Steinitz]
    Let $V$ be a finite dimensional vector space
    over $F$. Then any two basis of $V$ have the
    same number of vectors called the
    \emph{dimension} of $V$, denoted $\dim_F V$
    ($\in \NN$).
\end{corollary*}

\begin{proof}
    $(v_1, \dots, v_n)$, $(w_1, \dots, w_m)$ basis
    of $V$ over $F$. Then since $(v_i)_{1 \le i \le n}$ free,
    $(w_i)_{1 \le i \le m}$ generating, by
    Steinitz exchange lemma, $n \le m$. Similarly
    $m \le n$, so $n = m$.
\end{proof}

\begin{corollary*}
    Let $V$ be a vector space over $F$ with
    dimension $n \in \NN$.
    \begin{enumerate}[(i)]
        \item any set of independent vectors has
            at \emph{most} $n$ elements, with
            equality if and only if it is a basis
        \item any spanning (generating) set of
            vectors has at \emph{least} $n$
            elements with equality if and only if
            it is a basis.
    \end{enumerate}
\end{corollary*}

\begin{proof}
    Exercise.
\end{proof}

\begin{flashcard}[dim-U-plus-W-equals]
\begin{proposition*}
    Let $U, W$ be subspaces of $V$. If $U$ and $W$
    are finite dimensional, then so is $(U + W)$
    and:
    \[ \dim (U + W) = \cloze{\dim U + \dim W - \dim (U
    \cap W)} \]
\end{proposition*}
\prompt{

\begin{proof}
    \cloze{
    Pick $(v_1, \ldots, v_n)$ basis of $U \cap
    W$. Extend to bases
    \[ \langle v_1, \ldots, v_l, u_1, \ldots, u_m
    \rangle = U \]
    \[ \langle v_1, \ldots, v_l, w_1, \ldots, w_n
    \rangle = W \]
    Then check that $(v_1, \ldots, v_l, u_1,
    \ldots, u_m, w_1, \ldots, w_n)$ is a basis of
    $U + W$. (Check that it is a generating family
    and a free family).
    }
\end{proof}
}
\end{flashcard}

\begin{proof}
    Pick $(v_1, \dots, v_n)$ basis of $U \cap W$.
    Extend to bases:
    \[ \langle v_1, \dots, v_l, u_1, \dots, u_m
    \rangle = U \]
    \[ \langle v_1, \dots, v_l, w_1, \dots, w_n
    \rangle = W \]
    \begin{claim*}
        $(v_1, \dots, v_l, u_1, \dots, u_m, w_1,
        \dots, w_n)$ is a basis of $U + W$.
    \end{claim*}
    Proving it is a generating family is an
    exercise. Proving it is a free family:
    \[ \ub{\sum_{i = 1}^l \alpha_i v_i + \sum_{i =
    1}^m \beta_i u_i}_{\in U} + \ub{\sum_{i = 1}^n
    \gamma_i w_i}_{\in W} = 0 \tag{$*$} \]
    \[ \implies \sum_{i = 1}^n \gamma_i w_i \in U
    \cap W \]
    \[ \implies \sum_{i = 1}^l S_i v_i = \sum_{i =
    1}^n \gamma_i w_i \]
    \[ \stackrel{(*)}{\implies} \sum_{i = 1}^l
    (\alpha_i - S_i) v_i + \sum_{i = 1}^m \beta_i
    u_i = 0 \]
    \[ \stackrel{\text{$U$ basis}}{\implies}
    \beta_i = 0, \quad \alpha_i = S_i \]
    \[ \stackrel{(*)}{\implies} \sum_{i = 1}^l
    \alpha_i v_i + \sum_{i = 1}^n \gamma_i w_i = 0 \]
    \[ \stackrel{\text{$W$ basis}}{\implies}
    \alpha_i = \gamma_i = 0 \]
    so the set is free, so it's a basis.
\end{proof}

\begin{flashcard}[dimension-using-quotient]
\begin{proposition*}
    Let $V$ be a finite dimensional vector space
    over $F$. Let $U \le V$. Then $U$ and $V / U$
    are both finite dimensional and:
    \[ \dim V = \dim U + \dim (V / U) \]
\end{proposition*}

\begin{proof}
    \cloze{
    Let $(u_1, \dots, u_l)$ be a basis of $U$.
    Complete it to a basis $(u_1, \dots, u_l, w_{l
    + 1}, \dots, w_n)$ of $V$.\prompt{ Then check
    that $(w_{l + 1} + U, \dots, w_n + U)$ is a
    basis of $V / U$.}
    \fcscrap{
    \begin{claim*}
        $(w_{l + 1} + U, \dots, w_n + U)$ is a
        basis of $V / U$.
    \end{claim*}
    Exercise.
}
}
\end{proof}
\end{flashcard}

\begin{remark*}
    $V$ vector space over $F$ with $U \le V$. We say
    that $U$ is
    \emph{proper} if $U \neq V$. $U$ proper
    implies $\dim U < \dim V$, since $V / U \neq
    \{\emptyset\}$.
\end{remark*}

\begin{definition*}[Direct sum]
    Let $V$ be a vector space, and $U, W \le V$.
    We say
    \[ V = U \oplus W \]
    We say ``$V$ is the \emph{direct} sum of $U$
    and $W$'' if and only if any element $v \in V$
    can be \emph{uniquely} decomposed:
    \[ v = u + w, \quad u \in U, ~ w \in W \]
    Equivalently,
    \[ V = U \oplus W \iff \forall v \in V,
    \exists ! (u, w) \in U \times W  ~~ v = u + w \]
\end{definition*}

\begin{warning}
    If $V = U \oplus W$, we say that $W$ is
    \emph{a} complement of $U$ in $V$. There is no
    uniqueness of such a complement.
\end{warning}

\begin{example*}
    $V = \RR^2 = \langle (1, 0) \rangle \oplus \langle
    (0, 1) \rangle = \langle (1, 0) \rangle \oplus
    \langle (1, 1) \rangle$.
\end{example*}

\begin{notation*}
    We will in the sequel systematically use the
    following notation. Let two collections of
    vectors:
    \[ \mathcal{B}_1 = \{v_1, \dots, v_l\} \]
    \[ \mathcal{B}_2 = \{w_1, \dots, w_m\} \]
    then
    \[ \mathcal{B}_1 \cup \mathcal{B}_2 = \{u_1,
    \dots, u_l, w_l, \dots, w_m\} \]
    not a set, because we care about the order.
    (it is more like a list)
    With this notation:
    \[ \{u_1\} \cup \{u_1\} = \{u_1, u_1\} \]
    so the collection $\{u_1\} \cup \{u_1\}$ is
    never a free family.
\end{notation*}

\begin{flashcard}[direct-sum]
\begin{lemma*}
    $U, W \le V$. Then the following are
    equivalent (TFAE):
    \begin{enumerate}[(i)]
        \item $V = U \oplus W$
        \item \cloze{$V = U + W$ and $U \cap W =
            \{0\}$}
        \item \cloze{For any basis $\mathcal{B}_1$ of
            $U$, $\mathcal{B}_2$ of $W$, the union
            $\mathcal{B} = \mathcal{B}_1 +
            \mathcal{B}_2$ is a basis of $V$.}
    \end{enumerate}
\end{lemma*}
\end{flashcard}

\begin{proof}
    \begin{enumerate}[(i)]
        \item[(ii) $\implies$ (i)] $V = U + W$
            implies that $\forall v \in V$, there
            exists $(u, w) \in U \times W$ such
            that $v = u + w$. So it is generating.
            To show it is free, let $u_1 + w_1 =
            u_2 + w_2 = v$. Then
            \[ \ub{u_1 - u_2}_{\in U} = \ub{w_2 -
            w_1}_{\in W} \]
            \[ \implies u_1 - u_2, w_1 - w_2 \in U
            \cap W = \{0\} \]
            \[ \implies u_1 = u_2, ~ w_1 = w_2 \]
        \item[(i) $\implies$ (iii)] $\mathcal{B}_1$
            basis of $U$, $\mathcal{B}_2$ basis of
            $W$. Let $\mathcal{B} = \mathcal{B}_1
            + \mathcal{B}_2$. It is clearly a
            generating family of $U + W = V$ It is
            a free family because
            \[ \sum \lambda_i v_i = 0 \]
            must be decomposed as $0_U + 0_W$
            since $V = U \oplus W$. So
            \[ \sum_{u_1 \in \mathcal{B}_1}
            \lambda_i u_i = 0 \]
            \[ \sum_{w_1 \in \mathcal{B}_2}
            \lambda_i w_i = 0 \]
            so $\lambda_i = 0$ for all $i$.
        \item[(iii) $\implies$ (ii)] We need to
            show
            \[ V = U + W, \quad U \cap W = \{0\} \]
            This is obvious.
    \end{enumerate}
\end{proof}
