 reserve x,y,z for object,
   i,j,k,l,n,m for Nat,
   D,E for non empty set;
 reserve M for Matrix of D;
 reserve L for Matrix of E;

theorem EQ40:
  len M = len L & width M = width L &
  (for i, j being Nat st [i,j] in Indices M holds M*(i,j) = L*(i,j))
  implies M = L
  proof
    assume that
    A1: len M = len L and
    A2: width M = width L and
    A3: for i,j be Nat st [i,j] in Indices M holds M*(i,j) = L*(i,j);
    M is Matrix of E
    proof
      consider n be Nat such that
      A0: for x being object st x in rng M holds
      ex p being FinSequence of D st x = p & len p = n by MATRIX_0:9;
      per cases;
      suppose len M = 0;
        then M = {};
        then rng M c= E*;
        hence thesis by FINSEQ_1:def 4;
      end;
      suppose I0: len M <> 0;
        for x being object st x in rng M holds
        ex p being FinSequence of E st x = p & len p = n
        proof
          let x being object;
          assume S1: x in rng M;
          then consider p being FinSequence of D such that
          S3: x = p & len p = n by A0;
          X1: width M = n by S1,S3,MATRIX_0:def 3,I0;
          for z be object st z in rng p holds z in E
          proof
            let z be object;
            assume z in rng p;
            then consider j1 be object such that
            S4: j1 in dom p & z = p.j1 by FUNCT_1:def 3;
            S5: j1 in Seg n by S3,S4,FINSEQ_1:def 3;
            reconsider j1 as Nat by S4;
            consider i1 be object such that
            S6: i1 in dom M & x = M.i1 by S1,FUNCT_1:def 3;
            reconsider i1 as Nat by S6;
            S8: [i1,j1] in Indices M by S6,S5,X1,ZFMISC_1:87;
            then consider q being FinSequence of D such that
            S9: q = M.i1 & M*(i1,j1) = q.j1 by MATRIX_0:def 5;
            M*(i1,j1) = L*(i1,j1) by A3,S8;
            hence z in E by S3,S4,S6,S9;
          end;
          then rng p c= E;
          then reconsider p as FinSequence of E by FINSEQ_1:def 4;
          take p;
          thus x = p & len p = n by S3;
        end;
        hence M is Matrix of E by MATRIX_0:9;
      end;
    end;
    then reconsider L0 = M as Matrix of E;
    for i, j being Nat st [i,j] in Indices L0 holds L0*(i,j) = L*(i,j)
    proof
      let i, j be Nat;
      assume X3: [i,j] in Indices L0;
      then consider q be FinSequence of D such that
      S9: q = M.i & M*(i,j) = q.j by MATRIX_0:def 5;
      consider p be FinSequence of E such that
      T9: p = L0.i & L0*(i,j) = p.j by MATRIX_0:def 5,X3;
      thus L0*(i,j) = L*(i,j) by A3,S9,T9,X3;
    end;
    hence thesis by A1,A2,MATRIX_0:21;
  end;
