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;

theorem Th11:
  not y in union Y implies
       card Y = card swap(Y,x,y)
proof
  assume
A1: not y in union Y;
  set P ={X where X is Element of Y: x in X};
  set Py = {(X\{x})\/{y} where X is Element of Y: x in X};
  set N ={X where X is Element of Y: not x in X & X in Y};
  set Nx ={X\/{x} where X is Element of Y: not x in X & X in Y};
  deffunc F(set)=($1\{x})\/{y};
  consider f be Function such that
A2: dom f=P & for A be set st A in P holds f.A = F(A)
    from FUNCT_1:sch 5;
A3: rng f c= Py
  proof
    let a be object;
    assume a in rng f;
    then consider b such that
A4:   b in dom f & f.b=a by FUNCT_1:def 3;
    reconsider b as set by TARSKI:1;
    a = (b\{x})\/{y} &ex X be Element of Y st b=X & x in X by A4,A2;
    hence thesis;
  end;
  Py c= rng f
  proof
    let a be object;
    assume a in Py;
    then consider X be Element of Y such that
A5:   a=(X\{x})\/{y} & x in X;
A6:   X in P by A5;
    then f.X = a by A5,A2;
    hence thesis by A2,A6,FUNCT_1:def 3;
  end;
  then
A7: rng f = Py by A3;
  f is one-to-one
  proof
    let a,b be object such that
A8:   a in dom f & b in dom f & f.a=f.b;
    reconsider a,b as set by TARSKI:1;
A9:   f.a = (a\{x})\/{y} & f.b = (b\{x})\/{y} by A2,A8;
A10: (ex X be Element of Y st a=X & x in X)&
      ex X be Element of Y st b=X & x in X by A8,A2;
    then Y<>{} by SUBSET_1:def 1;
    then a c= union Y & b c= union Y & x in a & x in b by A10,ZFMISC_1:74;
    then {y} misses a & {y} misses b by A1,ZFMISC_1:50;
    then {y} misses a\{x} & {y} misses b\{x} by XBOOLE_1:80;
    then a\{x} = b\{x} by A8,A9,XBOOLE_1:71;
    then a = a\{x}\/{x} = b by ZFMISC_1:116,A10;
    hence thesis;
  end;
  then
A11: P,Py are_equipotent by A2,A7,WELLORD2:def 4;
  deffunc G(set)=$1\/{x};
  consider g be Function such that
A12: dom g=N & for A be set st A in N holds g.A = G(A) from FUNCT_1:sch 5;
A13: rng g c= Nx
  proof
    let a be object;
    assume a in rng g;
    then consider b such that
A14:  b in dom g & g.b=a by FUNCT_1:def 3;
    reconsider b as set by TARSKI:1;
    a = b\/{x} &ex X be Element of Y st b=X & not x in X & X in Y by A14,A12;
    hence thesis;
  end;
  Nx c= rng g
  proof
    let a be object;
    assume a in Nx;
    then consider X be Element of Y such that
A15:  a=X\/{x} & not x in X & X in Y;
A16:  X in N by A15;
    then g.X = a by A15,A12;
    hence thesis by A12,A16,FUNCT_1:def 3;
  end;
  then
A17: rng g = Nx by A13;
  g is one-to-one
  proof
    let a,b be object such that
A18:  a in dom g & b in dom g & g.a=g.b;
    reconsider a,b as set by TARSKI:1;
A19:  g.a = a\/{x} & g.b = b\/{x} by A12,A18;
    (ex X be Element of Y st a=X & not x in X & X in Y)&
      ex X be Element of Y st b=X & not x in X & X in Y by A18,A12;
    then {x} misses a & {x} misses b by ZFMISC_1:50;
    hence thesis by A18,A19,XBOOLE_1:71;
  end;
  then
A20: N,Nx are_equipotent by A12,A17,WELLORD2:def 4;
A21: P c= Y
  proof
    let a be object;
    assume a in P;
    then
A22:  ex X be Element of Y st a=X & x in X;
    then Y<>{} by SUBSET_1:def 1;
    hence thesis by A22;
  end;
A23: N c= Y
  proof
    let a be object;
    assume a in N;
    then ex X be Element of Y st a=X & not x in X & X in Y;
    hence thesis;
  end;
  Y c= N \/ P
  proof
    let a be object;
    assume
A24:  a in Y;
    then reconsider a as Element of Y;
    x in a or not x in a;
    then a in P or a in N by A24;
    hence thesis by XBOOLE_0:def 3;
  end;
  then
A25: Y = N \/P by A21,A23,XBOOLE_1:8;
A26: Nx misses Py
  proof
    assume Nx meets Py;
    then consider a be object such that
A27:  a in Nx/\Py by XBOOLE_0:4;
    a in Nx by A27,XBOOLE_0:def 4;
    then consider A be Element of Y such that
A28:  a=A\/{x} & not x in A & A in Y;
    a in Py by A27,XBOOLE_0:def 4;
    then consider B be Element of Y such that
A29:  a=(B\{x})\/{y} & x in B;
A30:  x in union Y by A28,A29,TARSKI:def 4;
    x in {x} by TARSKI:def 1;
    then x in (B\{x})\/{y} by A28,A29,XBOOLE_0:def 3;
    then x in (B\{x}) or x in {y} by XBOOLE_0:def 3;
    hence thesis by ZFMISC_1:56,TARSKI:def 1,A30,A1;
  end;
  N misses P
  proof
    assume N meets P;
    then consider a be object such that
A31:  a in N/\P by XBOOLE_0:4;
    a in N by A31,XBOOLE_0:def 4;
    then consider A be Element of Y such that
A32:  a=A & not x in A & A in Y;
    a in P by A31,XBOOLE_0:def 4;
    then ex B be Element of Y st a=B & x in B;
    hence thesis by A32;
  end;
  hence thesis by CARD_1:5,A26,A11,A20,CARD_1:31,A25;
end;
