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 Th129:
   A is commutative associative having_a_unity having_an_inverseOp &
    M is associative commutative having_a_unity &
   M is_distributive_wrt A implies
for E1 be Enumeration of F1 st union F1 c= Seg (1+m)
    for Es be Enumeration of swap(F1,1+m,2+m) st
        Es = Swap(E1,1+m,2+m)
ex S be Subset of doms(m+2,card F1) st
    S = (len E1)-tuples_on {1+m,2+m} &
    for CFs be non-empty non empty FinSequence of D*,f,d1,d2 st
        len f=m &
        CFs = SignGenOp(f^<*d1*>^<*d2*>,A, swap(F1,1+len f,2+len f) ) * Es
    for Sd be Element of Fin dom App CFs st Sd=S
  holds
(M "**" App (SignGenOp(f^<*A . ((the_inverseOp_wrt A).d1,d2)*>,A,F1) * E1))
    .(len E1|-> (1+ len f))
    = A$$(Sd,M"**"App CFs)
proof
  set I=the_inverseOp_wrt A;
  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;
  let E1 be Enumeration of F1 such that
  A4:union F1 c= Seg (1+m);
  let Es be Enumeration of swap(F1,1+m,2+m) such that
A5:        Es = Swap(E1,1+m,2+m);
  1+m < 1+m+1 by NAT_1:13;
  then not 2+m in Seg (1+m) by FINSEQ_1:1;
  then reconsider Ee = Ext(E1,1+m,2+m) as
    Enumeration of Ext(F1,1+m,2+m) by A4,Th28;
  consider S be Subset of doms(m+2,card F1) such that
A6:    S = (len E1)-tuples_on {1+m,2+m} and
A7:    for CFe be non-empty non empty FinSequence of D*,f,d1,d2 st
        len f=m &
        CFe = SignGenOp(f^<*d1*>^<*d2*>,A, Ext(F1,1+len f,2+len f) ) * Ee
    for Sd be Element of Fin dom App CFe st Sd=S
  holds
(M "**" App (SignGenOp(f^<*A . (d1,d2)*>,A,F1) * E1)).(len E1|-> (1+ len f))
    = A$$(Sd,M"**"App CFe) by A1,A2,A3,A4,Th127;
  take S;
  thus S = (len E1)-tuples_on {1+m,2+m} by A6;
  let CFs be non-empty non empty FinSequence of D*,f,d1,d2 such that
A8: len f=m and
A9:  CFs = SignGenOp(f^<*d1*>^<*d2*>,A, swap(F1,1+len f,2+len f) ) * Es;
  let Sd be Element of Fin dom App CFs such that
A10: Sd=S;
  set  CFe = SignGenOp(f^<*I.d1*>^<*d2*>,A, Ext(F1,1+len f,2+len f) ) * Ee;
A11: for x st x in dom CFe holds CFe.x is non empty
  proof
    let x;
    assume x in dom CFe;
    then CFe.x = SignGen(f^<*I.d1*>^<*d2*>,A,Ee.x) by A8,Th80;
    hence thesis;
  end;
  CFs = SignGenOp(f^<*d1*>^<*d2*>,A, swap(F1,1+m,2+m) ) * Es by A8,A9;
  then
A12: len CFs = len Es =len E1 = card F1 by A5,CARD_1:def 7;
A13: F1 is non empty by A12;
  rng CFe c= D*;
  then reconsider CFe as non-empty non empty FinSequence of D*
   by A13,A8,A11,FINSEQ_1:def 4,FUNCT_1:def 9;
A14: len (f^<*I.d1*>^<*d2*>) = 1 + len (f^<*I.d1*>) by FINSEQ_2:16
  .= 1+(1 + len f) by FINSEQ_2:16;
A15: len (f^<*d1*>^<*d2*>) = 1 + len (f^<*d1*>) by FINSEQ_2:16
  .= 1+(1 + len f) by FINSEQ_2:16;
  1+len f < 1+len f+1 by NAT_1:13;
  then not 2+len f in Seg (1+len f) by FINSEQ_1:1;
  then card swap(F1,1+len f,2+len f) = card F1 = card Ext(F1,1+len f,2+len f)
  by A8,A4,Th10,Th11;
  then
A16: doms CFe = doms CFs by A8,A9,A14,A15,Th107;
A17: dom App CFs = doms(m+2,card F1) by A9,A8,A12,A15,Lm3;
  then reconsider Ss=S as Element of Fin dom App CFs by FINSUB_1:def 5;
  S c= dom App CFs by A17;
  then S c= doms CFe by A16,Def9;
  then S c= dom App CFe by Def9;
  then reconsider Se=S as Element of Fin dom App CFe by FINSUB_1:def 5;
A18:(M "**" App (SignGenOp(f^<*A . (I.d1,d2)*>,A,F1) * E1)).
  (len E1|-> (1+ len f))= A$$(Se,M"**"App CFe) by A8,A7;
  I.(I.d1)=d1 by A1,FINSEQOP:62;
  hence thesis by A8,A18,A10,A1,A4,A5,A9,Th128;
end;
