reserve x,y for object,
  N for Element of NAT,
  c,i,j,k,m,n for Nat,
  D for non empty set,
  s for Element of 2Set Seg (n+2),
  p for Element of Permutations(n) ,
  p1, q1 for Element of Permutations(n+1),
  p2 for Element of Permutations(n +2),
  K for Field,
  a for Element of K,
  f for FinSequence of K,
  A for (Matrix of K),
  AD for Matrix of n,m,D,
  pD for FinSequence of D,
  M for Matrix of n,K;

theorem Th22:
  for i,j st i in Seg (n+1) & p1.i = j for M be Matrix of n+1,K
for DM be Matrix of n,K st DM = Delete(M,i,j) holds (Path_product M).p1 = power
  (K).(-1_K,i+j)*(M*(i,j))*(Path_product(DM)).Rem(p1,i)
proof
  reconsider N=n as Element of NAT by ORDINAL1:def 12;
  set n1 = N+1;
  let i,j be Nat such that
A1: i in Seg(n+1) and
A2: p1.i=j;
  set mm=the multF of K;
  set R=Rem(p1,i);
  let M be (Matrix of n+1,K),DM be (Matrix of n,K) such that
A3: DM=Delete(M,i,j);
  set PR=Path_matrix(R,DM);
  set Pp1=Path_matrix(p1,M);
  len Pp1=n1 by MATRIX_3:def 7;
  then dom Pp1=Seg n1 by FINSEQ_1:def 3;
  then
A4: Pp1.i=M*(i,j) by A1,A2,MATRIX_3:def 7;
A5: now
    per cases;
    suppose
A6:   N=0;
      then
A7:   len Pp1=1 by MATRIX_3:def 7;
      Pp1.1=M*(i,j) by A1,A4,A6,FINSEQ_1:2,TARSKI:def 1;
      then Pp1=<*M*(i,j)*> by A7,FINSEQ_1:40;
      then
A8:   mm $$ Pp1=M*(i,j) by FINSOP_1:11;
      len PR=0 by A6,MATRIX_3:def 7;
      then PR=<*>(the carrier of K);
      then
A9:   mm $$ PR = the_unity_wrt mm by FINSOP_1:10;
      the_unity_wrt mm=1_K by FVSUM_1:5;
      hence mm $$ Pp1=(M*(i,j))*(mm $$ PR) by A8,A9;
    end;
    suppose
A10:  N>0;
      len PR=n by MATRIX_3:def 7;
      then consider f be sequence of the carrier of K such that
A11:  f.1 = PR.1 and
A12:  for k being Nat st 0<>k & k<n holds f.(k+1) = mm.(f.k,PR.(k+1)) and
A13:  mm $$ PR=f.n by A10,FINSOP_1:def 1;
      len Pp1=n1 by MATRIX_3:def 7;
      then consider F be sequence of the carrier of K such that
A14:  F.1 = Pp1.1 and
A15:  for k being Nat st 0<>k & k<n1 holds F.(k+1) = mm.(F.k,Pp1.(k+1)) and
A16:  mm $$ Pp1=F.n1 by FINSOP_1:def 1;
      defpred P[Nat] means 1<=$1 & $1<i implies f.$1=F.$1;
A17:  for k st k in Seg n holds (k<i implies PR.k=Pp1.k) & (k>=i implies
      PR.k=Pp1.(k+1))
      proof
        len Pp1=n1 by MATRIX_3:def 7;
        then
A18:    dom Pp1=Seg n1 by FINSEQ_1:def 3;
        len PR=n by MATRIX_3:def 7;
        then
A19:    dom PR=Seg n by FINSEQ_1:def 3;
        reconsider p19=p1 as Permutation of Seg n1 by MATRIX_1:def 12;
        reconsider R9=R as Permutation of Seg n by MATRIX_1:def 12;
        let k such that
A20:    k in Seg n;
        reconsider k1=k+1 as Element of NAT;
A21:    k1 in Seg n1 by A20,FINSEQ_1:60;
A22:    rng p19=Seg n1 by FUNCT_2:def 3;
        dom p19=Seg n1 by FUNCT_2:52;
        then
A23:    j in Seg n1 by A1,A2,A22,FUNCT_1:def 3;
A24:    rng R9=Seg n by FUNCT_2:def 3;
        dom R9=Seg n by FUNCT_2:52;
        then
A25:    R.k in Seg n by A20,A24,FUNCT_1:def 3;
        then consider Rk be Nat such that
A26:    Rk=R.k and
        1<=Rk and
        Rk<=n;
A27:    n1-'1=n1-1 by XREAL_0:def 2;
        n<=n1 by NAT_1:11;
        then
A28:    Seg n c= Seg n1 by FINSEQ_1:5;
        thus k<i implies PR.k=Pp1.k
        proof
          assume
A29:      k<i;
          dom p19=Seg n1 by FUNCT_2:52;
          then p19.k<>p19.i by A1,A20,A28,A29,FUNCT_1:def 4;
          then p1.k<j or p1.k>j by A2,XXREAL_0:1;
          then Rk=p1.k & p1.k<j or p1.k>j&Rk=p1.k-1 by A1,A2,A20,A26,A29,Def3;
          then Rk=p1.k & p1.k<j or p1.k>j & p1.k=Rk+1;
          then Rk=p1.k & p1.k<j or p1.k>j & Rk>=j & p1.k=Rk+1 by NAT_1:13;
          then
          DM*(k,Rk)=M*(k,Rk) & PR.k=DM*(k,Rk) & Pp1.k=M*(k,Rk) or PR.k=DM
*(k,Rk) & DM*(k,Rk)=M*(k,Rk+1) & Pp1.k=M*(k,Rk+1) by A1,A3,A20,A25,A23,A26,A28
,A27,A19,A18,A29,Th13,MATRIX_3:def 7;
          hence thesis;
        end;
A30:    dom p19=Seg n1 by FUNCT_2:52;
        assume
A31:    k>=i;
        then k1 >i by NAT_1:13;
        then p19.k1<>p19.i by A1,A21,A30,FUNCT_1:def 4;
        then p1.k1<j or p1.k1>j by A2,XXREAL_0:1;
        then
        Rk=p1.k1 & p1.k1<j or p1.k1>j&Rk=p1.k1-1 by A1,A2,A20,A26,A31,Def3;
        then Rk=p1.k1 & p1.k1<j or p1.k1>j & p1.k1=Rk+1;
        then Rk=p1.k1 & p1.k1<j or p1.k1>j & Rk>=j & p1.k1=Rk+1 by NAT_1:13;
        then
        DM*(k,Rk)=M*(k+1,Rk) & PR.k=DM*(k,Rk) & Pp1.k1=M*(k+1,Rk) or PR.k
=DM*(k,Rk) & DM*(k,Rk)=M*(k+1,Rk+1) & Pp1.k1=M*(k1,Rk+1) by A1,A3,A20,A25,A23
,A26,A27,A21,A19,A18,A31,Th13,MATRIX_3:def 7;
        hence thesis;
      end;
A32:  for k st P[k] holds P[k+1]
      proof
        let k such that
A33:    P[k];
        reconsider e=k as Element of NAT by ORDINAL1:def 12;
        assume that
A34:    1<=k+1 and
A35:    k+1<i;
        set k1 = e+1;
        i<=n1 by A1,FINSEQ_1:1;
        then k1<n1 by A35,XXREAL_0:2;
        then k1<=n by NAT_1:13;
        then
A36:    k1 in Seg N by A34;
        per cases by NAT_1:14;
        suppose
          k=0;
          hence thesis by A14,A11,A17,A35,A36;
        end;
        suppose
A37:      k>=1;
          i<=n1 by A1,FINSEQ_1:1;
          then
A38:      k1<n1 by A35,XXREAL_0:2;
          then k<n1 by NAT_1:13;
          then
A39:      F.k1=mm.(F.k,Pp1.k1) by A15,A37;
          k1<=n by A38,NAT_1:13;
          then
A40:      k1 in Seg N by A34;
          k<n by A38,XREAL_1:6;
          then f.k1=mm.(f.k,PR.k1) by A12,A37;
          hence thesis by A17,A33,A35,A37,A39,A40,NAT_1:13;
        end;
      end;
      defpred Q[Nat] means i<=$1 & $1<=n1 implies ($1=1 implies F.($1)=M*(i,j)
      ) & ($1>1 implies for a st a=f.($1-1) holds F.$1=M*(i,j)*a);
A41:  P[0];
A42:  for k holds P[k] from NAT_1:sch 2(A41,A32);
A43:  for k st Q[k] holds Q[k+1]
      proof
        let k such that
A44:    Q[k];
        set k1=k+1;
        assume that
A45:    i<=k1 and
A46:    k1<=n1;
        per cases;
        suppose
A47:      k=0;
          1<=i by A1,FINSEQ_1:1;
          hence thesis by A4,A14,A45,A47,XXREAL_0:1;
        end;
        suppose
A48:      k>0;
          hence k1=1 implies F.k1=M*(i,j);
          assume k1>1;
          let a such that
A49:      a=f.(k1-1);
A50:      k<=n by A46,XREAL_1:6;
          k>=1 by A48,NAT_1:14;
          then
A51:      k in Seg n by A50;
          len PR=n by MATRIX_3:def 7;
          then
A52:      dom PR=Seg n by FINSEQ_1:def 3;
          then
A53:      PR.k=DM*(k,R.k) by A51,MATRIX_3:def 7;
          k<n1 by A46,NAT_1:13;
          then
A54:      F.k1=mm.(F.k,Pp1.k1) by A15,A48;
          per cases by A45,XXREAL_0:1;
          suppose
A55:        k1=i;
            then k<i by NAT_1:13;
            then F.k1=a*(M*(i,j)) by A4,A42,A48,A49,A54,A55,NAT_1:14;
            hence thesis;
          end;
          suppose
A56:        k1>i;
A57:        k<n1 by A46,NAT_1:13;
A58:        k>=i by A56,NAT_1:13;
            i>=1 by A1,FINSEQ_1:1;
            then
A59:        k>=1 by A58,XXREAL_0:2;
            per cases by A59,XXREAL_0:1;
            suppose
              k=1;
              hence thesis by A11,A17,A44,A46,A49,A51,A54,A58,NAT_1:13;
            end;
            suppose
A60:          k>1;
              reconsider k9=k-1 as Element of NAT by A48,NAT_1:20;
              reconsider fk9=f.k9 as Element of K;
              k9+1<=n by A57,NAT_1:13;
              then
A61:          k9<n by NAT_1:13;
              k9+1>0+1 by A60;
              then
A62:          a=mm.(fk9,PR.(k9+1)) by A12,A49,A61;
              F.k=M*(i,j)*fk9 by A44,A46,A56,A60,NAT_1:13;
              hence F.k1 = (M*(i,j)*fk9)*(DM*(k,R.k)) by A17,A51,A54,A53,A58
                .= M*(i,j)*(fk9*(DM*(k,R.k)))by GROUP_1:def 3
                .= M*(i,j)*a by A51,A52,A62,MATRIX_3:def 7;
            end;
          end;
        end;
      end;
A63:  Q[0];
A64:  for k holds Q[k] from NAT_1:sch 2(A63,A43);
A65:  i<=n1 by A1,FINSEQ_1:1;
A66:  n1-1=n;
      n1>0+1 by A10,XREAL_1:6;
      hence mm $$ Pp1=M*(i,j)*mm $$ PR by A16,A13,A64,A65,A66;
    end;
  end;
  per cases;
  suppose
A67: R is even;
    thus (Path_product(M)).p1 = -(mm $$ Pp1,p1) by MATRIX_3:def 8
      .= power(K).(-1_K,i+j)*-(mm $$ Pp1,R) by A1,A2,Th21
      .= power(K).(-1_K,i+j)*(M*(i,j)*mm $$ PR) by A5,A67,MATRIX_1:def 16
      .= power(K).(-1_K,i+j) * (M*(i,j))*mm $$ PR by GROUP_1:def 3
      .= power(K).(-1_K,i+j) * (M*(i,j))* -(mm $$ PR,R) by A67,MATRIX_1:def 16
      .= power(K).(-1_K,i+j)*(M*(i,j))*(Path_product(DM)).R by MATRIX_3:def 8;
  end;
  suppose
A68: R is odd;
    thus (Path_product(M)).p1=-(mm $$ Pp1,p1) by MATRIX_3:def 8
      .= power(K).(-1_K,i+j)*-(mm $$ Pp1,R) by A1,A2,Th21
      .= power(K).(-1_K,i+j)*(-(M*(i,j)*mm $$ PR)) by A5,A68,MATRIX_1:def 16
      .= power(K).(-1_K,i+j)*((M*(i,j)*(-(mm $$ PR)))) by VECTSP_1:8
      .= power(K).(-1_K,i+j)*(M*(i,j))*(-(mm $$ PR)) by GROUP_1:def 3
      .= power(K).(-1_K,i+j)*(M*(i,j))*-(mm $$ PR,R) by A68,MATRIX_1:def 16
      .= power(K).(-1_K,i+j)*(M*(i,j))*(Path_product(DM)).R by MATRIX_3:def 8;
  end;
end;
