
theorem Th23:
  for X, Y being set st card X = card Y holds card 2Set X = card 2Set Y
proof
  let X, Y be set;
  :: the basic idea is to build a canonical bijection between the 2Sets
  :: from the bijection of the sets
  assume card X = card Y;
  then consider g being Function such that
    A1: g is one-to-one & dom g = X & rng g = Y by CARD_1:5, WELLORD2:def 4;
  deffunc E1(set) = the Element of $1;
  deffunc E2(set) = the Element of ($1\{E1($1)});
  deffunc F(object) = {g.E1(In($1,bool X)),g.E2(In($1,bool X))};
  :: basically f.{x,y} = {g.x,g.y}
  consider f being Function such that
    A2: dom f = 2Set X & for x being object st x in 2Set X holds f.x = F(x)
    from FUNCT_1:sch 3;
  :: show that range equals 2Set Y
  now
    let y be object;
    hereby
      assume y in rng f;
      then consider x being object such that
        A3: x in dom f & f.x = y by FUNCT_1:def 3;
      consider X9 being Subset of X such that
        A4: x = X9 & card X9 = 2 by A2, A3;
      A5: y = {g.E1(In(X9,bool X)),g.E2(In(X9,bool X))} by A2, A3, A4
        .= {g.E1(X9),g.E2(X9)};
      X9 is non trivial
      proof
        assume A6: X9 is trivial;
        per cases;
        suppose X9 is empty;
          hence contradiction by A4;
        end;
        suppose X9 is non empty;
          then card X9 = 1 by A6, CARD_1:def 7;
          hence contradiction by A4;
        end;
      end;
      then X9 <> {} & X9\{E1(X9)} <> {} by ZFMISC_1:139;
      then A7: E1(X9) in X9 & E2(X9) in X9\{E1(X9)};
      then E2(X9) in X9 & not E2(X9) in {E1(X9)} by XBOOLE_0:def 5;
      then E2(X9) in X9 & E1(X9) <> E2(X9) by TARSKI:def 1;
      then A8: g.E1(X9) <> g.E2(X9) by A1, A7, FUNCT_1:def 4;
      g.E1(X9) in Y & g.E2(X9) in Y by A1, A7, FUNCT_1:3;
      then A9: {g.E1(X9),g.E2(X9)} c= Y by ZFMISC_1:32;
      card {g.E1(X9),g.E2(X9)} = 2 by A8, CARD_2:57;
      hence y in 2Set Y by A5, A9;
    end;
    assume y in 2Set Y;
    then consider Y9 being Subset of Y such that
      A10: y = Y9 & card Y9 = 2;
    consider y1,y2 being object such that
      A11: y1 <> y2 & Y9 = {y1,y2} by A10, CARD_2:60;
    y1 in Y9 & y2 in Y9 by A11, TARSKI:def 2;
    then A12: y1 in rng g & y2 in rng g by A1;
    then consider x1 being object such that
      A13: x1 in dom g & g.x1 = y1 by FUNCT_1:def 3;
    consider x2 being object such that
      A14: x2 in dom g & g.x2 = y2 by A12, FUNCT_1:def 3;
    A15: x1 <> x2 by A11, A13, A14;
    reconsider X9 = {x1,x2} as Subset of X by A1, A13, A14, ZFMISC_1:32;
    card X9 = 2 by A15, CARD_2:57;
    then A16: X9 in 2Set X;
    per cases by TARSKI:def 2;
    suppose A17: E1(X9) = x1;
      then X9\{E1(X9)} = {x2} by A15, ZFMISC_1:17;
      then A18: E2(X9) = x2 by TARSKI:def 1;
      f.X9 = {g.E1(In(X9,bool X)),g.E2(In(X9,bool X))} by A2, A16
        .= y by A10, A11, A13, A14, A17, A18;
      hence y in rng f by A2, A16, FUNCT_1:3;
    end;
    suppose A19: E1(X9) = x2;
      then X9\{E1(X9)} = {x1} by A15, ZFMISC_1:17;
      then A20: E2(X9) = x1 by TARSKI:def 1;
      f.X9 = {g.E1(In(X9,bool X)),g.E2(In(X9,bool X))} by A2, A16
        .= y by A10, A11, A13, A14, A19, A20;
      hence y in rng f by A2, A16, FUNCT_1:3;
    end;
  end;
  then A21: rng f = 2Set Y by TARSKI:2;
  :: show one-to-one property
  now
    let x1,x2 be object;
    assume A22: x1 in dom f & x2 in dom f & f.x1 = f.x2;
    then consider X1 being Subset of X such that
      A23: x1 = X1 & card X1 = 2 by A2;
    consider X2 being Subset of X such that
      A24: x2 = X2 & card X2 = 2 by A2, A22;
    A25: f.x1 = {g.E1(In(X1,bool X)),g.E2(In(X1,bool X))} by A2, A22, A23
      .= {g.E1(X1),g.E2(X1)};
    A26: f.x2 = {g.E1(In(X2,bool X)),g.E2(In(X2,bool X))} by A2, A22, A24
      .= {g.E1(X2),g.E2(X2)};
    X1 is non trivial
    proof
      assume A27: X1 is trivial;
      per cases;
      suppose X1 is empty;
        hence contradiction by A23;
      end;
      suppose X1 is non empty;
        then card X1 = 1 by A27, CARD_1:def 7;
        hence contradiction by A23;
      end;
    end;
    then X1 <> {} & X1\{E1(X1)} <> {} by ZFMISC_1:139;
    then A28: E1(X1) in X1 & E2(X1) in X1\{E1(X1)};
    then E2(X1) in X1 & not E2(X1) in {E1(X1)} by XBOOLE_0:def 5;
    then A29: E2(X1) in X1 & E2(X1) <> E1(X1) by TARSKI:def 1;
    A30: E1(X1) in X & E2(X1) in X by A28;
    X2 is non trivial
    proof
      assume A31: X2 is trivial;
      per cases;
      suppose X2 is empty;
        hence contradiction by A24;
      end;
      suppose X2 is non empty;
        then card X2 = 1 by A31, CARD_1:def 7;
        hence contradiction by A24;
      end;
    end;
    then X2 <> {} & X2\{E1(X2)} <> {} by ZFMISC_1:139;
    then A32: E1(X2) in X2 & E2(X2) in X2\{E1(X2)};
    then E2(X2) in X2 & not E2(X2) in {E1(X2)} by XBOOLE_0:def 5;
    then A33: E2(X2) in X2 & E2(X2) <> E1(X2) by TARSKI:def 1;
    A34: E1(X2) in X & E2(X2) in X by A32;
    A35: X1 is finite & X2 is finite by A23, A24;
    {E1(X1),E2(X1)} c= X1 & card {E1(X1),E2(X1)} = 2
      by A29, ZFMISC_1:32, CARD_2:57;
    then A36: {E1(X1),E2(X1)} = X1 by A23, A35, CARD_2:102;
    {E1(X2),E2(X2)} c= X2 & card {E1(X2),E2(X2)} = 2
      by A33, ZFMISC_1:32, CARD_2:57;
    then A37: {E1(X2),E2(X2)} = X2 by A24, A35, CARD_2:102;
    A38: f.x1 in rng f & f.x2 in rng f by A22, FUNCT_1:3;
    then consider Y1 being Subset of Y such that
      A39: f.x1 = Y1 & card Y1 = 2 by A21;
    consider Y2 being Subset of Y such that
      A40: f.x2 = Y2 & card Y2 = 2 by A21, A38;
    A41: g.E1(X1) <> g.E2(X1)
    proof
      assume g.E1(X1) = g.E2(X1);
      then f.x1 = {g.E1(X1)} by A25, ENUMSET1:29;
      hence contradiction by A39, CARD_1:30;
    end;
    A42: g.E1(X2) <> g.E2(X2)
    proof
      assume g.E1(X2) = g.E2(X2);
      then f.x2 = {g.E1(X2)} by A26, ENUMSET1:29;
      hence contradiction by A40, CARD_1:30;
    end;
    A43: {g.E1(X1),g.E2(X1)} = {g.E1(X2),g.E2(X2)} by A22, A25, A26;
    then per cases by ZFMISC_1:6;
    suppose A44: g.E1(X1) = g.E1(X2);
      then A45: E1(X1) = E1(X2) by A1, A30, A34, FUNCT_1:def 4;
      {g.E1(X1),g.E2(X1)} \ {g.E1(X1)} = {g.E2(X1)} by A41, ZFMISC_1:17;
      then {g.E2(X1)} = {g.E2(X2)} by A42, A43, A44, ZFMISC_1:17;
      then E2(X1) = E2(X2) by A1, A28, A32, FUNCT_1:def 4, ZFMISC_1:3;
      hence x1 = x2 by A23, A24, A36, A37, A45;
    end;
    suppose A46: g.E1(X1) = g.E2(X2);
      then A47: E1(X1) = E2(X2) by A1, A28, A32, FUNCT_1:def 4;
      {g.E1(X1),g.E2(X1)} \ {g.E1(X1)} = {g.E2(X1)} by A41, ZFMISC_1:17;
      then {g.E2(X1)} = {g.E1(X2)} by A42, A43, A46, ZFMISC_1:17;
      then E2(X1) = E1(X2) by A1, A28, A32, FUNCT_1:def 4, ZFMISC_1:3;
      hence x1 = x2 by A23, A24, A36, A37, A47;
    end;
  end;
  hence thesis by A2, A21, FUNCT_1:def 4, CARD_1:70;
end;
