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 Th18:
  rng(Mx2Tran M) = [#]Lin lines M
proof
  consider X be set such that
   A1: X c=dom M and
   A2: lines M=rng(M|X) and
   A3: M|X is one-to-one by MATRTOP1:6;
  set V=m-VectSp_over F_Real;
  set TM=Mx2Tran M;
  A4: len M=n by MATRIX_0:def 2;
  then reconsider X as Subset of Seg n by A1,FINSEQ_1:def 3;
  hereby let y be object;
   assume y in rng TM;
   then consider x be object such that
    A5: x in dom TM and
    A6: TM.x=y by FUNCT_1:def 3;
   reconsider x as Element of TOP-REAL n by A5;
   consider L be Linear_Combination of lines M such that
    A7: Sum L=y and
    for i be Nat st i in X holds L.Line(M,i)=Sum Seq(x|M"{Line(M,i)})
    by A2,A3,A6,Th15;
   Sum L in Lin lines M by VECTSP_7:7;
   hence y in [#]Lin lines M by A7;
  end;
  let y be object;
  assume y in [#]Lin lines M;
  then y in Lin lines M;
  then consider L be Linear_Combination of lines M such that
   A8: y=Sum L by VECTSP_7:7;
  defpred P[set,object] means
   ($1 in X implies $2=L.(M.$1)) & (not$1 in X implies $2=0);
  A9: for i be Nat st i in Seg n ex x be object st P[i,x]
  proof
   let i be Nat such that
    i in Seg n;
   i in X or not i in X;
   hence thesis;
  end;
  consider f be FinSequence such that
   A10: dom f=Seg n & for j be Nat st j in Seg n holds P[j,f.j]
    from FINSEQ_1:sch 1(A9);
  A11: dom M=Seg n by A4,FINSEQ_1:def 3;
  rng f c=REAL
  proof
   let z be object;
   assume z in rng f;
   then consider x be object such that
    A12: x in dom f and
    A13: f.x=z by FUNCT_1:def 3;
   reconsider x as Nat by A12;
   A14: P[x,f.x] by A10,A12;
   M.x=Line(M,x) by A11,A10,A12,MATRIX_0:60;
   then M.x in lines M by A10,A12,MATRIX13:103;
   then reconsider Mx=M.x as Element of V;
   per cases;
   suppose not x in X;
    then f.x=In(0,REAL) by A10,A12;
    hence thesis by A13;
   end;
   suppose x in X;
    thus thesis by A13,A14,XREAL_0:def 1;
   end;
  end;
  then reconsider f as FinSequence of REAL by FINSEQ_1:def 4;
  len f=n by A4,A10,FINSEQ_1:def 3;
  then A15: f is n-element by CARD_1:def 7;
  then consider K be Linear_Combination of lines M such that
   A16: Sum K=TM.f and
   A17: for i be Nat st i in X holds K.Line(M,i)=Sum Seq(f|M"{Line(M,i)})
    by A2,A3,Th15;
  now let v be Element of V;
   per cases;
   suppose v in lines M;
    then consider i be object such that
     A18: i in dom(M|X) and
     A19: (M|X).i=v by A2,FUNCT_1:def 3;
    A20: M.i=v by A18,A19,FUNCT_1:47;
    set D=dom(f|M"{v});
    Seq(f|M"{v})=@@Seq(f|M"{v});
    then reconsider F=Seq(f|M"{v}) as FinSequence of REAL;
    A21: rng Sgm D=D by FINSEQ_1:50;
    then A22: dom F=dom Sgm D by RELAT_1:27;
    A23: i in dom M by A18,RELAT_1:57;
    A24: i in X by A18;
    reconsider i as Nat by A18;
    M.i=Line(M,i) by A23,MATRIX_0:60;
    then A25: K.v=Sum Seq(f|M"{v}) by A17,A24,A20;
    v in {v} by TARSKI:def 1;
    then i in M"{v} by A23,A20,FUNCT_1:def 7;
    then i in D by A10,A24,RELAT_1:57;
    then consider j be object such that
     A26: j in dom Sgm D and
     A27: (Sgm D).j=i by A21,FUNCT_1:def 3;
    reconsider j as Element of NAT by A26;
    F.j=(f|M"{v}).i & i in D by A22,A26,A27,FUNCT_1:11,12;
    then A28: F.j=f.i by FUNCT_1:47;
    A29: Sgm D is one-to-one by FINSEQ_3:92;
    now let w be Nat;
     assume that
      A30: w in dom F and
      A31: w<>j;
     A32: (Sgm D).w in D by A21,A22,A30,FUNCT_1:def 3;
     then (Sgm D).w in M"{v} by RELAT_1:57;
     then M.((Sgm D).w) in {v} by FUNCT_1:def 7;
     then A33: M.((Sgm D).w)=v by TARSKI:def 1;
     A34: not(Sgm D).w in X
     proof
      assume(Sgm D).w in X;
      then A35: (Sgm D).w in dom(M|X) by A11,RELAT_1:57;
      then v=(M|X).((Sgm D).w) by A33,FUNCT_1:47;
      then i=(Sgm D).w by A3,A18,A19,A35,FUNCT_1:def 4;
      hence contradiction by A22,A29,A26,A27,A30,A31,FUNCT_1:def 4;
     end;
     F.w=(f|M"{v}).((Sgm D).w) by A30,FUNCT_1:12;
     then A36: F.w=f.((Sgm D).w) by A32,FUNCT_1:47;
     (Sgm D).w in dom f by A32,RELAT_1:57;
     hence F.w=0 by A10,A36,A34;
    end;
    then A37: F has_onlyone_value_in j by A22,A26,ENTROPY1:def 2;
    f.i=L.v by A10,A24,A20;
    hence L.v=K.v by A25,A28,A37,ENTROPY1:13;
   end;
   suppose A38: not v in lines M;
    Carrier L c=lines M by VECTSP_6:def 4;
    then not v in Carrier L by A38;
    then A39: L.v=0.F_Real by VECTSP_6:2;
    Carrier K c=lines M by VECTSP_6:def 4;
    then not v in Carrier K by A38;
    hence L.v=K.v by A39,VECTSP_6:2;
   end;
  end;
  then A40: Sum K=Sum L by VECTSP_6:def 7;
  dom TM=[#](TOP-REAL n) & f is Point of TOP-REAL n by A15,Lm3,FUNCT_2:def 1;
  hence thesis by A8,A16,A40,FUNCT_1:def 3;
end;
