reserve X for set,
        n,m,k for Nat,
        K for Field,
        f for n-element real-valued FinSequence,
        M for Matrix of n,m,F_Real;

theorem
  for A be affinely-independent Subset of TOP-REAL n st the_rank_of M = n
  for v be Element of TOP-REAL n st v in Affin A holds
   (Mx2Tran M).v in Affin(Mx2Tran M).:A &
   for f holds (v|--A).f = ((Mx2Tran M).v|--(Mx2Tran M).:A).((Mx2Tran M).f)
proof
  reconsider Z=0 as Element of NAT;
  set TRn=TOP-REAL n;
  set TRm=TOP-REAL m;
  let A be affinely-independent Subset of TRn such that
   A1: the_rank_of M=n;
  set MT=Mx2Tran M;
  let v be Element of TRn such that
   A2: v in Affin A;
  set vA=v|--A;
  set C=Carrier vA;
  defpred P[object,object] means
   (not$1 in rng MT implies $2=0) & ($1 in rng MT implies for f st MT.f=$1
    holds $2=vA.f);
  consider H be FinSequence of the carrier of TRn such that
   A3: H is one-to-one and
   A4: rng H=C and
   A5: Sum(vA(#)H)=Sum vA by RLVECT_2:def 8;
  A6: Sum vA=v by A2,RLAFFIN1:def 7;
  reconsider MTR=MT*H as FinSequence of TRm;
  A7: dom MT=[#]TRn by FUNCT_2:def 1;
  then rng H c=dom MT;
  then A8: len MTR=len H by FINSEQ_2:29;
  A9: MT is one-to-one by A1,MATRTOP1:39;
  A10: for x be object st x in the carrier of TRm
    ex y be object st y in REAL & P[x,y]
  proof
   let y be object such that
    y in the carrier of TRm;
   per cases;
   suppose A11: y in rng MT;
    then consider x be object such that
     A12: x in dom MT and
     A13: MT.x=y by FUNCT_1:def 3;
    reconsider x as Element of TRn by A12;
    take vA.x;
    thus vA.x in REAL & (not y in rng MT implies vA.x=0) by A11;
    assume y in rng MT;
    let f;
    assume A14: MT.f=y;
    f is Element of TRn by Lm3;
    hence thesis by A7,A9,A13,A14,FUNCT_1:def 4;
   end;
   suppose A15: not y in rng MT;
    take x=0;
    thus thesis by A15;
   end;
  end;
  consider F be Function of the carrier of TRm,REAL such that
   A16: for x be object st x in the carrier of TRm holds P[x,F.x]
   from FUNCT_2:sch 1(A10);
  reconsider F as Element of Funcs(the carrier of TRm,REAL) by FUNCT_2:8;
  A17: now let w be Element of TRm;
   assume A18: not w in MT.:C;
   assume A19: F.w<>0;
   then w in rng MT by A16;
   then consider f be object such that
    A20: f in dom MT and
    A21: MT.f=w by FUNCT_1:def 3;
   reconsider f as Element of TRn by A20;
   vA.f=F.w by A16,A19,A21;
   then f in C by A19,RLVECT_2:19;
   hence contradiction by A18,A20,A21,FUNCT_1:def 6;
  end;
  then reconsider F as Linear_Combination of TRm by RLVECT_2:def 3;
  A22: MT.:C c=Carrier F
  proof
   let y be object;
   assume A23: y in MT.:C;
   then consider x be object such that
    A24: x in dom MT and
    A25: x in C and
    A26: MT.x=y by FUNCT_1:def 6;
   reconsider x as Element of TRn by A24;
   A27: vA.x<>0 by A25,RLVECT_2:19;
   reconsider f=y as Element of TRm by A23;
   P[f,F.f] by A16;
   then F.f=vA.x by A24,A26,FUNCT_1:def 3;
   hence thesis by A27,RLVECT_2:19;
  end;
  Carrier F c=MT.:C
  proof
   let x be object;
   assume A28: x in Carrier F;
   then reconsider w=x as Element of TRm;
   F.w<>0 by A28,RLVECT_2:19;
   hence thesis by A17;
  end;
  then A29: Carrier F=MT.:C by A22;
  C c=A by RLVECT_2:def 6;
  then MT.:C c=MT.:A by RELAT_1:123;
  then reconsider F as Linear_Combination of MT.:A by A29,RLVECT_2:def 6;
  set Fm=F(#)MTR;
  consider fm be sequence of TRm such that
   A30: Sum Fm=fm.len Fm and
   A31: fm.0=0.TRm and
   A32: for j be Nat,v be Element of TRm st j<len Fm & v=Fm.(j+1)
holds fm.(j+1)=fm.j+v by RLVECT_1:def 12;
  A33: rng MTR=MT.:C by A4,RELAT_1:127;
  dom vA=[#]TRn by FUNCT_2:def 1;
  then A34: len(vA*H)=len H by A4,FINSEQ_2:29;
  set vAH=vA(#)H;
  consider h be sequence of TRn such that
   A35: Sum vAH=h.len vAH and
   A36: h.0=0.TRn and
   A37: for j be Nat,v be Element of TRn st j<len vAH & v=vAH.(j+1)
holds h.(j+1)=h.j+v by RLVECT_1:def 12;
  A38: len vAH=len H by RLVECT_2:def 7;
  defpred P[Nat] means
   $1<=len Fm implies fm.$1=MT.(h.$1);
  A39: len Fm=len MTR by RLVECT_2:def 7;
  A40: MT.:C c=rng MT by RELAT_1:111;
  A41: for j be Nat st P[j] holds P[j+1]
  proof
   reconsider TRM=TRm as RealLinearSpace;
   reconsider TRN=TRn as RealLinearSpace;
   let j be Nat;
   reconsider J=j as Element of NAT by ORDINAL1:def 12;
   set j1=J+1;
   assume A42: P[j];
   reconsider MTRj1=MTR/.j1 as Element of TRM;
   reconsider hj1=H/.j1 as n-element real-valued FinSequence;
   reconsider Hj1=H/.j1 as Element of TRN;
   assume A43: j+1<=len Fm;
   A44: 1<=j1 by NAT_1:11;
   then A45: j1 in dom MTR by A39,A43,FINSEQ_3:25;
   then A46: MTRj1=MTR.j1 by PARTFUN1:def 6;
   A47: MTR.j1 in MT.:C by A33,A45,FUNCT_1:def 3;
   j1 in dom H by A39,A8,A43,A44,FINSEQ_3:25;
   then A48: Hj1=H.j1 by PARTFUN1:def 6;
   then MTR.j1=MT.Hj1 by A45,FUNCT_1:12;
   then A49: F.MTRj1=vA.Hj1 by A16,A40,A46,A47;
   A50: j1 in dom vAH by A39,A38,A8,A43,A44,FINSEQ_3:25;
   then vAH.j1 in rng vAH by FUNCT_1:def 3;
   then reconsider vAHj1=vAH.j1 as Element of TRn;
   A51: j1 in dom Fm by A43,A44,FINSEQ_3:25;
   then Fm.j1 in rng Fm by FUNCT_1:def 3;
   then reconsider Fmj1=Fm.j1 as Element of TRm;
   A52: MT.vAHj1=MT.((vA.Hj1)*Hj1) by A50,RLVECT_2:def 7
    .=MT.((vA.Hj1)*hj1) by EUCLID:65
    .=(vA.Hj1)*MT.(hj1) by MATRTOP1:23
    .=F.MTRj1*MTRj1 by A45,A48,A46,A49,EUCLID:65,FUNCT_1:12
    .=Fmj1 by A51,RLVECT_2:def 7;
   A53: j<len Fm by A43,NAT_1:13;
   then h.j1=h.J+vAHj1 by A37,A39,A38,A8;
   hence MT.(h.(j+1))=MT.(h.J)+MT.vAHj1 by MATRTOP1:27
    .=fm.(j+1) by A32,A52,A53,A42;
  end;
  A54: P[0] by A36,A31,MATRTOP1:29;
  for j be Nat holds P[j] from NAT_1:sch 2(A54,A41);
  then Sum Fm=MT.(Sum vAH) by A35,A30,A39,A38,A8;
  then A55: Sum F=MT.v by A9,A29,A3,A5,A6,A33,RLVECT_2:def 8;
  A56: now let i be Nat;
   assume A57: 1<=i & i<=len H;
   then A58: i in dom H by FINSEQ_3:25;
   then A59: (vA*H).i=vA.(H.i) by FUNCT_1:13;
   H.i in rng H by A58,FUNCT_1:def 3;
   then reconsider Hi=H.i as Element of TRn;
   A60: MTR.i=MT.(H.i) by A58,FUNCT_1:13;
   A61: i in dom MTR by A8,A57,FINSEQ_3:25;
   then A62: MTR.i in rng MTR by FUNCT_1:def 3;
   (F*MTR).i=F.(MTR.i) by A61,FUNCT_1:13;
   then P[MT.Hi,(F*MTR).i] by A16,A60;
   hence (F*MTR).i=(vA*H).i by A33,A40,A59,A60,A62;
  end;
  dom F=[#]TRm by FUNCT_2:def 1;
  then len(F*MTR)=len MTR by A33,FINSEQ_2:29;
  then vA*H=F*MTR by A8,A34,A56;
  then Sum(F*MTR)=sum vA by A3,A4,RLAFFIN1:def 3
   .=1 by A2,RLAFFIN1:def 7;
  then A63: sum F=1 by A9,A29,A3,A33,RLAFFIN1:def 3;
  then Sum F in {Sum L where L is Linear_Combination of MT.:A:sum L=1};
  hence A64: MT.v in Affin(MT.:A) by A55,RLAFFIN1:59;
  let f;
  f is Element of TRn by Lm3;
  then A65: MT.f in rng MT by A7,FUNCT_1:def 3;
  MT.:A is affinely-independent by A1,Th24;
  then F=MT.v|--MT.:A by A55,A63,A64,RLAFFIN1:def 7;
  hence thesis by A16,A65;
end;
