
theorem TSum:
for F being Field,
    E being F-finite FieldExtension of F,
    K being E-finite F-extending FieldExtension of E
for BE being Basis of VecSp(E,F),
    BK being Basis of VecSp(K,E)
for l being Linear_Combination of Base(BE,BK) holds Sum l = Sum(down l)
proof
let F be Field, E be F-finite FieldExtension of F,
    K be E-finite F-extending FieldExtension of E;
let BE be Basis of VecSp(E,F), BK be Basis of VecSp(K,E);
let l be Linear_Combination of Base(BE,BK);

defpred P[Nat] means
  for l being Linear_Combination of Base(BE,BK)
  st card(Carrier l) = $1 holds Sum l = Sum(down l);

IA: P[0]
    proof
    now let l be Linear_Combination of Base(BE,BK);
      assume A: card(Carrier l) = 0; then
      Carrier l = {}; then
      A0: Sum l = 0.VecSp(K,F) by VECTSP_6:19 .= 0.K by FIELD_4:def 6;
      A1: now let b be Element of K;
          now let o be object;
            assume B2: o in Carrier down(l,b);
            reconsider a = o as Element of E by B2,FIELD_4:def 6;
            reconsider abV = @(a,K)*b as Element of VecSp(K,F)
                                                by FIELD_4:def 6;
            B3: down(l,b).a <> 0.F by B2,VECTSP_6:2; then
            a in BE & b in BK by down1; then
            down(l,b).a = l.(@(a,K)*b) by down1; then
            abV in Carrier l by B3,VECTSP_6:2;
            hence contradiction by A;
           end;
         then Carrier down(l,b) = {} by XBOOLE_0:def 1;
         hence Sum down(l,b) = 0.VecSp(E,F) by VECTSP_6:19
                            .= 0.E by FIELD_4:def 6;
         end;
      A2: for b being Element of K holds (down l).b = 0.E
          proof
          let b be Element of K;
          per cases;
          suppose b in BK;
            hence (down l).b = Sum down(l,b) by down2 .= 0.E by A1;
            end;
          suppose B0: not b in BK;
            B1: Carrier down l c= BK by VECTSP_6:def 4;
            reconsider bV = b as Element of VecSp(K,E) by FIELD_4:def 6;
            thus (down l).b = (down l).bV .= 0.E by B0,B1,VECTSP_6:2;
            end;
          end;
      now let o be object;
        assume B0: o in Carrier(down l);
        reconsider bV = o as Element of VecSp(K,E) by B0;
        reconsider b = o as Element of K by B0,FIELD_4:def 6;
        (down l).b <> 0.E by B0,VECTSP_6:2;
        hence contradiction by A2;
        end; then
      Carrier(down l) = {} by XBOOLE_0:def 1; then
      Sum(down l) = 0.VecSp(K,E) by VECTSP_6:19 .= 0.K by FIELD_4:def 6;
      hence Sum l = Sum(down l) by A0;
      end;
    hence thesis;
    end;

H1: the carrier of VecSp(E,F) = the carrier of E &
    the carrier of VecSp(K,E) = the carrier of K &
    the carrier of VecSp(K,F) = the carrier of K by FIELD_4:def 6;
E is Subring of K & F is Subring of E by FIELD_4:def 1; then
H3: the carrier of E c= the carrier of K &
    the carrier of F c= the carrier of E by C0SP1:def 3;

IS: now let k be Nat;
    assume IV: P[k];
    now let l be Linear_Combination of Base(BE,BK);
      assume A0: card(Carrier l) = k + 1; then
      A1: Carrier l <> {};
      set o = the Element of Carrier l;
      A2: o in Carrier l by A1;
      A6: Carrier l c= Base(BE,BK) by VECTSP_6:def 4; then
      A3: o in Base(BE,BK) by A1; then
      consider a,b being Element of K such that
      A4: o = a * b & a in BE & b in BK;
      reconsider abv = a * b as Element of VecSp(K,F) by FIELD_4:def 6;

         defpred P[Element of K,Element of F] means
         ($1 = a*b & $2 = l.(a*b)) or ($1 <> a*b & $2 = 0.F);
         G0: now let x be Element of K;
         per cases;
         suppose G: x = a * b;
           l.(a*b) in the carrier of F by H1,FUNCT_2:5;
           hence ex y being Element of F st P[x,y] by G;
           end;
         suppose x <> a * b;
           hence ex y being Element of F st P[x,y];
           end;
         end;
        consider f being Function of the carrier of K,the carrier of F
        such that
        G1: for x being Element of K holds P[x,f.x] from FUNCT_2:sch 3(G0);
        dom f = the carrier of VecSp(K,F) &
        rng f c= the carrier of F by H1,FUNCT_2:def 1; then
        reconsider f as
            Element of Funcs(the carrier of VecSp(K,F), the carrier of F)
            by FUNCT_2:def 2;
        now let v be Element of VecSp(K,F);
          assume not v in Base(BE,BK);
          then v <> a * b by A4;
          hence f.v = 0.F by H1,G1;
          end; then
        reconsider h=f as Linear_Combination of VecSp(K,F) by VECTSP_6:def 1;
        Z:now let o be object;
          assume C1: o in Carrier h; then
          reconsider v = o as Element of VecSp(K,F);
          reconsider x = v as Element of K by FIELD_4:def 6;
          h.x <> 0.F by C1,VECTSP_6:2;
          then v = a * b by G1;
          hence o in {abv} by TARSKI:def 1;
          end;
        then Carrier h c= {abv};
        then Y: h is Linear_Combination of {abv} by VECTSP_6:def 4;
        {abv} c= Base(BE,BK) by A3,A4,TARSKI:def 1; then
      reconsider h as Linear_Combination of Base(BE,BK) by Y,VECTSP_6:4;
      Carrier h = {abv}
           proof
           now let o be object;
             assume o in {abv}; then
             B2: o = abv by TARSKI:def 1;
             h.abv = l.(a*b) by G1; then
             h.abv <> 0.F by A1,A4,VECTSP_6:2;
             hence o in Carrier h by B2,VECTSP_6:2;
             end;
           hence thesis by Z,TARSKI:2;
           end; then
      A12: card(Carrier h) = 1 by CARD_2:42;
      l.(a*b) is Element of the carrier of F by H1,FUNCT_2:5; then
      reconsider lab = l.(a*b) as Element of K by H3;
      reconsider labF = l.(a*b) as Element of F by H1,FUNCT_2:5;

      set li = l - h;
        li - (l - h) = ZeroLC(VecSp(K,F)) by VECTSP_6:43; then
     B: l = li - (l - h) + l by VECTSP_6:27
         .= li + -(l - h) + l by VECTSP_6:def 11
         .= li + -(l + -h) + l by VECTSP_6:def 11
         .= li + (-(l + -h) + l) by VECTSP_6:26
         .= li + ((-1.F)*(l + -h) + l) by VECTSP_6:def 10
         .= li + (((-1.F)*l + (-1.F)*(-h)) + l) by VECTSP_6:33
         .= li + (((-1.F)*l + (-1.F)*((-1.F)*h)) + l) by VECTSP_6:def 10
         .= li + (((-1.F)*l + ((-1.F)*(-1.F))*h) + l) by VECTSP_6:34
         .= li + (((-1.F)*l + ((1.F)*(1.F))*h) + l) by VECTSP_1:10
         .= li + (((-1.F)*l + h) + l) by VECTSP_6:35
         .= li + ((-l + h) + l) by VECTSP_6:def 10
         .= li + ((h + -l) + l) by VECTSP_6:25
         .= li + (h + (-l + l)) by VECTSP_6:26
         .= li + (h + (l + -l)) by VECTSP_6:25
         .= li + (h + (l - l)) by VECTSP_6:def 11
         .= li + (h + ZeroLC(VecSp(K,F))) by VECTSP_6:43
         .= li + h by VECTSP_6:27;

      A8: li.(a*b) = l.abv - h.abv by VECTSP_6:40
                  .= labF + -labF by G1
                  .= 0.F by RLVECT_1:5;
      A9: for x being Element of K st x <> a * b holds li.x = l.x
          proof
          let x be Element of K;
          reconsider v = x as Element of VecSp(K,F) by FIELD_4:def 6;
          assume x <> a * b;
          then not v in {abv} by TARSKI:def 1;
          then h.v = 0.F by Z,VECTSP_6:1;
          then li.v = l.v - 0.F by VECTSP_6:40;
          hence thesis;
          end;
      A10:now let o be object;
        assume B0: o in Carrier li; then
        reconsider v = o as Element of VecSp(K,F);
        reconsider vK = v as Element of K by FIELD_4:def 6;
        B1: li.v <> 0.F by B0,VECTSP_6:2; then
        li.vK = l.vK by A9,A8;
        hence o in Carrier l by B1,VECTSP_6:2;
        end;
      then Carrier li c= Base(BE,BK) by A6; then
      reconsider li as Linear_Combination of Base(BE,BK) by VECTSP_6:def 4;

      A11: not (a * b) in Carrier li by A8,VECTSP_6:2;
      Carrier l = (Carrier li) \/ {a * b}
         proof
         B1: now let o be object;
             assume B2: o in Carrier l; then
             reconsider ab = o as Element of K by FIELD_4:def 6;
             reconsider abV = ab as Element of VecSp(K,F) by FIELD_4:def 6;
             per cases;
             suppose o = a * b;
               then o in {a*b} by TARSKI:def 1;
               hence o in (Carrier li) \/ {a * b} by XBOOLE_0:def 3;
               end;
             suppose o <> a * b;
               then l.ab = li.ab by A9;
               then li.ab <> 0.F by B2,VECTSP_6:2;
               then abV in Carrier li by VECTSP_6:2;
               hence o in (Carrier li) \/ {a * b} by XBOOLE_0:def 3;
               end;
             end;
         now let o be object;
            assume o in (Carrier li) \/ {a * b};
            then per cases by XBOOLE_0:def 3;
            suppose o in Carrier li;
              hence o in Carrier l by A10;
              end;
            suppose o in {a * b};
              hence o in Carrier l by A2,A4,TARSKI:def 1;
              end;
            end;
         hence thesis by B1,TARSKI:2;
         end;
      then card(Carrier li) + 1 = k + 1 by A0,A11,CARD_2:41; then
      G2: Sum li = Sum(down li) by IV;
      G3: Sum h = Sum(down h) by A12,LSum2;
      G4a: [h.abv,abv] in [:the carrier of F,the carrier of K:]
           by ZFMISC_1:def 2;
      G4: Sum h = h.abv * abv by Y,VECTSP_6:17
         .= (the multF of K)|[:the carrier of F,the carrier of K:].[h.abv,abv]
            by FIELD_4:def 6
         .= (the multF of K).[h.abv,abv] by G4a,FUNCT_1:49
         .= lab * (a*b) by G1;
      G5: down l = down li + down h by B,LSum1;

      reconsider Sdli = Sum(down li) as Element of K by FIELD_4:def 6;
      G6: Sdli + lab * (a*b)
            = Sum(down li) + Sum(down h) by G3,G4,FIELD_4:def 6
           .= Sum(down l) by G5,VECTSP_6:44;
      thus Sum l = Sum li + Sum h by B,VECTSP_6:44
                .= Sum(down l) by G6,G4,G2,FIELD_4:def 6;
      end;
    hence P[k+1];
    end;

I: for k being Nat holds P[k] from NAT_1:sch 2(IA,IS);
consider n being Nat such that H: card(Carrier l) = n;
thus thesis by I,H;
end;
