reserve i,j for Nat;

theorem Th22:
  for K being Field,a being Element of K,A,B being Matrix of K st
  width A=len B holds A*(a*B)=a*(A*B)
proof
  let K be Field,a be Element of K,A,B be Matrix of K;
  set C=a*B;
  set D=a*(A*B);
A1: len D=len (A*B) by MATRIX_3:def 5;
  assume
A2: width A=len B;
  then width (A*B)=width B by MATRIX_3:def 4;
  then
A3: width D=width B by MATRIX_3:def 5
    .=width C by MATRIX_3:def 5;
A4: width B=width (a*B) by MATRIX_3:def 5;
A5: for i,j st [i,j] in Indices D holds D*(i,j)=Line(A,i) "*" Col(C,j)
  proof
    let i,j;
    reconsider xo=Col(B,j) as Element of (width A)-tuples_on the carrier of K
    by A2;
    assume
A6: [i,j] in Indices (a*(A*B));
    then j in Seg width B by A4,A3,ZFMISC_1:87;
    then
A7: 1<=j & j<=width B by FINSEQ_1:1;
    dom (A*B)=dom (a*(A*B)) by A1,FINSEQ_3:29;
    then
A8: [i,j] in Indices (A*B) by A6,MATRIX_3:def 5;
    then (a*(A*B))*(i,j)=a*((A*B)*(i,j)) by MATRIX_3:def 5;
    then (a*(A*B))*(i,j)=a*((Line(A,i)) "*" (Col(B,j))) by A2,A8,MATRIX_3:def 4
      .=a*(Sum(mlt(Line(A,i),Col(B,j)))) by FVSUM_1:def 9
      .=Sum(a*mlt(Line(A,i),Col(B,j))) by FVSUM_1:73
      .=Sum(mlt(Line(A,i),a*xo)) by FVSUM_1:69
      .=Sum(mlt(Line(A,i),Col(a*B,j))) by A7,Th19;
    hence thesis by FVSUM_1:def 9;
  end;
  len C=len B & len (A*B)=len A by A2,MATRIX_3:def 4,def 5;
  hence thesis by A2,A1,A3,A5,MATRIX_3:def 4;
end;
