reserve i,j,n,k,m for Nat,
     a,b,x,y,z for object,
     F,G for FinSequence-yielding FinSequence,
     f,g,p,q for FinSequence,
     X,Y for set,
     D for non empty set;
reserve
  B,A,M for BinOp of D,
  F,G for D* -valued FinSequence,
  f for FinSequence of D,
  d,d1,d2 for Element of D;
reserve
  F,G for non-empty non empty FinSequence of D*,
  f for non empty FinSequence of D;
reserve f,g for FinSequence of D,
        a,b,c for set,
        F,F1,F2 for finite set;

theorem Th135:
  for f be FinSequence of D st
    A is commutative associative having_a_unity having_an_inverseOp &
    M is associative commutative having_a_unity &
    M is_distributive_wrt A & n in dom f holds
  for E be Enumeration of F
    for D be Subset of dom E st (for i holds i in D iff n in E.i) holds
      (card D is even implies
        (M "**" (App (SignGenOp(f,A,F) * E))).(len E |-> n) =
         M "**" (len E |-> f/.n)) &
       (card D is odd implies
         (M "**" (App (SignGenOp(f,A,F) * E))).(len E |-> n) =
         (the_inverseOp_wrt A).(M "**" (len E |-> f/.n)))
proof
  let f be FinSequence of D;
  assume that
A1: A is commutative associative having_a_unity having_an_inverseOp and
A2: M is associative commutative having_a_unity and
A3:M is_distributive_wrt A and
A4:n in dom f;
  set IA=the_inverseOp_wrt A;
  defpred P[Nat] means
  for F st card F=$1 for E be Enumeration of F
  for I be Subset of dom E st (for i holds i in I iff n in E.i) holds
  (card I is even implies
  (M "**" (App (SignGenOp(f,A,F) * E))).(len E |-> n) =
  M "**" (len E |-> f/.n)) &
  (card I is odd implies
  (M "**" (App (SignGenOp(f,A,F) * E))).(len E |-> n) =
  IA.(M "**" (len E |-> f/.n)));
A5: P[0]
  proof
    let F such that
A6: card F=0;
    let E be Enumeration of F;
    let I be Subset of dom E such that  i in I iff n in E.i;
A7: F={} by A6;
A8: dom E={} by A6;
A9:(M "**" (App (SignGenOp(f,A,F) * E))).(len E |-> n) = the_unity_wrt M
    by Th102,A4,A2,A7,Th118;
    len E |-> f/.n = {}=<*>D by A6;
    hence thesis by A8,A9,A2,FINSOP_1:10;
  end;
A10:P[j] implies P[j+1]
  proof
    assume
A11: P[j];
    let F such that
A12: card F=j+1;
    let E be Enumeration of F;
    let I be Subset of dom E such that
A13: (for i holds i in I iff n in E.i);
    set Fj=F\{E.len E},F1={E.len E};
A14:len E= card F by CARD_1:def 7;
    then reconsider Ej=E|j as Enumeration of Fj by Th96,A12;
    reconsider E1 = <*E.len E*> as Enumeration of F1 by Th96,A12,A14;
A15:F = Fj \/ F1 by Th96,A12,A14;
A16: j < j+1 by NAT_1:13;
A17: len Ej =j by CARD_1:def 7,A12;
    then dom Ej = Seg j by FINSEQ_1:def 3;
    then
A18: dom E = Seg (j+1)= (dom Ej)\/{j+1} by A12,A14,FINSEQ_1:def 3,9;
    I\{j+1} c= (dom E)\{j+1} by XBOOLE_1:33;
    then I\{j+1} c= (dom Ej)\{j+1} c= (dom Ej) by A18,XBOOLE_1:36,40;
    then reconsider Ij = I\{j+1} as Subset of dom Ej by XBOOLE_1:1;
A19: for i holds i in Ij iff n in Ej.i
    proof
      let i;
      thus i in Ij implies n in Ej.i
      proof
        assume
A20:    i in Ij;
        then n in E.i by A13,ZFMISC_1:56;
        hence thesis by A20,FUNCT_1:47;
      end;
      assume
A21:  n in Ej.i;
      then i in dom Ej by FUNCT_1:def 2;
      then n in E.i & i <=j by A21,FUNCT_1:47,A17,FINSEQ_3:25;
      hence i in Ij by A13,A16,ZFMISC_1:56;
    end;
    card Fj = j by A17,CARD_1:def 7;
    then
A22:(card Ij is even implies
    (M "**" (App (SignGenOp(f,A,Fj) * Ej))).(len Ej |-> n) =
    M "**" (len Ej |-> f/.n)) &
    (not card Ij is even implies
    (M "**" (App (SignGenOp(f,A,Fj) * Ej))).(len Ej |-> n) =
    (the_inverseOp_wrt A).(M "**" (len Ej |-> f/.n)))
    by A11,A19;
    set En = (len E) |-> n,E1n = (len E1) |-> n, Ejn = (len Ej) |-> n;
A23: Ejn in doms (SignGenOp(f,A,Fj) * Ej) &
    E1n in doms (SignGenOp(f,A,F1) * E1) &
    En in doms (SignGenOp(f,A,F) * E) by A4,Th102;
    then
A24: En in dom App (SignGenOp(f,A,F) * E) &
    Ejn in dom App (SignGenOp(f,A,Fj) * Ej) &
    E1n in doms (SignGenOp(f,A,F1) * E1) by Def9;
A25: len E1=1 by FINSEQ_1:40;
    then
A26: En = Ejn^E1n by FINSEQ_2:123,A12,A14,A17;
    E = Ej^E1 by A14,A12,FINSEQ_3:55;
    then SignGenOp(f,A,F) * E =
      (SignGenOp(f,A,Fj) * Ej)^(SignGenOp(f,A,F1) * E1) by A15,Th81;
    then
A27: (App(SignGenOp(f,A,F) * E)).En =
    ((App (SignGenOp(f,A,Fj) * Ej)).Ejn) ^ ((App (SignGenOp(f,A,F1) * E1)).E1n)
    by A23,Th61,A26;
A28: n in dom SignGen(f,A,E.len E) by A4,Def11;
    SignGen(f,A,E.len E).n in rng SignGen(f,A,E.len E) by A28,FUNCT_1:def 3;
    then reconsider cc = SignGen(f,A,E.len E).n as Element of D;
    SignGenOp(f,A,F1) * E1 = <* SignGen(f,A,E.len E) *> & E1n = <*n*>
    by Th78,FINSEQ_2:59,A25;
    then (App (SignGenOp(f,A,F1) * E1)).E1n = <* cc *> by A28,Th60;
    then
A29: M"**"((App (SignGenOp(f,A,F1) * E1)).E1n) = cc by FINSOP_1:11;
A30: (M "**" App(SignGenOp(f,A,F) * E)).En =
    M"**" ((App(SignGenOp(f,A,F) * E)).En) by A24,Def10
    .= M. (M"**"((App (SignGenOp(f,A,Fj) * Ej)).Ejn),
    M"**"((App (SignGenOp(f,A,F1) * E1)).E1n))
    by A2,A27,FINSOP_1:5
    .= M. ( (M"**"(App (SignGenOp(f,A,Fj) * Ej))).Ejn, cc)
    by A24,Def10,A29;
A31:len E1 |-> f/.n = <*f/.n*> by A25,FINSEQ_2:59;
A32: (len E |-> f/.n) = (len Ej |-> f/.n)^(len E1 |-> f/.n)
    by A12,A14,A17,A25,FINSEQ_2:123;
A33: f.n = f/.n by A4,PARTFUN1:def 6;
    per cases;
    suppose
A34:  n in E.len E;
A35:  not j+1 in Ij by ZFMISC_1:56;
      I = Ij \/{j+1} by A34,A13,A12,A14,ZFMISC_1:116;
      then
A36:  card I = card Ij+1 by A35,CARD_2:41;
      thus card I is even implies
      (M "**" (App (SignGenOp(f,A,F) * E))).En = M "**" (len E |-> f/.n)
      proof
        assume card I is even;
        hence (M "**" App(SignGenOp(f,A,F) * E)).En
        = M. (IA.(M "**" (len Ej |-> f/.n)),IA.(f/.n))
        by A34,A33,A28,Def11,A30,A36,A22
        .= IA. (M. (IA.(M "**" (len Ej |-> f/.n)),f/.n)) by A1,A3,FINSEQOP:67
        .= IA.(IA. (M. (M "**" (len Ej |-> f/.n),f/.n))) by A1,A3,FINSEQOP:67
        .= M. (M "**" (len Ej |-> f/.n),f/.n) by A1,FINSEQOP:62
        .= M"**" (len E |-> f/.n) by A32,A31,A2,FINSOP_1:4;
      end;
      assume not card I is even;
      hence (M "**" App(SignGenOp(f,A,F) * E)).En
      = M. (M "**" (len Ej |-> f/.n),IA.(f/.n))
      by A34,A33,A28,Def11,A30,A36,A22
      .= IA. (M. (M "**" (len Ej |-> f/.n),f/.n)) by A1,A3,FINSEQOP:67
      .= IA.(M"**" (len E |-> f/.n)) by A32,A31,A2,FINSOP_1:4;
    end;
    suppose
A37:  not n in E.len E;
      thus card I is even implies
      (M "**" (App (SignGenOp(f,A,F) * E))).En = M "**" (len E |-> f/.n)
      proof
        assume card I is even;
        hence (M "**" App(SignGenOp(f,A,F) * E)).En =
        M. (M "**" (len Ej |-> f/.n),f/.n)
        by A37,A33,A28,Def11,A30,A13,A12,A14,ZFMISC_1:57,A22
        .= M"**" (len E |-> f/.n) by A32,A31,A2,FINSOP_1:4;
      end;
      assume not card I is even;
      hence (M "**" App(SignGenOp(f,A,F) * E)).En =
      M. (IA.(M "**" (len Ej |-> f/.n)),f/.n)
      by A37,A33,A28,Def11,A13,A12,A14,ZFMISC_1:57,A30,A22
      .= IA. (M. (M "**" (len Ej |-> f/.n),f/.n)) by A1,A3,FINSEQOP:67
      .= IA.(M"**" (len E |-> f/.n)) by A32,A31,A2,FINSOP_1:4;
    end;
  end;
  P[j] from NAT_1:sch 2(A5,A10);
  hence thesis;
end;
