
theorem :: ordunordpairs:
for X being finite set holds
 card {[x, y] where x, y is Element of union X
                         : {x,y} in PairsOf X } = 2 * card PairsOf X
proof
 let X be finite set;
 set Y = union X;
 set B = {[x, y] where x, y is Element of Y : {x,y} in PairsOf X };
 set A = { {x,[y,Y]} where x, y is Element of Y : {x,y} in PairsOf X };
 per cases;
 suppose A1: B is empty;
   now
     assume A is non empty;
     then consider a being object such that
   A2: a in A;
     consider x, y being Element of union X such that a = {x, [y, Y]} and
   A3: {x,y} in PairsOf X by A2;
       [x,y] in B by A3;
    hence contradiction by A1;
   end;
  hence card B = 2 * card PairsOf X by A1,Th15;
 end;
 suppose A4: B is non empty;
     then consider b being object such that
  A5: b in B;
     consider x, y being Element of Y such that b = [x, y] and
  A6: {x,y} in PairsOf X by A5;
  A7: x in {x,y} by TARSKI:def 2;
  A8: Y <> {} by A6,A7,TARSKI:def 4;
  defpred P[object, object] means
    for a, b being Element of Y st a in Y & b in Y & $1 = {a,[b,Y]}
     holds $2 = [a,b];
  A9: for c being object st c in A ex d being object st d in B & P[c,d]
proof
      let c be object;
      assume c in A;
       then consider x, y being Element of union X such that
      A10: c = {x, [y, Y]} and
      A11: {x,y} in PairsOf X;
       take d = [x,y];
       thus d in B by A11;
       thus P[c,d] proof
         let a, b be Element of Y;
         assume A12: a in Y & b in Y;
         assume c = {a,[b,Y]};
          then a = x & b = y by A10,A12,Th4;
         hence d = [a,b];
       end;
     end;
  consider f being Function of A, B such that
  A13: for c being object st c in A holds P[c,f.c] from FUNCT_2:sch 1(A9);
  A14: dom f = A by A4,FUNCT_2:def 1;
  A15: f is one-to-one proof
        let c1,c2 be object such that
      A16: c1 in dom f and
      A17: c2 in dom f and
      A18: f.c1 = f.c2;
          consider x1, y1 being Element of Y such that
      A19: c1 = {x1,[y1,Y]} and {x1,y1} in PairsOf X by A16,A14;
          consider x2, y2 being Element of Y such that
      A20: c2 = {x2,[y2,Y]} and {x2,y2} in PairsOf X by A17,A14;
      A21: f.c1 = [x1,y1] by A13,A16,A14,A8,A19;
      A22: f.c2 = [x2,y2] by A13,A17,A14,A8,A20;
          x1 = x2 & y1 = y2 by A18,A21,A22,XTUPLE_0:1;
        hence c1 = c2 by A19,A20;
      end;
  A23: rng f = B proof
       thus rng f c= B proof
         let b be object;
         assume b in rng f;
         then consider a being object such that
       A24: a in dom f and
       A25: b = f.a by FUNCT_1:def 3;
          consider x, y being Element of Y such that
       A26: a = {x,[y,Y]} and
       A27: {x,y} in PairsOf X by A24,A14;
       A28: b = [x,y] by A25,A24,A13,A14,A8,A26;
         thus b in B by A28,A27;
       end;
       thus B c= rng f proof
        let b be object;
        assume A29: b in B;
         consider x, y being Element of Y such that
     A30: b = [x, y] and
     A31: {x,y} in PairsOf X by A29;
         set a = {x,[y,Y]};
     A32: a in A by A31;
     A33: f.a = b by A32,A13,A30,A8;
        thus b in rng f by A32,A33,A14,FUNCT_1:3;
       end;
      end;
  A34: f is onto by A23,FUNCT_2:def 3;
  thus card B = card A by A15,A34,A4,EULER_1:11
             .= 2 * card PairsOf X by Th15;
 end;
end;
