reserve X for non empty TopSpace;

theorem Th9:
  for A being Subset of X holds A is T_0 implies ex M being Subset
  of X st A c= M & M is maximal_T_0
proof
  let A be Subset of X;
  set D = [#]X \ MaxADSet(A);
  set F = {MaxADSet(d) where d is Point of X : d in D};
  now
    let C be object;
    assume C in F;
    then ex a being Point of X st C = MaxADSet(a) & a in D;
    hence C in bool the carrier of X;
  end;
  then reconsider F as Subset-Family of X by TARSKI:def 3;
  assume
A1: A is T_0;
  defpred X[Subset of X,set] means $2 in D & $2 in $1;
A2: D = (MaxADSet(A))`;
  then
A3: MaxADSet(A) misses D by SUBSET_1:24;
  A c= MaxADSet(A) by TEX_4:32;
  then A misses D by A2,SUBSET_1:24;
  then
A4: A /\ D = {} by XBOOLE_0:def 7;
  reconsider F as Subset-Family of X;
A5: for S being Subset of X st S in F ex x being Point of X st X[S,x]
  proof
    let S be Subset of X;
    assume S in F;
    then consider d being Point of X such that
A6: S = MaxADSet(d) and
A7: d in D;
    take d;
    {d} c= MaxADSet(d) by TEX_4:18;
    hence thesis by A6,A7,ZFMISC_1:31;
  end;
  consider f being Function of F,the carrier of X such that
A8: for S being Subset of X st S in F holds X[S,f.S] from TEX_2:sch 1(
  A5);
  set M = A \/ (f.: F);
  now
    let x be object;
    assume x in f.: F;
    then ex S being object st S in F & S in F & x = f.S by FUNCT_2:64;
    hence x in D by A8;
  end;
  then f.: F c= D by TARSKI:def 3;
  then
A9: MaxADSet(A) misses (f.:F) by A3,XBOOLE_1:63;
  thus ex M being Subset of X st A c= M & M is maximal_T_0
  proof
    take M;
    thus
A10: A c= M by XBOOLE_1:7;
    for x being Point of X ex a being Point of X st a in M & M /\
    MaxADSet(x) = {a}
    proof
      let x be Point of X;
A11:  [#]X = MaxADSet(A) \/ D by XBOOLE_1:45;
      now
        per cases by A11,XBOOLE_0:def 3;
        suppose
A12:      x in MaxADSet(A);
          now
            {x} c= MaxADSet(A) by A12,ZFMISC_1:31;
            then MaxADSet({x}) c= MaxADSet(A) by TEX_4:34;
            then MaxADSet(x) c= MaxADSet(A) by TEX_4:28;
            then (f.: F) misses MaxADSet(x) by A9,XBOOLE_1:63;
            then (f.: F) /\ MaxADSet(x) = {} by XBOOLE_0:def 7;
            then
A13:        M /\ MaxADSet(x) = (A /\ MaxADSet(x)) \/ {} by XBOOLE_1:23;
            x in union {MaxADSet(a) where a is Point of X : a in A} by A12,
TEX_4:def 11;
            then consider C being set such that
A14:        x in C and
A15:        C in {MaxADSet(a) where a is Point of X : a in A} by TARSKI:def 4;
            consider a being Point of X such that
A16:        C = MaxADSet(a) and
A17:        a in A by A15;
            take a;
            thus a in M by A10,A17;
            MaxADSet(a) = MaxADSet(x) by A14,A16,TEX_4:21;
            hence M /\ MaxADSet(x) = {a} by A1,A17,A13;
          end;
          hence thesis;
        end;
        suppose
A18:      x in D;
          then
A19:      MaxADSet(x) in F;
          now
            reconsider a = f.(MaxADSet(x)) as Point of X by A19,FUNCT_2:5;
            take a;
A20:        f.: F c= M by XBOOLE_1:7;
            now
              let y be object;
              assume
A21:          y in M /\ MaxADSet(x);
              then reconsider z = y as Point of X;
A22:          z in M by A21,XBOOLE_0:def 4;
A23:          z in MaxADSet(x) by A21,XBOOLE_0:def 4;
              then
A24:          MaxADSet(z) = MaxADSet(x) by TEX_4:21;
              now
                assume not MaxADSet(x) c= D;
                then MaxADSet(x) meets MaxADSet(A) by A2,SUBSET_1:23;
                then
A25:            MaxADSet(x) c= MaxADSet(A) by TEX_4:30;
                {x} c= MaxADSet(x) by TEX_4:18;
                then x in MaxADSet(x) by ZFMISC_1:31;
                hence contradiction by A3,A18,A25,XBOOLE_0:3;
              end;
              then not z in A by A4,A23,XBOOLE_0:def 4;
              then z in f.: F by A22,XBOOLE_0:def 3;
              then consider C being object such that
A26:          C in F and
              C in F and
A27:          z = f.C by FUNCT_2:64;
              reconsider C as Subset of X by A26;
              consider w being Point of X such that
A28:          C = MaxADSet(w) and
              w in D by A26;
              z in MaxADSet(w) by A8,A26,A27,A28;
              then f.(MaxADSet(w)) = a by A24,TEX_4:21;
              hence y in {a} by A27,A28,TARSKI:def 1;
            end;
            then
A29:        M /\ MaxADSet(x) c= {a} by TARSKI:def 3;
A30:        a in f.: F by A19,FUNCT_2:35;
            hence a in M by A20;
            a in MaxADSet(x) by A8,A19;
            then
A31:        {a} c= MaxADSet(x) by ZFMISC_1:31;
            {a} c= M by A20,A30,ZFMISC_1:31;
            then {a} c= M /\ MaxADSet(x) by A31,XBOOLE_1:19;
            hence M /\ MaxADSet(x) = {a} by A29,XBOOLE_0:def 10;
          end;
          hence thesis;
        end;
      end;
      hence thesis;
    end;
    hence M is maximal_T_0;
  end;
end;
