
theorem Th15: :: DIM:
  for F being finite Field, V being VectSp of F, n, q being Nat
  st V is finite-dimensional & n = dim V & q = card the carrier of F
  holds card the carrier of V = q |^ n
proof
  let F be finite Field, V be VectSp of F, n, q be Nat such that
A1: V is finite-dimensional and
A2: n = dim V and
A3: q = card the carrier of F;
  consider B being finite Subset of V such that
A4: B is Basis of V by A1,MATRLIN:def 1;
A5: B is linearly-independent by A4,VECTSP_7:def 3;
A6: Lin(B) = the ModuleStr of V by A4,VECTSP_7:def 3;
A7: card B = n by A1,A2,A4,VECTSP_9:def 1;
  now per cases;
    suppose
A8:   n = 0;
      then (Omega).V = (0).V by A1,A2,VECTSP_9:29;
      then the ModuleStr of V = (0).V by VECTSP_4:def 4;
      then the carrier of V = {0.V} by VECTSP_4:def 3;
      then card the carrier of V = 1 by CARD_1:30
        .= q #Z 0 by PREPOWER:34
        .= q |^ 0 by PREPOWER:36;
      hence thesis by A8;
    end;
    suppose n <> 0;
      then
A9:   B <> 0 by A7;
      consider bf being FinSequence such that
A10:  rng bf = B and
A11:  bf is one-to-one by FINSEQ_4:58;
      len bf = n by A7,A10,A11,FINSEQ_4:62;
      then
A12:  Seg n = dom bf by FINSEQ_1:def 3;
      reconsider Vbf = bf as FinSequence of the carrier of V by A10,
FINSEQ_1:def 4;
      set cLinB = the carrier of Lin(B);
      set ntocF = n-tuples_on the carrier of F;
      defpred P[Function, set] means ex lc being Linear_Combination of B st
      (for i being set st i in dom $1 holds lc.(Vbf.i) = $1.i) &
      $2 = Sum(lc (#) Vbf);
A13:  for x being Element of ntocF ex y being Element of cLinB st P[x,y]
      proof
        let f be Element of ntocF;
        ex lc being Linear_Combination of B st
        for i being set st i in dom f holds lc.(Vbf.i) = f.i
        proof
          deffunc LC(object) = f.(union (Vbf"{$1}));
A14:      for x being object st x in B holds LC(x) in the carrier of F
          proof
            let x be object;
            assume x in B;
            then consider i being object such that
A15:        Vbf"{x} = {i} by A10,A11,FUNCT_1:74;
A16:        union (Vbf"{x}) = i by A15,ZFMISC_1:25;
            i in Vbf"{x} by A15,TARSKI:def 1;
            then i in dom Vbf by FUNCT_1:def 7;
            then i in dom f by A12,FINSEQ_2:124;
            then f.i in rng f by FUNCT_1:3;
            hence thesis by A16;
          end;
          consider lc being Function of B, the carrier of F such that
A17:      for y being object st y in B holds lc.y = LC(y)
from FUNCT_2:sch 2
          (A14);
          set ll=lc +* (((the carrier of V)\B) --> 0.F);
A18:      dom (((the carrier of V)\B) --> 0.F) = (the carrier of V)\B;
          then dom ll = dom lc \/ ((the carrier of V)\B) by FUNCT_4:def 1;
          then dom ll = B \/ ((the carrier of V)\B) by FUNCT_2:def 1;
          then dom ll = B \/ (the carrier of V) by XBOOLE_1:39;
          then
A19:      dom ll = the carrier of V by XBOOLE_1:12;
          rng ll c= rng lc \/ rng (((the carrier of V)\B)--> 0.F)
          by FUNCT_4:17;
          then ll is Function of the carrier of V,the carrier of F
          by A19,FUNCT_2:2,XBOOLE_1:1;
          then
A20:      ll is Element of Funcs(the carrier of V, the carrier of F)
          by FUNCT_2:8;
A21:      for i being set st i in dom f holds ll.(Vbf.i) = f.i
          proof
            let i be set;
            assume i in dom f;
            then
A22:        i in dom Vbf by A12,FINSEQ_2:124;
            then Vbf.i in B by A10,FUNCT_1:3;
            then consider y being Element of B such that
A23:        y = Vbf.i;
A24:        Vbf.i in {y} by A23,TARSKI:def 1;
            consider ee being object such that
A25:        Vbf"{y} c= {ee} by A11,FUNCT_1:89;
A26:        i in Vbf"{y} by A22,A24,FUNCT_1:def 7;
            then {i} c= {ee} by A25,ZFMISC_1:31;
            then i = ee by ZFMISC_1:18;
            then
A27:        Vbf"{y} = {i} by A25,A26,ZFMISC_1:33;
            not y in (the carrier of V)\B by A9,XBOOLE_0:def 5;
            then ll.y = lc.y by A18,FUNCT_4:11;
            then ll.y = f.(union (Vbf"{y})) by A9,A17;
            hence thesis by A23,A27,ZFMISC_1:25;
          end;
A28:      for v being Element of V st not v in B holds ll.v = 0.F
          proof
            let v be Element of V;
            assume not v in B;
            then
A29:        v in (the carrier of V)\B by XBOOLE_0:def 5;
            then ll.v=(((the carrier of V)\B)-->0.F).v by A18,FUNCT_4:13;
            hence thesis by A29,FUNCOP_1:7;
          end;
          then reconsider L=ll as Linear_Combination of V by A20,VECTSP_6:def 1
          ;
          for v being Element of V holds v in Carrier(L) implies v in B
          proof
            let v be Element of V;
            assume
A30:        v in Carrier(L);
            now
              assume not v in B;
              then ll.v = 0.F by A28;
              hence contradiction by A30,VECTSP_6:2;
            end;
            hence thesis;
          end;
          then Carrier(L) c= B;
          then L is Linear_Combination of B by VECTSP_6:def 4;
          hence thesis by A21;
        end;
        then consider lc being Linear_Combination of B such that
A31:    for i being set st i in dom f holds lc.(Vbf.i) = f.i;
        ex y being Element of V st y = Sum(lc (#) Vbf);
        hence thesis by A6,A31;
      end;
      consider G being Function of ntocF,cLinB such that
A32:  for tup being Element of ntocF holds P[tup, G.tup]
      from FUNCT_2:sch 3(A13);
A33:  dom G = ntocF by FUNCT_2:def 1;
A34:  for L being Linear_Combination of B holds ex nt being Element of ntocF st
      for i being object st i in dom nt holds nt.i = L.(Vbf.i)
      proof
        let L be Linear_Combination of B;
        deffunc F(object) = L.(Vbf.$1);
A35:    for x being object st x in Seg n holds F(x) in the carrier of F
        proof
          let x be object;
          assume x in Seg n;
          then Vbf.x in rng Vbf by A12,FUNCT_1:3;
          then consider vv be Element of V such that
A36:      Vbf.x = vv;
          L.vv in the carrier of F;
          hence thesis by A36;
        end;
        consider f being Function of Seg n, the carrier of F such that
A37:    for x being object st x in Seg n holds f.x = F(x)
from FUNCT_2:sch 2(A35
        );
A38:    dom f = Seg n by FUNCT_2:def 1;
A39:    rng f c= the carrier of F;
A40:    n is Element of NAT by ORDINAL1:def 12;
        f is FinSequence-like by A38,FINSEQ_1:def 2;
        then reconsider ff=f as FinSequence of the carrier of F
        by A39,FINSEQ_1:def 4;
        len ff = n by A38,A40,FINSEQ_1:def 3;
        then ff is Element of ntocF by FINSEQ_2:92;
        hence thesis by A37,A38;
      end;

:: Show G is surjective
      for c being object st c in cLinB
ex x being object st x in ntocF & c = G.x
      proof
        let c be object;
        assume c in cLinB;
        then c in (Lin(B));
        then consider l being Linear_Combination of B such that
A41:    c = Sum(l) by VECTSP_7:7;
        Carrier(l) c= rng Vbf by A10,VECTSP_6:def 4;
        then
A42:    Sum(l (#) Vbf) = Sum(l) by A11,VECTSP_9:3;
        consider t being Element of ntocF such that
A43:    for i being object st i in dom t holds t.i = l.(Vbf.i) by A34;
        consider lc being Linear_Combination of B such that
A44:    for i being set st i in dom t holds lc.(Vbf.i) = t.i and
A45:    G.t = Sum(lc (#) Vbf) by A32;
        for v being Element of V holds l.v = lc.v
        proof
          let v be Element of V;
          now per cases;
            suppose v in rng Vbf;
              then consider x being object such that
A46:          [x,v] in Vbf by XTUPLE_0:def 13;
A47:          x in dom Vbf by A46,FUNCT_1:1;
A48:          Vbf.x = v by A46,FUNCT_1:1;
A49:          x in dom t by A12,A47,FINSEQ_2:124;
              then l.(Vbf.x) = t.x by A43;
              hence thesis by A44,A48,A49;
            end;
            suppose
A50:          not v in rng Vbf;
              now
                assume
A51:            v in Carrier(l);
                Carrier(l) c= rng Vbf by A10,VECTSP_6:def 4;
                hence contradiction by A50,A51;
              end;
              then
A52:          l.v = 0.F by VECTSP_6:2;
              now
                assume
A53:            v in Carrier(lc);
                Carrier(lc) c= rng Vbf by A10,VECTSP_6:def 4;
                hence contradiction by A50,A53;
              end;
              hence thesis by A52,VECTSP_6:2;
            end;
          end;
          hence thesis;
        end;
        then G.t = Sum(l (#) Vbf) by A45,VECTSP_6:def 7;
        hence thesis by A41,A42;
      end;
      then
A54:  rng G = cLinB by FUNCT_2:10;

:: Show G is injective
      for x1,x2 being object st x1 in dom G & x2 in dom G & G.x1 = G.x2
      holds x1 = x2
      proof
        let x1,x2 be object such that
A55:    x1 in dom G and
A56:    x2 in dom G and
A57:    G.x1 = G.x2;
        reconsider t1=x1 as Element of ntocF by A55;
        reconsider t2=x2 as Element of ntocF by A56;
        consider L1 being Linear_Combination of B such that
A58:    for i being set st i in dom t1 holds L1.(Vbf.i) = t1.i and
A59:    G.t1 = Sum(L1 (#) Vbf) by A32;
        consider L2 being Linear_Combination of B such that
A60:    for i being set st i in dom t2 holds L2.(Vbf.i) = t2.i and
A61:    G.t2 = Sum(L2 (#) Vbf) by A32;
        Carrier(L1) c= rng Vbf by A10,VECTSP_6:def 4;
        then
A62:    Sum(L1) = Sum(L1 (#) Vbf) by A11,VECTSP_9:3;
        Carrier(L2) c= rng Vbf by A10,VECTSP_6:def 4;
        then Sum(L2) = Sum(L2 (#) Vbf) by A11,VECTSP_9:3;
        then Sum(L1) - Sum(L2) = 0.V by A57,A59,A61,A62,VECTSP_1:19;
        then
A63:    Sum(L1 - L2) = 0.V by VECTSP_6:47;
        (L1 - L2) is Linear_Combination of B by VECTSP_6:42;
        then
A64:    Carrier(L1 - L2) = {} by A5,A63,VECTSP_7:def 1;
        for v being Element of V holds L1.v = L2.v
        proof
          let v be Element of V;
          reconsider LL = L1 - L2 as Linear_Combination of B by VECTSP_6:42;
          LL.v = 0.F by A64,VECTSP_6:2;
          then 0.F = L1.v - L2.v by VECTSP_6:40;
          hence thesis by VECTSP_1:27;
        end;
        then
A65:    L1 = L2 by VECTSP_6:def 7;
A66:    dom t1 = Seg n by FINSEQ_2:124;
A67:    dom t2 = Seg n by FINSEQ_2:124;
        for k being Nat st k in dom t1 holds t1.k = t2.k
        proof
          let k be Nat such that
A68:      k in dom t1;
          t1.k = L1.(Vbf.k) by A58,A68;
          hence thesis by A60,A65,A66,A67,A68;
        end;
        hence thesis by A67,FINSEQ_1:13,FINSEQ_2:124;
      end;
      then G is one-to-one;
      then ntocF, G.:(ntocF) are_equipotent by A33,CARD_1:33;
      then
A69:  ntocF, cLinB are_equipotent by A33,A54,RELAT_1:113;
A70:  card (Seg n) = card n by FINSEQ_1:55;
A71:  card q = card the carrier of F by A3;
      card (ntocF) = card Funcs (Seg n, the carrier of F) by FINSEQ_2:93
        .= card Funcs (n, q) by A70,A71,FUNCT_5:61
        .= q |^ n by A3,Th4;
      hence thesis by A6,A69,CARD_1:5;
    end;
  end;
  hence thesis;
end;
