reserve x,y,z for object,
  i,j,n,m for Nat,
  D for non empty set,
  s,t for FinSequence,
  a,a1,a2,b1,b2,d for Element of D,
  p, p1,p2,q,r for FinSequence of D;
reserve M,M1,M2 for Matrix of D;

theorem Th21:
  len M1 = len M2 & width M1 = width M2 & (for i,j st [i,j] in
  Indices M1 holds M1*(i,j) = M2*(i,j)) implies M1 = M2
proof
  assume that
A1: len M1 =len M2 and
A2: width M1= width M2 and
A3: for i,j st [i,j] in Indices M1 holds M1*(i,j) = M2*(i,j);
A4: dom M1= dom M2 by A1,FINSEQ_3:29;
  for k be Nat st k in dom M1 holds M1.k = M2.k
  proof
    let k be Nat;
    assume
A5: k in dom M1;
    then
A6: M1.k in rng M1 by FUNCT_1:def 3;
    rng M1 c= D* by FINSEQ_1:def 4;
    then reconsider p = M1.k as FinSequence of D by A6,FINSEQ_1:def 11;
    M1 <> {} by A5;
    then
A7: len M1 > 0;
    then M1 is Matrix of len M1,width M1,D by Th20;
    then
A8: len p = width M1 by A6,Def2;
A9: M2.k in rng M2 by A4,A5,FUNCT_1:def 3;
    rng M2 c= D* by FINSEQ_1:def 4;
    then reconsider q = M2.k as FinSequence of D by A9,FINSEQ_1:def 11;
    M2 is Matrix of len M1,width M1,D by A1,A2,A7,Th20;
    then
A10: len q = width M1 by A9,Def2;
    for l be Nat st 1 <= l & l <= len p holds p.l = q.l
    proof
      let l be Nat;
A11:  rng p c= D by FINSEQ_1:def 4;
      assume 1 <= l & l <= len p;
      then
A12:  l in Seg width M1 by A8,FINSEQ_1:1;
      then l in dom p by A8,FINSEQ_1:def 3;
      then p.l in rng p by FUNCT_1:def 3;
      then reconsider a = p.l as Element of D by A11;
A13:  rng q c= D by FINSEQ_1:def 4;
      l in dom q by A10,A12,FINSEQ_1:def 3;
      then q.l in rng q by FUNCT_1:def 3;
      then reconsider b = q.l as Element of D by A13;
      [k,l] in Indices M2 by A2,A4,A5,A12,ZFMISC_1:87;
      then
A14:  M2*(k,l)= b by Def5;
      [k,l] in Indices M1 by A5,A12,ZFMISC_1:87;
      then
A15:  M1*(k,l)=a by Def5;
      [k,l] in [:dom M1,Seg width M1:] by A5,A12,ZFMISC_1:87;
      hence thesis by A3,A15,A14;
    end;
    hence thesis by A8,A10,FINSEQ_1:14;
  end;
  hence thesis by A4,FINSEQ_1:13;
end;
