reserve X,Y,Z for set, x,y,z for object;
reserve i,j for Nat;
reserve A,B,C for Subset of X;
reserve R,R1,R2 for Relation of X;
reserve AX for Subset of [:X,X:];
reserve SFXX for Subset-Family of [:X,X:];
reserve EqR,EqR1,EqR2,EqR3 for Equivalence_Relation of X;

theorem Th34:
  for P being a_partition of X holds ex EqR st P = Class EqR
proof
  let P be a_partition of X;
A1: X <> {} implies ex EqR st P = Class EqR
  proof
    defpred P[object,object] means ex A st A in P & $1 in A & $2 in A;
    assume X <> {};
A2: for x,y,z st P[x,y] & P[y,z] holds P[x,z]
    proof
      let x,y,z;
      given A such that
A3:   A in P and
A4:   x in A & y in A;
      given B such that
A5:   B in P and
A6:   y in B & z in B;
      A = B or A misses B by A3,A5,Def4;
      hence thesis by A3,A4,A6,XBOOLE_0:3;
    end;
A7: union P = X by Def4;
A8: for x st x in X holds P[x,x]
    proof
      let x;
      assume x in X;
      then consider Z such that
A9:   x in Z and
A10:  Z in P by A7,TARSKI:def 4;
      reconsider A = Z as Subset of X by A10;
      take A;
      thus thesis by A9,A10;
    end;
A11: for x,y st P[x,y] holds P[y,x];
    consider R being Equivalence_Relation of X such that
A12: for x,y holds [x,y] in R iff x in X & y in X & P[x,y] from
    ExEqRel(A8,A11,A2);
    take R;
    now
      let A;
A13:  now
        set x = the Element of A;
        assume
A14:    A in P;
        then
A15:    A <> {} by Def4;
        then
A16:    x in X by TARSKI:def 3;
        now
          let y be object;
A17:      now
            assume y in Class(R,x);
            then [y,x] in R by Th19;
            then consider B such that
A18:        B in P & y in B and
A19:        x in B by A12;
            A meets B by A15,A19,XBOOLE_0:3;
            hence y in A by A14,A18,Def4;
          end;
          now
            assume y in A;
            then [y,x] in R by A12,A14,A16;
            hence y in Class(R,x) by Th19;
          end;
          hence y in A iff y in Class(R,x) by A17;
        end;
        then A = Class(R,x) by TARSKI:2;
        hence A in Class R by A16,Def3;
      end;
      now
        assume A in Class R;
        then consider x such that
A20:    x in X and
A21:    A = Class(R,x) by Def3;
        x in Class(R,x) by A20,Th20;
        then [x,x] in R by Th19;
        then consider B such that
A22:    B in P and
A23:    x in B and
        x in B by A12;
        now
          let y be object;
A24:      now
            assume y in A;
            then [y,x] in R by A21,Th19;
            then consider C such that
A25:        C in P & y in C and
A26:        x in C by A12;
            B meets C by A23,A26,XBOOLE_0:3;
            hence y in B by A22,A25,Def4;
          end;
          now
            assume y in B;
            then [y,x] in R by A12,A22,A23;
            hence y in A by A21,Th19;
          end;
          hence y in A iff y in B by A24;
        end;
        hence A in P by A22,TARSKI:2;
      end;
      hence A in P iff A in Class R by A13;
    end;
    hence thesis by SETFAM_1:31;
  end;
  X = {} implies ex EqR st P = Class EqR
  proof
    set EqR1 = the Equivalence_Relation of X;
    assume
A27: X = {};
    take EqR1;
    P = {} by A27;
    hence thesis by A27,Th31;
  end;
  hence thesis by A1;
end;
