reserve k,n,i,j for Nat;

theorem
  for K being Ring, n being Nat st n>=1 holds Det (1.(K,n)) = 1_K
proof
  let K be Ring, n be Nat;
  assume
A1: n>=1;
  deffunc F2(object) = IFEQ(idseq n,$1,1_K,0.K);
  set X=Permutations(n);
  set Y=the carrier of K;
A2: for x being object st x in X holds F2(x) in Y;
  ex f2 being Function of X,Y st
for x being object st x in X holds f2.x =
  F2(x) from FUNCT_2:sch 2(A2);
  then consider f2 being Function of X,Y such that
A3: for x being object st x in X holds f2.x = F2(x);
A4: id (Seg n) is even by MATRIX_1:16;
A5: for x being object st x in dom (Path_product(1.(K,n)))
    holds (Path_product(1.(K,n))).x=f2.x
  proof
    let x be object;
    assume x in dom (Path_product(1.(K,n)));
    for p being Element of Permutations(n) holds f2.p = -((the multF of K
    ) $$ Path_matrix(p,(1.(K,n))),p)
    proof
      defpred P[Nat] means (the multF of K) $$ ( ($1+1) |-> 1_K)=
      1_K;
      let p be Element of Permutations(n);
A6:   for k being Nat st P[k] holds P[k+1]
      proof
        let k be Nat;
A7:     (k+1+1) |-> 1_K = ((k+1) |-> 1_K) ^ <* 1_K *> by FINSEQ_2:60;
        assume P[k];
        then (the multF of K) $$ ( (k+1+1) |-> 1_K) = (1_K)*(1_K) by A7,
FINSOP_1:4
          .= 1_K;
        hence thesis;
      end;
A8:   now
        per cases;
        case
          p is even;
          hence -(0.K,p)=(0.K) by MATRIX_1:def 16;
        end;
        case
          not p is even;
          then -(0.K,p)= -(0.K) by MATRIX_1:def 16
            .=0.K by RLVECT_1:12;
          hence -(0.K,p)=0.K;
        end;
      end;
      n-'1=n-1 by A1,XREAL_1:233;
      then
A9:   n-'1+1=n;
      (1 |-> 1_K)= <* 1_K *> by FINSEQ_2:59;
      then
A10:  P[0] by FINSOP_1:11;
      for k being Nat holds P[k] from NAT_1:sch 2(A10,A6);
      then
A11:  len (n |-> 1_K)=n & (the multF of K) $$ (n |-> 1_K)=1_K by A9,
CARD_1:def 7;
      now
        per cases;
        case
A12:      p=idseq n;
A13:      for i,j st i in dom (n |-> 1_K) & j=p.i holds (n |-> 1_K).i=(1.
          (K,n))*(i,j)
          proof
A14:        Indices (1.(K,n))=[: Seg n,Seg n:] by A1,MATRIX_0:23;
            let i,j;
            assume that
A15:        i in dom (n |-> 1_K) and
A16:        j=p.i;
A17:        i in Seg n by A15,FUNCOP_1:13;
            then j in Seg n by A16,Th14;
            then
A18:        [i,j] in Indices (1.(K,n)) by A17,A14,ZFMISC_1:def 2;
            (n |-> 1_K).i=1_K & p.i=i by A12,A17,FUNCOP_1:7,FUNCT_1:17;
            hence thesis by A16,A18,MATRIX_1:def 3;
          end;
          len Permutations n = n by MATRIX_1:9;
          then
A19:      -((the multF of K) $$ Path_matrix(p,(1.(K,n))),p) = (the multF
          of K) $$ Path_matrix(p,(1.(K,n))) by A4,A12,MATRIX_1:def 16;
          f2.p=F2(p) by A3
            .= 1_K by A12,FUNCOP_1:def 8;
          hence thesis by A11,A19,A13,MATRIX_3:def 7;
        end;
        case
A20:      p<>idseq n;
          reconsider A=NAT as non empty set;
          defpred P3[Nat] means $1 < n implies ex p3 being
FinSequence of K st len p3=$1+1 & p3.1=(Path_matrix(p,(1.(K,n)))).1 & (for n3
being Nat st 0 <> n3 & n3 < $1+1 & n3<n holds p3.(n3 + 1) = (the
          multF of K). (p3.n3,(Path_matrix(p,(1.(K,n)))).(n3 + 1)));
A21:      rng ((Path_matrix(p,(1.(K,n))))) c= the carrier of K by
FINSEQ_1:def 4;
A22:      len (Path_matrix(p,(1.(K,n))))=n by MATRIX_3:def 7;
          then 1 in Seg len (Path_matrix(p,(1.(K,n)))) by A1;
          then 1 in dom (Path_matrix(p,(1.(K,n)))) by FINSEQ_1:def 3;
          then
          (Path_matrix(p,(1.(K,n)))).1 in rng ((Path_matrix(p,( 1.(K,n) )
          ))) by FUNCT_1:def 3;
          then reconsider d=(Path_matrix(p,(1.(K,n)))).1 as Element of K by A21
          ;
          reconsider q3=<* d *> as FinSequence of K;
A23:      for n3 being Nat st 0 <> n3 & n3 < 0+1 & n3< n holds
q3.(n3 + 1) = (the multF of K). (q3.n3,(Path_matrix(p,(1.(K,n)))).(n3 + 1)) by
NAT_1:13;
A24:      dom p = Seg len Permutations n by FUNCT_2:52;
          then
A25:      dom p = Seg n by MATRIX_1:9;
          then dom p = dom idseq n by RELAT_1:45;
          then consider i0 being object such that
A26:      i0 in dom p and
A27:      p.i0 <> (idseq n).i0 by A20,FUNCT_1:2;
          reconsider i0 as Element of NAT by A24,A26;
A28:      p.i0<>i0 by A25,A26,A27,FUNCT_1:18;
A29:      for k being Nat st P3[k] holds P3[k+1]
          proof
            let k be Nat;
            assume
A30:        P3[k];
            now
              per cases;
              case
A31:            k+1<n;
                then consider p3 being FinSequence of K such that
A32:            len p3=k+1 and
A33:            p3.1=(Path_matrix(p,(1.(K,n)))).1 and
A34:            for n3 being Nat st 0 <> n3 & n3 < k+1 &
n3<n holds p3.( n3 + 1) = (the multF of K). (p3.n3,(Path_matrix(p,(1.(K,n)))).(
                n3 + 1)) by A30,NAT_1:12;
                defpred P6[object,object] means
($1 in Seg (k+1) implies $2=p3.$1)&
                (not $1 in Seg (k+1) implies $2=0.K);
A35:       for x being object st x in NAT ex y being object st y in the
                carrier of K & P6[x,y]
                proof
                  let x be object;
                  assume x in NAT;
                  now
                    per cases;
                    case
A36:                  x in Seg (k+1);
                      then reconsider nx=x as Nat;
                      nx in dom p3 by A32,A36,FINSEQ_1:def 3;
                      then
A37:                  p3.nx in rng p3 by FUNCT_1:def 3;
                      rng p3 c= the carrier of K by FINSEQ_1:def 4;
                      then reconsider s=p3.nx as Element of K by A37;
                      x in Seg (k+1) implies s=p3.x;
                      hence thesis by A36;
                    end;
                    case
                      not x in Seg (k+1);
                      hence thesis;
                    end;
                  end;
                  hence thesis;
                end;
                ex f6 being sequence of the carrier of K st
for x   being object st x in NAT holds P6[x,f6.x] from FUNCT_2:sch 1(A35);
                then consider
                f6 being sequence of the carrier of K such that
A38:            for x being object st x in NAT holds P6[x,f6.x];
                1<=k+1+1 & k+1+1 <=n by A31,NAT_1:12,13;
                then k+1+1 in Seg len (Path_matrix(p,(1.(K,n)))) by A22;
                then k+1+1 in dom (Path_matrix(p,(1.(K,n)))) by FINSEQ_1:def 3;
                then rng ((Path_matrix(p,(1.(K,n))))) c= the carrier of K & (
Path_matrix(p,(1.(K, n)))).(k + 1+1) in rng (Path_matrix(p,(1.(K,n)))) by
FINSEQ_1:def 4,FUNCT_1:def 3;
                then [f6.(k+1),(Path_matrix(p,(1.(K,n)))).(k + 1+1)] in [:the
                carrier of K, the carrier of K:] by ZFMISC_1:def 2;
                then reconsider
                e=(the multF of K). (f6.(k+1),(Path_matrix(p,(1.(K,
                n)))).(k + 1+1)) as Element of K by FUNCT_2:5;
                reconsider q3=p3^<* e *> as FinSequence of K;
A39:            len q3=(len p3) + len (<*e*>) by FINSEQ_1:22
                  .=k+1+1 by A32,FINSEQ_1:40;
A40:            for n3 being Nat st 0 <> n3 & n3 < k+1+1 & n3<
n holds q3.(n3 + 1) = (the multF of K). (q3.n3,(Path_matrix(p,(1.(K,n)))).(n3 +
                1))
                proof
                  let n3 be Nat;
                  assume that
A41:              0 <> n3 and
A42:              n3 < k+1+1 and
A43:              n3<n;
                  now
                    per cases;
                    case
A44:                  n3<k+1;
                      then 1<=n3+1 & n3+1<=k+1 by NAT_1:12,13;
                      then n3+1 in Seg len p3 by A32;
                      then n3+1 in dom p3 by FINSEQ_1:def 3;
                      then
A45:                  p3.(n3+1)=q3.(n3+1) by FINSEQ_1:def 7;
                      0+1<=n3 by A41,NAT_1:13;
                      then n3 in Seg len p3 by A32,A44;
                      then
A46:                  n3 in dom p3 by FINSEQ_1:def 3;
                      p3.(n3 + 1) = (the multF of K) . (p3.n3,(
                      Path_matrix(p,(1.(K,n)))).(n3 + 1)) by A34,A41,A43,A44;
                      hence thesis by A45,A46,FINSEQ_1:def 7;
                    end;
                    case
A47:                  n3>=k+1;
A48:                  n3+1<=k+1+1 by A42,NAT_1:13;
A49:                  n3+1>k+1 by A47,NAT_1:13;
                      then n3+1>=k+1+1 by NAT_1:13;
                      then
A50:                  n3+1=k+1+1 by A48,XXREAL_0:1;
                      1<=k+1 by NAT_1:12;
                      then
A51:                  k+1 in Seg (k+1);
                      then k+1 in dom p3 by A32,FINSEQ_1:def 3;
                      then
A52:                  q3.(k+1)=p3.(k+1) by FINSEQ_1:def 7;
                      (q3).(n3+1) = (<*e*>).(n3+1 - (k+1)) by A32,A39,A49,A48,
FINSEQ_1:24
                        .= e by A50;
                      hence thesis by A38,A50,A51,A52;
                    end;
                  end;
                  hence thesis;
                end;
                1<=k+1 by NAT_1:12;
                then 1 in Seg len p3 by A32;
                then 1 in dom p3 by FINSEQ_1:def 3;
                then q3.1=(Path_matrix(p,(1.(K,n)))).1 by A33,FINSEQ_1:def 7;
                hence thesis by A39,A40;
              end;
              case
                k+1>=n;
                hence thesis;
              end;
            end;
            hence thesis;
          end;
          n<n+1 by NAT_1:13;
          then
A53:      n-1<n+1-1 by XREAL_1:14;
A54:      f2.p=F2(p) by A3
            .= 0.K by A20,FUNCOP_1:def 8;
A55:      n-1=n-'1 by A1,XREAL_1:233;
          len q3=1 & q3.1=(Path_matrix(p,(1.(K,n)))).1 by FINSEQ_1:40;
          then
A56:      P3[0] by A23;
          for k being Nat holds P3[k] from NAT_1:sch 2(A56,
          A29);
          then consider p3 being FinSequence of K such that
A57:      len p3=n-'1+1 and
A58:      p3.1=(Path_matrix(p,(1.(K,n)))).1 and
A59:      for n3 being Nat st 0 <> n3 & n3 < n-'1+1 & n3<
n holds p3.(n3 + 1) = (the multF of K). (p3.n3,(Path_matrix(p,(1.(K,n)))).(n3 +
          1)) by A55,A53;
          defpred P[set,set] means ($1 in Seg n implies $2=p3.$1)& (not $1 in
          Seg n implies $2=0.K);
A60:      for x3 being Element of A ex y3 being Element of K st P[x3,y3]
          proof
            let x3 be Element of A;
            now
              per cases;
              case
A61:            x3 in Seg n;
                then x3 in dom p3 by A55,A57,FINSEQ_1:def 3;
                then rng p3 c= the carrier of K & p3.x3 in rng p3 by
FINSEQ_1:def 4,FUNCT_1:def 3;
                hence thesis by A61;
              end;
              case
                not x3 in Seg n;
                hence thesis;
              end;
            end;
            hence thesis;
          end;
          ex f4 being Function of A,the carrier of K st for x2 being
          Element of A holds P[x2,f4.x2] from FUNCT_2:sch 3(A60);
          then consider f4 being sequence of the carrier of K such that
A62:      for x4 being Element of NAT holds (x4 in Seg n implies f4.
          x4=p3.x4)& (not x4 in Seg n implies f4.x4=0.K);
          p is Permutation of Seg n by MATRIX_1:def 12;
          then
A63:      p.i0 in Seg n by A25,A26,FUNCT_2:5;
          then reconsider j0=p.i0 as Element of NAT;
          Indices (1.(K,n))=[: Seg n,Seg n:] by A1,MATRIX_0:23;
          then
A64:      [i0,j0] in Indices (1.(K,n)) by A25,A26,A63,ZFMISC_1:def 2;
          i0 <= n by A25,A26,FINSEQ_1:1;
          then
A65:      n-'i0 =n-i0 by XREAL_1:233;
          i0 in dom (Path_matrix(p,(1.(K,n)))) by A25,A26,A22,FINSEQ_1:def 3;
          then
A66:      (Path_matrix(p,(1.(K,n)))).i0=(1.(K,n))*(i0,j0) by MATRIX_3:def 7;
          defpred P5[Nat] means f4.(i0+$1)=0.K;
A67:      0<i0 by A24,A26,FINSEQ_1:1;
A68:      for k being Nat st P5[k] holds P5[k+1]
          proof
            let k be Nat;
A69:        1<=1+(i0+k) by NAT_1:12;
            assume
A70:        P5[k];
            now
              per cases;
              case
A71:            i0+k+1<=n;
                1<=1+(i0+k) by NAT_1:12;
                then i0+k+1 in Seg len (Path_matrix(p,(1.(K,n)))) by A22,A71;
                then i0+k+1 in dom (Path_matrix(p,(1.(K,n)))) by FINSEQ_1:def 3
;
                then
A72:            (Path_matrix(p,(1.(K,n)))).(i0+k+1) in rng (Path_matrix(
                p,(1.(K,n)))) by FUNCT_1:def 3;
                rng (Path_matrix(p,(1.(K,n)))) c= the carrier of K by
FINSEQ_1:def 4;
                then reconsider
                b=(Path_matrix(p,(1.(K,n)))).(i0+k+1) as Element of
                K by A72;
A73:            i0+k<n by A71,NAT_1:13;
                0+1<=i0+k by A67,NAT_1:13;
                then
A74:            i0+k in Seg n by A73;
                i0+k+1 in Seg n by A69,A71;
                then f4.(i0+k+1)=p3.(i0+k+1) by A62
                  .=(the multF of K). (p3.(i0+k),(Path_matrix(p,(1.(K,n)))).
                (i0+k+1)) by A55,A59,A67,A73
                  .= (0.K)*(b) by A62,A70,A74
                  .= 0.K;
                hence thesis;
              end;
              case
                i0+k+1>n;
                then not i0+(k+1) in Seg n by FINSEQ_1:1;
                hence thesis by A62;
              end;
            end;
            hence thesis;
          end;
          1 in Seg n by A1;
          then
A75:      f4.1=(Path_matrix(p,(1.(K,n)))).1 by A58,A62;
A76:      for n3 being Nat st 0 <> n3 & n3 < len (Path_matrix
(p,(1.(K,n)))) holds f4.(n3 + 1) = (the multF of K). (f4.n3,(Path_matrix(p,(1.(
          K,n)))).(n3 + 1))
          proof
            let n3 be Nat;
            assume that
A77:        0 <> n3 and
A78:        n3 < len (Path_matrix(p,(1.(K,n))));
A79:        n3+1<=len (Path_matrix(p,(1.(K,n)))) by A78,NAT_1:13;
A80:        0+1<=n3 by A77,NAT_1:13;
            then
A81:        n3 in Seg n by A22,A78;
            1<n3+1 by A80,NAT_1:13;
            then n3+1 in Seg n by A22,A79;
            then
A82:        f4.(n3+1)=p3.(n3+1) by A62;
            p3.(n3 + 1) = (the multF of K). (p3.n3,(Path_matrix(p,(1.(K,
            n)))).(n3 + 1)) by A22,A55,A59,A77,A78;
            hence thesis by A62,A82,A81;
          end;
A83:      1 <= i0 by A24,A26,FINSEQ_1:1;
          now
            per cases;
            case
              i0<=1;
              then i0=1 by A83,XXREAL_0:1;
              hence P5[0] by A28,A66,A64,A75,MATRIX_1:def 3;
            end;
            case
A84:          i0>1;
              reconsider a=f4.(i0-'1) as Element of K;
              i0<i0+1 by NAT_1:13;
              then
A85:          i0-1<i0+1-1 by XREAL_1:14;
              i0 <= n by A25,A26,FINSEQ_1:1;
              then
A86:          i0-1<len (Path_matrix(p,(1.(K,n)))) by A22,A85,XXREAL_0:2;
              i0-'1=i0-1 by A84,XREAL_1:233;
              then
A87:          i0-'1+1=i0;
              i0-1> 1-1 by A84,XREAL_1:14;
              then f4.(i0) = (the multF of K). (f4.(i0-'1),(Path_matrix(p,(1.
              (K,n)))).(i0)) by A76,A86,A87
                .= a*(0.K) by A28,A66,A64,MATRIX_1:def 3
                .= 0.K;
              hence P5[0];
            end;
          end;
          then
A88:      P5[0];
          for k being Nat holds P5[k] from NAT_1:sch 2(A88,
          A68);
          then P5[n-'i0];
          then f4.(i0+(n-'i0))=0.K;
          hence thesis by A1,A8,A54,A22,A75,A76,A65,FINSOP_1:2;
        end;
      end;
      hence thesis;
    end;
    hence thesis by MATRIX_3:def 8;
  end;
  deffunc F3(set) = IFIN(idseq n,$1,1_K,0.K);

:: dla rodzin zbir? ??? !!!
  set F=(the addF of K);
  set f=Path_product(1.(K,n));
  set B=In(Permutations(n),Fin Permutations n);
A89: for x being set st x in Fin X holds F3(x) in Y
  proof
    let x be set;
    assume x in Fin X;
    now
      per cases;
      case
        idseq n in x;
        then F3(x)=1_K by Def1;
        hence thesis;
      end;
      case
        not idseq n in x;
        then F3(x)=0.K by Def1;
        hence thesis;
      end;
    end;
    hence thesis;
  end;
  ex f2 being Function of Fin X,Y st
for x being set st x in Fin X holds
  f2.x = F3(x) from FUNCT_2:sch 11(A89);
  then consider G0 being Function of Fin X,Y such that
A90: for x being set st x in Fin X holds G0.x = F3(x);
  dom (f2)=Permutations(n) by FUNCT_2:def 1;
  then
A91: dom (Path_product(1.(K,n)))=dom f2 by FUNCT_2:def 1;
  then
A92: Path_product(1.(K,n))=f2 by A5,FUNCT_1:2;
A93: for B9 being Element of Fin X st B9 c= B & B9 <> {} for x being
  Element of X st x in B\B9 holds G0.(B9 \/ {x}) = F.(G0.B9,f.x)
  proof
    let B9 be Element of Fin X;
    assume that
    B9 c= B and
    B9 <> {};
    thus for x being Element of X st x in B\B9 holds G0.(B9 \/ {x}) = F.(G0.B9
    ,f.x)
    proof
      let x be Element of X;
      assume
A94:  x in B\B9;
A95:  now
        assume
A96:    not idseq n in B9 \/ {x};
        thus G0.(B9 \/ {x})=IFIN(idseq n,B9 \/ {.x.},1_K,0.K) by A90
          .=0.K by A96,Def1;
      end;
A97:  0.K is_a_unity_wrt F by FVSUM_1:6;
A98:  now
        assume
A99:    not idseq n in B9;
        thus G0.(B9)=IFIN(idseq n,B9,1_K,0.K) by A90
          .=0.K by A99,Def1;
      end;
A100: now
        assume
A101:   not idseq n in B9 \/ {x};
        then not idseq n in {x} by XBOOLE_0:def 3;
        then
A102:   not idseq n=x by TARSKI:def 1;
        f.x=F2(x) by A3,A92
          .=0.K by A102,FUNCOP_1:def 8;
        hence F.(G0.B9,f.x)=0.K by A98,A97,A101,BINOP_1:3,XBOOLE_0:def 3;
      end;
A103: now
        assume
A104:   idseq n in B9;
        thus G0.(B9)=IFIN(idseq n,B9,1_K,0.K) by A90
          .=1_K by A104,Def1;
      end;
A105: now
        assume idseq n in B9 \/ {x};
        then
A106:   idseq n in B9 or idseq n in {x} by XBOOLE_0:def 3;
        now
          per cases by A106,TARSKI:def 1;
          case
A107:       idseq n in B9;
A108:       not x in B9 by A94,XBOOLE_0:def 5;
            f.x=F2(x) by A3,A92
              .=0.K by A107,A108,FUNCOP_1:def 8;
            hence F.(G0.B9,f.x)=1_K by A103,A97,A107,BINOP_1:3;
          end;
          case
A109:       idseq n=x;
            f.x=F2(x) by A3,A92
              .=1_K by A109,FUNCOP_1:def 8;
            hence F.(G0.B9,f.x)=1_K by A94,A98,A97,A109,BINOP_1:3
,XBOOLE_0:def 5;
          end;
        end;
        hence F.(G0.B9,f.x)=1_K;
      end;
      now
        assume
A110:   idseq n in B9 \/ {x};
        thus G0.(B9 \/ {x})=IFIN(idseq n,B9 \/ {.x.},1_K,0.K) by A90
          .=1_K by A110,Def1;
      end;
      hence thesis by A95,A105,A100;
    end;
  end;
A111: for x being Element of X holds G0.({x}) = f.x
  proof
    let x be Element of X;
    now
      per cases;
      case
A112:   x=idseq n;
        then idseq n in {x} by TARSKI:def 1;
        then
A113:   IFIN(idseq n,{x},1_K,0.K)=1_K by Def1;
        f2.x=F2(x) by A3
          .=1_K by A112,FUNCOP_1:def 8;
        hence G0.({.x.})=f2.x by A90,A113;
      end;
      case
A114:   x <> idseq n;
        then not idseq n in {x} by TARSKI:def 1;
        then
A115:   IFIN(idseq n,{x},1_K,0.K)=0.K by Def1;
        f2.x=F2(x) by A3
          .=0.K by A114,FUNCOP_1:def 8;
        hence G0.({.x.})=f2.x by A90,A115;
      end;
    end;
    hence thesis by A91,A5,FUNCT_1:2;
  end;
A116: for e being Element of Y st e is_a_unity_wrt F holds G0.({}) = e
  proof
    let e be Element of Y;
    assume e is_a_unity_wrt F;
    then
A117: F.(0.K,e)=0.K by BINOP_1:3;
    0.K is_a_unity_wrt F by FVSUM_1:6;
    then
A118: F.(0.K,e)=e by BINOP_1:3;
    IFIN(idseq n,{},1_K,0.K)=0.K by Def1;
    hence thesis by A90,A117,A118,FINSUB_1:7;
  end;
A119: now
    assume
A120: idseq n in B;
    thus G0.(B)=IFIN(idseq n,B,1_K,0.K) by A90
      .=1_K by A120,Def1;
  end;
S:  (idseq n) is Element of Group_of_Perm(n) by MATRIX_1:11;
  Permutations n in Fin Permutations n by FINSUB_1:def 5;
  then B=Permutations(n) & (idseq n) in the carrier of Group_of_Perm(n) by
S,SUBSET_1:def 8;
  then (the addF of K) $$ (In(Permutations n,Fin Permutations n),
Path_product(1.(K,n)))=
  1_K by A119,A116,A111,A93,MATRIX_1:def 13,SETWISEO:def 3;
  hence thesis by MATRIX_3:def 9;
end;
