Every vector in the span can be written as a unique linear combination This exercise is from my textbook:

Let $V$ be a vector space and $S$ an non-empty subset of $V$ with the property that whenever $v_1, v_2, \dots, v_n \in S$ and $a_1v_1 + \cdots a_nv_n=0$ then $a_1=a_2=\cdots=a_n=0$. Prove that every vector in the span of S can be uniquely written as a linear combination of elements of $S$

I found the same question here, but the answer is incomplete, this is quite easy if S is finite, the problem arises when S is infinite. Let $w\in span(S)$ then there exist a finite number of elements in S, $u_1, \dots, u_n \in S$ and scalars $a_1, \dots, a_n \in F$ such that $w= a_1u_1+\cdots+ a_nu_n$, if there exists another linear combination equal to $w$, then there exist vectors $e_1,\dots e_m \in S$ and scalars $b_1, \dots, b_m \in F$ such that $w=b_1v_1 + \cdots + b_mv_m$, but not necessarily $n=m$ and $u_1=e_1, \dots u_n=e_n$, at this point, I don't know exactly how to proceed to prove that the liner combination is unique.
Edit: The definitions of linear combination and span of a set that the author gives are the following

Let $V$ be a vector space and let $S$ be a non-empty subset of $V$, a vector $v\in V$ is a linear combination of elements of $S$ if there exist a finite number of vectors $u_1, \dots, u_n \in S$ and scalars $a_1, \dots, a_n \in F$ such that $v=a_1u_1 + \cdots+ a_nv_n$


Let $V$ be a vector space and let $S$ be a non-empty subset of $V$, we define $span(S)$ as the set $$span(S) := \{v\in V : v \ \text{is a linear combination of elements of} \ S\}$$

 A: Note that there is a "pairwise distinct" missing in your original exercise: the vectors $v_1,\ldots,v_n$ are assumed to be pairwise distinct. Otherwise, the assumption is never met, since taking $v_1=v_2$ be any vector in $S$, we can look at $1v_1-1v_2$.
Also, "unique expression" in the conclusion has to include a caveat that you are allowed to add summands of the form $0\mathbf{x}$ with arbitrary $\mathbf{x}$. Otherwise, if $S$ has more than one element then you never have uniqueness, since given $s_1,s_2\in S$, $s_1\neq s_2$, you could take $s_1 = 1s_1$, and also $s_1=1s_1+0s_2$ and they would be "different" (but not really). So we are allowed to add summands with other vectors if they are multiplied by $0$.
The key is that if you have two expressions
$$ v=a_1u_1+\cdots + a_nu_n = b_1v_1+\cdots + b_mv_m,$$
with $u_i,v_j\in S$, the $u_i$ pairwise distinct, the $v_j$ pairwise distinct, we can rewrite both expressions so that we use the exact same (finite) number of vectors.
If the two lists of vectors are the same after reordering (clearly the order is immaterial), then this is easy. We have:
$$\begin{align*}
v &= a_1u_1+\cdots + a_nu_n\\
&= b_1u_1+\cdots +b_nu_m,
\end{align*}$$
(because we are assuming $n=m$, and $u_1=v_1,\ldots,u_n=v_n$); taking the difference we get
$$\begin{align*}\mathbf{0} = v - v &= (a_1u_1+\cdots+a_nu_n) - (b_1u_1+\cdots +b_mu_m)\\
&= (a_1-b_1)u_1 + \cdots + (a_n-b_n)u_n,
\end{align*}$$
from which we get $a_i-b_i=0$ for $i=1,\ldots,n$, so $a_i=b_i$ for $i=1,\ldots,n$.
What if they are not the same list? Well, maybe some of the vectors are the same. So let us reorder the list so they both start with $x_1,\ldots,x_r$, and then we have $u_{r+1},\ldots,u_n$ and $v_{r+1},\ldots,v_m$, with $x_1,\ldots,x_r,u_{r+1},\ldots,u_n$ pairwise distinct, $x_1,\ldots,x_r,v_{r+1},\ldots,v_{m}$ pairwise distinct, and $u_{r+1},\ldots,u_n,v_{r+1},\ldots,v_m$ pairwise distinct. Proceeding as above, we have:
$$\begin{align*}
v &= a_1x_1+\cdots + a_rx_r + a_{r+1}u_{r+1}+\cdots + a_nu_n\\
&= b_1x_1+\cdots +b_rx_r + b_{r+1}v_{r+1}+\cdots + b_{m}v_m.
\end{align*}$$
Then taking the difference we get
$$\begin{align*}
\mathbf{0} = v - v & = (a_1x_1+\cdots + a_rx_r + a_{r+1}u_{r+1}+\cdots + a_nu_n)\\
&\qquad -
(b_1x_1+\cdots +b_rx_r + b_{r+1}v_{r+1}+\cdots + b_{m}v_m)\\
&= (a_1-b_1)x_1+\cdots + (a_r-b_r)x_r + a_{r+1}u_{r+1}+\cdots + a_nu_n\\
&\qquad -b_{r+1}v_{r+1}-\cdots - b_mv_m.
\end{align*}$$
Then we conclude that:

*

*$a_1-b_1=\cdots=a_r-b_r=0$,

*$a_{r+1}=\cdots=a_{n}=0$,

*$b_{r+1}=\cdots=b_{m}=0$.

But that means that the two expressions are the same, except for possibly extra summands where each vector is multiplied by $0$ (and which therefore don't really "count"). Which is what we wanted to prove.

An alternative approach is to finite-fy everything.
Lemma. A nonempty subset $S$ has the property that

for every finite collection of pairwise distinct vectors $v_1,\ldots,v_n\in S$, if $a_1v_1+\cdots+a_nv_n = 0$, then $a_1=\cdots=a_n=0$

if and only if every finite subset $S_0$ of $S$ has the property.
Lemma. Let $S$ be a nonempty set of vectors. Then $S$ has the property that

Every $s\in\mathrm{span}(S)$ can be expressed uniquely as a linear combination of pairwise distinct vectors in $S$, except perhaps for the order and extra summands of the form $0v$

if and only if every finite subset $S_0$ of $S$ has the property.
Proving these is not difficult. Then you can use the finite case to deal with the general case, since if $v=a_1u_1+\cdots+a_nu_n = b_1v_1+\cdots b_mv_m$, then it is all happening in the finite subset $\{u_1,\ldots,u_n\}\cup\{v_1,\ldots,v_n\}$.
A: That every vector can be written as a linear combination of vectors of $S$ is given by your definition of $\text{span}(S)$.
Now, for the uniqueness you can proceed by induction.
Suppose $w \not=0$ and $w=a_1 u_1=b_1v_1 + \cdots + b_mv_m$, then
$$a_1 u_1 -b_1v_1 - \cdots - b_mv_m=0 \hspace{5mm} (1)$$
Now, if $u_1 \not = v_i$ for all $i=1, \cdots, m$, then by your assumptions we get that $a_1=b_1= \cdots=b_m=0$, so $w=0$ getting a contradiction. Then, we must have that $u_1=v_i$ for some $i$ (suppose wlog that $i=1$), and by $(1)$ we get
$$(a_1-b_1)v_1 - b_2v_2 - \cdots - b_mv_m=0$$
so $a_1=b_1$ and $b_2=\cdots=b_m=0$ and we get the uniqueness.
Suppose then that the uniqueness is true for every vector $u \in \text{span}(S)$ that can be written as a linear combination of $n$ vectors in $S$, and let $w=a_1u_1+\cdots+a_n u_n +a_{n+1}u_{n+1}=b_1v_1 + \cdots + b_mv_m$.
Observe then that
$$a_1 u_1 +\cdots+a_n u_n +a_{n+1}u_{n+1} -b_1v_1 - \cdots - b_mv_m=0 \hspace{5mm} (2)$$
So, if every $u_i$ is dinstinc from every $v_j$, as before we get $w=0$ which is a contradiction. Then, wlog we get that $v_1=u_1$, and from $(2)$
$$(a_1-b_1) u_1 +\cdots+a_n u_n +a_{n+1}u_{n+1} -b_2v_2 - \cdots - b_mv_m=0 \hspace{5mm} (3)$$
As every $u_i$ with $i>1$ is different from $u_1$ and every $v_j$ with $j>1$ is different from $v_1=u_1$, we get from $(3)$ that $a_1=b_1$, and then that
$$a_2u_2+\cdots+a_n u_n +a_{n+1}u_{n+1}=b_2v_2 + \cdots + b_mv_m$$
Now, we have that $w'=a_2u_2+\cdots+a_n u_n +a_{n+1}u_{n+1}$ is a linear combination of $n$ vectors of $S$, so by the induction hypothesis we have that (after some possible rearrangement) $m=n+1$, $u_j=v_j$ and $a_j=b_j$ for $j=2, \cdots, n+1$, which concludes the induction.
EDITED: As explained by Arturo Magidin in his answer, in the prove is supposed that $w \not = 0$ and that the vectors $v_i$ and $u_j$ are pairwise distinct (between them) and not null.
A: Let $V$ be a vector space and $S$ be a set of vectors in $V$.
$S$ is linearly independent iff every finite subset of $S$ is linearly independent i.e $0$ vector has a unique finite linear combination ( all coefficients are $0$)
Let $U=\textrm{span}(S) $. Since $S$ span $U$ and $S$ is linearly independent, hence $S$ is basis( Hamel basis/ algebraic basis) of $U$.
Every vectors of $U$ is a unique finite linear combination of vectors in $S$.
