 reserve x,y,z for object, X for set,
         i,k,n,m for Nat,
         R for Relation,
         P for finite Relation,
         p,q for FinSequence;

theorem Th1:
  card R = card (R~)
proof
  defpred Q[object,object] means for x,y st [x,y]=$1 holds [y,x]=$2;
  A1:for x being object st x in R ex y being object st Q[x,y]
   proof
     let x be object;
     assume x in R;
     then consider y,z being object such that
         A2:[y,z]=x by RELAT_1:def 1;
     take zy=[z,y];
     let w,t be object;
     assume A3: [w,t]=x;
     then w=y by A2,XTUPLE_0:1;
     hence thesis by A3,A2,XTUPLE_0:1;
   end;
   consider h be Function such that
     A4:dom h=R &
for x being object st x in R holds Q[x,h.x] from CLASSES1:sch 1(A1 );
   A5: h is one-to-one
   proof
     let x1,x2 be object;
     assume that A6: x1 in dom h
       and       A7: x2 in dom h
       and       A8: h.x1=h.x2;
     consider y2,z2 be object such that
         A9:x2=[y2,z2] by A4,A7,RELAT_1:def 1;
     A10: h.x2 = [z2,y2] by A7,A9,A4;
     consider y1,z1 be object such that
         A11:x1=[y1,z1] by A6,A4,RELAT_1:def 1;
     A12: h.x1 = [z1,y1] by A11,A6,A4;
     then z1=z2 by A10,A8,XTUPLE_0:1;
     hence thesis by A12,A10,A8,XTUPLE_0:1,A11,A9;
   end;
   A13:rng h c= R~
   proof
     let y be object;
     assume y in rng h;
     then consider x being object such that
          A14: x in dom h
      and A15: h.x=y by FUNCT_1:def 3;
     consider t,r be object such that
         A16:x=[t,r] by A4,A14,RELAT_1:def 1;
     h.x =[r,t] by A14,A16,A4;
     hence thesis by A14,A16,A4,RELAT_1:def 7,A15;
   end;
   R~ c= rng h
   proof
     let y,z be object;
     assume [y,z] in R~;
     then A17: [z,y] in R by RELAT_1:def 7;
     then h.[z,y] = [y,z] by A4;
     hence thesis by A17,A4,FUNCT_1:def 3;
   end;
   then rng h = R~ by A13;
   hence thesis by A5,WELLORD2:def 4,A4,CARD_1:5;
 end;
