First recall
the definition of
spanning.
Let V be a vector space over a field k.
Vectors v_{1},...,v_{n}
are a spanning set, for V if for every vector
v in V there exist
scalars a_{i} in k (which depend on v)
such that v can be written in the form
v=a_{1}v_{1} + a_{2}v_{2} +...+ a_{n}v_{n}.
A vector space with a finite spanning set is called finite dimensional
otherwise it is infinite dimensional.
As Debbie points out the dimension
of a finite dimensional vector space
is the number of elements in a basis
of the space.
This does leave us with two rather unpleasant possibilities.
What if no such basis exists and what if
two different bases of the vector space could have different numbers of
elements? In either of these two
cases, our definition wouldn't make a whole lot of sense.
In this writeup I will show that these worrying possibilities do not occur
and we can all return safely to our normal activities safe in the knowledge
that things are exactly as they should be.
The main idea needed for this is the following lemma which
says roughly that we can
exchange elements from a spanning set for elements of a linearly
independent set and still keep the spanning property.
Steinitz Exchange Lemma
Let v_{1},...,v_{n} be a linearly independent
set of vectors in a vector space V and let S be a spanning set
with m elements. Then n<=m and we can replace
n suitable elements of S by the v_{i}
and still have a spanning set.
i.e.
{v_{1},...,v_{n},w_{n+1},...,w_{m}}
is a spanning for some
w_{n+1},...,w_{m} in
S.
Proof:
Consider the statement
I(r): There exists w_{r+1},...,w_{m}
in S
so that v_{1},...,v_{r},w_{r+1},...,w_{m}
give a spanning set for V.
I claim that
I(
r) is true for all
0<=r<=n.
Notice that when
r=n this is the assertion of the lemma.
We prove that I(r) is true for all 0<=r<=n
by induction. Start with r=0. The result is trivially true
because since S already spans V, so certainly any superset
of it does. Suppose then that I(r1) holds for some
r>0. Thus v_{1},...,v_{r1},w_{r},...,w_{m}
span V for some w_{r},...,w_{m} from S.
In particular, v_{r} must be a linear combination of
these vectors, that is
v_{r}=a_{1}v_{1} +...+ a_{r1}v_{r1}+b_{r}w_{r} +...+ b_{m}w_{m}. (*)
Now if
b_{r}=...=b_{m}=0 then this contradicts
the fact that the
v_{i} are linearly independent.
So
WLOG b_{r} is nonzero.
It follows from this that by rearranging (*) and multiplying by
b_{r}^{1}
we can express
w_{r} as a linear combination of
v_{1},...,v_{r}, w_{r+1},...,w_{m}.
It follows that this set spans
V as needed.
Corollary A finite dimensional vector space has
at least one basis and any two bases have the same number of elements.
Hence its dimension is welldefined.
Proof: Since the vector space
is finite dimensional it has a finite spanning set. If the elements of
this set
are linearly independent then by definition we have a basis.
If not we can express one of the vectors in our spanning set as
a linear combination of the others. Thus, we can safely remove this
vector from our spanning set and still have a spanning set. Repeating
this procedure as often as required we will arrive at a basis.
Now suppose that we have two bases S and T. A fortiori
S is a spanning set and T is a linearly indepednent set.
So by the exchange lemma. S >= T. By symmetry
we have the opposite inequality. Hence the result.
Some examples are long overdue.

k^{n} the collection of ntuples of elements of
k with its usual vector space vector structure has a basis consisting of
the coordinate vectors e_{i} (where e_{i} is the column vector with a zero in all positions except the ith row, where it has a 1). Thus it has dimension
n

We can add polynomials and multiply them by scalars and so
k[x] is a vector space. It is infinite dimensional.
Since if there were to be a finite spanning set then this would
put a limit on the degrees of polynomials.

The collection of nxn matrices over k form a vector
space with the obvious operations. This space has dimension
n^{2}. A basis is given by the usual matrix
units e_{i,j} (where e_{i,j}
is the matrix with a 1 in the i,j position and zeroes elsewhere).