Find a basis for the subspace $W= \left \{ f \in V | f(x)=0 \text{ } \forall x \in X, \text{ except for a finite number of elements of } X\right \}$ I need your help to check if my proof is correct please. This is what I have to prove:

Let be $X$ a not empty set and let be $F$ a field. Consider the vector
space given by the set $V= \left \{ f : X \rightarrow F \right \}$
with the usual operations. Find a basis for the subspace $W= \left \{
 f \in V |  f(x)=0 \text{ } \forall x \in X, \text{ except for a finite
 number of elements of } X\right \}$

My attempt:
With $i,j \in \left \{ 1,2,...,n \right \}$, we can define this functions:
\begin{equation*}
f_{x_{j}}(x_i)=
   \left\{
\begin{array}{rcl}
     1 & ~~~~~~~~~if & x_i=x_j, \text{ with } x_i,x_j\in X\\
     0 & ~~~~~~~~~&\text{another case}
\end{array}
\right.
\end{equation*}
Let's see if the set $S=\left \{ f_{x_1},f_{x_2},\cdots,f_{x_{n}} \right \}$ is a basis of $W$. First,
we note that if:
\begin{align}
\lambda_1 f_{x_1}(x_i)+\lambda_2 f_{x_2}(x_i)+\cdots+\lambda_n f_{x_n}(x_i)=0 & &\text{ for any $x_i \in X$}\\ & &\lambda_i \in F \\& &i \in \left \{ 1,...,n \right \}
\end{align}
then,
\begin{align}
\lambda_1 +\lambda_2 +\cdots+\lambda_n=0 & &\text{ for any $x_i \in X$}
\end{align}
So, that implies that $S=\left \{ f_{x_1},f_{x_2},\cdots,f_{x_{n}} \right \}$ is linearly independent (1)
By the other hand, let be $f \in W$, then $f(x_i)=0$, except for a finite number of elements of $X$. Then, we can propose to write $f$ as:
\begin{align}
f(x_i)=\lambda_1 f_{x_1}(x_i)+\lambda_2 f_{x_2}(x_i)+\cdots+\lambda_n f_{x_n}(x_i)
\end{align}
since the quantity of $\lambda_i$ that satisfies that $\lambda_i \neq 0$ is the number of finite elements of $X$ where $f(x_i)\neq 0$, that implies that $f \in span(S)$. So, $S$ is a generating set of $W$. (2)
By (1) and (2), $S$ is a basis of $W$.
 A: You seems to have the main ideas. However your « proof » seems to mention a finite number of maps to be a basis of $W$ which isn’t the case if $X$ is infinite.
$$\mathcal B=\{f_x \mid x \in X\}$$
where
$$f_x(v)=\begin{cases}
1 & v =x\\
0 & v \ne x
\end{cases}$$ is indeed a basis of $W$. To prove that $\mathcal B$ is linearly independent, suppose that a finite linear combination of elements of $\mathcal B$
$$\lambda_1 f_{a_1} + \dots +\lambda_n f_{a_n}=0$$ always vanishes. Then by plugging in $v=a_i$ you get $\lambda_i=0$ as desired.
You were almost there to prove that $\mathcal B$ spans $W$.
Note: the cardinality of $\mathcal B$ is the one of $X$.
A: You have the right idea but you're not quite there. I'll define $S = \{f_x | x \in X\}$ where $f_x: X \longrightarrow F$ is defined by $f_x(y) = 1$ if $x = y$ and $0$ otherwise. This is like your definition, but you only allowed $S$ to be finite. But that won't work in case $X$ is infinite, so you need to consider all of these elements.
Now we show linear independence. Your proof is wrong, in part because showing $\sum \lambda_i = 0$ is not what you need for linear independence. You want all of the $\lambda_i = 0$. Let's suppose we have $\sum_{i = 1}^n \lambda_i f_{x_i} = 0$ for distinct $x_i \in X$. Now, let $1 \leq j \leq n$ and evaluate this at $x_j$. This yields $\sum_i \lambda_i f_{x_i}(x_j) = 0$. For every $i \neq j$ we have $f_{x_i}(x_j) = 0$. Furthermore, $f_{x_j}(x_j) = 1$. Hence, we have $0 = \sum_i \lambda_i f_{x_i}(x_j) = \lambda_j$. Thus, each coefficient $\lambda_j = 0$ so $S$ is linearly independent.
Now let's show $S$ spans $W$. Take some $f: X \longrightarrow F$ in $W$. We claim that $f = \sum_{x \in X} f(x) f_x$. First of all, why is this sum even well defined? Well the set of $x$ such that $f(x) \neq 0$ is finite by definition of $W$, so this sum only has finitely many nonzero elements. Now, let's prove that these are equal. Take a $y \in X$ and compute $\left( \sum_x f(x) f_x \right)(y) = \sum_x f(x) f_x(y)$. Again, $f_x(y) = 0$ if $x \neq y$ and $1$ if $x = y$. Thus, this sum equals $f(y)$. Hence, $f = \sum_x f(x) f_x$. The right hand side is a linear combination of elements of $S$ (recall that we showed that this is a finite sum), so $f \in span(S)$.
Hence, $S \subseteq W$ is linearly independent and spans, so it is a basis.
