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

theorem Th22:
  (R c= R * R & R * (R \ id rng R) = {} implies id rng R c= R) &
  (R c= R * R & (R \ id dom R) * R = {} implies id dom R c= R)
proof
  thus R c= R * R & R * (R \ id rng R) = {} implies id rng R c= R
  proof
    assume that
A1: R c= R * R and
A2: R * (R \ id rng R) = {};
    for y being object holds y in rng R implies [y,y] in R
    proof
      let y be object;
      assume y in rng R;
      then consider x being object such that
A3:   [x,y] in R by XTUPLE_0:def 13;
      consider z being object such that
A4:   [x,z] in R and
A5:   [z,y] in R by A1,A3,RELAT_1:def 8;
      z = y
      proof
        assume z <> y;
        then not [z,y] in id rng R by RELAT_1:def 10;
        then [z,y] in (R \ id rng R) by A5,XBOOLE_0:def 5;
        hence contradiction by A2,A4,RELAT_1:def 8;
      end;
      hence thesis by A5;
    end;
    hence thesis by RELAT_1:47;
  end;
    assume that
A6: R c= R * R and
A7: (R \ id dom R) * R = {};
    for x being object holds x in dom R implies [x,x] in R
    proof
      let x be object;
      assume x in dom R;
      then consider y being object such that
A8:   [x,y] in R by XTUPLE_0:def 12;
      consider z being object such that
A9:   [x,z] in R and
A10:  [z,y] in R by A6,A8,RELAT_1:def 8;
      z = x
      proof
        assume z <> x;
        then not [x,z] in id dom R by RELAT_1:def 10;
        then [x,z] in R \ id dom R by A9,XBOOLE_0:def 5;
        hence contradiction by A7,A10,RELAT_1:def 8;
      end;
      hence thesis by A9;
    end;
    hence thesis by RELAT_1:47;
end;
