reserve x, y for object, X for set,
  i, j, k, l, n, m for Nat,
  D for non empty set,
  K for commutative Ring,
  a,b for Element of K,
  perm, p, q for Element of Permutations(n),
  Perm,P for Permutation of Seg n,
  F for Function of Seg n,Seg n,
  perm2, p2, q2, pq2 for Element of Permutations(n+2),
  Perm2 for Permutation of Seg (n+2);
reserve s for Element of 2Set Seg (n+2);
reserve pD for FinSequence of D,
  M for Matrix of n,m,D,
  pK,qK for FinSequence of K,
  A for Matrix of n,K;

theorem Th45:
  for M be Matrix of n+2,n+2,K, perm2,Perm2 st perm2=Perm2 holds
  Det(M*Perm2) = sgn(perm2,K)*Det(M)
proof
  set n2=n+2;
  let M be Matrix of n2,n2,K, perm2,Perm2 such that
A1: perm2=Perm2;
  set PathM=Path_product(M);
  set Mperm=M*Perm2;
  set P=Permutations(n2);
  set KK=the carrier of K;
  set aa=the addF of K;
  set PathMp=Path_product(Mperm);
  set F=In(P,Fin P);
  reconsider perm29=perm2" as Element of P by MATRIX_7:18;
  P in Fin P by FINSUB_1:def 5; then
A2: F=P by SUBSET_1:def 8;
  then consider GM be Function of Fin P,KK such that
A3: Det M = GM.F and
  for e being Element of KK st e is_a_unity_wrt aa holds GM.{} = e and
A4: for x being Element of P holds GM.{x} = PathM.x and
A5: for B9 being Element of Fin P st B9 c= F & B9 <> {} for x being
  Element of P st x in F \ B9 holds GM.(B9 \/ {x}) = aa.(GM.B9,PathM.x) by
SETWISEO:def 3;
  consider PERM be Permutation of P such that
A6: for p be Element of P holds PERM.p=p*perm29 by Th44;
  consider GMp be Function of Fin P,KK such that
A7: Det Mperm = GMp.F and
  for e being Element of KK st e is_a_unity_wrt aa holds GMp.{} = e and
A8: for x being Element of P holds GMp.{x} = PathMp.x and
A9: for B9 being Element of Fin P st B9 c= F & B9 <> {} for x being
Element of P st x in F \ B9 holds GMp.(B9 \/ {x}) = aa.(GMp.B9,PathMp.x) by A2,
SETWISEO:def 3;
  defpred P[Nat] means $1<>0 implies for B be Element of Fin P st card B=$1
  holds sgn(perm2,K)*GMp.B=GM.(PERM.:B);
A10: for k be Nat st P[k] holds P[k+1]
  proof
    let k be Nat such that
A11: P[k];
    set k1=k+1;
    assume k1<>0;
    let B be Element of Fin P such that
A12: card B=k1;
    per cases;
    suppose
      k=0;
      then consider x being object such that
A13:  B={x} by A12,CARD_2:42;
A14:  x in B by A13,TARSKI:def 1;
      B c= P by FINSUB_1:def 5;
      then reconsider x as Element of P by A14;
A15:  GM.{PERM.x}=PathM.(PERM.x) by A4;
A16:  PERM.x=x*perm29 by A6;
A17:  P=dom PERM by FUNCT_2:52;
      GMp.{x}=PathMp.x by A8;
      then sgn(perm2,K)* GMp.B = GM.{PERM.x} by A1,A13,A15,A16,Th43;
      then sgn(perm2,K)* GMp.B = GM.(Im(PERM,x)) by A17,FUNCT_1:59;
      hence thesis by A13;
    end;
    suppose
A18:  k>0;
      consider x being object such that
A19:  x in B by A12,CARD_1:27,XBOOLE_0:def 1;
      B c= P by FINSUB_1:def 5;
      then reconsider x as Element of P by A19;
      PERM.:(B\{x}) c= rng PERM by RELAT_1:111;
      then
A20:  PERM.:(B\{x}) c= P by FUNCT_2:def 3;
      reconsider Px=PERM.x as Element of P;
A21:  Px in {Px} by TARSKI:def 1;
      dom PERM=P by FUNCT_2:52;
      then
A22:  Im(PERM,x)={Px} by FUNCT_1:59;
A23:  B c= P by FINSUB_1:def 5;
      then B\{x} c= P;
      then reconsider
      B9=B\{x},PeBx=PERM.:(B\{x}),PeB=PERM.:B as Element of Fin P
      by A20,FINSUB_1:def 5;
A24:  {x} \/ B9=B by A19,ZFMISC_1:116;
      then
A25:  PERM.:B=Im(PERM,x)\/PeBx by RELAT_1:120;
      PERM.x=x*perm29 by A6;
      then
A26:  sgn(perm2,K)* PathMp.x = PathM.Px by A1,Th43;
A27:  dom PERM=P by FUNCT_2:52;
      B9 misses {x} by XBOOLE_1:79;
      then B9/\{x}={};
      then PERM.:{}={Px}/\PeBx by A22,FUNCT_1:62;
      then not Px in PeBx by A21,XBOOLE_0:def 4;
      then
A28:  Px in F\PeBx by A2,XBOOLE_0:def 5;
A29:  B9 c= P by FINSUB_1:def 5;
A30:  not x in B9 by ZFMISC_1:56;
      then
A31:  x in F\B9 by A2,XBOOLE_0:def 5;
A32:  k+1=card B9+1 by A12,A24,A30,CARD_2:41;
      then ex y being object st y in B9 by A18,CARD_1:27,XBOOLE_0:def 1;
      then GM.PeB = aa.(GM.PeBx,PathM.Px) by A2,A5,A20,A25,A22,A28,A29,A27;
      then GM.PeB=(sgn(perm2,K)*GMp.B9)+(sgn(perm2,K)*PathMp.x)by A11,A18,A32
,A26
        .=sgn(perm2,K)*(GMp.B9+PathMp.x) by VECTSP_1:def 7
        .=sgn(perm2,K)*GMp.B by A2,A9,A18,A23,A24,A32,A31,CARD_1:27,XBOOLE_1:1;
      hence thesis;
    end;
  end;
A33: P[0];
A34: for k be Nat holds P[k] from NAT_1:sch 2(A33,A10);
A35: rng PERM=P by FUNCT_2:def 3;
A36: dom PERM=P by FUNCT_2:52;
A37: PERM.:dom PERM=rng PERM by RELAT_1:113;
A38: (1_K)*(1_K)=(-1_K)*(-1_K) by VECTSP_1:10;
A39: sgn(perm2,K)=1_K or sgn(perm2,K)=-1_K by Th11;
  card F<>0 by A2;
  then sgn(perm2,K)*Det Mperm=Det M by A2,A3,A7,A34,A37,A36,A35;
  hence sgn(perm2,K)*Det M = 1_K*Det Mperm by A39,A38,GROUP_1:def 3
    .= Det Mperm;
end;
