reserve i,j,k,n,m for Nat,
        X for set,
        b,s for bag of X,
        x for object;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
          right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;
reserve O for Ordinal,
        R for right_zeroed add-associative right_complementable
             right_unital distributive non trivial doubleLoopStr,
        p for Polynomial of O, R;

theorem Th58:
  for L be add-associative right_zeroed right_complementable non
     empty doubleLoopStr
    for f,e be FinSequence, x be object,E be set st len f = len e & x in E
  holds
     SgnMembershipNumber(f^<*x*>,L,e^<*E*>) = - SgnMembershipNumber(f,L,e)
proof
  let L be add-associative right_zeroed right_complementable non
  empty doubleLoopStr;
  let f,e be FinSequence, x be object,E be set such that
A1:len e = len f and
A2:x in E;
  set fx= f^<*x*>, eX=e^<*E*>;
  set X1 = {x where x is Element of dom fx: x in dom fx & fx.x in eX.x};
  set X = {x where x is Element of dom f: x in dom f & f.x in e.x};
A3: dom f = dom e by A1,FINSEQ_3:29;
A4: X c= X1
  proof
    let a be object;
    assume a in X;
    then consider x be Element of dom f such that
A5: x=a & x in dom f & f.x in e.x;
    reconsider x as Nat;
A6: dom f c= dom fx by FINSEQ_1:26;
    eX.x = e.x & fx.x = f.x by A5,A3,FINSEQ_1:def 7;
    hence thesis by A6,A5;
  end;
  X1 c= dom fx
  proof
    let a be object;
    assume a in X1;
    then ex x be Element of dom fx st x=a & x in dom fx & fx.x in eX.x;
    hence thesis;
  end;
  then reconsider X1,X as finite set by A4;
  len <*x*> =1 by FINSEQ_1:39;
  then
A7:  len fx = len f+1 by FINSEQ_1:22;
A8: not len f+1 in X
  proof
    assume len f+1 in X;
    then consider x be Element of dom f such that
A9: x=len f+1 & x in dom f & f.x in e.x;
    len f+1 <= len f by A9,FINSEQ_3:25;
    hence thesis by NAT_1:13;
  end;
  1<= len f+1 by NAT_1:11;
  then fx.(len f+1) = x & eX.(len f+1) = E & len f+1 in dom fx
    by A1,A7,FINSEQ_3:25;
  then len f+1 in X1 by A2;
  then {len f+1} c= X1 by ZFMISC_1:31;
  then
A10: X\/{len f+1} c= X1 by A4,XBOOLE_1:8;
  X1 c= X\/{len f+1}
  proof
    let a be object;
    assume a in X1;
    then consider y be Element of dom fx such that
A11:y=a & y in dom fx & fx.y in eX.y;
    reconsider y as Nat;
    per cases;
    suppose y = len f+1;
      hence thesis by A11,ZFMISC_1:136;
    end;
    suppose
A12:y <> len f+1;
      y <= len f+1 by A7,FINSEQ_3:25;
      then y < len f+1 by A12,XXREAL_0:1;
      then 1<= y <= len f by NAT_1:13,FINSEQ_3:25;
      then
A13:y in dom f by FINSEQ_3:25;
      then fx.y = f.y & eX.y = e.y by A3,FINSEQ_1:def 7;
      then y in X by A11,A13;
      hence thesis by A11,ZFMISC_1:136;
    end;
  end;
  then X1 = X\/{len f+1} by A10,XBOOLE_0:def 10;
  then
A14: card X1 = card X+1 by A8,CARD_2:41;
  per cases;
  suppose
A15: card X is even;
    then SgnMembershipNumber(fx,L,eX) =-1.L by Def9,A14;
    hence thesis by A15,Def9;
  end;
  suppose
A16: card X is odd;
    SgnMembershipNumber(f,L,e) = - 1.L by A16,Def9;
    hence thesis by A16,Def9,A14;
  end;
end;
