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 Th25:
  MR=Vec2DiagMx p iff len MR = len p & width MR = len p & for i st
  i in dom MR holds Line(MR,i) has_onlyone_value_in i & Line(MR,i).i=p.i
proof
  hereby
    assume
A1: MR=Vec2DiagMx p;
    then reconsider M1=MR as diagonal Matrix of len p,REAL;
A2: len M1 = len p by MATRIX_0:24;
    then
A3: dom MR = dom p by FINSEQ_3:29;
    thus len MR = len p & width MR = len p by A2,MATRIX_0:24;
    width M1 = len p by MATRIX_0:24;
    then
A4: Seg width MR = dom p by FINSEQ_1:def 3;
    thus for i st i in dom MR holds Line(MR,i) has_onlyone_value_in i & Line(
    MR,i).i=p.i
    proof
      let i such that
A5:   i in dom MR;
A6:   Line(M1,i) has_onlyone_value_in i by A5,Th24;
      Line(MR,i).i = MR*(i,i) by A3,A4,A5,MATRIX_0:def 7
        .= p.i by A1,A3,A5,Def4;
      hence thesis by A6;
    end;
  end;
  assume that
A7: len MR = len p and
A8: width MR = len p and
A9: for i st i in dom MR holds Line(MR,i) has_onlyone_value_in i & Line
  (MR,i).i=p.i;
  reconsider MM = MR as Matrix of len p,REAL by A7,A8,MATRIX_0:51;
  for i st i in dom MM holds Line(MM,i) has_onlyone_value_in i by A9;
  then reconsider MM as diagonal Matrix of len p,REAL by Th24;
  for j st j in dom p holds MM*(j,j) = p.j
  proof
A10: dom MM = dom p by A7,FINSEQ_3:29;
    let j such that
A11: j in dom p;
    Seg width MM = dom p by A8,FINSEQ_1:def 3;
    hence MM*(j,j) = Line(MM,j).j by A11,MATRIX_0:def 7
      .= p.j by A9,A11,A10;
  end;
  hence thesis by Def4;
end;
