reserve x,y for object,X,Y for set,
  D for non empty set,
  i,j,k,l,m,n,m9,n9 for Nat,
  i0,j0,n0,m0 for non zero Nat,
  K for Field,
  a,b for Element of K,
  p for FinSequence of K,
  M for Matrix of n,K;

theorem
  for M be (Matrix of n,K),R be Element of Permutations(n) st R = Rev
idseq n & ((for i,j st i in Seg n & j in Seg n & i+j <= n holds M*(i,j) = 0.K)
or (for i,j st i in Seg n & j in Seg n & i+j > n+1 holds M*(i,j) = 0.K)) holds
  Det M = -((the multF of K) "**" Path_matrix(R,M), R)
proof
  let M be (Matrix of n,K),R be Element of Permutations(n) such that
A1: R=Rev idseq n and
A2: (for i,j st i in Seg n & j in Seg n & i+j <= n holds M*(i,j)=0.K)or
  for i,j st i in Seg n & j in Seg n & i+j > n+1 holds M*(i,j)=0.K;
  set mm=the multF of K;
  idseq n is Element of Group_of_Perm(n) by MATRIX_1:11;
  then reconsider I=idseq n as Element of Permutations(n) by MATRIX_1:def 13;
  set X=Seg n;
  reconsider r=Rev idseq n as Permutation of X by A1,MATRIX_1:def 12;
  set Mr=M*r;
  set PR=Path_matrix(R,M);
  set PI=Path_matrix(I,Mr);
A3: len PR=n by MATRIX_3:def 7;
A4: len PI=n by MATRIX_3:def 7;
A5: now
    per cases;
    suppose
A6:   n<1;
      then
A7:   PR={} by A3,NAT_1:14;
      PI={} by A4,A6,NAT_1:14;
      hence mm "**"PI=mm "**"PR by A7;
    end;
    suppose
A8:   n>=1;
      rng I=X;
      then
A9:   rng (Rev idseq n)=X by FINSEQ_5:57;
      reconsider PRR=PR*R as FinSequence of K by A3,A8,MATRIX_7:34;
A10:  dom r=X by FUNCT_2:52;
      dom PR=X by A3,FINSEQ_1:def 3;
      then
A11:  dom PRR=dom R by A1,A9,RELAT_1:27;
A12:  now
A13:    dom PR=Seg n by A3,FINSEQ_1:def 3;
A14:    dom PI=Seg n by A4,FINSEQ_1:def 3;
        let k such that
A15:    1 <=k and
A16:    k <= len PI;
A17:    k in Seg n by A4,A15,A16;
        then
A18:    n-k+1 in X by FINSEQ_5:2;
        I.k=k by A17,FUNCT_1:17;
        then
A19:    PI.k=Mr*(k,k) by A17,A14,MATRIX_3:def 7;
A20:    len idseq n = n by CARD_1:def 7;
        then r.k=I.(n-k+1) by A10,A17,FINSEQ_5:def 3;
        then
A21:    r.k=n-k+1 by A18,FUNCT_1:17;
A22:    Indices M=[:Seg n,Seg n:] by MATRIX_0:24;
        then [k,k] in Indices M by A17,ZFMISC_1:87;
        then consider m such that
A23:    r.k = m and
A24:    [m,k] in Indices M and
A25:    Mr*(k,k) = M*(m,k) by MATRIX11:37;
A26:    m in X by A22,A24,ZFMISC_1:87;
        then
A27:    n-m+1 in X by FINSEQ_5:2;
        r.m=I.(n-m+1) by A10,A20,A26,FINSEQ_5:def 3;
        then
A28:    R.m=k by A1,A23,A27,A21,FUNCT_1:17;
        m in Seg n by A22,A24,ZFMISC_1:87;
        then PR.m=M*(m,k) by A13,A28,MATRIX_3:def 7;
        hence PI.k=PRR.k by A1,A11,A10,A17,A23,A25,A19,FUNCT_1:12;
      end;
      n is Element of NAT by ORDINAL1:def 12;
      then len PRR=n by A1,A11,A10,FINSEQ_1:def 3;
      hence mm "**"PI=mm "**"PR by A4,A3,A8,A12,FINSEQ_1:14,MATRIX_7:33;
    end;
  end;
  Mr is upper_triangular Matrix of n,K or Mr is lower_triangular Matrix
  of n,K by A2,Th12,Th13;
  then
A29: mm $$ diagonal_of_Matrix Mr = Det Mr by Th7,Th8
    .= -(Det M,R) by A1,MATRIX11:46;
  then
A30: -(Det M,R)=mm $$ PR by A5,Th6;
  per cases;
  suppose
    R is even;
    then -(Det M,R)=Det M by MATRIX_1:def 16;
    hence thesis by A5,A29,Th6;
  end;
  suppose
A31: R is odd;
    then
A32: -(mm"**"PR,R)= -mm"**"PR by MATRIX_1:def 16;
    -(Det M,R)= -Det M by A31,MATRIX_1:def 16;
    then -(mm"**"PR,R)+(-Det M) =0.K by A30,A32,VECTSP_1:19;
    hence thesis by VECTSP_1:19;
  end;
end;
