reserve D for non empty set,
  i,j,k,l for Nat,
  n for Nat,
  x for set,
  a,b,c,r,r1,r2 for Real,
  p,q for FinSequence of REAL,
  MR,MR1 for Matrix of REAL;

theorem Th27:
  len p = len MR implies (MR1 = (Vec2DiagMx p) * MR iff len MR1 =
len p & width MR1 = width MR & for i st i in dom MR1 holds Line(MR1,i) = p.i *
  Line(MR,i))
proof
  set MM = Vec2DiagMx p;
  assume
A1: len p = len MR;
  hereby
    assume
A2: MR1 = MM * MR;
    hence len MR1 = len p & width MR1 = width MR by A1,Th26;
A3: width MR1 = width MR by A1,A2,Th26;
    thus for i st i in dom MR1 holds Line(MR1,i) = p.i * Line(MR,i)
    proof
      let i;
      assume i in dom MR1;
      then
A4:   i in Seg len MR1 by FINSEQ_1:def 3;
A5:   for j be Nat st j in dom Line(MR1,i) holds (Line(MR1,i)).j = (p.i *
      Line(MR,i)).j
      proof
        let j be Nat;
        assume j in dom Line(MR1,i);
        then j in Seg len Line(MR1,i) by FINSEQ_1:def 3;
        then
A6:     j in Seg width MR1 by MATRIX_0:def 7;
        then
A7:     [i,j] in Indices MR1 by A4,MATRPROB:12;
        thus (Line(MR1,i)).j = MR1*(i,j) by A6,MATRIX_0:def 7
          .= p.i*(MR*(i,j)) by A1,A2,A7,Th26
          .= p.i*(Line(MR,i).j) by A3,A6,MATRIX_0:def 7
          .= (p.i * Line(MR,i)).j by RVSUM_1:44;
      end;
      dom Line(MR1,i) = Seg len Line(MR1,i) by FINSEQ_1:def 3
        .= Seg width MR1 by MATRIX_0:def 7
        .= Seg len Line(MR,i) by A3,MATRIX_0:def 7
        .= dom Line(MR,i) by FINSEQ_1:def 3
        .= dom(p.i * Line(MR,i)) by VALUED_1:def 5;
      hence thesis by A5,FINSEQ_1:13;
    end;
  end;
  assume that
A8: len MR1 = len p and
A9: width MR1 = width MR and
A10: for i st i in dom MR1 holds Line(MR1,i) = p.i*Line(MR,i);
  for i,j st [i,j] in Indices MR1 holds MR1*(i,j) = p.i*(MR*(i,j))
  proof
    let i,j such that
A11: [i,j] in Indices MR1;
A12: i in dom MR1 by A11,MATRPROB:13;
A13: j in Seg width MR1 by A11,MATRPROB:12;
    hence MR1*(i,j) = (Line(MR1,i)).j by MATRIX_0:def 7
      .= (p.i*Line(MR,i)).j by A10,A12
      .= p.i * Line(MR,i).j by RVSUM_1:44
      .= p.i*(MR*(i,j)) by A9,A13,MATRIX_0:def 7;
  end;
  hence thesis by A1,A8,A9,Th26;
end;
