 reserve x,y,z,t for object,X,Y,Z,W for set;
 reserve R,S,T for Relation;

theorem
  R c= [:X,X:] implies R \ id dom R = R \ id X & R \ id rng R = R \ id X
proof
A1: R \ id dom R c= R \ id X
  proof
    let x,y be object;
    assume
A2: [x,y] in R \ id dom R; then
A3: not [x,y] in id dom R by XBOOLE_0:def 5;
    not [x,y] in id X
    proof
      assume [x,y] in id X; then
A4:   x = y by RELAT_1:def 10;
      x in dom R by A2,XTUPLE_0:def 12;
      hence contradiction by A3,A4,RELAT_1:def 10;
    end;
    hence thesis by A2,XBOOLE_0:def 5;
  end;
A5: R \ id rng R c= R \ id X
  proof
    let x,y be object;
    assume
A6: [x,y] in R \ id rng R; then
A7: not [x,y] in id rng R by XBOOLE_0:def 5;
    not [x,y] in id X
    proof
      assume [x,y] in id X; then
A8:   x = y by RELAT_1:def 10;
      y in rng R by A6,XTUPLE_0:def 13;
      hence contradiction by A7,A8,RELAT_1:def 10;
    end;
    hence thesis by A6,XBOOLE_0:def 5;
  end;
  assume
A9: R c= [:X,X:];
  then id dom R c= id X by Th3,Th15;
  then R \ id X c= R \ id dom R by XBOOLE_1:34;
  hence R \ id dom R = R \ id X by A1;
  id(rng R) c= id X by A9,Th3,Th15;
  then R \ id(X) c= R \ id rng R by XBOOLE_1:34;
  hence thesis by A5;
end;
